Discussion:
[mrtg] MRTG with extend command in Net-SNMP
Shu Hung (Koala)
2010-09-03 17:24:21 UTC
Permalink
Hello,

I'm trying to make a custom SNMP graph with extend command and MRTG
I've manage to get results from snmpwalk. The command and result looks like
this:

[***@foobar ~] snmpwalk -v 2c -c public somehost
'NET-SNMP-EXTEND-MIB::nsExtendOutputFull."testshell"'
NET-SNMP-EXTEND-MIB::nsExtendOutputFull."testshell" = STRING: 1
2
custom 1
custom 2

I then try to get these figures with MRTG. My config looks like this:

Target[testshell]:
`NET-SNMP-EXTEND-MIB::nsExtendOutputFull."testshell"`:***@somehost:::::2
Title[testshell]: Test Shell
MaxBytes[testshell]: 5
PageTop[testshell]: <H1>Test Shell</H1>
YLegend[testshell]: Test Shell
ShortLegend[testshell]: &nbsp;
Options[testshell]: nopercent, gauge


Then when I run MRTG, the following error appears:

sh: NET-SNMP-EXTEND-MIB::nsExtendOutputFull.testshell: command not found
2010-09-04 01:17:21: WARNING: Could not get any data from external command
'NET-SNMP-EXTEND-MIB::nsExtendOutputFull."testshell"'
Maybe the external command did not even start. (Illegal seek)

2010-09-04 01:17:21: WARNING: Problem with External get
'NET-SNMP-EXTEND-MIB::nsExtendOutputFull."testshell"':
Expected a Number for 'in' but nothing'

2010-09-04 01:17:21: WARNING: Problem with External get
'NET-SNMP-EXTEND-MIB::nsExtendOutputFull."testshell"':
Expected a Number for 'out' but nothing'

2010-09-04 01:17:21: ERROR: Target[testshell][_IN_] ' $target->[5]{$mode}
:***@somehost:::::2' (eval): syntax error at (eval 23) line 1, near "} :"

2010-09-04 01:17:21: ERROR: Target[testshell][_OUT_] ' $target->[5]{$mode}
:***@somehost:::::2' (eval): syntax error at (eval 24) line 1, near "} :"



What could be the problem? Any suggestion?

Thanks!
Daniel McDonald
2010-09-03 18:56:33 UTC
Permalink
Post by Shu Hung (Koala)
Post by Shu Hung (Koala)
sh: NET-SNMP-EXTEND-MIB::nsExtendOutputFull.testshell: command not found
What could be the problem? Any suggestion?
Paths or permissions. Put the full path to your script and it will likely
work, assuming the mrtg user has the permissions to execute the file...
--
Daniel J McDonald, CCIE # 2495, CISSP # 78281
Steve Shipway
2010-09-04 20:59:23 UTC
Permalink
I think you are misunderstanding how to specify an MRTG Target.

The backticks `xxx` are used to specify an external program (data collection plugin) to run which will output the values to graph.

However, the format of your Target seems to indicate that you are attempting to specify an OID this way.

Read the MRTG manaual on the format of the Target specifier -- oid&oid:***@device . You can use symbolic names for an OID if you have previously loaded the MIB -- you can't specify the MIB with the :: notation in the Target line. Also, MRTG does not support the ."xxx" suffic for identifying table members, you have to use numeric syntax (I know this can cause problems with dynamic tables as produced by net-snmp; you can get around this by writing a data collection plugin to do it, see the check_ucd data collection plugin which will get data via SNMP from a net-snmp module.

Steve

Steve Shipway
University of Auckland ITS
UNIX Systems Design Lead
***@auckland.ac.nz<mailto:***@auckland.ac.nz>
Ph: +64 9 373 7599 ext 86487

________________________________
From: mrtg-bounces+s.shipway=***@lists.oetiker.ch [mrtg-bounces+s.shipway=***@lists.oetiker.ch] on behalf of Shu Hung (Koala) [***@gmail.com]
Sent: Saturday, 4 September 2010 5:24 a.m.
To: ***@lists.oetiker.ch
Subject: [mrtg] MRTG with extend command in Net-SNMP

Hello,

I'm trying to make a custom SNMP graph with extend command and MRTG
I've manage to get results from snmpwalk. The command and result looks like this:

[***@foobar ~] snmpwalk -v 2c -c public somehost 'NET-SNMP-EXTEND-MIB::nsExtendOutputFull."testshell"'
NET-SNMP-EXTEND-MIB::nsExtendOutputFull."testshell" = STRING: 1
2
custom 1
custom 2

I then try to get these figures with MRTG. My config looks like this:

Target[testshell]: `NET-SNMP-EXTEND-MIB::nsExtendOutputFull."testshell"`:***@somehost:::::2
Title[testshell]: Test Shell
MaxBytes[testshell]: 5
PageTop[testshell]: <H1>Test Shell</H1>
YLegend[testshell]: Test Shell
ShortLegend[testshell]: &nbsp;
Options[testshell]: nopercent, gauge

Then when I run MRTG, the following error appears:

sh: NET-SNMP-EXTEND-MIB::nsExtendOutputFull.testshell: command not found
2010-09-04 01:17:21: WARNING: Could not get any data from external command 'NET-SNMP-EXTEND-MIB::nsExtendOutputFull."testshell"'
Maybe the external command did not even start. (Illegal seek)

2010-09-04 01:17:21: WARNING: Problem with External get 'NET-SNMP-EXTEND-MIB::nsExtendOutputFull."testshell"':
Expected a Number for 'in' but nothing'

2010-09-04 01:17:21: WARNING: Problem with External get 'NET-SNMP-EXTEND-MIB::nsExtendOutputFull."testshell"':
Expected a Number for 'out' but nothing'

2010-09-04 01:17:21: ERROR: Target[testshell][_IN_] ' $target->[5]{$mode} :***@somehost:::::2' (eval): syntax error at (eval 23) line 1, near "} :"

2010-09-04 01:17:21: ERROR: Target[testshell][_OUT_] ' $target->[5]{$mode} :***@somehost:::::2' (eval): syntax error at (eval 24) line 1, near "} :"


What could be the problem? Any suggestion?

Thanks!
Shu Hung (Koala)
2010-09-07 09:27:48 UTC
Permalink
I'm not quite sure I get you.

As far as I know, the '::::2' suffix is to set the SNMP version number that
MRTG would use. It's not a part of OID at all. To my understanding, I'm
using this text OID for my script:

NET-SNMP-EXTEND-MIB::nsExtendOutputFull."testshell"

And the snmpwalk result seems to indicate that my script works with snmpd as
expected. This is the result:

NET-SNMP-EXTEND-MIB::nsExtendOutputFull."testshell" = STRING: 1
2
custom 1
custom 2

How can I plot a graph with MRTG?
Or which part did I get wrong?


Koala Yeung
Post by Steve Shipway
I think you are misunderstanding how to specify an MRTG Target.
The backticks `xxx` are used to specify an external program (data
collection plugin) to run which will output the values to graph.
However, the format of your Target seems to indicate that you are
attempting to specify an OID this way.
Read the MRTG manaual on the format of the Target specifier --
notation in the Target line. Also, MRTG does not support the ."xxx" suffic
for identifying table members, you have to use numeric syntax (I know this
can cause problems with dynamic tables as produced by net-snmp; you can get
around this by writing a data collection plugin to do it, see the check_ucd
data collection plugin which will get data via SNMP from a net-snmp module.
Steve
*Steve Shipway*
University of Auckland ITS
*UNIX Systems Design Lead*
Ph: +64 9 373 7599 ext 86487
**
------------------------------
*Sent:* Saturday, 4 September 2010 5:24 a.m.
*Subject:* [mrtg] MRTG with extend command in Net-SNMP
Hello,
I'm trying to make a custom SNMP graph with extend command and MRTG
'NET-SNMP-EXTEND-MIB::nsExtendOutputFull."testshell"'
NET-SNMP-EXTEND-MIB::nsExtendOutputFull."testshell" = STRING: 1
2
custom 1
custom 2
:::::2
Title[testshell]: Test Shell
MaxBytes[testshell]: 5
PageTop[testshell]: <H1>Test Shell</H1>
YLegend[testshell]: Test Shell
ShortLegend[testshell]: &nbsp;
Options[testshell]: nopercent, gauge
sh: NET-SNMP-EXTEND-MIB::nsExtendOutputFull.testshell: command not found
2010-09-04 01:17:21: WARNING: Could not get any data from external
command 'NET-SNMP-EXTEND-MIB::nsExtendOutputFull."testshell"'
Maybe the external command did not even start. (Illegal seek)
2010-09-04 01:17:21: WARNING: Problem with External get
Expected a Number for 'in' but nothing'
2010-09-04 01:17:21: WARNING: Problem with External get
Expected a Number for 'out' but nothing'
2010-09-04 01:17:21: ERROR: Target[testshell][_IN_] ' $target->[5]{$mode}
2010-09-04 01:17:21: ERROR: Target[testshell][_OUT_] '
24) line 1, near "} :"
What could be the problem? Any suggestion?
Thanks!
Shu Hung (Koala)
2010-09-17 10:00:31 UTC
Permalink
I tried this configuration in my snmpd.conf

extend 1.3.6.1.4.1.1.2.3.4.5.6 /usr/local/snmpd-5.5/etc/snmp/scripts/test.sh

After restarting snmpd, I use snmpwalk to test it:

[***@foobar ~] snmpwalk -v 2c -c public somehost 1.3.6.1.4.1.1.2.3.4.5.6

It gives me this error:

SNMPv2-SMI::enterprises.1.2.3.4.5.6 = No Such Object available on this agent
at this OID

I tried to run mrtg right the way. It gives me this error:

2010-09-17 17:58:01: ERROR: Target[testshell][_IN_] '1.3.6.1.4.1.1.2.3.4.5.
$target->[5]{$mode} ' (warn): Use of uninitialized value in concatenation
(.) or string at (eval 23) line 1.
2010-09-17 17:58:01: ERROR: Target[testshell][_OUT_] '1.3.6.1.4.1.1.2.3.4.5.
$target->[5]{$mode} ' (warn): Use of uninitialized value in concatenation
(.) or string at (eval 24) line 1.

What should I do?



Koala Yeung
NET-SNMP-EXTEND-MIB::nsExtendOutputFull.”testshell”
1.3.6.1.4.1.1.2.3.4.5.6
ifInErrors.6
However you cannot specify an OID using the ‘*MIBNAME*::*symbolicname*format, and you cannot use the .”textindex” suffix, only a numeric suffix.
The output of snmpwalk is not necessarily compatible with MRTG as it can
use these additional two notation formats.
The ‘:::::2’ suffix is a collapsed form of the Extended Hostname Syntax for
specifying a Target in MRTG and is separate from the OID specification.
See http://oss.oetiker.ch/mrtg/doc/mrtg-reference.en.html for
documentation on the Target syntax, and how you can specify an OID.
Steve
------------------------------
*Steve Shipway*
http://www.steveshipway.org/software
P Please consider the environment before printing this e-mail
*Sent:* Tuesday, 7 September 2010 9:28 p.m.
*To:* Steve Shipway
*Subject:* Re: [mrtg] MRTG with extend command in Net-SNMP
I'm not quite sure I get you.
As far as I know, the '::::2' suffix is to set the SNMP version number that
MRTG would use. It's not a part of OID at all. To my understanding, I'm
NET-SNMP-EXTEND-MIB::nsExtendOutputFull."testshell"
And the snmpwalk result seems to indicate that my script works with snmpd
NET-SNMP-EXTEND-MIB::nsExtendOutputFull."testshell" = STRING: 1
2
custom 1
custom 2
How can I plot a graph with MRTG?
Or which part did I get wrong?
Koala Yeung
Loading...