|
|
| Author |
Message |
dreness
Joined: 02 Jan 2004 Posts: 7 Location: Cupertino, CA
|
Posted: Fri Jan 02, 2004 7:09 pm Post subject: Multiple values from a single OID? |
|
|
So, I'm in sort of a weird spot. 3/4 of my machines are darwin / mac os x, and netsnmp doesn't know how to get cpu stats in the 1.3.6.1.4.1.2021.11 tree (system / user / nice). I'm trying to work around this using custom scripts.
I'm using
iostat -C -d -n 1 -c 2 | tail -n 1 | awk '{print $4 " " $5 " " $6}'
... which returns exactly three numbers: user / system / idle
I've got an 'exec' in my snmpd.conf pointing to this script, and I can successfully fetch the value:
andre@IP41-89[~]snmpwalk -c foo -v 2c -On blah .1.3.6.1.4.1.2021.8.1.101.1
.1.3.6.1.4.1.2021.8.1.101.1 = STRING: 2 1 97
So, three pieces of data out of a single SNMP query. What I can't figure out is how to parse that output into three different pieces of data on the cacti end, or even if this is possible. I've scrubbed these forums and from what I can gather, I need a data template for each VALUE, not each snmp query.
A related problem is that iostat only displays 'current' statistics starting on the second sample. This is why I have to -c 2 in the usage above, and then get the last line with tail. What I want to avoid is running that script three times and pulling off only one piece of data at a time, since then it would take 6 seconds to get all the data instead of 2.
By the way, if anybody has a better idea of how to get this info in darwin, please let me know
Thanks much. Cacti rocks  |
|
| Back to top |
|
 |
raX Lead Developer
Joined: 13 Oct 2001 Posts: 2237 Location: Carlisle, PA
|
Posted: Sun Jan 04, 2004 11:38 pm Post subject: |
|
|
You can do this with the help from an external script. Cacti is not going to like the "2 1 97" string alone since it requires multiple outputs to be formatted a certain way. The script could gather these three values from the OID and format it as:
user:2 system:1 idle:97
(using your field names of course)
Once you write this script, you need to create a new data input method that specifies three output fields. The field name you specify in the script's output must match the field names you define in Cacti. After creating the data input method, you can create data sources and then graphs.
-Ian |
|
| Back to top |
|
 |
dreness
Joined: 02 Jan 2004 Posts: 7 Location: Cupertino, CA
|
Posted: Thu Jan 08, 2004 12:49 am Post subject: |
|
|
thanks for the reply
I haven't figured out exactly how to define custom fields in an input method yet, so what I did was store the three values in three seperate OIDs by changing the exec statement in snmpd.conf to:
exec 1.3.6.1.4.1.2021.8.1.101 cpumon /Users/andre/cpumon
I also updated the cpumon script to return the values on three separate lines, which creates an snmp table rooted at the above OID. Then I duplicated one of the existing data templates and just changed the OID to point where I needed.
This is probably a weird solution, but I came into this without really knowing much of rrdtool. |
|
| Back to top |
|
 |
fletch Cacti User
Joined: 06 Oct 2003 Posts: 108 Location: Stanford, CA
|
Posted: Mon Jan 12, 2004 1:19 pm Post subject: |
|
|
Ok I wrote a script for our Netscreen that outputs its stats like so:
| Code: |
cpu1:1 cpu5:1 cpu15:1 memoryAllocated:131975312 memoryAvailable:117585776 memoryFragmented:8665 sessionsAllocated:645 sessionsMaximum:250000 sessionsFailed:0
|
I then followed your instructions:
1) Create a data input method with the output fields matching those output by my script
2) Create Data Sources/Templates
3) Graph Templates
4) Graphs
The graphs are rendered without any data in them - and I get NaN for the LAST value.
Any idea how to debug this - will rrdinfo verify the data fromthe script is being stored?
here is the code I used:
<cactipath>/scripts/getNSdata
| Code: |
#!/bin/csh
snmpwalk -v 1 -c public xx.xx.xx.xx .1.3.6.1.4.1.3224.16 >! /tmp/NSsnmp.out
foreach i (`cat /usr/local/cacti/scripts/NSmib | awk '{print $NF}'`)
/usr/ucb/echo -n `grep $i /usr/local/cacti/scripts/NSmib | awk '{print $1}'`":"`grep $i /tmp/NSsnmp.
out | awk '{print $NF}'`" "
end
|
It uses the following OID/output field name mapping file:
| Code: |
cpu1 .16.1.2.0
cpu5 .16.1.3.0
cpu15 .16.1.4.0
memoryAllocated .16.2.1.0
memoryAvailable .16.2.2.0
memoryFragmented .16.2.3.0
sessionsAllocated .16.3.2.0
sessionsMaximum .16.3.3.0
sessionsFailed .16.3.4.0
|
| raX wrote: | You can do this with the help from an external script. Cacti is not going to like the "2 1 97" string alone since it requires multiple outputs to be formatted a certain way. The script could gather these three values from the OID and format it as:
user:2 system:1 idle:97
(using your field names of course)
Once you write this script, you need to create a new data input method that specifies three output fields. The field name you specify in the script's output must match the field names you define in Cacti. After creating the data input method, you can create data sources and then graphs.
-Ian |
|
|
| Back to top |
|
 |
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|