Hello
I have a fully working NET-SNMP perl program, using
use NetSNMP::OID (':all');
use NetSNMP::agent (':all');
use NetSNMP::ASN (':all');
The problem is that when I send an OID request (e.g -
snmpget -c public -v 1 MY_IP .1.3.6.1.4.1.54321.1.2.1 )
I get the answer -
SNMPv2-SMI::enterprises.54321.1.2.1 = INTEGER: 2082447.
Now, the part:
54321.1.2.1
cannot be understood by anyone who does not hold a list of OIDs and their meaning, furthermore, the
SNMPv2-SMI::enterprises is not needed or used.
So I'd like to change this.
How do I change this line and delete(or not present) the part I don't want ?? ( I don't actually write it- it is done by the wrapper )
Thanks
Re: Formatting snmpget output and OIDs
I'm not quite clear about your question, but I figure that you are probably only really interested in the return value of the SNMP query. That is, everything after the equals sign (=).
In which case, I'd just do a [doc://split] like so:
my $snmp_return = "SNMPv2-SMI::enterprises.54321.1.2.1 = INTEGER: 2082447";
my (undef, $wanted) = split /=/, $snmp_return;
Does that help?
Cheers,
Darren :)
Re^2: SNMP
Thanks Darren, But I probably didn't explain myself correctly, I'll try and explain again:
I don't "have" the
SNMPv2-SMI::enterprises.54321.1.2.1 = INTEGER: 2082 string.
This is what is sent as an answer to whom ever sent the querry.
It is sent by the netsnmpand, the only thing I do is send the appropriate value. e.g
$request->setValue($fieldtype, $sumValue);
where $fieldtype is ASN_INTEGER and $sumValue is the value I get from a file.
the $request is set(as shown above), and used by the handler that is registered to the agent.
I hope it is clear now (tried my best ... :-) )
Thanks again
Re^3: SNMP
Okay, well I obviously didn't get it the first time - but I'm afraid that I still don't.
Those modules you are using - are they home-grown?
I can't find any of them on CPAN, and setValue is not a function that's available via Net::SNMP.
Perhaps you can show some code that demonstrates your problem a bit clearer?
Sorry I can't be of more help.
Re^3: SNMP
If I understand the question correctly you are working on an SNMP server in perl (apparently using NetSNMP::agent, although it would help if you specified that) and you want to change the output format that someone who runs 'snmpget' on your servers sees? Do I understand that correctly?
If so, the answer is "you can't", the server can only return the values, you would have to change the client to control how they are displayed at that end.
| We're not surrounded, we're in a target-rich environment! |
|---|
Re^4: Formatting snmpget output and OIDs
Thanks to both of you
Jason, you are almost correct, I want to change the output format that someone who runs 'snmpWALK' on my servers sees, and I understud that it IS possible since the 'walk' does work with names, no ??
Re: Formatting snmpget output and OIDs
Thanks Darren, But I probably didn't explain myself correctly, I'll try and explain again:
I don't "have" the SNMPv2-SMI::enterprises.54321.1.2.1 = INTEGER: 2082 string.
This is what is sent as an answer to whom ever sent the querry.
It is sent by the netsnmpand, the only thing I do is send the appropriate value. e.g
$request->setValue($fieldtype, $sumValue);
where $fieldtype is ASN_INTEGER and $sumValue is the value I get from a file.
the $request is set(as shown above), and used by the handler that is registered to the agent.
I hope it is clear now (tried my best ... :-) )
Thanks again