Page 1 of 1

Solaris 10 NCPA bash plugin not working

Posted: Sun Jan 10, 2021 11:10 pm
by lucasari
Hi,

i created a Bash script that allows me to check for connection (ping or specific port) from a monitored Solaris 10 server to other destinations.
the script works on its own, but not when ran from NCPA. am I calling it wrong?

Code: Select all

#!/bin/bash

server=$1;
port=$2;

#netcat location
#netcat=nc
netcat=/opt/csw/bin/netcat

#timeout time. maximum time to wait before exiting with timeout
timeout=15

if [ $# -lt 2 ];then
  echo "$0 <server> <port>"
    echo "$0 nagios 80"
    exit 1;
fi
s=$(nawk "BEGIN{print srand}")
check_port=$($netcat -v -z $server $port -w $timeout 2>&1; echo -n $?)
exit_code=${check_port: -1}
length=${#check_port}
result=${check_port:0: length - 1}
f=$(nawk "BEGIN{print srand}")
sum=$(( $f - $s ))
if [[ $exit_code == 0 ]]; then
    echo "$result|time="$sum"s;;;0 "
    exit $exit_code
else
    echo "ERROR: netcat $server $port failed - critical|time="$sum"s;;;0 "
    exit $exit_code
fi

Re: Solaris 10 NCPA bash plugin not working

Posted: Mon Jan 11, 2021 5:12 pm
by ssax
What is the output you are receiving from the check?

Are you calling it like this?

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H X.X.X.X -t 'yourtoken' -M plugins/yourplugin.sh -a 'Y.Y.Y.Y 80'