Forum Discussion

Daniel_Ao_10370's avatar
Daniel_Ao_10370
Icon for Nimbostratus rankNimbostratus
Jan 29, 2018

Arguments in External Monitor

I have created a script to monitor Windows service state through WMI. Below is the script.

!/bin/sh

IP=

echo ${1} | sed 's/::ffff://'
PORT=${2} PIDFILE="/var/run/
basename ${0}
.${IP}_${PORT}.pid"

if [ -f $PIDFILE ] then echo "EAV exceeded runtime needed to kill ${IP}:${PORT}" | logger -p local0.error kill -9

cat $PIDFILE
> /dev/null 2>&1 fi echo "$$" > $PIDFILE rm -f $PIDFILE wmic -U $3/$4%$5 //$IP "select State from Win32_Service where Name=$6" | grep -i ".*|Running" 2>&1

if [ $? -eq 0 ] then

I would like to know how to pass the arguments with space in GUI to the script. For example:

Arguments: domain user password "Windows Service"

1 Reply

  • !/bin/sh

    IP=

    echo ${1} | sed 's/::ffff://'
    PORT=${2} PIDFILE="/var/run/
    basename ${0}
    .${IP}_${PORT}.pid"

    kill of the last instance of this monitor if hung and log current pid

    if [ -f $PIDFILE ] then echo "EAV exceeded runtime needed to kill ${IP}:${PORT}" | logger -p local0.error kill -9

    cat $PIDFILE
    > /dev/null 2>&1 fi echo "$$" > $PIDFILE rm -f $PIDFILE wmic -U $3/$4%$5 //$IP "select State from Win32_Service where Name=$6" | grep -i ".*|Running" 2>&1

    mark node UP if expected response was received

    if [ $? -eq 0 ] then echo "UP" fi exit

    text