I modified the script as per your suggestion and saved the script to
"/usr/lib/nagios/plugins" as "check_reboot_required". I then went to
"/etc/icinga2/conf.d" directory and added a config file called
"reboot_required.conf" with the following in it.
apply Service "reboot_required" {
import "generic-service"
check_command = "reboot_required"
assign where (host.address || host.address6) && host.vars.os == "Linux"
}
I restarted the icinga2 service and checked the Icinga2 startup.log file and
found the following error
check_command = "reboot_required"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I don't believe I have the new script properly defined in Icinga2. I have been
reading the docs and don't see yet see the step(s) I have missed. I am new to
Icinga2.
Robert
----- Original Message -----
> From: "Antony Stone" <[email protected]>
> To: "Icinga User's Corner" <[email protected]>
> Sent: Tuesday, September 6, 2016 11:21:28 AM
> Subject: Re: [icinga-users] Reboot Required
>
> 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
> [email protected]
> https://lists.icinga.org/mailman/listinfo/icinga-users
>
_______________________________________________
icinga-users mailing list
[email protected]
https://lists.icinga.org/mailman/listinfo/icinga-users