32 |
|
# Type 0 is plain integers. |
33 |
|
my $KIBIBYTES = 1; |
34 |
|
my $PERCENT = 2; |
35 |
+ |
my $FLOAT = 3; |
36 |
|
|
37 |
|
# Print an entry in the MRTG config file. |
38 |
|
sub entry ($$$$$$$$$$) { |
43 |
|
$options .= " gauge" if $gauge; |
44 |
|
my $sgoptions = ""; |
45 |
|
$sgoptions .= " -o -p" if $type == $PERCENT; |
46 |
+ |
$sgoptions .= " -f 1000" if $type == $FLOAT; |
47 |
|
|
48 |
|
print "\n"; |
49 |
|
print "Title[$name]: $title\n"; |
55 |
|
print "LegendO[$name]: $legendo\n" if defined $valo; |
56 |
|
if ($type == $KIBIBYTES) { |
57 |
|
print "kMG[$name]: Ki,Mi,Gi,Ti\n"; |
58 |
+ |
$sgoptions .= " -K"; |
59 |
|
} |
60 |
|
$valo = "const.0" unless defined $valo; |
61 |
|
print "Options[$name]:$options\n" if $options ne ""; |
134 |
|
|
135 |
|
foreach my $disk (sort keys %disks) { |
136 |
|
my $name = $stats{"disk.$disk.disk_name"}; |
137 |
< |
entry("Disk $name IO", "disk.$disk.read_bytes", "disk.$disk.write_bytes", 100*$mib, "IO rate", "B/s", "read", "write", 0, 0); |
137 |
> |
entry("Disk $name IO", "disk.$disk.read_bytes", "disk.$disk.write_bytes", 100*$mib, "IO rate", "KiB/s", "read", "write", 0, $KIBIBYTES); |
138 |
|
} |
139 |
|
|
140 |
|
foreach my $fs (sort keys %fss) { |
141 |
|
my $name = $stats{"fs.$fs.mnt_point"}; |
142 |
|
my $size = $stats{"fs.$fs.size"}; |
143 |
|
my $inodes = $stats{"fs.$fs.total_inodes"}; |
144 |
< |
entry("Filesystem $name space usage", "fs.$fs.used", undef, $size, "Space used", "B", "used", undef, 1, 0); |
144 |
> |
entry("Filesystem $name space usage", "fs.$fs.used", undef, $size, "Space used", "KiB", "used", undef, 1, $KIBIBYTES); |
145 |
|
entry("Filesystem $name inode usage", "fs.$fs.used_inodes", undef, $inodes, "Inodes used", "inodes", "used", undef, 1, 0); |
146 |
|
} |
147 |
|
|
148 |
|
if (exists $toplevel{"load"}) { |
149 |
< |
entry("Load average over 1 minute", "load.min1", undef, 100, "Load average", "running", "load", undef, 1, 0); |
150 |
< |
entry("Load average over 5 minutes", "load.min5", undef, 100, "Load average", "running", "load", undef, 1, 0); |
151 |
< |
entry("Load average over 15 minutes", "load.min15", undef, 100, "Load average", "running", "load", undef, 1, 0); |
149 |
> |
entry("Load average over 1 minute", "load.min1", undef, 100, "Load average", "running * 1000", "load", undef, 1, $FLOAT); |
150 |
> |
entry("Load average over 5 minutes", "load.min5", undef, 100, "Load average", "running * 1000", "load", undef, 1, $FLOAT); |
151 |
> |
entry("Load average over 15 minutes", "load.min15", undef, 100, "Load average", "running * 1000", "load", undef, 1, $FLOAT); |
152 |
|
} |
153 |
|
|
154 |
|
if (exists $toplevel{"mem"}) { |
155 |
|
my $total = $stats{"mem.total"}; |
156 |
< |
entry("Memory usage", "mem.used", "mem.cache", $total, "Memory usage", "B", "total", "cache", 1, 0); |
156 |
> |
entry("Memory usage", "mem.used", "mem.cache", $total, "Memory usage", "KiB", "total", "cache", 1, $KIBIBYTES); |
157 |
|
} |
158 |
|
|
159 |
|
foreach my $net (sort keys %nets) { |
160 |
|
my $name = $stats{"net.$net.interface_name"}; |
161 |
< |
# FIXME should be able to discover interface speed |
162 |
< |
entry("Network interface $name IO", "net.$net.rx", "net.$net.tx", 100*$mib, "Network IO", "B", "rx", "tx", 0, 0); |
161 |
> |
my $speed = int($stats{"net.$net.speed"}); |
162 |
> |
$speed = 100 if $speed == 0; |
163 |
> |
|
164 |
> |
# The speed is reported in Mbit/s; we want KiB/s. |
165 |
> |
$speed = int(($speed * 1000000) / (8 * $kib)); |
166 |
> |
|
167 |
> |
entry("Network interface $name IO", "net.$net.rx", "net.$net.tx", $speed, "Network IO", "KiB/s", "rx", "tx", 0, $KIBIBYTES); |
168 |
|
} |
169 |
|
|
170 |
|
if (exists $toplevel{"page"}) { |
184 |
|
|
185 |
|
if (exists $toplevel{"swap"}) { |
186 |
|
my $swapsize = $stats{"swap.total"}; |
187 |
< |
entry("Swap usage", "swap.used", undef, $swapsize, "Swap usage", "B", "used", undef, 1, 0); |
187 |
> |
if ($swapsize ne "0") { |
188 |
> |
entry("Swap usage", "swap.used", undef, $swapsize, "Swap usage", "KiB", "used", undef, 1, $KIBIBYTES); |
189 |
> |
} |
190 |
|
} |
191 |
|
|
192 |
|
if (exists $toplevel{"user"}) { |