I have made on another
#!/usr/bin/perl #use strict; use Net::SNMP; my @ips=(11); foreach my $k (@ips) { my $hostname = "10.0.0.$k"; my $password = "public"; my $sysUpTime = '.1.3.6.1.2.1.1.3'; my $sysName = '.1.3.6.1.2.1.1.5'; my $hrPrinterStatus = '.1.3.6.1.2.1.25.3.5.1.1'; my $hrPrinterDetectedErrorState = '.1.3.6.1.2.1.25.3.5.1.2'; my $prtCoverStatus = '.1.3.6.1.2.1.43.6.1.1.3'; my $status; my ( $session, $error ) = Net::SNMP->session ( Hostname => $hostname, Community => $password ); die "session error: $error" unless ( $session ); $result = $session->get_next_request ( varbindlist => [$sysName.$1] ); + die "request error: ".$session->error unless ( defined $result ); ( $sysName, $name1 ) = each %$result; unless ( $sysName =~ /$sysName(. +*)/ ) { last; } $result = $session->get_next_request ( varbindlist => [$prtCoverStatus +.$1] ); die "request error: ".$session->error unless ( defined $resul +t ); ( $prtCoverStatus, $name2 ) = each %$result; unless ( $prtCoverStatus +=~ /$prtCoverStatus(.*)/ ) { last; } $result = $session->get_next_request ( varbindlist => [$hrPrinterDetec +tedErrorState.$1] ); die "request error: ".$session->error unless ( d +efined $result ); ( $hrPrinterDetectedErrorState, $name3 ) = each %$result; unless ( $hr +PrinterDetectedErrorState =~ /$hrPrinterDetectedErrorState(.*)/ ) { l +ast; } $result = $session->get_next_request ( varbindlist => [$hrPrinterStatu +s.$1] ); die "request error: ".$session->error unless ( defined $resu +lt ); ( $hrPrinterStatus, $name4 ) = each %$result; unless ( $hrPrinterStatu +s =~ /$hrPrinterStatus(.*)/ ) { last; } $session->close; print "$name1\t$name2\t$name3\t$name4\n"; } exit 0;
There was other question why there are no data in .1.3.6.1.2.1.25.3.5.1.2, $name3 - it is empty.

In reply to Re^2: Where is the bug in this Net::SNMP code? by tolyan77
in thread Where is the bug in this Net::SNMP code? by tolyan77

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.