Hi, everybody! ------------------------------------------------------------------------------- These scripts are aimed to collect some statistics on FreeBSD boxes. I wrote them one year ago and used heavily during this period of time... Sample mrtg.cfg provided is from one of my servers, here You will find examples of usage of all scripts described below... And You may use this file as a template for Your own install of MRTG. ------------------------------------------------------------------------------- df.pl - dump statistics about the file system parameters: 1 - name of file system or swap for swap partition (I use pstat -s to obtain the information), default value: swap 2 - order of output, T - stands for total, 'A' - for available and 'U' - for used, default value: TU (i.e. total then used) 3 - multiplication factor (value returned will be multiplied by this, cause df returns amount of sizes in various measurement units), default value: 1024 (stands for 1 KByte) remark: Thanks for Tobias Oetiker who showed a workaround here example: Target[swap]: `/usr/local/etc/mrtg/df.pl swap _u` Target[usr]: `/usr/local/etc/mrtg/df.pl /usr tu 1` kMG[usr]: k,M,G,T,P we don't need ratio of swap usage, we need ability to control swap usage deviations, cause I don't think that Your system use 100% of swap memory :-) so we redefine second parameter to be '_U' meaning that we don't need first value /usr partition is larger than 4 GB, so to prevent overflows I use another measurement units and need to correctly specify kMG parameter of MRTG. And I'm interesting in ratio of usage for /usr, so I used 'TU' as a second parameter ------------------------------------------------------------------------------- ipfw.pl - dump statistics about the ipfw rule counters parameters: 1 - number of bunch of rules to dump data from, default value: 10000 2 - name of system monitored, default value: "IP Firewall on FreeBSD" 3 - string that triggers sucking data for input, default value: "in" 4 - string that triggers sucking data for output, default value: "out" examples: Target[ether]: `/usr/local/etc/mrtg/ipfw.pl 10000 "RTL-8139"` Target[modem]: `/usr/local/etc/mrtg/ipfw.pl 10001 "MegaBit SDSL Modem 300S"` You need four ipfw rules for examples shown above, for instance: add 10000 count all from any to any via rl0 in add 10000 count all from any to any via rl0 out add 10001 count all from any to any via rl1 in add 10001 count all from any to any via rl1 out In order to swap input and output graphs (if say output traffic is higher than input) call script on such way: ipfw.pl 1000 "RL0" out in ------------------------------------------------------------------------------- load.pl - dump statistics about the system load parameters: 1 - column to show, default value 1 (5 min averages) 2 - higher border of dumping data, default value 100 (it can't be higher :-) examples: Target[cpu]: `/usr/local/etc/mrtg/load.pl 1 0` we are interesting in small deviations of parameters rather then in estimating total system load, so we redefine second parameter to be 0 instead of 100 ------------------------------------------------------------------------------- snmpget.pl - dump statistics about the any SNMPable device parameters: 1 - target address and name for sucking, default value: -squidHost I will explain -options below 2 - additional MIB file used to convert symbolical SNMP names into numerical ones, default value: -squidMib 3 - "output" counter, default value: -p1 4 - "input" counter, default value: -p2 5 - uptime value, default value: -p3 6 - system name, default value: -p4 Script is able to substitute parameters, define them inside body of it. Predefined parameters are: '-squidHost' => 'public@localhost:3401' '-squidMib' => '/usr/local/etc/squid/mib.txt', '-p1' => 'cacheHttpOutKb', '-p2' => 'cacheHttpInKb', '-p3' => 'cacheUptime', '-p4' => 'cacheSoftware cacheVersionId', These are defaults for local SQUID proxy-server examples: LoadMIBs: /usr/local/etc/squid/mib.txt Target[proxyio]: cacheHttpOutKb&cacheHttpInKb:public@localhost:3401 Target[proxyio]: `/usr/local/etc/mrtg/snmpget.pl -squidHost -squidMib` First example uses internal MRTG capabilities to talk with SNMP devices, second uses my script. MRTG isn't able to suck uptime and system name from SQUID and other non-standard peers, so the second example is workaround. First example needs LoadMIBs clause to force MRTG to understand SQUID SNMP counters. ------------------------------------------------------------------------------- squid.1.pp and squid.2.pp produce OID_cache.txt file with all SQUID counters sorted by name and by OID respectively ------------------------------------------------------------------------------- I hope my small contribution effort to MRTG program will be usefull for You. No restrictions, no copyrights, only implied GPL and thanks for Tobias for his great tool. 28-Aug-2002y Hard Wisdom // hw@ksue.edu.ua