Solved

extend snmp through snmpd.conf

Posted on 2011-02-25
6
949 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
Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

 
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

2017 Webroot Threat Report

MSPs: Get the facts you need to protect your clients.
The 2017 Webroot Threat Report provides a uniquely insightful global view into the analysis and discoveries made by the Webroot® Threat Intelligence Platform to provide insights on key trends and risks as seen by our users.

Question has a verified solution.

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

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…
David Varnum recently wrote up his impressions of PRTG, based on a presentation by my colleague Christian at Tech Field Day at VMworld in Barcelona. Thanks David, for your detailed and honest evaluation!
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

728 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