stumbleupon toolbar
Make payments with PayPal - it's fast, free and secure!
This site is up for
Get Firefox!
Last Shout - Posted by: dingetje - Wednesday, 25 April 2012 13:17

First of all install the excellent MRTG package on your FREESCO box. For FREESCO 027 this package requires installation of:

  1. The utils-1 package
  2. The eco-lib package or the lewy-lib package
  3. The Perl package (also by eco) or the Perl 5.6.1 package (by dingetje)
  4. The snmpd package by bako
  5. ...and finally the MRTG package by Scuttle

All these packages are available at FREESCOsoft

From the MRTG's online doc's:

External Monitoring Scripts

if you want to monitor something which does not provide data via SNMP you can use some external program to do the data gathering.
The external command must return 4 lines of output:

Line 1
current state of the first variable, normally 'incoming bytes count'
Line 2
current state of the second variable, normally 'outgoing bytes count'
Line 3
string (in any human readable format), telling the uptime of the target.
Line 4
string, telling the name of the target.

Depending on the type of data your script returns you might want to use the 'gauge' or 'absolute' arguments for the Options keyword.


Target[foo]: `/usr/local/bin/df2mrtg /dev/dsk/c0t2d0s0`

Note the use of the backticks (`), not apostrophes (') around the command.

External 'ping' shell script for MRTG

Based on this, it's amazingly simple to add some graph to your MRTG display. To demonstrate this I wrote the following shell script that uses the output of the ping command to generate MRTG data. You can view/get it here (right click, Save (link) as, then remove the .txt extension).

Finally add the test to your mrtg.cfg file (don't forget to stop the MRTG package and restart it after the change). This config file is located at /mnt/router/packages/mrtg-2

Target[ping_yh]: `/mnt/router/packages/mrtg-2/bin/`
MaxBytes[ping_yh]: 100000
YLegend[ping_yh]: ms
Legend1[ping_yh]: .
Legend2[ping_yh]: .
Legend3[ping_yh]: .
Legend4[ping_yh]: .
LegendI[ping_yh]: Min.roundtrip:
LegendO[ping_yh]: Max.roundtrip:
ShortLegend[ping_yh]: ms (x 10)
Title[ping_yh]: ping test
Options[ping_yh]: growright, gauge, nopercent, integer, unknaszero
Colours[ping_yh]: GREEN#00eb0c,BLUE#0000ff,GRAY#AAAAAA,VIOLET#ff00ff
WithPeak[ping_yh]: ymw

ping test

This will use the above script and measure the min/max round-trip delays to in your graph. Note that the shell script removes the decimal dots in the raw ping results to feed MRTG with integer data. Therefore the data is in ms times 10. The MRTG program is default executed every 5 min.

External 'ping' perl script for MRTG

This script that I have shamelessly copied from External Fun things to do with MRTG shows how to do the same trick using a perl script. Since MRTG itself is written in perl, this is a more logical choice. The only difference is that the shell script above can be called with an external IP address, whereas the perl's address is hard coded (I don't know enough about perl (yet) to change this). The config file for MRTG is similar to the above, except of course for the part.

You can get the perl script here (Right click, Save link as, then remove the .txt extension).

The results

The traffic button below will take you to the 'default' SNMP/MRTG generated graph for this server. The first 'ping graph' button will take you to the graph generated by the above script.

The last 'ping graph' button will show the results of the perl based ping script to my gateway.


The FREESCO Router WebRing
[ Join Now | Ring Hub | Random | << Prev | Next >> ]

Nedstat Basic - Gratis web site statistieken
Eigen homepage website teller

MKPortal ©2003-2006
Page generated in 0.3496 seconds with 16 queries