LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 06-11-2009, 03:17 AM   #1
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 115Reputation: 115
console snmp monitor


Greetings to all.
I am looking for an shell/console bandwidth monitor that can measure bandwidth stats on remote switch interfaces/ports using snmp. Strictly no graphing, just average interval stats in a console. I do not mind if it is an ncurses console but would just prefer a simple kind of perl or shell script. I did have a go at writing one, but the results are just not what i expected....
I would be most grateful if anyone that knows of one points me in the right direction.
 
Old 06-11-2009, 09:02 AM   #2
Ygrex
Member
 
Registered: Nov 2004
Location: Russia (St.Petersburg)
Distribution: Debian
Posts: 406

Rep: Reputation: 32
Smile

if you want to know a bandwith and nothing more, IMHO snmp is an excessive tool for you; snmp uses ifconfig's statictics for its calculations; you can do the same work without snmp

for example, the following script will continuously out put the specified interface statistics:
Code:
#!/bin/sh

# output precision
PRECISION=3
INTERVAL=1

while (true); do

# read statistics
STAT="$(ifconfig $1 | sed -n 's/^.*bytes:\([0-9]\+\).*bytes:\([0-9]\+\).*$/\1 \2/p')"

# received
rx[0]=$(echo $STAT | awk '{print $1}')
# transferred
tx[0]=$(echo $STAT | awk '{print $2}')

# wait
sleep $INTERVAL

# read statistics
STAT="$(ifconfig $1 | sed -n 's/^.*bytes:\([0-9]\+\).*bytes:\([0-9]\+\).*$/\1 \2/p')"

# received
rx[1]=$(echo $STAT | awk '{print $1}')
# transferred
tx[1]=$(echo $STAT | awk '{print $2}')

# inbound
rx_bw=$( echo -e "scale = $PRECISION \n ( ${rx[1]} - ${rx[0]} ) / 256 " | bc )
# outbound
tx_bw=$( echo -e "scale = $PRECISION \n ( ${tx[1]} - ${tx[0]} ) / 256 " | bc )

# output results
echo "$rx_bw $tx_bw"

done
you can transfer it anywhere you want with netcat:
Code:
$ ./script.sh eth0 | nc remote_host 1234
providing the specified port is open on the remote_host with:
Code:
$ nc -l -p 1234
Best regards,

Igor
 
Old 06-12-2009, 02:57 AM   #3
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Original Poster
Rep: Reputation: 115Reputation: 115
Hey igor, very big thanks for that, but you see my issue is i need stats from a remote switch interface - hence me needing a tool/program that works with snmp...
 
Old 06-12-2009, 03:52 AM   #4
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,034

Rep: Reputation: 97
is mrtg not suitable??, by using mrtg you can get clear stats about bandwidth on each ports, new TCP and established TCP connections.
 
Old 06-12-2009, 06:09 AM   #5
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Original Poster
Rep: Reputation: 115Reputation: 115
Quote:
Originally Posted by kirukan View Post
is mrtg not suitable??, by using mrtg you can get clear stats about bandwidth on each ports, new TCP and established TCP connections.
No, because it is not console or shell based...
 
Old 06-12-2009, 06:13 AM   #6
Ygrex
Member
 
Registered: Nov 2004
Location: Russia (St.Petersburg)
Distribution: Debian
Posts: 406

Rep: Reputation: 32
maybe net-snmp CLI?
 
Old 06-12-2009, 08:02 AM   #7
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Original Poster
Rep: Reputation: 115Reputation: 115
Quote:
Originally Posted by Ygrex View Post
Well i can get the raw data using snmpwalk anyway. The data is returned in octets.
What i want is something that could convert the data the way cacti or any other rrdbased graphing tool does.
Even something like bwm-ng would do - if it could monitor remote switch ports/interfaces.

Any suggestions??
My perl isnt good enough to come up with a decent script...
Of course i could learn it properly, but i a solution in the next couple of days....
 
Old 06-12-2009, 08:21 AM   #8
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,034

Rep: Reputation: 97
check the output of this snmpwalk
snmpwalk -v 1 -c public 192.168.11.211 interfaces.
 
Old 06-15-2009, 10:03 AM   #9
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Original Poster
Rep: Reputation: 115Reputation: 115
Quote:
Originally Posted by kirukan View Post
check the output of this snmpwalk
snmpwalk -v 1 -c public 192.168.11.211 interfaces.
????
That doesnt help much ...like i said, i can already gather the raw snmp data in octets using snmpwalk....
Just want to know if anyone knows of a console program that does this, but also converts the data in a format like cacti or mrtg might do it.
Anyone else??
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SNMP monitor that sends alerts fancylad Linux - Server 2 05-12-2008 06:31 PM
simple SNMP monitor Hewson Linux - Networking 2 09-05-2007 01:36 PM
Connecting a console to a monitor help! Mega Man X General 2 09-29-2006 08:15 PM
snmp cpu monitor hank43 Linux - Networking 0 04-11-2004 03:20 AM
snmp (ucd-snmp, net-snmp) markus1982 Linux - Software 1 11-21-2002 10:45 AM


All times are GMT -5. The time now is 08:27 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration