diff options
author | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-09-29 22:03:24 (GMT) |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-09-29 22:03:24 (GMT) |
commit | 0b6423f9c99d9edf8c96fefd0f6c453859395aa1 (patch) | |
tree | 1c2b6b21704a294940f87c7892676998d8371707 /web/attachments/134274-check_mem | |
download | site-0b6423f9c99d9edf8c96fefd0f6c453859395aa1.tar.gz |
Import Nagios Plugins site
Import the Nagios Plugins web site, Cronjobs, infrastructure scripts,
and configuration files.
Diffstat (limited to 'web/attachments/134274-check_mem')
-rw-r--r-- | web/attachments/134274-check_mem | 26 |
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 | |||
12 | my ($mem_percent) = &sys_stats(); | ||
13 | print "$mem_percent\% Memory Used | MemUsed=$mem_percent\%;0;0;\n"; | ||
14 | exit(0); | ||
15 | |||
16 | sub 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 | } | ||