Monitoring IPCop via nrpe

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
mkot
Posts: 68
Joined: Tue Feb 25, 2014 1:47 am
Location: Poland

Monitoring IPCop via nrpe

Post by mkot »

Hi, I found plugin for monitoring IPCop via nrpe plugin:
http://ipcop.stankowic-development.net/index_en.php. I can't find manual how to do this. I installed plugin, configured nrpe.cfg at IPCop and added services for monitoring /dev/md0, /dev/md1 disks but I get

Code: Select all

(Return code of 255 is out of bounds) 
. How should I configure it properly?

Oh, when I run

Code: Select all

root@router-wa-vectra:~ #  /var/ipcop/addons/nrpe/plugins/check_disk -w 20 -c 10 -p /dev/md0
DISK OK - free space: / 144 MB (24% inode=70%);| /=452MB;608;618;0;628
I get good info.
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Monitoring IPCop via nrpe

Post by slansing »

Can you show us an example of the command that is failing? We really need to see how you are running it. Additionally that error is generally thrown when a plugin is not executable, have you made it executable on the remote server?
mkot
Posts: 68
Joined: Tue Feb 25, 2014 1:47 am
Location: Poland

Re: Monitoring IPCop via nrpe

Post by mkot »

Hi, acctually I disabled nrpe, because it caused issues with passive checks via nsca client - http://support.nagios.com/forum/viewtop ... =7&t=26251. So I'll try figure out wtf is going on ;)

Is there a procedure for configuring nsca at linux hosts? I'd like to monitor HDD (e.g. /, /home, /mnt/backup), CPU and MEM usage but I can't find simple procedure for this :(
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Monitoring IPCop via nrpe

Post by abrist »

Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
mkot
Posts: 68
Joined: Tue Feb 25, 2014 1:47 am
Location: Poland

Re: Monitoring IPCop via nrpe

Post by mkot »

Yes, I found this http://nagios.sourceforge.net/download/ ... _Setup.pdf but I stuck at page 5 - configuration service at host machine :/ I'll try figure it out how to do it.


EDIT:
Sorry, but I don't get it. How should I configure nsca at remote host which should be monitoring via passive checks? In this pdf I can see how to configure localhost (Nagios server?) but how should I configure other hosts?
mkot
Posts: 68
Joined: Tue Feb 25, 2014 1:47 am
Location: Poland

Re: Monitoring IPCop via nrpe

Post by mkot »

slansing wrote:Can you show us an example of the command that is failing? We really need to see how you are running it. Additionally that error is generally thrown when a plugin is not executable, have you made it executable on the remote server?
And commands for this (only for HDD):

Code: Select all

command[check_/]=/usr/local/nagios/libexec/check_disk -w 1% -c 0% -p /dev/md0
command[check_/var/log]=/usr/local/nagios/libexec/check_disk -w 1% -c 0% -p /dev/md1
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Monitoring IPCop via nrpe

Post by slansing »

What is giving you trouble on page 5? We can help you out!
mkot
Posts: 68
Joined: Tue Feb 25, 2014 1:47 am
Location: Poland

Re: Monitoring IPCop via nrpe

Post by mkot »

Bassically I dont get it. I know I have to create command, template service for this command and service for checking stuff send from hosts. But what should I do at host side? Configure nsca (send_nsca.cfg, nsca.cfg, xinet.d), but what next? Where should I add commands for sending informations from host to serwer?

At nrpe in host I had nrpe.cfg file where I had to add some command which return some values:

Code: Select all

command[check_mem]=/usr/local/nagios/libexec/check_mem.pl -w 98 -c 99
command[check_cpu]=/usr/local/nagios/libexec/check_cpu.sh -w 98 -c 99
command[check_/]=/usr/local/nagios/libexec/check_disk -w 1% -c 0% -p /dev/mapper/pdc_dfagcaei1
But how is it done in nsca???
Attachments
check_mem.pl
Usage of memory
(6.49 KiB) Downloaded 286 times
check_cpu.sh
Usage of CPU
(6.21 KiB) Downloaded 283 times
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Monitoring IPCop via nrpe

Post by slansing »

So essentially what you need to do now, is create a host, and services that match what is being sent in by the NSCA packets, you should have tested this further up in the document to see what is sent over to the nagios server, and from that, you would name your host/services. Nagios will then push data from the NSCA packets being send in from the remote host, to those services with updated status information each time nsca runs the checks on that host. The packet, and it's output you checked for in the log, should match similar to this:

Code: Select all

<hostname>[tab]<svc_description>[tab]<return_code>[tab]<plugin_output>[newline]
mkot
Posts: 68
Joined: Tue Feb 25, 2014 1:47 am
Location: Poland

Re: Monitoring IPCop via nrpe

Post by mkot »

Ok, I managed to set up monitoring Windows hosts via nsca, sample code:

commands.cfg

Code: Select all

# Dodane 2014-03-26 - mkot
# 'check_nsca' command definition for passive hosts checking
define command{
        command_name    check_nsca
        command_line    $USER1$/check_nsca -H $HOSTADDRESS$ -c $ARG1$ -t 20
        }
# KONIEC - 2014-03-26 - mkot
TAIWA.cfg (one of hosts' definition cfg file)

Code: Select all

# Create a service for monitoring CPU load
# Change the host_name to match the name of the host you defined above

define service{
        use                     generic-service,nagiosgraph
        hostgroup_name          TAIWA
        service_description     CPU Load
        check_command           check_nsca!CPU Load
        notification_options    w,c
        flap_detection_enabled  0
        active_checks_enabled   0
        passive_checks_enabled  1
        }

# Create a service for monitoring memory usage
# Change the host_name to match the name of the host you defined above

define service{
        use                     generic-service,nagiosgraph
        hostgroup_name          TAIWA
        service_description     MEM Load
        check_command           check_nsca!MEM Load
        notification_options    w,c
        flap_detection_enabled  0
        active_checks_enabled   0
        passive_checks_enabled  1
        }

# Create a service for monitoring C:\ disk usage
# Change the host_name to match the name of the host you defined above

define service{
        use                     generic-service,nagiosgraph
        hostgroup_name          TAIWA
        service_description     DISK Load C
        check_command           check_nsca!DISK Load C
        notification_options    w,c
        flap_detection_enabled  0
        active_checks_enabled   0
        passive_checks_enabled  1
        }

NSC.ini and nsclient.ini

Code: Select all

NSC.ini
CPU Load=checkCPU warn=50 crit=80 time=20m time=10s time=4
MEM Load=checkMem MaxWarn=85% MaxCrit=90% ShowAll type=physical
DISK Load C=CheckDriveSize MinWarn=2% MinCrit=1% Drive=C FilterType=FIXED

nsclient.ini
; alias_cpu - Alias for alias_cpu. To configure this item add a section called: /settings/external scripts/alias/alias_cpu
alias_cpu = checkCPU warn=50 crit=80 time=5m time=1m time=30s

; alias_disk - Alias for alias_disk. To configure this item add a section called: /settings/external scripts/alias/alias_disk
alias_disk_c = CheckDriveSize MinWarn=2% MinCrit=1% Drive=C FilterType=FIXED

; alias_mem - Alias for alias_mem. To configure this item add a section called: /settings/external scripts/alias/alias_mem
alias_mem = checkMem MaxWarn=85% MaxCrit=90% ShowAll=long type=physical

CPU Load=alias_cpu
MEM Load=alias_mem
DISK Load C=alias_disk_c
Now I want make Active checking for Linux servers (Ubuntu, CentOS, FreeBSD, IPCop (firewall - http://www.ipcop.org/)). I added command for checking nrpe in commands.cfg file:

Code: Select all

# Dodane 2014-03-06 - mkot
# 'check_nrpe' command definition for active hosts checking
define command{
        command_name    check_nrpe
        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -t 20
        }
and added some piece of code to linux.cfg file:

Code: Select all

# Użycie dysków twardych #
# główna partycja - /
define service{
        use                     local-service
        host_name               domena-wa, router-wa-vectra
        service_description     /
        check_command           check_nrpe!check_/
        notifications_enabled   1
        flap_detection_enabled  0
        active_checks_enabled   1
        passive_checks_enabled  0
        }
At Linux host I installed nrpe addon with xinetd, the configuration is:
- added: user/group

Code: Select all

nagios/nagios
- /etc/xinet.d/nrpe

Code: Select all

# default: on
# description: NRPE (Nagios Remote Plugin Executor)
service nrpe
{
        flags           = REUSE
        socket_type     = stream
        port            = 5666
        wait            = no
        user            = nagios
        group           = nagios
        server          = /usr/local/nagios/bin/nrpe
        server_args     = -c /usr/local/nagios/etc/nrpe.cfg --inetd
        log_on_failure  += USERID
        disable         = no
        only_from       = <IP_Nagios_Server>
}
- /usr/local/nagios/etc/nrpe.cfg

Code: Select all

log_facility=daemon

pid_file=/var/run/nrpe.pid

server_port=5666

nrpe_user=nagios

nrpe_group=nagios

allowed_hosts=<IP_Nagios_Server>

dont_blame_nrpe=0

allow_bash_command_substitution=0

debug=1

command_timeout=60

connection_timeout=300

command[check_/]=/usr/local/nagios/libexec/check_disk -w 1% -c 0% -p /dev/mapper/pdc_dfagcaei1
#command[check_/mnt/backup]=/usr/local/nagios/libexec/check_disk -w 1% -c 0% -p /dev/sda1
#command[check_/home]=/usr/local/nagios/libexec/check_disk -w 1% -c 0% -p /dev/mapper/pdc_dfagcaei6
#command[check_/home/domena/raporty]=/usr/local/nagios/libexec/check_disk -w 1% -c 0% -p /dev/mapper/pdc_jifggjdg6
#command[check_/home/domena/wymiana_miedzyoddzial]=/usr/local/nagios/libexec/check_disk -w 1% -c 0% -p /dev/mapper/pdc_jifggjdg5
#command[check_raid]=/usr/local/nagios/libexec/check_raid
#command[check_mem]=/usr/local/nagios/libexec/check_mem.pl -w 98 -c 99
#command[check_cpu]=/usr/local/nagios/libexec/check_cpu.sh -w 98 -c 99
-/etc/services

Code: Select all

nrpe  5666/tcp #nrpe

Code: Select all

root@domena-wa:~# netstat -an |grep 5666
tcp        0      0 0.0.0.0:5666            0.0.0.0:*               LISTEN

Code: Select all

root@domena-wa:~# ps aux |grep nrpe
root      6295  0.0  0.0   5708   768 pts/0    S+   21:16   0:00 grep --color=auto nrpe
And this is not working correctly, I get status OK with status information:

Code: Select all

(Return code of 255 is out of bounds) 
EDIT:
Code from /var/log/syslog from Nagios Server

Code: Select all

Mar 26 22:11:18 nagios nagios: Warning: Return code of 255 for check of service '/' on host 'domena-wa' was out of bounds.
Code from /var/log/syslog from monitored Linux Ubuntu Server:

Code: Select all

Mar 26 20:49:47 domena-wa nrpe[5778]: Added command[check_/]=/usr/local/nagios/libexec/check_disk -w 1% -c 0% -p /dev/mapper/pdc_dfagcaei1
When I run /usr/local/nagios/libexec/check_disk -w 1% -c 0% -p /dev/mapper/pdc_dfagcaei1 at LUS I get:

Code: Select all

DISK OK - free space: / 32982 MB (74% inode=96%);| /=11567MB;46463;46933;0;46933
Locked