How install a new plugin

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.
afigles
Posts: 19
Joined: Wed Sep 11, 2019 12:15 pm

How install a new plugin

Post by afigles »

Hello,

I am a new admin nagios, I have download this check https://exchange.nagios.org/directory/P ... em/details Its a .sh file but my problem is, How install/load the .sh file? I have copied the .sf file in /usr/local/nagios/libexec/, what will be the next steps??

In commands.cfg should write the following no??

# 'check_all_fs' command definition
define command{
command_name check_all_fs
command_line $USER1$/check_all_fs -w $ARG1$ -c $ARG2$
}
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: How install a new plugin

Post by scottwilkerson »

First mark the file executable

Code: Select all

chmod +x  /usr/local/nagios/libexec/check_all_fs.sh
then change your command to

Code: Select all

# 'check_all_fs' command definition
define command{
command_name check_all_fs
command_line $USER1$/check_all_fs.sh -w $ARG1$ -c $ARG2$
}
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
afigles
Posts: 19
Joined: Wed Sep 11, 2019 12:15 pm

Re: How install a new plugin

Post by afigles »

I got this error in the console:

stderr: execvp(/usr/local/nagios/libexec/check_all_fs.sh, ...) failed. errno is 2: No such file or directory

The config:

In commands.cfg

Code: Select all

# 'check_all_fs' command definition
define command{
        command_name    check_all_fs
        command_line    $USER1$/check_all_fs.sh -w $ARG1$ -c $ARG2$
        }
In linux.cfg

Code: Select all

define service{
        use                             local-service         ; Name of service template to use
        host_name                       localhost
        hostgroup_name                  linux-servers
        service_description             FS
        check_command                   check_all_fs!90!95
        notifications_enabled           0
        }
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: How install a new plugin

Post by scottwilkerson »

Where is the file check_all_fs.sh located?
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
afigles
Posts: 19
Joined: Wed Sep 11, 2019 12:15 pm

Re: How install a new plugin

Post by afigles »

Code: Select all

root@rdxnagios:/usr/local/nagios/libexec# ls -l
total 10324
-rwxr-xr-x 1 root nagios    4353 Oct 22 11:17 check_all_fs.sh
In /usr/local/nagios/libexec
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: How install a new plugin

Post by scottwilkerson »

Where does $USER1$ point to in the resources.cfg in your installation?
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
afigles
Posts: 19
Joined: Wed Sep 11, 2019 12:15 pm

Re: How install a new plugin

Post by afigles »

Code: Select all

$USER1$=/usr/local/nagios/libexec
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: How install a new plugin

Post by scottwilkerson »

That's strange, and you were able to run this from the command line successfully to test it?

Code: Select all

su nagios
/usr/local/nagios/libexec/check_all_fs.sh -w 90 -c 95
Can you also show the results of the following

Code: Select all

ps -ef|grep nagios.cfg
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
afigles
Posts: 19
Joined: Wed Sep 11, 2019 12:15 pm

Re: How install a new plugin

Post by afigles »

Code: Select all

root@rdxnagios:/usr/local/nagios/etc# su nagios
$ /usr/local/nagios/libexec/check_all_fs.sh -w 90 -c 95
sh: 1: /usr/local/nagios/libexec/check_all_fs.sh: not found
$ /usr/local/nagios/libexec/check_all_fs.sh -w 90 -c 95
sh: 2: /usr/local/nagios/libexec/check_all_fs.sh: not found
$ exit
root@rdxnagios:/usr/local/nagios/etc# /usr/local/nagios/libexec/check_all_fs.sh -w 90 -c 95
bash: /usr/local/nagios/libexec/check_all_fs.sh: /bin/sh^M: bad interpreter: No such file or directory
root@rdxnagios:/usr/local/nagios/etc# ps -ef|grep nagios.cfg
nagios   12412     1  0 16:33 ?        00:00:02 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
nagios   12417 12412  0 16:33 ?        00:00:00 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
root     17579 34599  0 17:10 pts/0    00:00:00 grep nagios.cfg
root@rdxnagios:/usr/local/nagios/etc#
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: How install a new plugin

Post by scottwilkerson »

I believe you have Windows line endings in the plugin

Lets run the following

Code: Select all

sed -i 's/\r//g' /usr/local/nagios/libexec/check_all_fs.sh
then try running the plugin again
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked