Skip to content

Instantly share code, notes, and snippets.

@HackRanger
Last active December 21, 2015 12:19
Show Gist options
  • Save HackRanger/6305157 to your computer and use it in GitHub Desktop.
Save HackRanger/6305157 to your computer and use it in GitHub Desktop.
main.mk
all_hosts += [
'localhost',
'node1|SKF|node1',
'node2|SKF|node2',
'node3|SKF|node3',
'node4|SKF|node4',
'node5|SKF|node5',
]
ipaddresses = {
"localhost" : "127.0.0.1",
"node1": "127.0.0.1",
"node2": "127.0.0.1",
"node3": "127.0.0.1",
"node4": "127.0.0.1",
"node5": "127.0.0.1",
}
# Settings for alias
datasource_programs += [
( "cat /tmp/cmkresult.node1", [ 'node1' ] ),
( "cat /tmp/cmkresult.node2", [ 'node2' ] ),
( "cat /tmp/cmkresult.node3", [ 'node3' ] ),
( "cat /tmp/cmkresult.node4", [ 'node4' ] ),
( "cat /tmp/cmkresult.node5", [ 'node5' ] ),
]
host_groups = [
( 'SKF', [ 'SKF' ], ALL_HOSTS ),
]
define_hostgroups = True
check_parameters = [
( (101, 101), [ 'SKF'], [ 'node1' ], [ "/tmp/cmkresult.node1" ]),
( (101, 101), [ 'SKF'], [ 'node2' ], [ "/tmp/cmkresult.node2" ]),
( (101, 101), [ 'SKF'], [ 'node3' ], [ "/tmp/cmkresult.node3" ]),
( (101, 101), [ 'SKF'], [ 'node4' ], [ "/tmp/cmkresult.node4" ]),
( (101, 101), [ 'SKF'], [ 'node5' ], [ "/tmp/cmkresult.node5" ]),
]
@FlorianHeigl
Copy link

ll_hosts += [
'localhost',
    'node1|tcp|SKF|fileagent',
    'node2|tcp|SKF|fileagent',
    'node3|tcp|SKF|fileagent', # TCP or SNMP or PING check is mandatory for 2 years
    'node4|tcp|SKF|fileagent',
    'node5|tcp|SKF|fileagent|slow', # This one will be allowed checkresult files of higher age than the others
]

# this would overwrite the dict and delete other ip settings that
# were made from WATO
# instead, use ipaddresses.update( { } ) if possible
ipaddresses = {
"localhost" : "127.0.0.1", # makes no sense, localhost always 127.0.0.1
  "node1": "127.0.0.1",
  "node2": "127.0.0.1",
  "node3": "127.0.0.1",
  "node4": "127.0.0.1",
  "node5": "127.0.0.1",
}

# Settings for alias
# <HOST> is auto-completed by Check_MK
datasource_programs += [
  ( "cat /tmp/cmkresult.<HOST>", [ 'tcp', 'fileagent' ], ALL_HOSTS ),
]

host_groups = [
 ( 'SKF', [ 'SKF' ], ALL_HOSTS ),
]

define_hostgroups = True

check_parameters = [
# use wildcard match on service name (anything that starts with /tmp/cmkresult
# add fileagent tag so it only affects those but not servers that are directly
# checked
 ( (101, 101), [ 'SKF', 'fileagent'], ALL_HOSTS , [ "/tmp/cmkresult" ]),
]
######## NOW
# YOU DO NOT HAVE A HOST CHECK DEFINITION
# NO MATTER WHAT YOU THINK YOU DONT HAVE IT.
# The above config (101, 101) affects a SERVICE CHECK
# NOT A HOST CHECK.
# A service is a object ON a host thus it can't directly change the HOST state
# thus the host is never shown as DOWN.

extra_host_conf["check_command"] = [("check-mk-hostfileage!80!120", [ "fileagent" ], ALL_HOSTS)]
extra_host_conf["check_command"] = [("check-mk-hostfileage!240!360", [ "fileagent", "slow" ], ALL_HOSTS)]

extra_nagios_conf+="""
define command{
    command_name       check-mk-hostfileage
    command_line       $USER4$/lib/nagios/plugins/check_file_age -w $ARG1$ -c $ARG2$ -f %s/tmp/check_mk/cmkr
esult.$HOSTNAME$
}
""" % omd_root



# if you don't use OMD make it like this and create /var/tmp/check_mk writeable for nagios

#extra_nagios_conf+="""
#define command{
#    command_name       check-mk-hostfileage
#    command_line       $USER4$/lib/nagios/plugins/check_file_age -w $ARG1$ -c $ARG2$ -f /var/tmp/check_mk/c
mkr
#esult.$HOSTNAME$
#}
#"""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment