#!/usr/bin/perl # dhcp-mrtg (c) 12-30-1999 Leif Sawyer under the GPL # # This is for a scope with multiple pools, so we cheat a little my(%count); my($StatsProg) = "/usr/local/bin/dhcp-status|"; my($grandused) = 0; my($grandtotal) = 0; open (LEASES, "$StatsProg") || die "Can't open $StatsProg for reading,"; while () { # You'll need to edit the line to match your netblock # You may need to have multiple matches, if you have more # than one netblock that can't be distilled down.. if (m/24\.237\.\d{1,3}\.\d{1,3}/) { my($scope,$used,$pused,$free,$pfree,$aband,$paband,$total) = split (/[\s\/]+/); # Here you'll need to edit to list the scopes you # want to match. Really i should recode this to look # at an array of scopes, but heck, it's a 2 minute hack.. if (($scope eq "24.237.0.0") || ($scope eq "24.237.28.0") ) { $grandtotal += $total; $grandused += ($used + $aband); } } } close(LEASES); my($uptime) = `uptime | cut -f 6-9 -d" " | cut -f 1-2 -d,`; chop($uptime); $uptime =~ s/\s+(.*)/$1/; my($hostname) = `hostname`; chop($hostname); print "$grandused\n$grandtotal\n$uptime\n$hostname\n";