Solved

extend snmp through snmpd.conf

Posted on 2011-02-25
6
942 Views
Last Modified: 2012-05-11
I'm trying to add a custom OID to report the value of USED swap sapce.  I'm missing something with the syntax I guess.

Here is what I have tried:
extend .1.3.6.1.4.1.9999.1.16.24 swapUsed free|grep Swap:|awk '{print $3}'
extend .1.3.6.1.4.1.9999.1.16.24 swapUsed `free|grep Swap:|awk '{print $3}'`
sh .1.3.6.1.4.1.9999.1.16.24 swapUsed free|grep Swap:|awk '{print $3}'
sh .1.3.6.1.4.1.9999.1.16.24 swapUsed `free|grep Swap:|awk '{print $3}'`

When I poll .1.3.6.1.4.1.9999.1.16.24 with a mib browser I get "snmp no such object"

If I used extend I get:
snmpwalk -c public -v 2c localhost .1.3.6.1.4.1.9999.1.16.24                                        -Os
enterprises.9999.1.16.24.1.0 = INTEGER: 1
enterprises.9999.1.16.24.2.1.2.8.115.119.97.112.85.115.101.100 = STRING: "`free|                                       grep"
enterprises.9999.1.16.24.2.1.3.8.115.119.97.112.85.115.101.100 = STRING: "Swap:|                                       awk '{print $3}'`"
enterprises.9999.1.16.24.2.1.4.8.115.119.97.112.85.115.101.100 = ""
enterprises.9999.1.16.24.2.1.5.8.115.119.97.112.85.115.101.100 = INTEGER: 5
enterprises.9999.1.16.24.2.1.6.8.115.119.97.112.85.115.101.100 = INTEGER: 1
enterprises.9999.1.16.24.2.1.7.8.115.119.97.112.85.115.101.100 = INTEGER: 1
enterprises.9999.1.16.24.2.1.20.8.115.119.97.112.85.115.101.100 = INTEGER: 4
enterprises.9999.1.16.24.2.1.21.8.115.119.97.112.85.115.101.100 = INTEGER: 1
enterprises.9999.1.16.24.3.1.1.8.115.119.97.112.85.115.101.100 = STRING: "`free|                                       grep: No such file or directory"
enterprises.9999.1.16.24.3.1.2.8.115.119.97.112.85.115.101.100 = STRING: "`free|                                       grep: No such file or directory"
enterprises.9999.1.16.24.3.1.3.8.115.119.97.112.85.115.101.100 = INTEGER: 1
enterprises.9999.1.16.24.3.1.4.8.115.119.97.112.85.115.101.100 = INTEGER: 1
enterprises.9999.1.16.24.4.1.2.8.115.119.97.112.85.115.101.100.1 = STRING: "`fre                                       e|grep: No such file or directory"

If I use sh I get:
snmpwalk -c public -v 2c localhost .1.3.6.1.4.1.9999.1.16.24 -Os
enterprises.9999.1.16.24.1.1 = INTEGER: 1
enterprises.9999.1.16.24.2.1 = STRING: "swapUsed"
enterprises.9999.1.16.24.3.1 = STRING: "`free|grep Swap:|awk '{print $3}'`"
enterprises.9999.1.16.24.100.1 = INTEGER: 32512
enterprises.9999.1.16.24.102.1 = INTEGER: 0
enterprises.9999.1.16.24.103.1 = ""


0
Comment
Question by:Dooglave
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
6 Comments
 
LVL 6

Author Comment

by:Dooglave
ID: 34981708
This is actually what I started with:
extend .1.3.6.1.4.1.9999.1.16.24 swapUsed /usr/bin/free grep Swap:|awk '{print $3}'

As you can see by the walk it's like it doesn't take the args after the free command. How do I make it include the grep Swap:|awk '{print $3}'



snmpwalk -c public -v 2c localhost .1.3.6.1.4.1.9999.1.16.24
SNMPv2-SMI::enterprises.9999.1.16.24.1.0 = INTEGER: 1
SNMPv2-SMI::enterprises.9999.1.16.24.2.1.2.8.115.119.97.112.85.115.101.100 = STRING: "/usr/bin/free"
SNMPv2-SMI::enterprises.9999.1.16.24.2.1.3.8.115.119.97.112.85.115.101.100 = STRING: "grep Swap:|awk '{print $3}'"
SNMPv2-SMI::enterprises.9999.1.16.24.2.1.4.8.115.119.97.112.85.115.101.100 = ""
SNMPv2-SMI::enterprises.9999.1.16.24.2.1.5.8.115.119.97.112.85.115.101.100 = INTEGER: 5
SNMPv2-SMI::enterprises.9999.1.16.24.2.1.6.8.115.119.97.112.85.115.101.100 = INTEGER: 1
SNMPv2-SMI::enterprises.9999.1.16.24.2.1.7.8.115.119.97.112.85.115.101.100 = INTEGER: 1
SNMPv2-SMI::enterprises.9999.1.16.24.2.1.20.8.115.119.97.112.85.115.101.100 = INTEGER: 4
SNMPv2-SMI::enterprises.9999.1.16.24.2.1.21.8.115.119.97.112.85.115.101.100 = INTEGER: 1
SNMPv2-SMI::enterprises.9999.1.16.24.3.1.1.8.115.119.97.112.85.115.101.100 = STRING: "             total       used       free     shared    buffers     cached"
SNMPv2-SMI::enterprises.9999.1.16.24.3.1.2.8.115.119.97.112.85.115.101.100 = STRING: "             total       used       free     shared    buffers     cached
Mem:       6218628    4185380    2033248          0     132724    3778520
-/+ buffers/cache:     274136    5944492
Swap:     14707496         72   14707424"
SNMPv2-SMI::enterprises.9999.1.16.24.3.1.3.8.115.119.97.112.85.115.101.100 = INTEGER: 4
SNMPv2-SMI::enterprises.9999.1.16.24.3.1.4.8.115.119.97.112.85.115.101.100 = INTEGER: 0
SNMPv2-SMI::enterprises.9999.1.16.24.4.1.2.8.115.119.97.112.85.115.101.100.1 = STRING: "             total       used       free     shared    buffers     cached"
SNMPv2-SMI::enterprises.9999.1.16.24.4.1.2.8.115.119.97.112.85.115.101.100.2 = STRING: "Mem:       6218628    4185380    2033248          0     132724    3778520"
SNMPv2-SMI::enterprises.9999.1.16.24.4.1.2.8.115.119.97.112.85.115.101.100.3 = STRING: "-/+ buffers/cache:     274136    5944492"
SNMPv2-SMI::enterprises.9999.1.16.24.4.1.2.8.115.119.97.112.85.115.101.100.4 = STRING: "Swap:     14707496         72   14707424"
0
 
LVL 6

Author Comment

by:Dooglave
ID: 34982042
seems like it's not honoring the pipe
0
 
LVL 6

Author Comment

by:Dooglave
ID: 34982360
This might be good enough: extend-sh .1.3.6.1.4.1.9999.1.16.24 swapUsed /usr/bin/free grep Swap:|awk '{print $3}'

I changed extend to extend-sh and now I get the value in OID SNMPv2-SMI::enterprises.9999.1.16.24.4.1.2.8.115.119.97.112.85.115.101.100.4 = STRING: "72"

Which is the correct value .....but what is all that other junk? I just want 72 as an integer and not all the other junk.
And were does all this (.4.1.2.8.115.119.97.112.85.115.101.100.4)added on to my OID come from?

snmpwalk -c public -v 2c localhost .1.3.6.1.4.1.9999.1.16.24
SNMPv2-SMI::enterprises.9999.1.16.24.1.0 = INTEGER: 1
SNMPv2-SMI::enterprises.9999.1.16.24.2.1.2.8.115.119.97.112.85.115.101.100 = STRING: "/usr/bin/free"
SNMPv2-SMI::enterprises.9999.1.16.24.2.1.3.8.115.119.97.112.85.115.101.100 = STRING: "grep Swap:|awk '{print $3}'"
SNMPv2-SMI::enterprises.9999.1.16.24.2.1.4.8.115.119.97.112.85.115.101.100 = ""
SNMPv2-SMI::enterprises.9999.1.16.24.2.1.5.8.115.119.97.112.85.115.101.100 = INTEGER: 5
SNMPv2-SMI::enterprises.9999.1.16.24.2.1.6.8.115.119.97.112.85.115.101.100 = INTEGER: 2
SNMPv2-SMI::enterprises.9999.1.16.24.2.1.7.8.115.119.97.112.85.115.101.100 = INTEGER: 1
SNMPv2-SMI::enterprises.9999.1.16.24.2.1.20.8.115.119.97.112.85.115.101.100 = INTEGER: 4
SNMPv2-SMI::enterprises.9999.1.16.24.2.1.21.8.115.119.97.112.85.115.101.100 = INTEGER: 1
SNMPv2-SMI::enterprises.9999.1.16.24.3.1.1.8.115.119.97.112.85.115.101.100 = STRING: "free"
SNMPv2-SMI::enterprises.9999.1.16.24.3.1.2.8.115.119.97.112.85.115.101.100 = STRING: "free
4191572
274464
72"
SNMPv2-SMI::enterprises.9999.1.16.24.3.1.3.8.115.119.97.112.85.115.101.100 = INTEGER: 4
SNMPv2-SMI::enterprises.9999.1.16.24.3.1.4.8.115.119.97.112.85.115.101.100 = INTEGER: 0
SNMPv2-SMI::enterprises.9999.1.16.24.4.1.2.8.115.119.97.112.85.115.101.100.1 = STRING: "free"
SNMPv2-SMI::enterprises.9999.1.16.24.4.1.2.8.115.119.97.112.85.115.101.100.2 = STRING: "4191572"
SNMPv2-SMI::enterprises.9999.1.16.24.4.1.2.8.115.119.97.112.85.115.101.100.3 = STRING: "274464"
SNMPv2-SMI::enterprises.9999.1.16.24.4.1.2.8.115.119.97.112.85.115.101.100.4 = STRING: "72"
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Author Comment

by:Dooglave
ID: 34982439
I fogot to add the pipe back.  output is a little better now. So how do I make it an integer or does it matter. I think it does because I want to creat a trap to see if it's >0

snmpwalk -c public -v 2c localhost .1.3.6.1.4.1.9999.1.16.24
SNMPv2-SMI::enterprises.9999.1.16.24.1.0 = INTEGER: 1
SNMPv2-SMI::enterprises.9999.1.16.24.2.1.2.8.115.119.97.112.85.115.101.100 = STRING: "/usr/bin/free"
SNMPv2-SMI::enterprises.9999.1.16.24.2.1.3.8.115.119.97.112.85.115.101.100 = STRING: "|grep Swap:|awk '{print $3}'"
SNMPv2-SMI::enterprises.9999.1.16.24.2.1.4.8.115.119.97.112.85.115.101.100 = ""
SNMPv2-SMI::enterprises.9999.1.16.24.2.1.5.8.115.119.97.112.85.115.101.100 = INTEGER: 5
SNMPv2-SMI::enterprises.9999.1.16.24.2.1.6.8.115.119.97.112.85.115.101.100 = INTEGER: 2
SNMPv2-SMI::enterprises.9999.1.16.24.2.1.7.8.115.119.97.112.85.115.101.100 = INTEGER: 1
SNMPv2-SMI::enterprises.9999.1.16.24.2.1.20.8.115.119.97.112.85.115.101.100 = INTEGER: 4
SNMPv2-SMI::enterprises.9999.1.16.24.2.1.21.8.115.119.97.112.85.115.101.100 = INTEGER: 1
SNMPv2-SMI::enterprises.9999.1.16.24.3.1.1.8.115.119.97.112.85.115.101.100 = STRING: "72"
SNMPv2-SMI::enterprises.9999.1.16.24.3.1.2.8.115.119.97.112.85.115.101.100 = STRING: "72"
SNMPv2-SMI::enterprises.9999.1.16.24.3.1.3.8.115.119.97.112.85.115.101.100 = INTEGER: 1
SNMPv2-SMI::enterprises.9999.1.16.24.3.1.4.8.115.119.97.112.85.115.101.100 = INTEGER: 0
SNMPv2-SMI::enterprises.9999.1.16.24.4.1.2.8.115.119.97.112.85.115.101.100.1 = STRING: "72"
0
 
LVL 6

Accepted Solution

by:
Dooglave earned 0 total points
ID: 34982623
I've tried a few things like int(command) and add INTEGER at the end of the extend line. It returns an integer but it's 512 instead of the current used value of swap which should be 72
0
 
LVL 6

Author Closing Comment

by:Dooglave
ID: 35946509
I'm done with this.
0

Featured Post

Surfing Is Meant To Be Done Outdoors

Featuring its rugged IP67 compliant exterior and delivering broad, fast, and reliable Wi-Fi coverage, the AP322 is the ideal solution for the outdoors. Manage this AP with either a Firebox as a gateway controller, or with the Wi-Fi Cloud for an expanded set of management features

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When replacing some switches recently I started playing with the idea of having admins authenticate with their domain accounts instead of having local users on all switches all over the place. Since I allready had an w2k8R2 NPS running for my acc…
Managing 24/7 IT Operations is a hands-on job and indeed a difficult one. Over the years I have found some simple tips and techniques to increase the efficiency of the overall operations. The core concept has always been on continuous improvement; a…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question