[mrtg] Re: External program question

Alex van den Bogaerdt alex at slot.hollandcasino.nl
Sat Sep 8 01:38:12 MEST 2001


Paul C. Williamson wrote:

> I have been asked to monitor the number of problem tickets that 
> are open in our Help Desk software program.  After seeing what the 
> information looks like, it's kinda boring.  Always about 260 open 
> tickets.  What I thought would be more interesting is the number 
> of NEW calls opened in the last 5 minutes.  So I figured out that 
> the call number is incremented each time a new call is opened.

First of all:  make sure you are allowed to decide it is boring (!)
Knowing that the total number of open calls is 260 probably has
some comforting significance.  Would it be 0, or would it be much
larger than 260, something's obviously wrong.  Maybe the graph has
to be used for trend analysis, it could be 320 next year.

Also: make sure the call number does increment by one, no exceptions.

> I'm not concerned about closed calls in the same period(yet).
> So I can write that info out to a text file, grab it and see that 
> number.  I did a small sample and it is incrementing at about 
> 5 per 5 minutes.  Should I use the perminute option and still 
> query every 5 minutes?  Or get the stats hourly and use the 
> perhour option?  Any thoughts are appreciated...

5 per 5 minutes...  This means that the rounding done by MRTG will
have a big impact on the numbers.

I think that polling every 5 minutes and using the perhour option
is best here.  This won't produce the number of newly opened calls.
It will produce a rate of calls per hour.  Maybe a bit confusing.
However, as a rate it does surve its purpose.

If you really want to show the number of new calls, try using the
gauge option and edit the script so that it subtracts the previous
value from the current value, leaving you with the difference.

> The other question I have is it is in a character string.  How could 
> I use sed or awk to strip off the leading 0's?  The statement I 
> have now:
> 
> new_calls=`grep 'incidents' /usr/local/mrtg/repository/numbers.txt | awk '{print $2}'`
> 
> produces a string like this:
> 
> 000000000160267
> 
> I just want 160267.  I just can't get the statement right...

1)  Using grep and awk as you did can be done by awk alone:
    awk '/incidents/{print $2}' < /usr/local/mrtg/repository/numbers.txt
2)  Tell awk to process '$2' as a number:
    awk '/incidents/{print $2+0}' < /usr/local/mrtg/repository/numbers.txt
3)  For use in a script that is called by the external program interface
    you don't need to use variable new_calls.  Sample program:

    #!/bin/bash

    < /usr/local/mrtg/repository/numbers.txt awk '
        /incidents/ { print $2+0 "\n0\nA very long time\nSome system" }
    '

    A real guru could probably skip bash, running awk directly.

The script to store and use the previous value is not as simple as
my next example (especially error checking is left out), however it
will give you a start:

    #!/bin/bash

    DIR=/usr/local/mrtg/repository/

    cat ${DIR}numbers.txt ${DIR}oldnumber.txt | awk '
        /incidents/ { NEW=$2+0; print NEW > '${DIR}'oldnumber.txt}
        /mrtgvalue/ { OLD=$1 }
        END { print NEW-OLD "\n0\nA very long time\nSome system" }
    '

cheers,
-- 
   __________________________________________________________________
 / alex at slot.hollandcasino.nl                  alex at ergens.op.het.net \
| work                                                         private |
| My employer is capable of speaking therefore I speak only for myself |
+----------------------------------------------------------------------+
| Technical questions sent directly to me will be nuked. Use the list. | 
+----------------------------------------------------------------------+
| http://faq.mrtg.org/                                                 |
| http://rrdtool.eu.org  --> tutorial                                  |
+----------------------------------------------------------------------+

--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://www.ee.ethz.ch/~slist/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the mrtg mailing list