Page 1 of 3

Check CPU Load and Logged in Users on Remote Host

Posted: Mon Dec 28, 2015 1:58 pm
by ep7network
I have successfully installed nagios 4.1.1, nagios plugins 2.1.1 and I installed NRPE 2.15. My Nagios server is running centOS 7. My remote hosts are running centOS 6.6.
My question is how can I monitor a remote host, specifically CPU load, memory usage and logged in users?
I've already installed nrpe and nagios-plugins on my client system.
When I access nagios through the web, I do see my remote client and I see CPU Load and check_local_users, but the status information read "SSH OK -OpenSSH_5.3"
I believe it should provide a description of how many users are logged in.
In my client configuration file I have this
define service {
use generic-service
host_name NS1
service_description SSH
check_command check_ssh
notifications_enabled 0
}
define service {
use generic-service
host_name NS1
service_description CPU Load
check_command check_ssh
notifications_enabled 0
}
define service {
use generic-service
host_name NS1
service_description check_local_users
check_command check_ssh
notifications_enabled 0
}

Re: Check CPU Load and Logged in Users on Remote Host

Posted: Mon Dec 28, 2015 2:09 pm
by hsmith
Can you run this from the command line?

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H <IPADDRESS> -c check_users -a '-w 2 -c 3'
You should see output like:

Code: Select all

USERS OK - 0 users currently logged in |users=0;2;3;0
This will verify check_users is working.

Re: Check CPU Load and Logged in Users on Remote Host

Posted: Mon Dec 28, 2015 2:14 pm
by rkennedy
To clarify, the check_ssh command checks the ssh service on the machine. It doesn't run commands like the check_by_ssh command.

Also, to clarify, you mention NRPE, but your check commands are using ssh - are you looking to do NRPE checks or check_by_ssh checks?

Re: Check CPU Load and Logged in Users on Remote Host

Posted: Mon Dec 28, 2015 2:32 pm
by ep7network
I ran the command from my nagios server and I received a message saying "No such file or directory"?

Re: Check CPU Load and Logged in Users on Remote Host

Posted: Mon Dec 28, 2015 2:36 pm
by ep7network
rkennedy wrote:To clarify, the check_ssh command checks the ssh service on the machine. It doesn't run commands like the check_by_ssh command.

Also, to clarify, you mention NRPE, but your check commands are using ssh - are you looking to do NRPE checks or check_by_ssh checks?
I want to run NRPE checks. I choose to run NRPE to check how many users are logged in and CPU Load

Re: Check CPU Load and Logged in Users on Remote Host

Posted: Mon Dec 28, 2015 2:37 pm
by rkennedy
That's where your plugins should be installed. Can you run this and post the output? -

Code: Select all

ls -l /usr/local/nagios/libexec
ep7network wrote:
rkennedy wrote:To clarify, the check_ssh command checks the ssh service on the machine. It doesn't run commands like the check_by_ssh command.

Also, to clarify, you mention NRPE, but your check commands are using ssh - are you looking to do NRPE checks or check_by_ssh checks?
I want to run NRPE checks. I choose to run NRPE to check how many users are logged in and CPU Load
Thanks for the clarification.

Re: Check CPU Load and Logged in Users on Remote Host

Posted: Mon Dec 28, 2015 2:43 pm
by ep7network
rkennedy wrote:That's where your plugins should be installed. Can you run this and post the output? -

Code: Select all

ls -l /usr/local/nagios/libexec
ep7network wrote:
rkennedy wrote:To clarify, the check_ssh command checks the ssh service on the machine. It doesn't run commands like the check_by_ssh command.

Also, to clarify, you mention NRPE, but your check commands are using ssh - are you looking to do NRPE checks or check_by_ssh checks?
I want to run NRPE checks. I choose to run NRPE to check how many users are logged in and CPU Load
Thanks for the clarification.
I ran the command from my nagios server and my output is below
total 6844
-rwxr-xr-x. 1 nagios nagios 205922 Dec 27 08:41 check_apt
-rwxr-xr-x. 1 nagios nagios 2309 Dec 27 08:41 check_breeze
-rwxr-xr-x. 1 nagios nagios 210135 Dec 27 08:41 check_by_ssh
lrwxrwxrwx. 1 root root 9 Dec 27 08:41 check_clamd -> check_tcp
-rwxr-xr-x. 1 nagios nagios 158867 Dec 27 08:41 check_cluster
-r-sr-xr-x. 1 root nagios 207752 Dec 27 08:41 check_dhcp
-rwxr-xr-x. 1 nagios nagios 202417 Dec 27 08:41 check_dig
-rwxr-xr-x. 1 nagios nagios 224866 Dec 27 08:41 check_disk
-rwxr-xr-x. 1 nagios nagios 9348 Dec 27 08:41 check_disk_smb
-rwxr-xr-x. 1 nagios nagios 225334 Dec 27 08:41 check_dns
-rwxr-xr-x. 1 nagios nagios 118795 Dec 27 08:41 check_dummy
-rwxr-xr-x. 1 nagios nagios 3542 Dec 27 08:41 check_file_age
-rwxr-xr-x. 1 nagios nagios 6375 Dec 27 08:41 check_flexlm
lrwxrwxrwx. 1 root root 9 Dec 27 08:41 check_ftp -> check_tcp
-rwxr-xr-x. 1 nagios nagios 348334 Dec 27 08:41 check_http
-r-sr-xr-x. 1 root nagios 219403 Dec 27 08:41 check_icmp
-rwxr-xr-x. 1 nagios nagios 165745 Dec 27 08:41 check_ide_smart
-rwxr-xr-x. 1 nagios nagios 15238 Dec 27 08:41 check_ifoperstatus
-rwxr-xr-x. 1 nagios nagios 13386 Dec 27 08:41 check_ifstatus
lrwxrwxrwx. 1 root root 9 Dec 27 08:41 check_imap -> check_tcp
-rwxr-xr-x. 1 nagios nagios 6947 Dec 27 08:41 check_ircd
lrwxrwxrwx. 1 root root 9 Dec 27 08:41 check_jabber -> check_tcp
-rwxr-xr-x. 1 nagios nagios 183434 Dec 27 08:41 check_load
-rwxr-xr-x. 1 nagios nagios 6595 Dec 27 08:41 check_log
-rwxr-xr-x. 1 nagios nagios 22730 Dec 27 08:41 check_mailq
-rwxr-xr-x. 1 nagios nagios 164911 Dec 27 08:41 check_mrtg
-rwxr-xr-x. 1 nagios nagios 166276 Dec 27 08:41 check_mrtgtraf
-rwxr-xr-x. 1 nagios nagios 182294 Dec 27 08:41 check_nagios
lrwxrwxrwx. 1 root root 9 Dec 27 08:41 check_nntp -> check_tcp
lrwxrwxrwx. 1 root root 9 Dec 27 08:41 check_nntps -> check_tcp
-rwxrwxr-x. 1 nagios nagios 81510 Dec 27 08:49 check_nrpe
-rwxr-xr-x. 1 nagios nagios 211452 Dec 27 08:41 check_nt
-rwxr-xr-x. 1 nagios nagios 214711 Dec 27 08:41 check_ntp
-rwxr-xr-x. 1 nagios nagios 203908 Dec 27 08:41 check_ntp_peer
-rwxr-xr-x. 1 nagios nagios 199073 Dec 27 08:41 check_ntp_time
-rwxr-xr-x. 1 nagios nagios 245989 Dec 27 08:41 check_nwstat
-rwxr-xr-x. 1 nagios nagios 8926 Dec 27 08:41 check_oracle
-rwxr-xr-x. 1 nagios nagios 184583 Dec 27 08:41 check_overcr
-rwxr-xr-x. 1 nagios nagios 214756 Dec 27 08:41 check_ping
lrwxrwxrwx. 1 root root 9 Dec 27 08:41 check_pop -> check_tcp
-rwxr-xr-x. 1 nagios nagios 215914 Dec 27 08:41 check_procs
-rwxr-xr-x. 1 nagios nagios 181357 Dec 27 08:41 check_real
-rwxr-xr-x. 1 nagios nagios 9642 Dec 27 08:41 check_rpc
-rwxr-xr-x. 1 nagios nagios 1465 Dec 27 08:41 check_sensors
lrwxrwxrwx. 1 root root 9 Dec 27 08:41 check_simap -> check_tcp
-rwxr-xr-x. 1 nagios nagios 272363 Dec 27 08:41 check_smtp
lrwxrwxrwx. 1 root root 9 Dec 27 08:41 check_spop -> check_tcp
-rwxr-xr-x. 1 nagios nagios 180856 Dec 27 08:41 check_ssh
lrwxrwxrwx. 1 root root 9 Dec 27 08:41 check_ssmtp -> check_tcp
-rwxr-xr-x. 1 nagios nagios 162647 Dec 27 08:41 check_swap
-rwxr-xr-x. 1 nagios nagios 257854 Dec 27 08:41 check_tcp
-rwxr-xr-x. 1 nagios nagios 182651 Dec 27 08:41 check_time
lrwxrwxrwx. 1 root root 9 Dec 27 08:41 check_udp -> check_tcp
-rwxr-xr-x. 1 nagios nagios 195159 Dec 27 08:41 check_ups
-rwxr-xr-x. 1 nagios nagios 155189 Dec 27 08:41 check_uptime
-rwxr-xr-x. 1 nagios nagios 153879 Dec 27 08:41 check_users
-rwxr-xr-x. 1 nagios nagios 2995 Dec 27 08:41 check_wave
-rwxr-xr-x. 1 nagios nagios 149404 Dec 27 08:41 negate
-rwxr-xr-x. 1 nagios nagios 147040 Dec 27 08:41 urlize
-rwxr-xr-x. 1 nagios nagios 1949 Dec 27 08:41 utils.pm
-rwxr-xr-x. 1 nagios nagios 2791 Dec 27 08:41 utils.sh

Re: Check CPU Load and Logged in Users on Remote Host

Posted: Mon Dec 28, 2015 2:48 pm
by hsmith
The command I pasted should have worked. That was run from the Nagios server, right?

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H <IPADDRESS> -c check_users -a '-w 2 -c 3'
Did you replace <IPADDRESS> with your client IP?

Like this:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H 172.16.0.1 -c check_users -a '-w 2 -c 3'

Re: Check CPU Load and Logged in Users on Remote Host

Posted: Mon Dec 28, 2015 2:48 pm
by ep7network
hsmith wrote:Can you run this from the command line?

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H <IPADDRESS> -c check_users -a '-w 2 -c 3'
You should see output like:

Code: Select all

USERS OK - 0 users currently logged in |users=0;2;3;0
This will verify check_users is working.
I ran the command from my nagios server and I received a message saying "No such file or directory"?

Re: Check CPU Load and Logged in Users on Remote Host

Posted: Mon Dec 28, 2015 2:49 pm
by ep7network
hsmith wrote:The command I pasted should have worked. That was run from the Nagios server, right?

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H <IPADDRESS> -c check_users -a '-w 2 -c 3'
Did you replace <IPADDRESS> with your client IP?

Like this:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H 172.16.0.1 -c check_users -a '-w 2 -c 3'
Yes!!