How to use alias from NSClient in Nagios

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.
Locked
Melanie123
Posts: 10
Joined: Wed Mar 07, 2018 7:19 am

How to use alias from NSClient in Nagios

Post by Melanie123 »

Hi all,

I have Nagios Core 3.5.1 on Ubuntu and monitoring remote Windows 7.
I installed NSClient++ there, the check_nt plugins work. Currently, I started to play with check_nrpe and I would ask for help.

I declared on remote host in the nsclient.ini:

Code: Select all

[/settings/external scripts/alias]
alias_test = CheckDriveSize FilterType=FIXED matching=.*[CD].* ShowAll=long CheckAll $ARG1$ $ARG2$ $ARG3$ $ARG4$
On Nagios, when I write:

Code: Select all

root@ubuntu:/usr/local/nagios/libexec# ./check_nrpe -H xxx.xxx.xx.xxx -c alias_test
I have answer:

Code: Select all

OK C:\: Total: 78.702GB - Used: 18.597GB (24%) - Free: 60.105GB (76%), D:\: Total: 81.295GB - Used: 3.49GB (5%) - Free: 77.804GB (95%)|'C:\ used'=18.59669GB;62.96171;70.83193;0;78.70214 'C:\ used %'=24%;80;90;0;100 'D:\ used'=3.49046GB;65.03593;73.16542;0;81.29491 'D:\ used %'=4%;80;90;0;100
But now I would like to see it on the website.
I've tried various combinations found (changes in commands.cfg, windows.cfg) on the internet, but the effect is that I always have "Status Information: (Return code of 127 is out of bounds - plugin may be missing)"

I will mention that I also have a problem with the plugin check_nrpe. On the example of check_users, where:
In commands.cfg:

Code: Select all

define command{
 	command_name 	check_nrpe
 	command_line 	$USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ 
 	}
In nrpe.cfg on Nagios:

Code: Select all

# The following examples use hardcoded command arguments...

command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
And in windows.cfg:

Code: Select all

define service{
    use                 generic-service
    host_name           StacjaWindows
    service_description nrpe_Users
    check_command       check_nrpe!check_users
}
On website I have answer: "(Return code of 127 is out of bounds - plugin may be missing)".
On command line:

Code: Select all

root@ubuntu:/usr/local/nagios/libexec# ./check_nrpe -H xxx.xxx.xx.xxx -c check_users
Unknown command(s): check_users
Any ideas? Thanks for any help!
Regards
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: How to use alias from NSClient in Nagios

Post by scottwilkerson »

you should be able to just do this

Code: Select all

define service{
    use                 generic-service
    host_name           StacjaWindows
    service_description alias_test
    check_command       check_nrpe!alias_test
}
If you keep getting "Return code of 127 is out of bounds - plugin may be missing" this is file permissions
show us the output of the following

Code: Select all

cat /usr/local/nagios/etc/resources.cfg
ls -al /usr/local/nagios/
ls -al /usr/local/nagios/libexec
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Melanie123
Posts: 10
Joined: Wed Mar 07, 2018 7:19 am

Re: How to use alias from NSClient in Nagios

Post by Melanie123 »

I've tried this service before, but the result is this:
Image
Again "(Return code of 127 is out of bounds - plugin may be missing)"...

I don't have config resources.cfg:

Code: Select all

root@ubuntu:/home/monkol13# cat /usr/local/nagios/etc/resources.cfg
cat: /usr/local/nagios/etc/resources.cfg: No such file or directory

Code: Select all

root@ubuntu:/home/monkol13# ls -al /usr/local/nagios/
total 32
drwxr-xr-x  8 nagios nagios 4096 Feb 27 16:00 .
drwxr-xr-x 12 root   root   4096 Dec 15 16:01 ..
drwxr-xr-x  2 nagios nagios 4096 Feb 27 16:02 bin
drwxrwxr-x  3 nagios nagios 4096 Mar  7 17:05 etc
drwxr-xr-x  2 root   root   4096 Feb 27 16:00 include
drwxrwxr-x  2 nagios nagios 4096 Feb 27 16:02 libexec
drwxr-xr-x  3 root   root   4096 Feb 27 16:00 share
drwxr-xr-x  3 nagios nagios 4096 Mar  8 11:02 var

Code: Select all

root@ubuntu:/home/monkol13# ls -al /usr/local/nagios/libexec
total 11120
drwxrwxr-x 2 nagios nagios   4096 Feb 27 16:02 .
drwxr-xr-x 8 nagios nagios   4096 Feb 27 16:00 ..
-rwxr-xr-x 1 root   nagios 251280 Feb 27 16:00 check_apt
-rwxr-xr-x 1 root   nagios   6897 Feb 27 16:02 check_asterisk.pl
-rwxr-xr-x 1 root   nagios   1978 Feb 27 16:02 check_asterisk_sip_peers.sh
-rwxr-xr-x 1 root   nagios   2346 Feb 27 16:00 check_breeze
-rwxr-xr-x 1 root   nagios 258264 Feb 27 16:00 check_by_ssh
-rwxr-xr-x 1 root   nagios   6632 Feb  8 13:32 check_cisco_old.pl
-rwxr-xr-x 1 root   nagios  16210 Feb 20 15:15 check_cisco.pl
lrwxrwxrwx 1 root   root        9 Feb 27 16:00 check_clamd -> check_tcp
-rwxr-xr-x 1 root   nagios 196480 Feb 27 16:00 check_cluster
-rwxr-xr-x 1 root   nagios   5582 Feb 27 16:02 check_cpu_stats.sh
-rwxr-xr-x 1 root   nagios  25758 Feb 20 16:31 check_cpu_udc.pl
-rwxr-xr-x 1 root   nagios 259104 Sep 26 13:31 check_dbi
-rwsr-xr-x 1 root   nagios 259072 Feb 27 16:00 check_dhcp
-rwxr-xr-x 1 root   nagios 248040 Feb 27 16:00 check_dig
-rwxr-xr-x 1 root   nagios 270224 Feb 27 16:00 check_disk
-rwxr-xr-x 1 root   nagios  40020 Apr 19  2017 check_disk.c
-rwxr-xr-x 1 root   nagios   9469 Feb 27 16:00 check_disk_smb
-rwxr-xr-x 1 root   nagios 278744 Feb 27 16:00 check_dns
-rwxr-xr-x 1 root   nagios 152432 Feb 27 16:00 check_dummy
-rwxr-xr-x 1 root   nagios   3860 Feb 27 16:00 check_file_age
-rwxr-xr-x 1 root   nagios   6504 Feb 27 16:00 check_flexlm
-rwxr-xr-x 1 root   nagios 258432 Sep 26 13:31 check_fping
lrwxrwxrwx 1 root   root        9 Feb 27 16:00 check_ftp -> check_tcp
-rwxr-xr-x 1 root   nagios 221832 Sep 26 13:31 check_game
-rwxr-xr-x 1 root   nagios 250064 Feb 27 16:00 check_hpjd
-rwxr-xr-x 1 root   nagios 419960 Feb 27 16:00 check_http
-rwsr-xr-x 1 root   nagios 271624 Feb 27 16:00 check_icmp
-rwxr-xr-x 1 root   nagios 204192 Feb 27 16:00 check_ide_smart
-rwxr-xr-x 1 root   nagios  15275 Feb 27 16:00 check_ifoperstatus
-rwxr-xr-x 1 root   nagios  13423 Feb 27 16:00 check_ifstatus
lrwxrwxrwx 1 root   root        9 Feb 27 16:00 check_imap -> check_tcp
-rwsr-xr-x 1 root   nagios    972 Feb 27 16:02 check_init_service
-rwxr-xr-x 1 root   nagios   6984 Feb 27 16:00 check_ircd
lrwxrwxrwx 1 root   root        9 Feb 27 16:00 check_jabber -> check_tcp
-rwxr-xr-x 1 root   nagios 232112 Sep 26 13:31 check_ldap
lrwxrwxrwx 1 root   root       10 Feb 27 16:00 check_ldaps -> check_ldap
-rwxr-xr-x 1 root   nagios 221576 Feb 27 16:00 check_load
-rwxr-xr-x 1 root   nagios   6669 Feb 27 16:00 check_log
-rwxr-xr-x 1 root   nagios  22733 Feb 27 16:00 check_mailq
-rwxr-xr-x 1 root   nagios 205160 Feb 27 16:00 check_mrtg
-rwxr-xr-x 1 root   nagios 206696 Feb 27 16:00 check_mrtgtraf
-rwxr-xr-x 1 root   nagios 247064 Sep 26 13:31 check_mysql
-rwxr-xr-x 1 root   nagios 231080 Sep 26 13:31 check_mysql_query
-rwxr-xr-x 1 root   nagios 222120 Feb 27 16:00 check_nagios
-rwxr-xr-x 1 root   nagios   3104 Sep 25 13:54 check_nagios.t
-rwxr-xr-x 1 root   nagios   9821 Sep 21 17:25 check_ncpa.py
-rwxr-xr-x 1 root   nagios  25602 Feb 27 16:02 check_netstat.pl
lrwxrwxrwx 1 root   root        9 Feb 27 16:00 check_nntp -> check_tcp
lrwxrwxrwx 1 root   root        9 Feb 27 16:00 check_nntps -> check_tcp
-rwxr-xr-x 1 root   nagios 175000 Feb 27 16:02 check_nrpe
-rwxr-xr-x 1 root   nagios 265792 Feb 27 16:00 check_nt
-rwxr-xr-x 1 root   nagios 264552 Feb 27 16:00 check_ntp
-rwxr-xr-x 1 root   nagios 253984 Feb 27 16:00 check_ntp_peer
-rwxr-xr-x 1 root   nagios 243040 Feb 27 16:00 check_ntp_time
-rwxr-xr-x 1 root   nagios 297768 Feb 27 16:00 check_nwstat
-rwxr-xr-x 1 root   nagios   3259 Feb 27 16:02 check_open_files.pl
-rwxr-xr-x 1 root   nagios   9457 Feb 27 16:00 check_oracle
-rwxr-xr-x 1 root   nagios 232888 Feb 27 16:00 check_overcr
-rwxr-xr-x 1 root   nagios 243336 Sep 26 13:31 check_pgsql
-rwxr-xr-x 1 root   nagios 266032 Feb 27 16:00 check_ping
lrwxrwxrwx 1 root   root        9 Feb 27 16:00 check_pop -> check_tcp
-rwxr-xr-x 1 root   nagios 261688 Feb 27 16:00 check_procs
-rwxr-xr-x 1 root   nagios 224304 Sep 26 13:31 check_radius
-rwxr-xr-x 1 root   nagios 225304 Feb 27 16:00 check_real
-rwxr-xr-x 1 root   nagios   9679 Feb 27 16:00 check_rpc
-rwxr-xr-x 1 root   nagios   1533 Feb 27 16:00 check_sensors
-rwxr-xr-x 1 root   nagios   2174 Feb 27 16:02 check_services
lrwxrwxrwx 1 root   root        9 Feb 27 16:00 check_simap -> check_tcp
-rwxr-xr-x 1 root   nagios   7599 Feb 27 16:02 check_sip
-rwxr-xr-x 1 root   nagios 315024 Feb 27 16:00 check_smtp
-rwxr-xr-x 1 root   nagios 328128 Feb 27 16:00 check_snmp
-rwxr-xr-x 1 root   nagios  33646 Feb 21 13:32 check_snmp_int.pl
lrwxrwxrwx 1 root   root        9 Feb 27 16:00 check_spop -> check_tcp
-rwxr-xr-x 1 root   nagios 222744 Feb 27 16:00 check_ssh
lrwxrwxrwx 1 root   root        9 Feb 27 16:00 check_ssmtp -> check_tcp
-rwxr-xr-x 1 root   nagios 199648 Feb 27 16:00 check_swap
-rwxr-xr-x 1 root   nagios 296984 Feb 27 16:00 check_tcp
-rwxr-xr-x 1 root   nagios 223888 Feb 27 16:00 check_time
lrwxrwxrwx 1 root   root        9 Feb 27 16:00 check_udp -> check_tcp
-rwxr-xr-x 1 root   nagios 240240 Feb 27 16:00 check_ups
-rwxr-xr-x 1 root   nagios 191104 Feb 27 16:00 check_uptime
-rwxr-xr-x 1 root   nagios 189064 Feb 27 16:00 check_users
-rwxr-xr-x 1 root   nagios   3032 Feb 27 16:00 check_wave
-rwxr-xr-x 1 root   nagios    710 Feb 27 16:02 check_yum
-rwxr-xr-x 1 root   nagios   3435 Feb 27 16:02 custom_check_mem
-rwxr-xr-x 1 root   nagios    915 Feb 27 16:02 custom_check_procs
-rwxr-xr-x 1 root   nagios   4176 Feb 27 16:02 nagisk.pl
-rwxr-xr-x 1 root   nagios 187808 Feb 27 16:00 negate
-rwxr-xr-x 1 root   nagios 184392 Feb 27 16:00 urlize
-rwxr-xr-x 1 root   nagios   1949 Feb 27 16:00 utils.pm
-rwxr-xr-x 1 root   nagios   2791 Feb 27 16:00 utils.sh
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: How to use alias from NSClient in Nagios

Post by scottwilkerson »

can you attach your nagios.cfg we need to figure out where your user macros are being set so we know what $USER1$ equates to
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Melanie123
Posts: 10
Joined: Wed Mar 07, 2018 7:19 am

Re: How to use alias from NSClient in Nagios

Post by Melanie123 »

Oh my God, thank you very much!

In my nagios.cfg I have a small mess:

Code: Select all

resource_file=/etc/nagios3/resource.cfg
I went to resource.cfg and found this:

Code: Select all

$USER1$=/usr/lib/nagios/plugins
But... I have all my plugins in "/usr/local/nagios/libexec". :lol:

I changed everything and it works now.
Thank you very much for directing! In case of problems, I will ask you again.

Best wishes!
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: How to use alias from NSClient in Nagios

Post by scottwilkerson »

Awesome.. I'm glad to be of assistance!
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked