[hobbit] Hobbit help

Strandell, Ralf Ralf.Strandell at silja.com
Thu Nov 30 12:43:15 CET 2006


Are you trying to do something with
 
TIMESTAMP=`/bin/ping -c1 -T tsonly host.domain.com | /usr/bin/awk ' $1 == "TS:" { print $2 } '`
 
The key here is that you can use an awk script to extract the number (field no 2 on the line begining with TS:)
This extracts the big integer from the timestamp answer, but you need to know what to do with it.
You can learn awk scripts and regular expressions in O´Reilly's "sed & awk pocket reference".
 
Another solution is to have a nice Bourne shell function like this:
 
tsprint() {
    while read line
    do
        set bogus $line    # $line could be empty. Plain "set" would dump the environment variables. Hence a "bogus" and shift.
        shift
        if [ "$1" == "TS:" ]
        then
            echo "$2"
            break
        else
            continue # loop
        fi
    done
}
    
TIMESTAMP=`/bin/ping -c1 -T tsonly host.domain.com | tsprint`
 
Then you can compare the size of the timestamp using ' if [ $VARIABLE -lt $THRESHOLD ]; then ...
Numeric comparisons: -lt, -le, -eq, -ge, -gt
String comparisons: ==, !=
 
 
Recommended reading:
1) A good book about bourne shell scripts and Unix command line in general is "Sams teach yourself shell programming in 24 hours".
2) Bourne shell is a bit archaic, and Bash provides many nice improvements such as calculations and arrays. "man bash" is enough, after you master the Bourne shell.
 
You should now be able to complete yout monitoring plugin. As your thesis is about Hobbit, you should certainly know how to implement basic extensions. Take a look at the plugins.

 
________________________________

From: Giorgio Volpini [mailto:vorpini at gmail.com] 
Sent: Thursday, November 30, 2006 11:46 AM
To: henrik at hswn.dk; hobbit at hswn.dk
Subject: [hobbit] Hobbit help


Dear Mr.Storner,
my name's Giorgio Volpini, I'm a Computer Science student of the university of Pisa.
 
I need some help about your program : Hobbit. Few months ago I used Hobbit during my stage and now I'm writing a thesis about it. I'd like to complete my report with a dimostration of Bash-script to use in the program; my problem is that i don't know Bash-scripting and I have not enought time to learn it. If I don't give you too much trouble, I needa script to control the time of presence rivelators connected in Lan with Hobbit server.
 
I also have a general idea about the script:
    - ping the rivelator
    - compare the time of the answer packet with Hobbit system time
    - decide if it's all ready or not
    - warn the administrator with e-mail, sms or only with Hobbit web interface
I need only a dimostrative script to add an my report, so is not important that it works perfectly, but only that bash-script has right syntax.
 
Your help is very important for me and I think it is an work for you.
 
Thank you very much for your attention.
 
Your faithfully.
 
Giorgio Volpini.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20061130/514fd2bf/attachment.html>


More information about the Xymon mailing list