Forum Discussion

Segman_342030's avatar
Segman_342030
Icon for Nimbostratus rankNimbostratus
May 08, 2018

Need help with - External Monitor Using SSH

Hi,

 

We are trying to monitor specific process on remote server, if it run's then application is up if not then it is down. For that we developed small script (Shown below). The point is that when we run the script from F5 GUI it look like it does not doing what it should do. When running the commands form command line all seem to be OK.

 

Thanks in advance for the help on this topic.

 

!/bin/sh

ip=$1

 

port=$2

 

ssh root@$ip "ps -ef | grep ygwmanmx | grep -v grep" 2>&1 >/tmp/result.mon

 

grep ygwmanmx /tmp/result.mon 2>&1 >/dev/null status=$?

 

if [ $status -eq 0 ] then rm /tmp/result.mon echo UP exit 0 fi

 

rm /tmp/result.mon exit 0

 

 

  • Here what we are getting from test: LTM::Monitor /Common/Yossi_Monitoring

    Monitor Test Result: Destination: 10.0.10.2:5588 Last state: down State time: 2018.05.08 12:33:44 (0hr:0min:6sec ago) Last result: Test Completed (DOWN) No successful responses received before deadline. See /var/log/monitors/Common_Yossi_Monitoring-Common_monitor_test-5588.log

     

    from log we see: [0][26611] 2018-05-08 12:33:33.761496: ID 593 :(_do_ping): post ping, status=UNKNOWN [ addr=::ffff:10.0.10.2:5588 mon=/Common/Yossi_Monitoring fd=12 pend=0 conn=0 up_intvl=60 dn_intvl=60 timeout=70 time_until_up=0 immed=0 next_ping=[1525772073.746410][2018-05-08 12:34:33] last_ping=[1525772013.760362][2018-05-08 12:33:33] deadline=[1525772023.746410][2018-05-08 12:33:43] on_service_list=True snd_cnt=2 rcv_cnt=0 ]

     

    [0][26611] 2018-05-08 12:33:33.902712: ID 593 :(_main_loop): Service ready for read, now=[1525772013.902673][2018-05-08 12:33:33] [ addr=::ffff:10.0.10.2:5588 srcaddr=::%0:0 fd=12 pend=0 conn=0 ]

     

    [0][26611] 2018-05-08 12:33:33.902736: ID 593 :(_recv_external_node_ping): reading [ addr=::ffff:10.0.10.2:5588 ]

     

    [0][26611] 2018-05-08 12:33:33.902744: ID 593 :(recv_external_node_ping): EAV failed [ addr=::ffff:10.0.10.2:5588 ]

     

    [0][26611] 2018-05-08 12:33:33.902750: ID 593 :(_kill_external_pinger): killing pid=1694 [ addr=::ffff:10.0.10.2:5588 fd=12 ]

     

    [0][26611] 2018-05-08 12:33:44.432794: ID 593 :(service_ping_timeout_message): timed out, status=DOWN, now=[1525772024.432463][2018-05-08 12:33:44] [ addr=::ffff:10.0.10.2:5588 mon=/Common/Yossi_Monitoring fd=-1 pend=0 conn=0 up_intvl=60 dn_intvl=60 timeout=70 time_until_up=0 immed=0 next_ping=[1525772073.746410][2018-05-08 12:34:33] last_ping=[1525772013.760362][2018-05-08 12:33:33] deadline=[1525772023.746410][2018-05-08 12:33:43] on_service_list=True snd_cnt=2 rcv_cnt=0 ]

     

    [0][26611] 2018-05-08 12:33:44.432884: ID 593 :(_change_state_to_failure) [ addr=::ffff:10.0.10.2:5588 mon=/Common/Yossi_Monitoring up_intvl=60 dn_intvl=60 timeout=70 time_until_up=0 immed=0 next_ping=[1525772073.746410][2018-05-08 12:34:33] last_ping=[1525772013.760362][2018-05-08 12:33:33] deadline=[1525772023.746410][2018-05-08 12:33:43] on_service_list=True ]

     

    [0][26611] 2018-05-08 12:33:44.432902: ID 593 :(change_state_common) monitor test completed, result DOWN [ addr=::ffff:10.0.10.2:5588 mon=/Common/Yossi_Monitoring ]

     

    [0][26611] 2018-05-08 12:33:44.432939: ID 593 :(_change_state_common): Node DOWN (was UNKNOWN) [ addr=::ffff:10.0.10.2:5588 mon=/Common/Yossi_Monitoring up_intvl=60 dn_intvl=60 timeout=70 time_until_up=0 immed=0 next_ping=[1525772073.746410][2018-05-08 12:34:33] last_ping=[1525772013.760362][2018-05-08 12:33:33] deadline=[1525772023.746410][2018-05-08 12:33:43] on_service_list=True snd_cnt=2 rcv_cnt=0 ]

     

    [0][26611] 2018-05-08 12:33:44.432957: ID 593 :(adjust_deadline): from [1525772023.746410][2018-05-08 12:33:43] to [1525772084.432463][2018-05-08 12:34:44] [ addr=::ffff:10.0.10.2:5588 mon=/Common/Yossi_Monitoring fd=-1 pend=0 conn=0 up_intvl=60 dn_intvl=60 timeout=70 time_until_up=0 immed=0 next_ping=[1525772073.746410][2018-05-08 12:34:33] last_ping=[1525772013.760362][2018-05-08 12:33:33] deadline=[1525772084.432463][2018-05-08 12:34:44] on_service_list=True snd_cnt=2 rcv_cnt=0 ]

     

  • Hi

     

    Are you converting your pool member ip from v6 to v4? Loads of info can be found here and a template script here

     

  • Hi,

    I can see you probably forgot to set param to that ssh non-default port (-p $2).

    Anyway, what about to try this way:

    !/bin/sh
    
    pidfile="/var/run/`basename ${0}`.$1..$2.pid"
    if [ -f $pidfile ]
    then
       kill -9 -`cat $pidfile` > /dev/null 2>&1
    fi
    echo "$$" > $pidfile
    
     Remove the IPv6/IPv4 compatibility prefix
    ip=`echo $1 | sed 's/::ffff://'`
    port=$2
    
    ssh -p $port root@$ip "ps -ef |grep ygwmanmx |grep -v grep 2>&1 > /dev/null"
    status=$?
    
    if [ $status -eq 0 ]
    then
        rm -f $pidfile
        echo "up"
    fi
    

    Test:

    &1 > /dev/null'
    + status=0
    + '[' 0 -eq 0 ']'
    + rm -f /var/run/monitor.sh.192.168.74.6..5588.pid
    + echo up
    up
    

    Best Regards.