RE: script for restart the gnugk

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



A better solution would be to try to connect to port 1720 (or 1721 deppending on your gnugk settings) and see if it's responding.
For that you can try an 'expect' script like this:

#!/usr/local/bin/expect -f
set prompt "(%|#|\\$) $"          ;# default prompt
catch {set prompt $env(EXPECT_PROMPT)}

set timeout 5
spawn $env(SHELL)
expect -re $prompt
send -- "telnet localhost 1720\r"
        set date [exec date]
expect {
    -re ".*Unable to connect to remote host"
    {
        send_user "\rGK not running! Initiating restart. $date\r"
        send -- "/usr/local/bin/gnugk -c /usr/local/etc/gnugk.ini -ttt -o /var/log/gnugk\r"
        expect -re ".*Listen on"
        send -- "\r"
        exit
    } -re ".*Connected to" {
        send_user "\rGK is running at $date\r"
        exit
    }
}

You will have to modify the path to 'expect' and to your 'gnugk' location. And you need to install expect first.
If you use mysql or postgresql you can try a similar mechanism to check if their ports are answering and restart them also if needed.

Regards,
Gabriel


At 08:42 AM 6/11/2005, you wrote:
As simple shell script which you can run after 1/5 minute interval using cron job. May be someone can write a better shell script , I am not an expert in writing shell scripts but this does work.
 
#!/bin/sh
value=`/bin/ps -e|grep gnugk`
if [ ! "$value" ]; then
/sbin/service gk restart
fi

 
Deepak Singhal


From: openh323gk-users-admin@xxxxxxxxxxxxxxxxxxxxx [ mailto:openh323gk-users-admin@xxxxxxxxxxxxxxxxxxxxx] On Behalf Of Jeff Chen
Sent: Saturday, June 11, 2005 4:21 AM
To: openh323gk-users@xxxxxxxxxxxxxxxxxxxxx
Subject: script for restart the gnugk

are there any script for restart the gnugk automatically if it dies ?
 

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

[Index of Archives]     [SIP]     [Open H.323]     [Gnu Gatekeeper]     [Asterisk PBX]     [ISDN Cause Codes]     [Yosemite News]

  Powered by Linux