-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmemory_lru
executable file
·106 lines (90 loc) · 2.55 KB
/
memory_lru
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/perl -w
#
# Plugin to monitor memory usage.
#
# Origional Author: Jimmy Olsen, Mike Fedyk
# Author: KOSAKI Motohiro
#
# Parameters:
#
# config (required)
# autoconf (optional - only used by munin-config)
#
# Magic markers (optional - only used by munin-config and some
# installation scripts):
#%# family=auto
#%# capabilities=autoconf
if ($ARGV[0] and $ARGV[0] eq "autoconf")
{
if (-r "/proc/meminfo")
{
print "yes\n";
exit 0;
}
else
{
print "/proc/meminfo not found\n";
exit 1;
}
}
my %mems;
&fetch_meminfo;
if ($ARGV[0] and $ARGV[0] eq "config")
{
print "graph_args --base 1024 -l 0 --vertical-label Bytes --upper-limit ", $mems{'Active'} + $mems{'Inactive'} + $mems{'Unevictable'}, "\n";
print "graph_title LRU diagnostics\n";
print "graph_category system\n";
print "graph_info xxx\n";
print "graph_order active_anon inactive_anon active_file inactive_file unevictable\n";
print "active_anon.label Active(anon)\n";
print "active_anon.draw AREA\n";
print "active_anon.info Swap backed pages. (e.g. anon, tmpfs, shmem, shmfs)\n";
print "inactive_anon.label Inactive(anon)\n";
print "inactive_anon.draw STACK\n";
print "inactive_anon.info Swap backed pages, this pages might be evicted soon\n";
print "active_file.label Active(file)\n";
print "active_file.draw STACK\n";
print "active_file.info File backed page. (i.e. regular file cache)\n";
print "inactive_file.label Inactive(file)\n";
print "inactive_file.draw STACK\n";
print "inactive_file.info File backed page. this pages might be evicted soon\n";
print "unevictable.label Unevictable\n";
print "unevictable.draw STACK\n";
print "unevictable.info Unevictable Memory (e.g. mlock()ed, shmctl(SHM_LOCK)ed, ramfs pages)\n";
exit 0;
}
# Any optional value needs to be initialized to zero if it's used in a calculation below
# and is has not been set by &fetch_meminfo
if (exists $mems{'Active(anon)'})
{
print "active_anon.value ", $mems{'Active(anon)'}, "\n";
}
if (exists $mems{'Inactive(anon)'})
{
print "inactive_anon.value ", $mems{'Inactive(anon)'}, "\n";
}
if (exists $mems{'Active(file)'})
{
print "active_file.value ", $mems{'Active(file)'}, "\n";
}
if (exists $mems{'Inactive(file)'})
{
print "inactive_file.value ", $mems{'Inactive(file)'}, "\n";
}
if (exists $mems{'Unevictable'})
{
print "unevictable.value ", $mems{'Unevictable'}, "\n";
}
sub fetch_meminfo
{
open (IN, "/proc/meminfo") || die "Could not open /proc/meminfo for reading: $!";
while (<IN>)
{
if (/^([\w\(\)]+):\s*(\d+)\s+kb/i)
{
$mems{"$1"} = $2 * 1024;
}
}
close (IN);
}
# vim:syntax=perl:ts=8