LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 02-11-2014, 02:08 AM   #1
rohitchauhan
Member
 
Registered: Nov 2010
Distribution: RedHat
Posts: 80

Rep: Reputation: 1
how to get modified output from 'snmpwalk' command


Hi guys,
I was trying SNMP monitoring in my linux system. I installed and configured the required package. Then I run the following command to get the memory status:

[root@nagios ~]# snmpwalk -c public -v 2c localhost memory
UCD-SNMP-MIB::memIndex.0 = INTEGER: 0
UCD-SNMP-MIB::memErrorName.0 = STRING: swap
UCD-SNMP-MIB::memTotalSwap.0 = INTEGER: 4030456 kB
UCD-SNMP-MIB::memAvailSwap.0 = INTEGER: 4030456 kB
UCD-SNMP-MIB::memTotalReal.0 = INTEGER: 3890484 kB
UCD-SNMP-MIB::memAvailReal.0 = INTEGER: 1750044 kB
UCD-SNMP-MIB::memTotalFree.0 = INTEGER: 5780500 kB
UCD-SNMP-MIB::memMinimumSwap.0 = INTEGER: 16000 kB
UCD-SNMP-MIB::memBuffer.0 = INTEGER: 128844 kB
UCD-SNMP-MIB::memCached.0 = INTEGER: 1038836 kB
UCD-SNMP-MIB::memSwapError.0 = INTEGER: noError(0)
UCD-SNMP-MIB::memSwapErrorMsg.0 = STRING:



Now, my requirement is that I want the SNMP output to show the figure "2850" from the second line. Or if possible some kind of edited (or tweaked) output i.e. (1710+125+1014=2849).

[root@nagios ~]# free -m
total used free shared buffers cached
Mem: 3799 2088 1710 0 125 1014
-/+ buffers/cache: 948 2850
Swap: 3935 0 3935


In a line, I want SNMP to reflect the output 2850 by command.

Is there a way to do this ?
Is there a way to tweak the output of snmpwalk command ?
Is there a way to achieve this in another fashion ?

Thanks in advance.


Note: Also please tell me best practices of posting a question here. I think there is a way of highlighting the command and output in my question.
 
Old 02-11-2014, 06:00 AM   #2
Nephew
LQ Newbie
 
Registered: Jun 2013
Posts: 14

Rep: Reputation: Disabled
We do it like this:
Create a script that will be called by snmpd to get that value. Lets call it /usr/local/bin/getmem.sh

Code:
#!/bin/bash
free -m|egrep 'buffers\/cache' | awk '{print $4}'
Run this script manually to make sure it echo the value you are looking for.

Now change your snmpd.conf and add a entry like this:
Quote:
extend .1.3.6.1.4.1.12345.123.1 mem2 /usr/local/bin/getmem.sh
Restart snmpd
Now run snmpwalk with the oid to see which output is the one that is needed
Code:
snmpwalk -c public -v 2c localhost 1.3.6.1.4.1.12345.123.1
 
1 members found this post helpful.
Old 02-15-2014, 06:17 AM   #3
rohitchauhan
Member
 
Registered: Nov 2010
Distribution: RedHat
Posts: 80

Original Poster
Rep: Reputation: 1
Hi,
Thanks for your solution. It worked for me perfectly.

NOW I have 1 more query. When I run the command:
Code:
# snmpwalk -c public -v 2c localhost 1.3.6.1.4.1.12345.123.1
# snmpwalk -c public -v 2c 127.0.0.1 1.3.6.1.4.1.12345.123.1
Both commands run successfully.

But when I run the command with IP address:
Code:
# snmpwalk -c public -v 2c 192.168.1.71 1.3.6.1.4.1.12345.123.1
It says:
Timeout: No Response from 192.168.1.71

I am not sure where should I look for it in configuration.

Can you please suggest something.

Thanks.
 
Old 02-15-2014, 01:58 PM   #4
Nephew
LQ Newbie
 
Registered: Jun 2013
Posts: 14

Rep: Reputation: Disabled
SNMPD is probably not listening on all interfaces, just on localhost.

On my distro(Slackware) to listen on the interface and on localhost I can run it like this:
Quote:
/usr/sbin/snmpd -c /etc/snmp/snmpd.conf 127.0.0.1 192.168.1.71
 
Old 02-15-2014, 02:18 PM   #5
Habitual
Senior Member
 
Registered: Jan 2011
Location: Yawnstown, Ohio
Distribution: This is my kung.fu
Posts: 4,399
Blog Entries: 4

Rep: Reputation: Disabled
Linux SNMP OID’s for CPU,Memory and Disk Statistics

Hope that's helpful.
 
Old 02-18-2014, 01:37 AM   #6
rohitchauhan
Member
 
Registered: Nov 2010
Distribution: RedHat
Posts: 80

Original Poster
Rep: Reputation: 1
Hi Nephew,
I did run the command as you mentioned and here is what happened with me:

Code:
[root@client ~]# /usr/sbin/snmpd -c /etc/snmp/snmpd.conf 127.0.0.1 192.168.1.71
[root@client ~]# echo $?
1
Looks like something is wrong.

Well I will look into that as soon as I get sufficient time.

But meanwhile, can you please tell me one more thing, that How can I get the OID of any of the below parameter (by using its name or string i.e. memTotalSwap.0) ?

Example:
"UCD-SNMP-MIB::memIndex.0 = INTEGER: 0
UCD-SNMP-MIB::memErrorName.0 = STRING: swap
UCD-SNMP-MIB::memTotalSwap.0 = INTEGER: 4030456 kB
UCD-SNMP-MIB::memAvailSwap.0 = INTEGER: 4030456 kB
UCD-SNMP-MIB::memTotalReal.0 = INTEGER: 3890484 kB"


To find the OID, I used run the command:
Code:
# snmptranslate -Td -IR memTotalSwap.0

UCD-SNMP-MIB::memTotalSwap.0
memTotalSwap OBJECT-TYPE
  -- FROM       UCD-SNMP-MIB
  SYNTAX        Integer32
  UNITS         "kB"
  MAX-ACCESS    read-only
  STATUS        current
  DESCRIPTION   "The total amount of swap space configured for this host."
::= { iso(1) org(3) dod(6) internet(1) private(4) enterprises(1) ucdavis(2021) memory(4) memTotalSwap(3) 0 }
So this is not showing OID actually. Only some information.

Thanks.
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Understanding output generated by snmpwalk yaron.kadem Linux - Networking 3 08-29-2013 08:18 AM
Snmpwalk command not giving response in arm based controller porting biyabani Linux - Newbie 0 06-13-2013 04:45 PM
How to convert MIBs to snmpwalk output? ronbarak Linux - Software 3 05-26-2013 02:41 PM
snmpwalk command not show appropriate output. gardenair Linux - Networking 6 09-17-2012 12:57 PM
bash: snmpwalk: command not found no1san Linux - Newbie 6 09-26-2010 04:36 AM


All times are GMT -5. The time now is 04:01 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration