Hi all,

I am having quite some problems with this, so perhaps someone could
point me in the right direction.....
I am using Joe Marzots' SNMP 4.2.0 module.....
Here is my code thus far.

$var = new SNMP::Varbind([$devtypes{$mydev}{$object}]);
print ("Length of \$var\-\>[2] is " . length ($var->[2]) . "\n");
print (":] " . $var->[0] . "\n");
for ($val = $sess->getnext($var);
     ! $sess->{ErrorStr} and $var->[0] =~ /$devtypes{$mydev}{$object}/
and
       $object !~ /sysoid/;
     $val = $sess->getnext($var)) {
  if ($var->[0] =~ /.1.3.6.1.4.1.18.3.1.2.1.27/ ) { # This is a hex time
of config creation on Wellfleet
     print ("We need to change this to time date\n");
  }
  $node = $SNMP::MIB{$var->[0]};
  print (":] " . $var->[0] . "|" . $var->[1] . "|");
  if ( $node->{syntax} eq 'OCTETSTR' ) {
     while ($var->[2] =~ /(.{8})/g) {
        print (bin2dec($1) ."[]");
     }
     $j = pack("BBBBB", $var->[2]);
     print ($var->[2] . "|")
  } else {
       print ($var->[2] . "|");
  }
print ($var->[3] . "\n");

I get things that are not OCTETSTR's and can happily print them, but
then I get something that is an OCTETSTR and voila, I now have a
problem. For example, Wellfleets store the date and time of their config
in an OCTETSTR variable. The date is stored at "first 2 bytes = year,
3rd byte = day, 4th = month, 5&6th = hour, minute and second"

When I snmpwalk this, I get 
snmpwalk 10.126.1.3 public .1.3.6.1.4.1.18.3.1.2.1.27 
enterprises.18.3.1.2.1.27.1 =  Hex: 07 D0 0B 11 00 33 3A 00 2B 00 00

This is a type OCTETSTR, so now I want to split it up as per the mib
(byte 1+2 and work out year, byte 3 = day, etc.). Interestingly, when I
do the print (.... length ....) above, I get a string length of 0. So
now, despite advise, I'm stumped. Any help would be most appreciated in
getting this solved.

Thanks in advance.

Hamish

-- 
This message contains confidential information intended only for the use
of the addressee named above. If you are not the intended recipient of
this message, you are hereby notified that you must not disseminate,
copy or take any action in reliance on it. If you have received this
message in error, please delete it. Any views expressed in this message
are those of the individual sender, except where the sender specifically
states them to be the view of QED Technologies. We aim to provide the
highest degree of security for our customers. Where necessary, all
messages are encrypted, all servers are secured and will henceforth
remain so. If this is an inconvenience to you, we are sorry, but our
business is at stake; a risk we consider no worth taking.
~~
Hamish Whittal          QED Technologies                Tel: +27 21 448 9291
[EMAIL PROTECTED]                                      Fax: +27 21 448 9551
                        `The' Linux Services Company    Cel: +27 82 803 5533

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to