On Tuesday 06 September 2016 at 16:50:29, Robert Jenkins wrote: > I would like a service check in icinga2 to test if a reboot is required on > my ubuntu servers. something like > > #!/bin/bash > if [ ! -f /var/run/reboot-required ]; then > # no reboot required (0=OK) > echo "OK: no reboot required" > exit 0 > else > # reboot required (1=WARN) > echo "WARNING: `cat /var/run/reboot-required`" > exit 1 > fi > How would I go about doing this?
Um, well, the above would work pretty well :) You do realise you can write check scripts in any language you like, and Bash is as good a choice as any (as you can see from the standard library if you take a look)? You can do things a bit better by following the guidelines at http://docs.icinga.org/latest/en/pluginapi.html (Icinga 1, but check scripts work the same for both) or http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/service- monitoring for Icinga 2 specifically. Just as a minor point, I would recommend making your logic a little easier to follow by rewriting your script to test for the existence of the file, instead of the non-existence: #!/bin/bash if [ -f /var/run/reboot-required ]; then # reboot required (1=WARN) echo "WARNING: `cat /var/run/reboot-required`" exit 1 else # no reboot required (0=OK) echo "OK: no reboot required" exit 0 fi Hope that helps, Antony. -- The Magic Words are Squeamish Ossifrage. Please reply to the list; please *don't* CC me. _______________________________________________ icinga-users mailing list icinga-users@lists.icinga.org https://lists.icinga.org/mailman/listinfo/icinga-users