ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/statgrab/statgrab-make-mrtg-config.in
(Generate patch)

Comparing projects/libstatgrab/src/statgrab/statgrab-make-mrtg-config.in (file contents):
Revision 1.1 by ats, Thu Aug 28 11:26:42 2003 UTC vs.
Revision 1.10 by tdb, Thu Mar 13 10:29:18 2008 UTC

# Line 1 | Line 1
1   #!/usr/bin/perl -w
2 < # i-scream central monitoring system
2 > # i-scream libstatgrab
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
# Line 16 | Line 16
16   # You should have received a copy of the GNU General Public License
17   # along with this program; if not, write to the Free Software
18   # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19 + #
20 + # $Id$
21  
22   use strict;
23   use Getopt::Long;
# Line 27 | Line 29 | my $workdir = undef;
29   my $kib = 1024;
30   my $mib = $kib * $kib;
31  
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 ($$$$$$$$$$) {
39 <        my ($title, $vali, $valo, $max, $ylegend, $yunit, $legendi, $legendo, $gauge, $in_kib) = @_;
39 >        my ($title, $vali, $valo, $max, $ylegend, $yunit, $legendi, $legendo, $gauge, $type) = @_;
40          my $name = $vali;
41          my $options = "";
42          $options .= " noo" unless defined $valo;
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";
# Line 43 | Line 53 | sub entry ($$$$$$$$$$) {
53          print "ShortLegend[$name]: $yunit\n";
54          print "LegendI[$name]: $legendi\n";
55          print "LegendO[$name]: $legendo\n" if defined $valo;
56 <        if ($in_kib) {
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 "";
62 <        print "Target[$name]: `$statgrab -p -m $vali $valo`\n";
62 >        print "Target[$name]: `$statgrab$sgoptions -m $vali $valo`\n";
63   }
64  
65   my $package_version = '@PACKAGE_VERSION@';
# Line 113 | Line 124 | sub main () {
124          }
125  
126          if (exists $toplevel{"cpu"}) {
127 <                entry("CPU idle", "cpu.idle", undef, "100", "Idle", "%", "idle", undef, 1, 0);
128 <                entry("CPU iowait", "cpu.iowait", undef, "100", "iowait", "%", "iowait", undef, 1, 0);
129 <                entry("CPU kernel", "cpu.kernel", undef, "100", "Kernel", "%", "kernel", undef, 1, 0);
130 <                entry("CPU nice", "cpu.nice", undef, "100", "Nice", "%", "nice", undef, 1, 0);
131 <                entry("CPU swap", "cpu.swap", undef, "100", "Swap", "%", "swap", undef, 1, 0);
132 <                entry("CPU user", "cpu.user", undef, "100", "User", "%", "user", undef, 1, 0);
127 >                entry("CPU idle", "cpu.idle", undef, "100", "Idle", "%", "idle", undef, 1, $PERCENT);
128 >                entry("CPU iowait", "cpu.iowait", undef, "100", "iowait", "%", "iowait", undef, 1, $PERCENT);
129 >                entry("CPU kernel", "cpu.kernel", undef, "100", "Kernel", "%", "kernel", undef, 1, $PERCENT);
130 >                entry("CPU nice", "cpu.nice", undef, "100", "Nice", "%", "nice", undef, 1, $PERCENT);
131 >                entry("CPU swap", "cpu.swap", undef, "100", "Swap", "%", "swap", undef, 1, $PERCENT);
132 >                entry("CPU user", "cpu.user", undef, "100", "User", "%", "user", undef, 1, $PERCENT);
133          }
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"}) {
# Line 168 | Line 184 | sub main () {
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"}) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines