1 |
|
#!/usr/bin/perl -w |
2 |
|
# i-scream central monitoring system |
3 |
|
# http://www.i-scream.org |
4 |
< |
# Copyright (C) 2000-2003 i-scream |
4 |
> |
# Copyright (C) 2000-2004 i-scream |
5 |
|
# |
6 |
|
# This program is free software; you can redistribute it and/or |
7 |
|
# modify it under the terms of the GNU General Public License |
27 |
|
my $kib = 1024; |
28 |
|
my $mib = $kib * $kib; |
29 |
|
|
30 |
+ |
# Type 0 is plain integers. |
31 |
+ |
my $KIBIBYTES = 1; |
32 |
+ |
my $PERCENT = 2; |
33 |
+ |
|
34 |
|
# Print an entry in the MRTG config file. |
35 |
|
sub entry ($$$$$$$$$$) { |
36 |
< |
my ($title, $vali, $valo, $max, $ylegend, $yunit, $legendi, $legendo, $gauge, $in_kib) = @_; |
36 |
> |
my ($title, $vali, $valo, $max, $ylegend, $yunit, $legendi, $legendo, $gauge, $type) = @_; |
37 |
|
my $name = $vali; |
38 |
|
my $options = ""; |
39 |
|
$options .= " noo" unless defined $valo; |
40 |
|
$options .= " gauge" if $gauge; |
41 |
+ |
my $sgoptions = ""; |
42 |
+ |
$sgoptions .= " -o -p" if $type == $PERCENT; |
43 |
|
|
44 |
|
print "\n"; |
45 |
|
print "Title[$name]: $title\n"; |
49 |
|
print "ShortLegend[$name]: $yunit\n"; |
50 |
|
print "LegendI[$name]: $legendi\n"; |
51 |
|
print "LegendO[$name]: $legendo\n" if defined $valo; |
52 |
< |
if ($in_kib) { |
52 |
> |
if ($type == $KIBIBYTES) { |
53 |
|
print "kMG[$name]: Ki,Mi,Gi,Ti\n"; |
54 |
|
} |
55 |
|
$valo = "const.0" unless defined $valo; |
56 |
|
print "Options[$name]:$options\n" if $options ne ""; |
57 |
< |
print "Target[$name]: `$statgrab -p -m $vali $valo`\n"; |
57 |
> |
print "Target[$name]: `$statgrab$sgoptions -m $vali $valo`\n"; |
58 |
|
} |
59 |
|
|
60 |
|
my $package_version = '@PACKAGE_VERSION@'; |
119 |
|
} |
120 |
|
|
121 |
|
if (exists $toplevel{"cpu"}) { |
122 |
< |
entry("CPU idle", "cpu.idle", undef, "100", "Idle", "%", "idle", undef, 1, 0); |
123 |
< |
entry("CPU iowait", "cpu.iowait", undef, "100", "iowait", "%", "iowait", undef, 1, 0); |
124 |
< |
entry("CPU kernel", "cpu.kernel", undef, "100", "Kernel", "%", "kernel", undef, 1, 0); |
125 |
< |
entry("CPU nice", "cpu.nice", undef, "100", "Nice", "%", "nice", undef, 1, 0); |
126 |
< |
entry("CPU swap", "cpu.swap", undef, "100", "Swap", "%", "swap", undef, 1, 0); |
127 |
< |
entry("CPU user", "cpu.user", undef, "100", "User", "%", "user", undef, 1, 0); |
122 |
> |
entry("CPU idle", "cpu.idle", undef, "100", "Idle", "%", "idle", undef, 1, $PERCENT); |
123 |
> |
entry("CPU iowait", "cpu.iowait", undef, "100", "iowait", "%", "iowait", undef, 1, $PERCENT); |
124 |
> |
entry("CPU kernel", "cpu.kernel", undef, "100", "Kernel", "%", "kernel", undef, 1, $PERCENT); |
125 |
> |
entry("CPU nice", "cpu.nice", undef, "100", "Nice", "%", "nice", undef, 1, $PERCENT); |
126 |
> |
entry("CPU swap", "cpu.swap", undef, "100", "Swap", "%", "swap", undef, 1, $PERCENT); |
127 |
> |
entry("CPU user", "cpu.user", undef, "100", "User", "%", "user", undef, 1, $PERCENT); |
128 |
|
} |
129 |
|
|
130 |
|
foreach my $disk (sort keys %disks) { |