Solaris 10 NCPA bash plugin not working

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
lucasari
Posts: 15
Joined: Tue Aug 13, 2019 4:26 am

Solaris 10 NCPA bash plugin not working

Post 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
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Solaris 10 NCPA bash plugin not working

Post 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'
Locked