blob: ed13f2548641148c3b238e89f904876c71b3b72c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#!/usr/bin/perl -w
#
# check_mem v1.0 plugin for nagios
#
# uses the output of `free` to find the percentage of memory used
#
# Copyright Notice: GPL
#
# Garrett Honeycutt - gh@3gupload.com
#
my ($mem_percent) = &sys_stats();
print "$mem_percent\% Memory Used | MemUsed=$mem_percent\%;0;0;\n";
exit(0);
sub sys_stats {
my ($mem_total, $mem_used);
chomp($mem_total = `free -mt | grep Mem | awk '{print \$2}'`);
chomp($mem_used = `free -mt | grep cache | tail -1 | awk '{print \$3}'`);
my $mem_percent = ($mem_used / $mem_total) * 100;
return (sprintf("%.0f",$mem_percent));
}
|