0

I am a beginner in icinga and nagios usage for server management. I setup icinga on a machine and set up all the basics. The next step I tried was to check if certain services were running at ports 8080, 8081 and 8082 or not. I wrote a quick python script for that. I placed that file under /usr/local/lib/myscript.py. The next step I did was to create a command under /etc/nagios-plugins/config/testone.cfg . My command looks like this

define command{
        command_name    check_restarts
        command_line    python /usr/local/lib/myscript.py -w 3 -c 5 -p 8080
        command_line    python /usr/local/lib/myscript.py -w 3 -c 5 -p 8081
        command_line    python /usr/local/lib/myscript.py -w 3 -c 5 -p 8082
        }

I then added a service to services.conf under /etc/icinga2/conf.d/services.conf. But this leads to an error when I restart icinga which shows up a message Backend icinga not running on the UI and errors point to services.conf when I try sudo service icings2 status.

Can anyone please guid me around these steps?

Beginner
  • 2,643
  • 9
  • 33
  • 51
  • My apologies, it looks like Icinga2 shares no more common code or configurations with Nagios so my earlier advice is incorrect so I deleted my answer. I'm unfamiliar with Icinga2 format so can't help further, but I urge you to take a look at: http://docs.icinga.org/icinga2/latest/doc/module/icinga2/toc#!/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2-first-steps#configuring-icinga2-first-steps – Joe Young Oct 28 '15 at 17:49
  • Looks like you use old Icinga1 syntax for defining commands. Icinga1 syntax is compatible with Nagios syntax, but the old .cfg syntax of Icinga1 is not compatible with the new .conf syntax of Icinga2. This link might help you find the right syntax for defining custom commands: http://docs.icinga.org/icinga2/latest/doc/module/icinga2/toc#!/icinga2/latest/doc/module/icinga2/chapter/monitoring-basics#commands – Ciprian Stoica Nov 21 '15 at 11:28

1 Answers1

1

The easiest way to do this is as follows:

Once you have nagios installed go to /etc/nagios/nrpe.d/commands.conf (if you dont have a commands.conf create it ). In that file place this

command[check_process] = /usr/bin/python /path/to/your/script

Here check_process can be any name you wish to keep.

Once this is in place, check it using the check_nrpe plugin. Its places in /usr/lib/nagios/../check_nrpe (dont fully remember the location)

type this in your terminal: path/to/check_nrpe -H localhost -c check_process

Considering this is localhost i.e. your running the script on the same system i dont see any issues cropping up.

Next go the /etc/icinga/conf.d/mychecks.conf (again create this file, preferably create a new folder and place it in there). This should be the content of your file:

apply Service "My service" {
    import "generic-service"
    check_command = "check_process"

    assign where host.name == NodeName
}

you can check for any issues using sudo /etc/init.d/icinga2 checkconfig . ANy issues are usually very descriptive and helpfull. If the checkconfig is [ok] then restart icinga and you're set.

letsc
  • 2,515
  • 5
  • 35
  • 54