summaryrefslogtreecommitdiffstats
path: root/web/attachments/134274-check_mem
diff options
context:
space:
mode:
Diffstat (limited to 'web/attachments/134274-check_mem')
-rw-r--r--web/attachments/134274-check_mem26
1 files changed, 26 insertions, 0 deletions
diff --git a/web/attachments/134274-check_mem b/web/attachments/134274-check_mem
new file mode 100644
index 0000000..ed13f25
--- /dev/null
+++ b/web/attachments/134274-check_mem
@@ -0,0 +1,26 @@
1#!/usr/bin/perl -w
2#
3# check_mem v1.0 plugin for nagios
4#
5# uses the output of `free` to find the percentage of memory used
6#
7# Copyright Notice: GPL
8#
9# Garrett Honeycutt - gh@3gupload.com
10#
11
12my ($mem_percent) = &sys_stats();
13print "$mem_percent\% Memory Used | MemUsed=$mem_percent\%;0;0;\n";
14exit(0);
15
16sub sys_stats {
17
18 my ($mem_total, $mem_used);
19
20 chomp($mem_total = `free -mt | grep Mem | awk '{print \$2}'`);
21 chomp($mem_used = `free -mt | grep cache | tail -1 | awk '{print \$3}'`);
22
23 my $mem_percent = ($mem_used / $mem_total) * 100;
24
25 return (sprintf("%.0f",$mem_percent));
26}