Number of active interfaces?

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
User avatar
Ancalagon
Posts: 15
Joined: Wed Mar 14, 2007 9:44 am
Location: Germany

Number of active interfaces?

Post by Ancalagon »

Hi @all,

my problem: I need a graph over the number of all interfaces of a switch where ifAdminStatus=up AND ifOperStatus=up.

How can I do this?

Thanks in advance.

Stefan
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

I'm pretty sure there's no SNMP OID that will tell you this (the ifTable only tells you how many interfaces), so you would need to write a script to fetch all the 1.3.6.1.2.1.2.2.1.8 and 1.3.6.1.2.1.2.2.1.9 entries from the MIB-2 ifTable, and add them up yourself.

Script queries are pretty straightforward to write, if you have any scripting experience (perl, awk, shell). Start here: http://docs.cacti.net/node/224
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
User avatar
Ancalagon
Posts: 15
Joined: Wed Mar 14, 2007 9:44 am
Location: Germany

Post by Ancalagon »

Howie wrote: Script queries are pretty straightforward to write, if you have any scripting experience (perl, awk, shell).
Thx, Howie.

Yep, I got plenty of scripting experience - on windows-based machines. :roll: :wink:
Too bad I just killed my old windows-cacti and migrated the server to linux. :-?

Ok, I think I'll make it quick and dirty and use a shell-script (*Hiding the "linux-scripting-for-bloody-beginners" book behind the back*). snmpwalk and grep will do the job.

Edit:
Ok, very quick and VERY dirty (and dropped the adminstatus thing):

Code: Select all

#!/bin/sh
hostname=$1
community=$2
snmpversion=$3
authprotocol=$4
authpass=$5
privprot=$6
privpass=$7
user=$8

if $snmpversion = 1 
	then snmpwalk -Os -c $community -v 1 $hostname interfaces |grep "ifOperStatus" | grep "up" -c | awk '{printf "actint:" $1}'
	else snmpwalk -Os -v $snmpversion -u $user -a $authprotocol -A $authpass -x $privprot -X $privpass -l authPriv $hostname interfaces |grep "ifOperStatus" | grep "up" -c | awk '{printf "actint:" $1}'
fi
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests