Hi Monks,
Writing Nagios plugin to check the status of Solaris 10 zones and having exit values issue, must return exit 2 if any zone is not running, in a loop when I call "exit 2 " program exits but doesn't display all the items in loop, how can I fix this, any help would be really appreciated
#!/usr/bin/perl
@zone = qx {zoneadm list -ip};
foreach (@zone) {
($id,$name,$state) = split(/:/,$_);
if($state ne "running"){
print "$name\n";
exit 2;\\here it prints only 1 item and exit how I can print all the items and exit with value 2
}
}
root@dory# zoneadm list -ip
0:global:running:/::native:shared
-:drvldap-dev:installed:/export/zones/drvldap-dev:44a6b308-7cd5-669f-93f6-90447fcd22ca:native:shared
-:drvsps-test:installed:/export/zones/drvsps-test:f786c808-f9b8-6bae-970d-b9fb9969ec80:native:shared
want to display following lines with exit value 2, but when I call exit 2 , it display 1 line and then exit which is the expected behavior. How can I fix this
root@dory# perl check_zones.pl
drvldap-dev
drvsps-test
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.