From f40727423e447fc98b5a0bd521e879700cedf78f Mon Sep 17 00:00:00 2001
From: Mark Harrison <mark@omniti.com>
Date: Mon, 19 May 2008 17:46:25 +0000
Subject: [PATCH] Adding updated FILECOUNT check used in bluestreak ionmx
 monitoring.

git-svn-id: https://labs.omniti.com/resmon/trunk@98 8c0face9-b7db-6ec6-c4b3-d5f7145c7d55
---
 lib/Resmon/Module/FILECOUNT.pm | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 lib/Resmon/Module/FILECOUNT.pm

diff --git a/lib/Resmon/Module/FILECOUNT.pm b/lib/Resmon/Module/FILECOUNT.pm
new file mode 100644
index 0000000..bfc305d
--- /dev/null
+++ b/lib/Resmon/Module/FILECOUNT.pm
@@ -0,0 +1,24 @@
+package Resmon::Module::FILECOUNT;
+use Resmon::ExtComm qw/cache_command/;
+use vars qw/@ISA/;
+@ISA = qw/Resmon::Module/;
+
+sub handler {
+        my $arg = shift;
+        my $os = $arg->fresh_status();
+        return $os if $os;
+        my $dir = $arg->{'object'};
+        my $hlimit = $arg->{'hard_limit'};
+        my $slimit = $arg->{'soft_limit'};
+        my $output = cache_command("ls $dir | wc -l",30);
+        chomp($output);
+        if ($output > $hlimit) {
+                return "BAD", "$output files";
+        } elsif ($output > $slimit) {
+                return "WARNING", "$output files";
+        } else {
+                return "OK", "$output files";
+        }
+}
+
+1;
-- 
GitLab