0

I have a server running Plex and two other services I want to monitor with Icinga2 and for the life of me I can't figure out how to get that to work. If I run the following command:

./check_procs -c 1:1 -a '/usr/lib/plexmediaserver/Plex Media Server'

Which returns the following when I manually kill Plex:

PROCS CRITICAL: 0 processes with args '/usr/lib/plexmediaserver/Plex Media Server' | procs=0;;1:1;0;

I just can't figure out how to add this check to the server.. where do I put it ?

I tried adding another declaration to /etc/icinga2/conf.d/services.conf as follows:

apply Service "procs" 
    {
        import "generic-service"

        check_command = "procs"

        assign where host.name == NodeName

        arguments = 
        {
            "-a" = 
            {
              value = "/usr/lib/plexmediaserver/Plex Media Server"
              description = "service name"
              required = true
            }
        }
    }

But then the agent wouldn't start at all.

stumped221
  • 89
  • 4
  • 18

2 Answers2

1

I solved this by defining a service:

apply Service for (service => config in host.vars.processes_linux) {
  import "generic-service"
  check_command = "nrpe"
  display_name = config.display_name
  vars.nrpe_command = "check_process"
  vars.nrpe_arguments = [ config.process, config.warn_range, config.crit_range ]
}

In the host definition I then just add a config, let's say for mongodb:

vars.processes_linux["trench-srv-lin-process-mongodb"] = {
  display_name = "MongoDB processes"
  process = "mongod"
  warn_range = "1:"
  crit_range = "1:"
}

On the remote host, I need to install the package nagios-nrpe-server

And in the configfile /etc/nagios/nrpe_local.cfg I add this line:

command[check_procs]=/usr/lib/nagios/plugins/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$
mortomanos
  • 128
  • 7
0

i am running a small cluster of Raspberry Pi's which i am monitoring with Icinga2. On the master node of my cluster i have a dhcp server running. I check it's status the following way.

First i downloaded the check service status plugin from the Icinga Exchange, made it executable and moved it to /usr/lib/nagios/plugins (your path may differ).

Then i defined a check command for it:

object CheckCommand "Check Service" {
import "plugin-check-command"
command = [ PluginDir + "/check_service.sh" ]
arguments += {
    "-o" = {
        required = true
        value = "$check_service_os$"
    }
    "-s" = {
        required = true
        value = "$check_service_name$"
    }
}
}

Now all that was left was defining a Service:

object Service "Check DHCP" {
host_name = "Localhost"
check_command = "Check Service"
enable_perfdata = true
event_command = "Restart DHCP"
vars.check_service_name = "isc-dhcp-server"
vars.check_service_os = "linux"
}

As a Bonus you can even define a event command that restarts your service:

object EventCommand "Restart DHCP" {
    import "plugin-event-command"
    command = [ "/usr/bin/sudo", "systemctl", "restart" ]
    arguments += {
        "(no key)" = {
            skip_key = true
            value = "$check_service_name$"
        }
    }
    vars.check_service_name = "isc-dhcp-server"
}

But for this to work, you have to give your nagios user (or whatever user runs your icinga service) sudo privileges to restart services. Add this line to your sudoers file:

nagios ALL = (ALL) NOPASSWD: /bin/systemctl restart *

I hope this helps you with your problem :-)

Jan

Jan
  • 41
  • 6