Problem:
(No output on stdout) stderr: Can't open perl script "/usr/local/nagios/libexec/check_apc.pl": No such file or directory
I can perform a manual test of the plugin, but I get an error (path not found) when I plug it into Nagios. Why is nagios distorting the file path?
I downloaded check_apc.pl from https://exchange.nagios.org/directory/P ... pl/details
I have not made any modifications to the script. I just copied it into my /usr/local/nagios/libexec folder and changed the permissions to match the other plugins.
Configuration:
techservices@vpd-nagios:/usr/local/nagios/libexec$ ls -al check_apc.pl
-rwxr-xr-x 1 nagios nagios 34159 Feb 3 16:27 check_apc.pl
<commands.cfg>
define command {
command_name check_apc.pl
command_line /usr/bin/perl /usr\\/local/nagios/libexec/check_apc.pl -H $HOSTADDRESS$ -C public -l $ARG1$ $ARG2$ $ARG3$
}
Note: in the command line..../usr\\ is there so that the path is correct. If I don't have the \\ after /usr....then the return in Nagios is
(No output on stdout) stderr: Can't open perl script "/uslocal/nagios/libexec/check_apc.pl": No such file or directory
Using the original $USER1$ in the command line produces the error:
(No output on stdout) stderr: Can't open perl script "/uslocal/nagios/libexec/check_apc.pl": No such file or directory
I've tried creating the path in 'resource.cfg' $APC_PATH$=/usr\\/local/nagios/libexec but it didn't seem to take when I use
//usr/bin/perl $APC_PATH$/check_apc.pl on the command line in commands.cfg...so I've just put the path in as you see above.
<UPS.cfg>
define service {
use generic-service
host_name VPD-UPS1
service_description UPS Main Stn Rack 1 Bottom
check_command check_apc.pl! -H 192.168.60.3 -C public -l bat_status
}
Testing
techservices@vpd-nagios:/usr/local/nagios/libexec$ sudo ./check_apc.pl -H 192.168.60.3 -C public -l bat_status
OK: Battery Status is Normal
<full commands.cfg>
###############################################################################
# COMMANDS.CFG - SAMPLE COMMAND DEFINITIONS FOR NAGIOS 4.4.5
#
#
# NOTES: This config file provides you with some example command definitions
# that you can reference in host, service, and contact definitions.
#
# You don't need to keep commands in a separate file from your other
# object definitions. This has been done just to make things easier to
# understand.
#
###############################################################################
################################################################################
#
# SAMPLE NOTIFICATION COMMANDS
#
# These are some example notification commands. They may or may not work on
# your system without modification. As an example, some systems will require
# you to use "/usr/bin/mailx" instead of "/usr/bin/mail" in the commands below.
#
################################################################################
define command {
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}
define command {
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
################################################################################
#
# SAMPLE HOST CHECK COMMANDS
#
################################################################################
# This command checks to see if a host is "alive" by pinging it
# The check must result in a 100% packet loss or 5 second (5000ms) round trip
# average time to produce a critical error.
# Note: Five ICMP echo packets are sent (determined by the '-p 5' argument)
define command {
command_name check-host-alive
command_line $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5
}
################################################################################
#
# SAMPLE SERVICE CHECK COMMANDS
#
# These are some example service check commands. They may or may not work on
# your system, as they must be modified for your plugins. See the HTML
# documentation on the plugins for examples of how to configure command definitions.
#
# NOTE: The following 'check_local_...' functions are designed to monitor
# various metrics on the host that Nagios is running on (i.e. this one).
################################################################################
define command {
command_name check_local_disk
command_line $USER1$/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$
}
define command {
command_name check_local_load
command_line $USER1$/check_load -w $ARG1$ -c $ARG2$
}
define command {
command_name check_local_procs
command_line $USER1$/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$
}
define command {
command_name check_local_users
command_line $USER1$/check_users -w $ARG1$ -c $ARG2$
}
define command {
command_name check_local_swap
command_line $USER1$/check_swap -w $ARG1$ -c $ARG2$
}
define command {
command_name check_local_mrtgtraf
command_line $USER1$/check_mrtgtraf -F $ARG1$ -a $ARG2$ -w $ARG3$ -c $ARG4$ -e $ARG5$
}
################################################################################
# NOTE: The following 'check_...' commands are used to monitor services on
# both local and remote hosts.
################################################################################
define command {
command_name check_ftp
command_line $USER1$/check_ftp -H $HOSTADDRESS$ $ARG1$
}
define command {
command_name check_hpjd
command_line $USER1$/check_hpjd -H $HOSTADDRESS$ $ARG1$
}
define command {
command_name check_snmp
command_line $USER1$/check_snmp -H $HOSTADDRESS$ $ARG1$
}
define command {
command_name check_http
command_line $USER1$/check_http -I $HOSTADDRESS$ $ARG1$
}
define command {
command_name check_ssh
command_line $USER1$/check_ssh $ARG1$ $HOSTADDRESS$
}
define command {
command_name check_dhcp
command_line $USER1$/check_dhcp $ARG1$
}
define command {
command_name check_ping
command_line $USER1$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p 5
}
define command {
command_name check_pop
command_line $USER1$/check_pop -H $HOSTADDRESS$ $ARG1$
}
define command {
command_name check_imap
command_line $USER1$/check_imap -H $HOSTADDRESS$ $ARG1$
}
define command {
command_name check_smtp
command_line $USER1$/check_smtp -H $HOSTADDRESS$ $ARG1$
}
define command {
command_name check_tcp
command_line $USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$ $ARG2$
}
define command {
command_name check_udp
command_line $USER1$/check_udp -H $HOSTADDRESS$ -p $ARG1$ $ARG2$
}
define command {
command_name check_nt
command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v $ARG1$ $ARG2$
}
define command {
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -2 -t 30 -c $ARG1$ $ARG2$
}
################################################################################
#
# SAMPLE PERFORMANCE DATA COMMANDS
#
# These are sample performance data commands that can be used to send performance
# data output to two text files (one for hosts, another for services). If you
# plan on simply writing performance data out to a file, consider using the
# host_perfdata_file and service_perfdata_file options in the main config file.
#
################################################################################
define command {
command_name process-host-perfdata
command_line /usr/bin/printf "%b" "$LASTHOSTCHECK$\t$HOSTNAME$\t$HOSTSTATE$\t$HOSTATTEMPT$\t$HOSTSTATETYPE$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$\n" >> /usr/local/nagios/var/host-perfdata.out
}
define command {
command_name process-service-perfdata
command_line /usr/bin/printf "%b" "$LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$SERVICEATTEMPT$\t$SERVICESTATETYPE$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$\n" >> /usr/local/nagios/var/service-perfdata.out
}
define command {
command_name check_mssql_health
command_line $USER1$/check_mssql_health --server $HOSTADDRESS$ --username $ARG1$ --password $ARG2$ --mode $ARG3$
}
#define command {
# command_name check_snmp_ups
# command_line $USER1$/check_snmp_ups -H $HOSTADDRESS$ -t $ARG1$
#}
#define command {
# command_name check_ups_snmp
# command_line $ USER1 $ / $ HOSTADDRESS check_ups_snmp.sh -H $ ARG1 $ -p -C $ ARG2 $ - w $ ARG3 $ - c $ ARG4 $ register 1
#}
define command {
command_name check_ups
command_line $USER1$/check_ups -u $ARG1$ -H $HOSTNAME$ -v $ARG2$
}
define command {
command_name check_apc.pl
command_line /usr/bin/perl /usr\\/local/nagios/libexec/check_apc.pl -H $HOSTADDRESS$ -C public -l $ARG1$ $ARG2$ $ARG3$
}
<resource.cfg>
###########################################################################
#
# RESOURCE.CFG - Sample Resource File for Nagios 4.4.5
#
#
# You can define $USERx$ macros in this file, which can in turn be used
# in command definitions in your host config file(s). $USERx$ macros are
# useful for storing sensitive information such as usernames, passwords,
# etc. They are also handy for specifying the path to plugins and
# event handlers - if you decide to move the plugins or event handlers to
# a different directory in the future, you can just update one or two
# $USERx$ macros, instead of modifying a lot of command definitions.
#
# The CGIs will not attempt to read the contents of resource files, so
# you can set restrictive permissions (600 or 660) on them.
#
# Nagios supports up to 256 $USERx$ macros ($USER1$ through $USER256$)
#
# Resource files may also be used to store configuration directives for
# external data sources like MySQL...
#
###########################################################################
# Sets $USER1$ to be the path to the plugins
$USER1$=/usr/local/nagios/libexec
$APC_PATH$=/usr\\/local/nagios/libexec
# Sets $USER2$ to be the path to event handlers
#$USER2$=/usr/local/nagios/libexec/eventhandlers
# Store some usernames and passwords (hidden from the CGIs)
#$USER3$=someuser
#$USER4$=somepassword
any help would be appreciated.
Tal
having issues with check_apc.pl
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: having issues with check_apc.pl
Whatever is causing this issue is the root of your problem. I've never seen such an issue like this before, however I have seen copy and paste cause weird issues.Tal wrote:Note: in the command line..../usr\\ is there so that the path is correct. If I don't have the \\ after /usr....then the return in Nagios is
(No output on stdout) stderr: Can't open perl script "/uslocal/nagios/libexec/check_apc.pl": No such file or directory
Using the original $USER1$ in the command line produces the error:
(No output on stdout) stderr: Can't open perl script "/uslocal/nagios/libexec/check_apc.pl": No such file or directory
I would:
- Delete the command definition you added and any blank lines before or after in commands.cfg
Save the file and close
Edit the commands.cfg
MANUALLY type the entire command definition in, don't copy and paste
Save the file and close
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: having issues with check_apc.pl
Ok, thanks for the suggestion, BOX293.....
I did as you suggested with my commands.cfg (this time I entered the paths completely as well)
(new commands.cfg input)
define command {
command_name check_apc.pl
command_line /usr/bin/perl /usr/local/nagios/libexec/check_apc.pl -H $HOSTADDRESS$ -C public -l $ARG1$ $ARG2$ $ARG3$
}
and it works!!!
I did find out that you need to write the specfic target command like so....
(note how there is no space between the option and the option entries)
use generic-service
host_name VPD-UPS1
service_description UPS Main Stn Rack 1 Bottom
check_command check_apc.pl! -H192.168.60.3 -Cpublic -lout_phase
}
thanks for your help
Tal
I did as you suggested with my commands.cfg (this time I entered the paths completely as well)
(new commands.cfg input)
define command {
command_name check_apc.pl
command_line /usr/bin/perl /usr/local/nagios/libexec/check_apc.pl -H $HOSTADDRESS$ -C public -l $ARG1$ $ARG2$ $ARG3$
}
and it works!!!
I did find out that you need to write the specfic target command like so....
(note how there is no space between the option and the option entries)
use generic-service
host_name VPD-UPS1
service_description UPS Main Stn Rack 1 Bottom
check_command check_apc.pl! -H192.168.60.3 -Cpublic -lout_phase
}
thanks for your help
Tal
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: having issues with check_apc.pl
Great!Tal wrote:Ok, thanks for the suggestion, BOX293.....
I did as you suggested with my commands.cfg (this time I entered the paths completely as well)
(new commands.cfg input)
define command {
command_name check_apc.pl
command_line /usr/bin/perl /usr/local/nagios/libexec/check_apc.pl -H $HOSTADDRESS$ -C public -l $ARG1$ $ARG2$ $ARG3$
}
and it works!!!
I did find out that you need to write the specfic target command like so....
(note how there is no space between the option and the option entries)
use generic-service
host_name VPD-UPS1
service_description UPS Main Stn Rack 1 Bottom
check_command check_apc.pl! -H192.168.60.3 -Cpublic -lout_phase
}
thanks for your help
Tal
Locking thread