From owner-freebsd-questions Mon Mar 26 20:49:17 2001 Delivered-To: freebsd-questions@freebsd.org Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by hub.freebsd.org (Postfix) with ESMTP id 5541C37B718 for ; Mon, 26 Mar 2001 20:49:10 -0800 (PST) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.11.3/8.11.3) id f2R4mgC00466; Mon, 26 Mar 2001 22:48:42 -0600 (CST) (envelope-from dan) Date: Mon, 26 Mar 2001 22:48:42 -0600 From: Dan Nelson To: dannyman Cc: freebsd-questions@FreeBSD.ORG Subject: pretty system monitoring graphs Message-ID: <20010326224842.A17294@dan.emsphone.com> References: <20010326203255.I45348@dell.dannyland.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="huq684BweRXVnRxX" Content-Disposition: inline User-Agent: Mutt/1.3.14i In-Reply-To: <20010326203255.I45348@dell.dannyland.org>; from "dannyman" on Mon Mar 26 20:32:55 GMT 2001 X-OS: FreeBSD 5.0-CURRENT Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --huq684BweRXVnRxX Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In the last episode (Mar 26), dannyman said: > So, I have diddled with Perl, MRTG, RRDTool, Cricket, Orca ... > > I have rolled my own "FreeBSD System Stats" using Orca and some scripts that > snarf data out of a Perl script that gets called from inetd. > > But, as I re-build a shell system, I can't help but wonder that somebody has > already rolled up a better system than mine, possibly using SNMP? 'twould be > nice to install it in the new shell cluster I build ... > > Anyone? Anyone? Suggestions? Beuller? Depends on the stats you're looking for. I'm graphing traffic, CPU, and disk usage with mrtg and ucd-snmp right now; attached are my get-cpu and get-space scripts; use them like Target[a_cpu]: `/usr/local/bin/get-cpu a.host.com` Target[a_usr]: `/usr/local/bin/get-space a.host.com /usr` get-space should work on any Unix running just about any snmpd, and graphs used space in green and total in blue. get-cpu is tested to work on FreeBSD, Solaris, and Tru64 (the latter two using their native snmpds), and doesn't seem to work right on Linux, no matter how I try :) It graphs total CPU in green and system cpu in blue. Examples at http://www.emsphone.com/stats/e5cpu.html and http://www.emsphone.com/stats/e5io1.html -- Dan Nelson dnelson@emsphone.com --huq684BweRXVnRxX Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=get-cpu #! /usr/local/bin/zsh case $2 in tru64v4) # Have to total per-cpu stats together GET=(snmpget -m PMGRD-2-0 -Oqv $1 public) WALK=(snmpwalk -m PMGRD-2-0 -Oqv $1 public) cpus=$($GET pmCmSysNumCpusOnline.0) userA=($($WALK pmAoCuUser)) niceA=($($WALK pmAoCuNice)) systemA=($($WALK pmAoCuSystem)) cpu=0 while (( cpu < cpus )) ; do (( total += userA[cpu] + niceA[cpu] + systemA[cpu] )) (( system += systemA[cpu] )) (( cpu++ )) done uptime=$(snmpget -Ov $1 public hrSystemUptime.0) ;; solaris) results=$(snmpget -m sun-snmp -Oqv $1 public rsIdleModeTime.0 rsUserProcessTime.0 rsNiceModeTime.0 rsSystemProcessTime.0 sysUpTime.0) results=(${(f)results}) total=$(( results[2]+results[3]+results[4] )) system=$results[4] uptime=${results[6]-$results[5]} ;; linux ) # regular CPU stats are broken; get raw ones results=$(snmpget -Oqv $1 public ssCpuRawIdle.0 ssCpuRawSystem.0 ssCpuRawUser.0 sysUpTime.0 hrSystemUptime.0 2>/dev/null) results=(${(f)results}) total=$(( results[2]+results[3] )) system=$results[2] uptime=${results[5]-$results[4]} ;; * ) results=$(snmpget -Ov $1 public ssCpuIdle.0 ssCpuSystem.0 ssCpuUser.0 sysUpTime.0 hrSystemUptime.0 2>/dev/null) results=(${(f)results}) total=$(( results[2]+results[3] )) system=$results[2] uptime=${results[5]-$results[4]} ;; esac # uptime=$(snmpget -Ov $1 public hrSystemUptime.0) echo $total echo $system echo $uptime echo $1 --huq684BweRXVnRxX Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=get-space #! /usr/local/bin/zsh results=$(snmptable -Cf : $1 public hrStorageTable | grep :$2:) results=(${(s.:.)results}) (( results[5] == 0 )) && exit 1 scale=${results[4]% *} (( scale == 0 )) && scale=4096 echo $(( results[6] / 1024 * scale )) echo $(( results[5] / 1024 * scale )) echo echo $1 --huq684BweRXVnRxX-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message