From c2112fbb97d4df59431db59de6802219b623d007 Mon Sep 17 00:00:00 2001
From: Eric Sproul <esproul@omniti.com>
Date: Mon, 2 Jun 2008 20:18:36 +0000
Subject: [PATCH] Module for checking free memory remaining on Solaris

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

diff --git a/lib/Resmon/Module/SWAPSIZE.pm b/lib/Resmon/Module/SWAPSIZE.pm
new file mode 100644
index 0000000..832ad03
--- /dev/null
+++ b/lib/Resmon/Module/SWAPSIZE.pm
@@ -0,0 +1,22 @@
+package Resmon::Module::SWAPSIZE;
+use Resmon::Module;
+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 $object = $arg->{'object'};
+  my $output = cache_command("df -k /tmp", 30);
+  my ($line) = grep(/^swap/, split(/\n/, $output));
+  if($line =~ /(\d+)\s+(\d+)\s+(\d+)\s+(\d+)%/) {
+    if($1 >= $arg->{'limit'}) {
+      return $arg->set_status("OK($1 k size)");
+    }
+    return $arg->set_status("BAD($1 k size)");
+  }
+  return $arg->set_status("BAD(no data)");
+};
+
-- 
GitLab