<div dir="ltr"><div>Recently we've had some developers complain that it's difficult to determine at a glance what is wrong with certain checks so I've made a slight modification to the output - I'm not an expert in perl but it's been helpful so far, see attached : <br><br></div><div> sub print_usage ();<br><br> my ($opt_c, $opt_f, $opt_w, $opt_C, $opt_W, $opt_h, $opt_V, $opt_i);<br>-my ($result, $message, $age, $size, $st, $perfdata);<br>+my ($result, $prepend, $message, $age, $size, $st, $perfdata);<br><br> $PROGNAME="check_file_age";<br><br>@@ -91,7 +91,7 @@ $age = time - $st->mtime;<br> $size = $st->size;<br><br> $result = 'OK';<br>-<br>+$prepend = '';<br> if ($opt_c !~ m/^\d+$/ or ($opt_C and $opt_C !~ m/^\d+$/)<br> or $opt_w !~ m/^\d+$/ or ($opt_W and $opt_W !~ m/^\d+$/)) {<br> # range has been specified so use M::P::R to process<br>@@ -103,34 +103,49 @@ if ($opt_c !~ m/^\d+$/ or ($opt_C and $opt_C !~ m/^\d+$/)<br> if (Monitoring::Plugin::Range->parse_range_string($opt_c)<br> ->check_range($age) == 1) { # 1 means it raises an alert because it's OUTSIDE the range<br> $result = 'CRITICAL';<br>+ $prepend = 'AGE';<br> }<br> elsif (Monitoring::Plugin::Range->parse_range_string($opt_C)<br> ->check_range($size) == 1) {<br> $result = 'CRITICAL';<br>+ $prepend = 'SIZE';<br> }<br> elsif (Monitoring::Plugin::Range->parse_range_string($opt_w)<br> ->check_range($age) == 1) {<br> $result = 'WARNING';<br>+ $prepend = 'AGE';<br> }<br> elsif (Monitoring::Plugin::Range->parse_range_string($opt_W)<br> ->check_range($size) == 1) {<br> $result = 'WARNING';<br>+ $prepend = 'SIZE';<br> }<br> }<br> else {<br> # use permissive defaults for size when none specified<br> $opt_W = 0 unless ($opt_W);<br> $opt_C = 0 unless ($opt_C);<br>- if ($age > $opt_c or $size < $opt_C) {<br>- $result = 'CRITICAL';<br>+ if ($age > $opt_c) {<br>+ $result = 'CRITICAL';<br>+ $prepend = 'AGE';<br>+ }<br>+ elsif ($size < $opt_C) {<br>+ $result = 'CRITICAL';<br>+ $prepend = 'SIZE';<br> }<br>- elsif ($age > $opt_w or $size < $opt_W) {<br>- $result = 'WARNING';<br>+ elsif ($age > $opt_w) {<br>+ $result = 'WARNING';<br>+ $prepend = "AGE";<br> }<br>+ elsif ($size < $opt_W) {<br>+ $result = 'WARNING';<br>+ $prepend = 'SIZE';<br>+ }<br>+<br> }<br><br> $perfdata = "age=${age}s;${opt_w};${opt_c} size=${size}B;${opt_W};${opt_C};0";<br>-print "FILE_AGE $result: $opt_f is $age seconds old and $size bytes | $perfdata\n";<br>+print "FILE $prepend $result: $opt_f is $age seconds old and $size bytes | $perfdata\n";</div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Thanks,<br><br>Joseph McCarthy | IT | Simplex | 312-754-3588<br>230 S. LaSalle St., Suite 8-500, Chicago, IL 60604</div></div></div>
<br>
DISCLAIMER: NOTICE REGARDING PRIVACY AND CONFIDENTIALITY <br><br>The information contained in and/or accompanying this communication is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution or copying of this information, and any attachments thereto, is strictly prohibited. If you have received this e-mail in error, please immediately notify the sender and permanently delete the original and any copy of any e-mail and any printout thereof. Electronic transmissions cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. Simplex Trading, LLC and its affiliates reserves the right to intercept, monitor, and retain electronic communications to and from its system as permitted by law. Simplex Trading, LLC is a registered Broker Dealer with CBOE and a Member of SIPC.