/usr/share/doc/check-mk-doc/predictive/foo.check is in check-mk-doc 1.2.8p16-1ubuntu0.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | #!/usr/bin/python
# Example check. Put this into local/share/check_mk/checks
# Inventory function without any specialities. Return
# None as a default parameter (meaning: no levels).
def inventory_foo(info):
if len(info) > 0:
return [(None, None)]
def check_foo(_no_item, params, info):
# Step 1: extract the measured value from the agent output. Here
# of course trivial
value = float(info[0][0])
# Step 2: Output the value (and maybe others) as performance data.
# This is mandatory when using predictive levels. The name of the
# value (here 'fooval') is needed later.
perfdata = [("fooval", value)]
# Step 3: Prepare some informative output text
text = "%d running processes" % value
# Step 4: let the helper function check_levesl() do the rest.
# The params can be None (lo levels), a pair of fixed levels for
# WARN/CRIT or a dictionary with the parameters for the prediction.
# In return we get the resulting Nagios state and in case of prediciton
# an extra text and extra perfdata (the predicted reference).
state, extratext, extraperf = check_levels(value, "fooval", params)
# Put that extratext together with our own text
if extratext:
text += ", " + extratext
# Also append the extra performance data and return the stuff
return state, text, perfdata + extraperf
check_info['foo'] = {
"check_function" : check_foo,
"inventory_function" : inventory_foo,
"service_description" : "FOO",
"has_perfdata" : True, # must be true
"group" : "foobar", # configuration group for WATO
}
|