RE: Help with exec and pass
Santanu Misra <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <[email protected]> |
Sorry for the double post. But still Looks like I am banging my head against a wall. I am using "pass" with snmpd.conf. Here is my Perl script any help will be great. As I still get (root@admsrv01:166) /usr/local/net-snmp/bin/snmpwalk -v 1 -c public ptxslicsrv01 .1.3.6.1.4.1.9999 SNMPv2-SMI::enterprises.9999.1.101.1 = STRING: "QAC_runtime" SNMPv2-SMI::enterprises.9999.1.101.1 = STRING: "QAC_runtime" Error: OID not increasing: SNMPv2-SMI::enterprises.9999.1.101.1 >= SNMPv2-SMI::enterprises.9999.1.101.1 -Thanks Santanu -----Original Message----- From: Dave Shield [mailto:[email protected]] Sent: Thursday, 13 October, 2005 10:44 To: Santanu Misra Cc: [email protected] Subject: Re: Help with exec and pass On Wed, 2005-10-12 at 18:21 +0200, Santanu Misra wrote: > This is my entry in snmpd.conf file; > only using one of this at a given time. > > > #pass .1.3.6.1.4.1.9999.1 /usr/bin/lmstat.pl > exec .1.3.6.1.4.1.9999.1 FLEXLM /usr/bin/lmstat.pl Please note that "pass" and "exec" are *NOT* direct equivalents. "exec" (and "sh") are used to report the output of an arbitrary command - which will typically know nothing about SNMP. "pass" is used to implement SNMP-style behaviour without needing to incorporate code into the agent proper. The pass-through script is expected to follow a particular API, as described in snmpd.conf(5) (see under "PASS-THROUGH CONTROL") The agent does *NOT* simply report back the output of a pass-through script "blind" - that's the role of the "exec" and "sh" directives. With "exec" and "sh", the agent moulds the MIB structure to match the output of the command. With "pass", the script must mould its output to the needs of the agent. Please note too that the exec OID .... style is being deprecated, and will be phased out at some time in the future. If you're using 5.2 or above, you may wish to investigate the replacement extend OID .... directive, which works in a similar way, but provides a much more flexible (and legal!) output format. Dave > ----------------------------------------------------------------- Visit our Internet site at http://www.reuters.com To find out more about Reuters Products and Services visit http://www.reuters.com/productinfo Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of Reuters Ltd.
lmstat.pl
(application/octet-stream, 1.1 KB)
#!/usr/bin/perl
# lmwho details for cacti
sub echo {
my $stdout = shift;
my $string = shift;
my $log_opened = 0;
if($stdout) {
print $string;
} elsif($log_opened) {
print LOG &get_timestring()," " if($DEBUG > 2);
print LOG $string;
}
}
sub lmstat {
my $BASE = ".1.3.6.1.4.1.9999.1" ;
my $STATUS_CMD = "/opt/Compuware/licenses/lmwho -c /opt/Compuware/licenses/license.dat";
my $i = 1;
open(STATUS,"$STATUS_CMD|") or die("Can't execute $STATUS_CMD\n");
while (<STATUS>) {
my $available = 0;
chomp();
if ($_ =~ /Connection refused/) {
print "Serverproblem \n" ;
}
else {
if ($_ =~ /Users of/) {
my @TEMP = split(/\,/,$_);
my @TEMP_feature = split(/:/,$TEMP[2]) ;
my $feature = $TEMP_feature[0] ;
my $available = $TEMP[5] ;
push @FEATURES,$feature ;
}
}
}
close(STATUS);
foreach $j (@FEATURES) {
&echo (1, "$BASE.101.$i\n");
&echo (1, "string\n");
&echo (1, "$j\n");
$i++;
}
return 1;
}
&lmstat ;