sorry about the confusion. here is the code in full.
sub create_pr_table { my $get_pr_names = shift; my $row; # printer status my $OID = ".1.3.6.1.4.1.11.2.4.3.1.2.0"; # LCD messages my @OIDs = (".1.3.6.1.2.1.43.16.5.1.2.1.1", # ".1.3.6.1.2.1.43.16.5.1.2.1.2", # ".1.3.6.1.2.1.43.16.5.1.2.1.3", ); my $pr_section_name; # create the printer snmp info in html tag foreach $pr_section_name (values %{$config}) { my $pr_name = $pr_section_name->{pr_name}; next unless $pr_name; $pr_names{$pr_name}=""; # called from show_lpq_info and only need printer names info. next if $get_pr_names == 1; my $cmnt = $pr_section_name->{cmnt}; my $ip = $pr_section_name->{ip}; $row .= "<tr>"; $row .= "<td nowrap><a href=index.pl?printer=$pr_name><font fa +ce=\"arial\" size=2>$pr_name</font></a></td>"; my ($session, $error) = Net::SNMP->session( -hostname => $ip, -community => chomp($cmnt), -port => 161, -timeout => 5, ); if (!defined($session)) { print STDERR $error; next; } # printer status row my $result = $session->get_request( -varbindlist => [$OID] ); $row .= "<td nowrap><font face=\"arial\" size=2>".lc($result-> +{$OID})."&nbsp;</font></td>"; # LCD messages $row .="<td nowrap><font face=\"arial\" size=2>"; foreach my $oid (@OIDs) { #eval { #local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required #alarm 5; $result = $session->get_request( -varbindlist => [$oid] ); #alarm 0; #}; $row .= lc($result->{$oid})."&nbsp;"; # last if $result->{$oid} =~ m#powersave on#i; } $row .="</font></td>"; # get this printer's queue my $queues = get_lpq_info($pr_name,1); $row .= "<td nowrap><center><font face=\"arial\" size=2>$queue +s</font></center></td>"; $row .= "</tr>"; } return $row; }
the eval part is commented out now. within every loop of the first foreach, it queries a printer for status etc via SNMP.

In reply to Re: Re: eval alarm on mod_perl by Qiang
in thread eval alarm on mod_perl by Qiang

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.