Hey PerlMonks I am not sure is this the right place to ask this question ? if not, please guide me. My problem, i have a perl script running in the Linux box to get the XML from Activemq server.it seems like there is a problem with GET element in the script. Anyone can help me please ? I am not familiar with Perl at all. I am able to get the result through URL - example (http://10.10.10.10:8161/admin/xml/queues.jsp) ---------------------------------------
#!/usr/bin/perl -w # Nagios plugin to check the current messages waiting in the ActiveMQ +queue. # Author: Maxim Janssens # Company: Synquad BV # Website: http://www.synquad.nl # Email: maxim@synquad.nl use strict; use Switch; use LWP::Simple; my $address = "localhost"; my $port = "8161"; my $page = get "http://$address:$port/admin/xml/queues.jsp" or die "Ca +nnot get XML file: $!\n";; my (%args, %queues); my %error=('ok'=>0,'warning'=>1,'critical'=>2,'unknown'=>3); my ($warninglevel, $criticallevel, $tmp, $evalcount, $switch, $queuese +lect, $queuevalue); my $key = my $value = my $i = my $k = 0; my $exitcode = "unknown"; for(my $m = 0; $m <= $#ARGV; $m++){ if($ARGV[$m] =~ /^\-/){ if($ARGV[$m] eq "-w"||"-c"||"-q"){ $switch = $ARGV[$m]; $args{$switch} = (); if($switch eq "-q"){ $k = 1; } } else { &help; } } else { if($switch eq "-q"){ $args{$switch} = $ARGV[$m]; } elsif($ARGV[$m] =~ /[0-9]{1,5}/){ $args{$switch} = $ARGV[$m]; } else { &help; } } } # main(); $warninglevel = $args{"-w"}; $criticallevel = $args{"-c"}; if($k == 1) { $queueselect = $args{"-q"}; } &getinfo; if($k == 1){ foreach my $str (keys %queues){ if($queueselect eq $str){ $queuevalue = $queues{$queueselect}; + last; } else { next; } } if($queuevalue eq ''){ $exitcode = "unknown"; exit $error{"$exitco +de"};} else { &checkstatus($queuevalue,$queueselect); } } else { while(($key, $value) = each(%queues)){ &checkstatus($value,$key); +} } # Subroutines sub getinfo { my @lines = split ' ', $page; foreach my $line (@lines){ if($line =~ /name/i || $line =~ /size/i){ $line =~ s/^name="//g; $line =~ s/^size="//g; $line =~ s/"(>)?$//g; if($i == 1){ $queues{$tmp} = $line; $i = 0; } else{ $tmp = $line; $i++; } } } } sub checkstatus { my $val=shift; my $key=shift; switch($val){ case { $val <= $warninglevel } { print "OK +- $key holding: $val msgs "; $exitcode = "ok" } case { $val > $warninglevel && $val <= $criticallevel } + { print "WARNING - $key holding: $val msgs "; $exitcode = "warning" +} case { $val > $criticallevel } { print "CRI +TICAL - $key holding: $val msgs "; $exitcode = "critical" } else { &help; } } } sub help { print "Usage: activemq_watch -w <warninglevel> -c <criticallevel> +(-p <queue>)\n"; $exitcode = "unknown"; exit $error{"$exitcode"}; } exit $error{"$exitcode"};
----------------------------------------------- If anyone get difficulty to read the script so i put the web link from where i get the script http://exchange.nagios.org/directory/Plugins/Java-Applications-and-Servers/ActiveMQ_Watch/details thanks

In reply to Error in the script by cesargarza

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.