NRPE Chcek_Memory on Linix

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.
kwhogster
Posts: 644
Joined: Wed Oct 14, 2015 6:51 pm
Location: Wood Ridge NJ USA
Contact:

Re: NRPE Chcek_Memory on Linix

Post by kwhogster »

My nrpe.cfg on VMA host is this now
command[check_mem]=/usr/local/nagios/libexec/check_mem.sh -w $ARG1$ -c $ARG2$

After I changed the file I ran this
vi-admin@tgkw002:~> sudo service nrpe status
Checking for nrpe daemon... running
vi-admin@tgkw002:~> sudo service nrpe restart
Shutting down nrpe done
Starting nrpe done

Ran this on VMA host

vi-admin@tgkw002:~> sudo /usr/local/nagios/libexec/check_mem.sh -w 80% -c 90%
vi-admin's password:
/usr/local/nagios/libexec/check_mem.sh: line 1: et: command not found
error: Not a number


Ran this on Nagios Host

root@tgcs017:/home/thomas# /usr/lib/nagios/plugins/check_nrpe -H 10.2.8.7 -t 30 -c check_mem -a '-w 80% -c 90%'
NRPE: Unable to read output


What I am doing wrong here?
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: NRPE Chcek_Memory on Linix

Post by ssax »

Please attach the exact check_mem.sh file so that I can review it.


Thank you
kwhogster
Posts: 644
Joined: Wed Oct 14, 2015 6:51 pm
Location: Wood Ridge NJ USA
Contact:

Re: NRPE Chcek_Memory on Linix

Post by kwhogster »

See attached

also I got it from here

https://exchange.nagios.org/components/ ... 4&cf_id=24


Update

This lead me to looking at the script I downloaded myself and found the first two lines where not correct.

I changed them on my Nagios server
restarted Nagios and now the localhost is working

next will be getting the remote hosts to work

two more to go.
Attachments
check_mem.sh
check_mem.sh
(3.32 KiB) Downloaded 249 times
kwhogster
Posts: 644
Joined: Wed Oct 14, 2015 6:51 pm
Location: Wood Ridge NJ USA
Contact:

Re: NRPE Chcek_Memory on Linix

Post by kwhogster »

Ok

I have two Linux Hosts not working yet

1. RaspberryPi Debain 8 UNKNOWN STATUS No handler for command: check_mem
2. SUSE Enterprise Linux 11.0 SP3 UNKNOWN STATUS NRPE: Unable to read output


1. NRPE.CFG
command[check_mem]=/usr/local/nagios/libexec/check_mem.sh -w $ARG1$ -c $ARG2$

pi@raspberrypi /usr/local/nagios/libexec $ ls
check_apt check_flexlm check_mem.sh check_overcr check_udp
check_breeze check_ftp check_mrtg check_ping check_ups
check_by_ssh check_http check_mrtgtraf check_pop check_uptime
check_clamd check_icmp check_nagios check_procs check_users
check_cluster check_ide_smart check_nntp check_real check_wave
check_dhcp check_ifoperstatus check_nrpe check_rpc negate
check_dig check_ifstatus check_nt check_sensors urlize
check_disk check_imap check_ntp check_smtp utils.pm
check_disk_smb check_ircd check_ntp_peer check_ssh utils.sh
check_dns check_load check_ntp_time check_swap
check_dummy check_log check_nwstat check_tcp
check_file_age check_mailq check_oracle check_time


pi@raspberrypi /usr/local/nagios/libexec $ sudo service nagios-nrpe-server restart




2 NRPE.CFG
command[check_mem]=/usr/local/nagios/libexec/check_mem.sh -w $ARG1$ -c $ARG2$

vi-admin@tgkw002:~> ls /usr/local/nagios/libexec
check_mem.sh check_nrpe

vi-admin@tgkw002:~> sudo service nrpe status
vi-admin's password:
Checking for nrpe daemon... running
vi-admin@tgkw002:~> sudo service nrpe restart
Shutting down nrpe done
Starting nrpe done
vi-admin@tgkw002:~> sudo service nrpe status
Checking for nrpe daemon... running


What am I missing here
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: NRPE Chcek_Memory on Linix

Post by Box293 »

kwhogster wrote:1. RaspberryPi Debain 8 UNKNOWN STATUS No handler for command: check_mem
kwhogster wrote:1. NRPE.CFG
command[check_mem]=/usr/local/nagios/libexec/check_mem.sh -w $ARG1$ -c $ARG2$
What is the output of this command on your Pi:

Code: Select all

find /usr/ -name 'nrpe.cfg'
kwhogster wrote:2. SUSE Enterprise Linux 11.0 SP3 UNKNOWN STATUS NRPE: Unable to read output
What happens when you execute the plugin on the vMA?

Code: Select all

/usr/local/nagios/libexec/check_mem.sh
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
kwhogster
Posts: 644
Joined: Wed Oct 14, 2015 6:51 pm
Location: Wood Ridge NJ USA
Contact:

Re: NRPE Chcek_Memory on Linix

Post by kwhogster »

On my PI

root@raspberrypi:~# find /usr/ -name 'nrpe.cfg'
/usr/local/nagios/etc/nrpe.cfg

and in nrpe.cfg I have this line
command[check_mem]=/usr/local/nagios/libexec/check_mem.sh -w $ARG1$ -c $ARG2$


On WMA SUS Enterprise 11.0 SP3

Welcome to vMA
vi-admin@tgkw002:~> /usr/local/nagios/libexec/check_mem.sh
[MEMORY] Total: 576 MB - Used: 116 MB - 19% [SWAP] Total: 133 MB - Used: 2 MB - 1% | MTOTAL=604598272;;;; MUSED=120762368;;;; MCACHE=56971264;;;; MBUFFER=63148032;;;; STOTAL=140505088;;;; SUSED=2162688;;;;
vi-admin@tgkw002:~>



Thoughts?

Thanks
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: NRPE Chcek_Memory on Linix

Post by lmiltchev »

I have two Linux Hosts not working yet

1. RaspberryPi Debain 8 UNKNOWN STATUS No handler for command: check_mem
2. SUSE Enterprise Linux 11.0 SP3 UNKNOWN STATUS NRPE: Unable to read output
Let's troubleshoot one issue at a time, starting with the RaspberryPi box. Run the following commands, and show the output:

On the RaspberryPi:

Code: Select all

ip addr
ps axuw | grep nrpe
netstat -at | grep nrpe
grep only_from /etc/xinetd.d/nrpe
grep 'allowed_hosts\|check_mem' /usr/local/nagios/etc/nrpe.cfg
/usr/local/nagios/libexec/check_mem.sh -w 80 -c 90
On Nagios server:

Code: Select all

ip addr
/usr/lib/nagios/plugins/check_nrpe -H <client ip>
/usr/lib/nagios/plugins/check_nrpe -H <client ip> -c check_mem -a 80 90
Be sure to check out our Knowledgebase for helpful articles and solutions!
kwhogster
Posts: 644
Joined: Wed Oct 14, 2015 6:51 pm
Location: Wood Ridge NJ USA
Contact:

Re: NRPE Chcek_Memory on Linix

Post by kwhogster »

from the raspberry Pi

root@raspberrypi:~# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether b8:27:eb:d9:3e:c0 brd ff:ff:ff:ff:ff:ff
inet 10.2.8.72/22 brd 10.2.11.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::ba27:ebff:fed9:3ec0/64 scope link
valid_lft forever preferred_lft forever
root@raspberrypi:~# ps axuw | grep nrpe
nagios 2927 0.0 0.4 4256 1964 ? Ss Aug19 0:00 /usr/sbin/nrpe -c /etc/nagios/nrpe.cfg -d
root 10372 0.0 0.4 4272 1872 pts/0 S+ 20:31 0:00 grep nrpe
root@raspberrypi:~# netstat -at | grep nrpe
tcp 0 0 *:nrpe *:* LISTEN
tcp6 0 0 [::]:nrpe [::]:* LISTEN
root@raspberrypi:~# grep only_from /etc/xinetd.d/nrpe
grep: /etc/xinetd.d/nrpe: No such file or directory
root@raspberrypi:~# grep 'allowed_hosts\|check_mem' /usr/local/nagios/etc/nrpe.cfg
allowed_hosts=10.2.8.79
command[check_mem]=/usr/local/nagios/libexec/check_mem.sh -w $ARG1$ -c $ARG2$
root@raspberrypi:~# /usr/local/nagios/libexec/check_mem.sh -w 80 -c 90
[MEMORY] Total: 434 MB - Used: 162 MB - 37% [SWAP] Total: 99 MB - Used: 0 MB - 0% | MTOTAL=455725056;;;; MUSED=169955328;;;; MCACHE=163807232;;;; MBUFFER=106954752;;;; STOTAL=104853504;;;; SUSED=45056;;;;
root@raspberrypi:~#



From the Nagios server
root@tgcs017:/usr/local/nagios/etc/objects# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:0c:29:ec:4f:3d brd ff:ff:ff:ff:ff:ff
inet 10.2.8.79/22 brd 10.2.11.255 scope global ens160
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:feec:4f3d/64 scope link
valid_lft forever preferred_lft forever
root@tgcs017:/usr/local/nagios/etc/objects# /usr/lib/nagios/plugins/check_nrpe -H 10.2.8.72
NRPE v2.15
root@tgcs017:/usr/local/nagios/etc/objects# /usr/lib/nagios/plugins/check_nrpe -H 10.2.8.72 -c check_mem -a 80 90
CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.
root@tgcs017:/usr/local/nagios/etc/objects#



Thoughts?
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: NRPE Chcek_Memory on Linix

Post by tgriep »

This output

Code: Select all

/usr/sbin/nrpe -c /etc/nagios/nrpe.cfg -d
Shows that the nrpe is running as a daemon and that we are editing the wrong nrpe.cfg file.
Edit this file

Code: Select all

/etc/nagios/nrpe.cfg
and make sure the allowed_hosts setting has the nagios server's IP address and that the check_mem command is defined in the file.

Code: Select all

command[check_mem]=/usr/local/nagios/libexec/check_mem.sh -w $ARG1$ -c $ARG2$
Then restart the nrpe daemon and see if the test from the Nagios server works for you.
Be sure to check out our Knowledgebase for helpful articles and solutions!
kwhogster
Posts: 644
Joined: Wed Oct 14, 2015 6:51 pm
Location: Wood Ridge NJ USA
Contact:

Re: NRPE Chcek_Memory on Linix

Post by kwhogster »

On the Raspberry Pi

I found two nrpe.cfg files they both contain the same values

root@raspberrypi:~# find / -name nrpe.cfg
/usr/local/nagios/etc/nrpe.cfg
/etc/nagios/nrpe.cfg
/tmp/linux-nrpe-agent/subcomponents/nrpe/mods/cfg/nrpe.cfg
/tmp/nrpe-3.0/sample-config/nrpe.cfg

both have Allowed Hosts 10.2.8.79 which is the Nagios servers ip address

both have this command defined
command[check_mem]=/usr/local/nagios/libexec/check_mem.sh -w $ARG1$ -c $ARG2$

Puzzled on why this is not working


Thoughts?
Locked