0

I have installed Nagios successfully, and added the following services:

nano /usr/local/nagios/etc/objects/services.cfg

define host {
    use                 linux-server
    host_name           dcctst1e
    address             160.81.38.74
}

define host {
    use                 linux-server
    host_name           dcctst1f
    address             160.81.38.75
}

define host {
    use                 linux-server
    host_name           dcctst1g
    address             160.81.38.76
}

define hostgroup {
    hostgroup_name ganglia-servers
    alias   nagios server
    members *
}

define servicegroup {
  servicegroup_name ganglia-metrics
  alias Ganglia Metrics
}

define command {
  command_name check_ganglia
  command_line $USER1$/check_ganglia.py -h $HOSTNAME$ -m $ARG1$ -w $ARG2$ -c $ARG3$ -o $ARG4$
}

define service{
        use                             ganglia-service
        service_description             Free Memory
        check_command                   check_ganglia!mem_free!200!50!1
        contact_groups admins
}

define service{
        use                             ganglia-service
        service_description             load_one
        check_command                   check_ganglia!load_one!4!5!0
        contact_groups admins
}
define service{
        use                             ganglia-service
        service_description             disk_free
        check_command                   check_ganglia!disk_free!40!50!0
        contact_groups admins
}
define service{
        use                             ganglia-service
        service_description             yarn.NodeManagerMetrics.AvailableGB
        check_command                   check_ganglia!yarn.NodeManagerMetrics.AvailableGB!8!4!1
        contact_groups admins
}
define service{
        use                             ganglia-service
        service_description             Temperature
        check_command                   check_ganglia!!8!4!1
        contact_groups admins
}

As shown in the screenshot below, some of the relevant plugins (like, disk_free, load_one, etc are present in /usr/local/nagios/libexec/. But, when checking the service disk_free, it gives error:

$ python check_ganglia.py

Usage: check_ganglia -h|--host= -m|--metric= -w|--warning= -c|critical= [-o|--opposite=] [-s|--server=] [-p|--port=]

$ python check_ganglia.py -h dcctst1f -m disk_free -w 40 -c 50 -o 1

CHECKGANGLIA UNKNOWN: Error while getting value"no element found: line1, column 0"

Why is this? What can I do to make it work?

I am also attaching a screenshot of the web version of the services; I expected 3 of the services to be green as their plugins are installed.

enter image description here

P.S.

Since the error in Nagios web says:

(No output on stdout) stderr: /usr/local/nagios/libexec/check_ganglia.py: line 4: import command not found

I commented the 4th line of check_ganglia.py, which was import sys. When I ran the command again, it gives the error:

NameError: name sys is not defined

So, clearly, I cannot comment out import sys

How can I resolve this?

Ivan
  • 34,531
  • 8
  • 55
  • 100
Kristada673
  • 3,512
  • 6
  • 39
  • 93
  • Do you have on the first line of your script `check_ganglia.py` something like `#!/usr/bin/python`? – Rohlik Dec 29 '17 at 09:01
  • Yes, the exact first line is `#!/usr/bin/env python` – Kristada673 Dec 29 '17 at 09:05
  • So, `python check_ganglia.py` works without problem. What about `./check_ganglia.py`? Is it working?` – Rohlik Dec 29 '17 at 15:28
  • @Rohlik Yes, it is working. Gives the same output as that by `python check_ganglia.py`. – Kristada673 Jan 02 '18 at 02:36
  • Can you try run the `check_ganglia.py` script as Nagios user? – Rohlik Jan 02 '18 at 12:25
  • I am yet to check that. However, I managed to get around this issue by installing NRPE (Nagios Remote Plugin Executor), where I am able to successfully run commands defined in it like `/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 -c check_load`. But, and this is a different issue, I am not able to install more plugins. I have described the problem in more detail here: https://stackoverflow.com/questions/48070470/how-do-i-get-a-custom-nagios-plugin-to-work-with-nrpe If you don't mind, would you kindly have a look and guide me on how to install the `check_hadoop_namenode.pl` service?Thanks – Kristada673 Jan 03 '18 at 02:40

0 Answers0