[mrtg] scripts and ThreshProg

Steve Shipway s.shipway at auckland.ac.nz
Thu Jul 3 04:23:23 CEST 2008


>
> I did not see this explicitly prohibited in the docs but is it possible
> to pass arguments to a shell script from ThreshProg?  If not, my
> question would be, why not?
>

Last time I looked, you could not pass additional arguments directly.  The only way to do it is to set environment variables using the SetEnv directive.

The specified script is already called with a number of arguments automatically and you can't add extra ones (because then it would violate the defined API).  The online documentation is actually out of date as it only lists 3 parameters, whereas in fact there are five.

Passed parameters:
1. the target name
2. the defined threshold value
3. the current value
4. Threshold description, if set, else "No Description" (this is also in the environment variable THRESH_DESC)
5. the current value to be compared to threshold

Item (5) is the same as item (3), unless the threshold (item 2) is a percentage, in which case item (5) is expressed as a percentage of maxbytes.

Confused?

For example:

ThreshProgI[foo]: handler
ThreshDesc[foo]: bar baz
ThreshMaxI[foo]: 10

If the current value hits 11, then the called parameters are:
  handler foo 10 11 "bar baz" 11

Next example.

ThreshProgI[foo]: handler
ThreshDesc[foo]: bar baz
ThreshMaxI[foo]: 5%
MaxBytes[foo]: 200

If the current value hits 11, then the called parameters are:
  handler foo 5% 11 "bar baz" 5.5
You can see that the last parameter is now the percentage that the actual value is of MaxBytes, and this is what is compared to the threshold value.

I'm a bit surprised it was done this way round - I would have expected a threshold value and 'translated' threshold value, rather than translating the actual value, but hey - it works either way.  Also, omitting the direction (i/o) from the list of passed parameters was probably an oversight.

The best way to pass useful information - like device name, and so on - is via setting environment variables in SetEnv which will be passed to the called script.

SetEnv[foo]: EXTRAPARAM="fish and cheese" MRTG_INT_DESC="ent0"

Hope this makes sense,

Steve



More information about the mrtg mailing list