Forum Discussion

Ofir_73471's avatar
Ofir_73471
Icon for Nimbostratus rankNimbostratus
Jun 06, 2009

Assistance with writing an External Monitor

Hi,

 

 

I need to sample my servers by sending a UDP packet and if i am getting an answer meaning the server is up .

 

i have used netcat and it works but i dnot know how to write the script and use the External monitor , i appriciate of anyone can help

 

 

the command which i used :

 

 

nc -w -u -w 3 -o /root/x-reply.hex 1.1.1.1 29000 < /root/x.hex

 

 

now 1.1.1.1 is just one ip from 10 serevrs

 

 

Thanks
  • Try this:

      
      !/bin/sh  
       Adopted from /usr/bin/monitors/sample_monitor  
        
      
      pidfile="/var/run/pinger.$1..$2.pid"  
      
      if [ -f $pidfile ]  
      then  
         kill -9 `cat $pidfile` > /dev/null 2>&1  
      fi  
      
      echo "$$" > $pidfile  
      
      node_ip=`echo $1 | sed 's/::ffff://'`  
      
      nc -w -u -w 3 -o /root/x-reply.hex $node_ip $2 < /root/x.hex > /dev/null  
      
      status=$?  
      if [ $status -eq 0 ]  
      then  
          echo "up"  
      fi  
      
      rm -f $pidfile  
     

    Don't forget to make the script executable (e.g. chmod a+x