How install a new plugin

This forum is intended for the discussion of Nagios plugin development. Feature requests, patches, bug fixes, and all types of development-related discussions are welcome!

NOTE: The SourceForge.net nagiosplug-devel mailing list has been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

How install a new plugin

Postby afigles » Tue Oct 22, 2019 4:54 am

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

Re: How install a new plugin

Postby scottwilkerson » Tue Oct 22, 2019 6:25 am

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$
}
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 17032
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: How install a new plugin

Postby afigles » Tue Oct 22, 2019 9:36 am

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

Re: How install a new plugin

Postby scottwilkerson » Tue Oct 22, 2019 9:49 am

Where is the file check_all_fs.sh located?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 17032
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: How install a new plugin

Postby afigles » Tue Oct 22, 2019 9:54 am

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

Re: How install a new plugin

Postby scottwilkerson » Tue Oct 22, 2019 9:55 am

Where does $USER1$ point to in the resources.cfg in your installation?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 17032
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: How install a new plugin

Postby afigles » Tue Oct 22, 2019 9:59 am

Code: Select all
$USER1$=/usr/local/nagios/libexec
afigles
 
Posts: 19
Joined: Wed Sep 11, 2019 12:15 pm

Re: How install a new plugin

Postby scottwilkerson » Tue Oct 22, 2019 10:02 am

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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 17032
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: How install a new plugin

Postby afigles » Tue Oct 22, 2019 10:10 am

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

Re: How install a new plugin

Postby scottwilkerson » Tue Oct 22, 2019 10:24 am

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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 17032
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Next

Return to Nagios Plugin Development

Who is online

Users browsing this forum: No registered users and 2 guests