LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 03-14-2013, 01:17 PM   #1
gtludwig
Member
 
Registered: Oct 2005
Location: Brazil
Distribution: Slackware64-current
Posts: 219

Rep: Reputation: 16
how can I use snmp to gather data from other network hosts and display on conky?


I'm trying to build a conky config file (.conkyrc) that polls into 4 linux servers I have on the network so I can have a quick glance at my desktop and be able to check each server for the top processes, memory and cpu consumption, network interface usage, etc.

I originally posted a related question on unix.stackexchange.com here and someone there said the ideal way to poll a network server is via snmp.
Is it so? If so, how can I poll a snmpd running on another server?

Thanks in advance,

Last edited by gtludwig; 03-14-2013 at 01:20 PM. Reason: add URL
 
Old 03-14-2013, 09:38 PM   #2
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: Carrollton, Texas
Distribution: Slackware64 14.1
Posts: 1,412

Rep: Reputation: 398Reputation: 398Reputation: 398Reputation: 398
As far as I can tell from a 2 minute read of the conky documentation, there's no built-in support for snmp polling.

A detailed answer depends upon if you want to use snmpv3 to poll or snmpv2c (the security models are different). Essentially, you'd have to run snmpget/snmpbulk to get the OID values for the various MIBs that you want.

If you don't know SNMP, the "simple" part isn't referring to how you actually get any information out of the *bleeping* thing.

You'd spend a lot less time running gkrellmd on each machine that you want to monitor and run gkrellm instances on your desktop to see the values you are interested in seeing.
 
Old 03-14-2013, 10:03 PM   #3
mumpster
LQ Newbie
 
Registered: Apr 2008
Location: Novosibirsk, Russia
Posts: 5

Rep: Reputation: 0
Cool

Quote:
Originally Posted by gtludwig View Post
I'm trying to build a conky config file ... be able to check each server for the top processes, memory and cpu consumption, network interface usage, etc.
...
If so, how can I poll a snmpd running on another server?
Hm. I has not dealt with conky but IMHO usually it is much more easier just to poll Linux servers through special scripts rather than trying to grok and to figure out "Simple" management protocol. Frankly, it is simpler when compares with TNM, ha-ha-ha .

Nevertheless...I'm sure almost anyone can cope with SNMP.
So you just need:
1) to choose (if there is something suitable) or to make youself a script for SNMPd giving correct results depending on requested OID.
2) to tell conky which OID to use. That's the main problem because there are too many OIDs.:-|
Though to give you a common idea about SNMP usage I put here my simple handler for SNMPd:

#!/bin/sh -f
#Give used real memory

PLACE=".1.3.6.1.4.1.2021.4.55"
REQ="$2"

case "$REQ" in
$PLACE.0) RET=$PLACE.0 ;;
*) exit 0 ;;
esac
case "$RET" in
$PLACE.0) echo "integer"; \
# total=`snmpget -v 2c -c public localhost .1.3.6.1.4.1.2021.4.5.0 | cut -d\ -f4`; \
# avail=`snmpget -v 2c -c public localhost .1.3.6.1.4.1.2021.4.6.0 | cut -d\ -f4`; \
#/usr/bin/free | /usr/bin/awk '{if (FNR==2) print $3}';;
/usr/bin/vmstat | /usr/bin/awk '{if (NR==3) print $4}'; exit 0;;
*) echo "string"; echo "ack... $RET $REQ"; exit 0 ;;
esac

I also have in my snmpd.conf this line:

pass .1.3.6.1.4.1.2021.4.55.0 /bin/sh /MY-SWEETHOME/bin/passtest

snmpget/snmpwalk utility allows to check manually what and where. I.e. to verify you can really get what you want if any.
After snmpget results make you happy you can proceed further with conky itself...
I suggest this way.
BTW, there are a lot stuff in /etc/snmp/snmpd.conf
It worths to read and there are good and ready-to-use examples in that config file
but you have to read about SNMP first. Otherwise some things look Greek.

And as always, YMMV.
Cheers!
 
Old 03-15-2013, 12:31 AM   #4
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: Carrollton, Texas
Distribution: Slackware64 14.1
Posts: 1,412

Rep: Reputation: 398Reputation: 398Reputation: 398Reputation: 398
Quote:
Originally Posted by mumpster View Post
Hm. I has not dealt with conky but IMHO usually it is much more easier just to poll Linux servers through special scripts rather than trying to grok and to figure out "Simple" management protocol. Frankly, it is simpler when compares with TNM, ha-ha-ha .

Nevertheless...I'm sure almost anyone can cope with SNMP.
So you just need:
1) to choose (if there is something suitable) or to make youself a script for SNMPd giving correct results depending on requested OID.
2) to tell conky which OID to use. That's the main problem because there are too many OIDs.:-|
Though to give you a common idea about SNMP usage I put here my simple handler for SNMPd:

#!/bin/sh -f
#Give used real memory

PLACE=".1.3.6.1.4.1.2021.4.55"
REQ="$2"

case "$REQ" in
$PLACE.0) RET=$PLACE.0 ;;
*) exit 0 ;;
esac
case "$RET" in
$PLACE.0) echo "integer"; \
# total=`snmpget -v 2c -c public localhost .1.3.6.1.4.1.2021.4.5.0 | cut -d\ -f4`; \
# avail=`snmpget -v 2c -c public localhost .1.3.6.1.4.1.2021.4.6.0 | cut -d\ -f4`; \
#/usr/bin/free | /usr/bin/awk '{if (FNR==2) print $3}';;
/usr/bin/vmstat | /usr/bin/awk '{if (NR==3) print $4}'; exit 0;;
*) echo "string"; echo "ack... $RET $REQ"; exit 0 ;;
esac

I also have in my snmpd.conf this line:

pass .1.3.6.1.4.1.2021.4.55.0 /bin/sh /MY-SWEETHOME/bin/passtest

snmpget/snmpwalk utility allows to check manually what and where. I.e. to verify you can really get what you want if any.
After snmpget results make you happy you can proceed further with conky itself...
I suggest this way.
BTW, there are a lot stuff in /etc/snmp/snmpd.conf
It worths to read and there are good and ready-to-use examples in that config file
but you have to read about SNMP first. Otherwise some things look Greek.

And as always, YMMV.
Cheers!
Heh. TMN documents are like peanuts: you can't read just one.
For those who haven't had to read TMN docs, the people who write them never duplicate information. They just refer to other documents. It's like unraveling a ball of string.
In fact, the OP would have to read /etc/snmp/snmpd.conf since the Slackware default values don't allow access to any OIDs that are useful. If the OP wants to do this to learn about SNMP (which is not a bad idea if you work in IT or telecom), then it's not a bad exercise. In that case, you should bookmark the MIB depot. Slackware comes with tkmib, which allows you to use a GUI to examine what an SNMP agent has in it. (There's some Perl dependencies that you'll have to resolve to get it to work.)
 
Old 03-17-2013, 06:53 PM   #5
Habitual
Senior Member
 
Registered: Jan 2011
Distribution: Slack14_64_Multilib
Posts: 3,039
Blog Entries: 4

Rep: Reputation: 734Reputation: 734Reputation: 734Reputation: 734Reputation: 734Reputation: 734Reputation: 734
Code:
${execpi 60 snmpwalk -v 2c -c public <host> .1.3.6.1.4.1.2021.4.55}
for example.

other usual conky data ("top 5" etc...) could best be utilized via key-based ssh commands such as top.
It will take quite a bit of scripting, both in ConkyRCs and or .sh scripts proper.

Last edited by Habitual; 03-17-2013 at 06:57 PM.
 
  


Reply

Tags
conky, network, snmp


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Temp script to minus value to display in conky? corbintechboy Linux - General 21 01-19-2011 02:44 PM
[SOLVED] How do I display external IP address in Conky? PClOStinspace Linux - Software 2 11-27-2010 11:58 AM
how ubuntu can be programmed to gather data serially or usb input darragh Ubuntu 2 02-13-2009 08:20 AM
Incoming connections won't display in conky Decalore Slackware 8 09-12-2008 10:37 AM
tool to gather network information paul_mat Linux - Networking 3 01-18-2006 05:01 AM


All times are GMT -5. The time now is 04:16 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 Google+: linuxquestions
Open Source Consulting | Domain Registration