[mrtg] Re: OID math in MRTG
Jacek Zabicki
jzabicki at equifax.ca
Wed Oct 20 17:55:20 MEST 1999
If you are using Unix you can do any math operations you want. You can write
a shell script and then call it from Target line. Here is is my script that
counts number of telnet sessions and number of different users that opened
telnet sessions. In your script you could do snmpget and do math operations
on results. Consult config.htm about integrating shell scripts from Target
line.
Tis is my target line:
Target[_tor_volcan.telnet_sessions]: `/apps/bat/mrtg/telnet_sessions.sh
172.18.232.22 public`
This is my shell script:
<<<<<<<< CUT HERE >>>>>>>>>>>
#!/bin/sh
# This script is used by MRTG, it is specified on Target line of .cfg file
# $1 must be IP address of target
# $2 must be community name on the target
# This script returns four lines
# line 1: number of telnet sessions
# line 2: number of telnetting users
# line 3: system uptime
# line 4: system name and IP
# For more info consult config.htm
# BEGIN ============
# LINE 1
# Number of telnet sessions
# 2 is substracted because first two lines are headers
let sessions=`finger -m @$1 | grep -c ""`-2
echo $sessions
# LINE 2
# Number of telneting users
let a=999
let users=0
for i in `finger @$1 | sort | cut -c0-9`
do
b=$a
a=$i
if ! [ "$a" = "$b" ]
then
let users=$users+1
fi
done
# Substract 2. The first twa lines of command finger are headers.
let users=$users-2
echo $users
# LINE 3
snmpget $1 $2 system.sysUpTime.0 | cut -c22-70
# LINE 4
echo -n `snmpget $1 $2 system.sysName.0 | cut -c20-45`; echo -n " "; echo $1
# END ============
<<<<<<<< CUT HERE >>>>>>>>>>>
-----Original Message-----
From: mrtg-bounce at list.ee.ethz.ch [mailto:mrtg-bounce at list.ee.ethz.ch]On
Behalf Of Emery, Mark
Sent: 19 October, 1999 11:24
To: 'mrtg at list.ee.ethz.ch'
Subject: [mrtg] OID math in MRTG
Hello All,
I'm trying to graph the number of calls being handled by a Remote
Access device. I'd like the graph to show the TOTAL number of calls in
green, with the blue line showing the number of calls that are outgoing.
I've got two OIDS available, one from incoming, one for outgoing.
Is there any easy way to do this? I need to do A+B & A not the
documented A&B:s at n + C&D:s at n.
e.g. Target[rasbox]:
1.3.6.1.4.1.529.11.7.0+1.3.6.1.4.1.529.11.7.0&1.3.6.1.4.1.529.11.6.0:snmpcom
m at nodename
Thanks,
Mark Emery.
P.S. My employer is not officially using MRTG yet, I'm experimenting to see
if it will meet my teams requirements.
--
* To unsubscribe from the mrtg mailing list, send a message with the
subject: unsubscribe to mrtg-request at list.ee.ethz.ch
* The mailing list archive is at http://www.ee.ethz.ch/~slist/mrtg
More information about the mrtg
mailing list