First of all install the excellent MRTG package on your FREESCO box. For FREESCO 027 this package requires installation of:
- The utils-1 package
- The eco-lib package or the lewy-lib package
- The Perl package (also by eco) or the Perl 5.6.1 package (by dingetje)
- The snmpd package by bako
- ...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
The external command must return 4 lines of output:
current state of the first variable, normally 'incoming bytes count'
current state of the second variable, normally 'outgoing bytes count'
string (in any human readable format), telling the uptime of the target.
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
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
ShortLegend[ping_yh]: ms (x 10)
Title[ping_yh]: ping test www.yahoo.com
Options[ping_yh]: growright, gauge, nopercent, integer, unknaszero
ping test www.yahoo.com
This will use the above ping.sh script and measure the min/max
round-trip delays to www.yahoo.com 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 www.yahoo.com
You can get the perl script here (Right
click, Save link as, then remove the .txt extension).
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