Es gibt die Möglichkeit Check Ergebnisse wenn ein Host nicht direkt erreichbar ist für Check_MK oder man bestimmte Dinge z.B. Erreichbarkeit eines TCP Services von einem anderen Host aus testen möchte, als Piggyback über den Agenten eines anderen Hosts mitzugeben.
In den Beispiel haben wir einen Host (router) der ein Check Ergebnis von einem anderen Host (localhost) bekommen soll. Check_MK verwendet hierfür folgenden Syntax:
<<<<hostname>>>>
Check Ergebnisse, Ausgaben von Local Checks, etc.
<<<<>>>>
Das Piggyback File muss auf dem Host mit Agenten unter /var/lib/check_mk_agent/spool abgelegt werden. Ich habe die Ausgabe für ein Agent Check + einen Local Check eingebaut.
root@cmkdev:/var/lib/check_mk_agent/spool# cat piggy_router <<<<router>>>> <<<mycheck>>> foo 1 bar 2 <<<local>>> 0 Mein_piggyback_localcheck - TEST TEST TEST <<<<>>>>
Dazu ein einfacher Check der in der Zeile den 2 Parameter als Status für den ersten zurückgibt:
OMD[dev1]:~/local/share/check_mk/checks$ cat mycheck #!/usr/bin/python # -*- encoding: utf-8; py-indent-offset: 4 -*- def inventory_mycheck(info): if len(info) > 1: yield '', None def check_mycheck(item, params, info): for i in info: yield int(i[1]), "Status von: %s" % i[0] check_info['mycheck'] = { 'inventory_function' : inventory_mycheck, 'check_function' : check_mycheck, 'service_description' : 'MyCheck', }
Inventory, Reload und Test:
OMD[dev1]:~$ cmk -v -II router Discovering services on router: router: Using piggyback information from host localhost. 1 local 1 mycheck OMD[dev1]:~$ cmk -R Generating configuration for core (type cmc)...OK Packing config...OK Restarting monitoring core...OK OMD[dev1]:~$ cmk -v router Check_MK version 1.4.0p8 Using piggyback information from host localhost. Mein_piggyback_localcheck OK - TEST TEST TEST MyCheck CRIT - Status von: foo(!), Status von: bar(!!) OK - execution time 0.0 sec|execution_time=0.002 user_time=0.000 system_time=0.010 children_user_time=0.000 children_system_time=0.000
Check_MK weist auf der Shell darauf hin das Piggyback Informationen verwendet wurden:
Using piggyback information from host localhost.
Viel Spaß beim piggybacken 😉
Thanks for the explanation. How do you define the local check ?
For example, I have a host A which has a local check in /usr/lib64/check_mk_agent/local/check_local.sh
This check returns the output like below:
0 TUNNEL1- active
0 TUNNEL2 – active
2 TUNNEL5 – inactive
2 TUNNEL6- inactive
like this there are around 100 tunnels in the check output.
Now, I want to piggyback the complete output of this local check i.e. check_local.sh to Host B.I tried like this:
$vim /var/lib/check_mk_agent/spool/piggy_router
<<<>>>
<<>> local
/usr/lib64/check_mk_agent/local/check_local.sh
<<<>>>
But it doesn’t seem to work. Can you please advise ?