diff options
author | bouyer <bouyer@pkgsrc.org> | 2001-11-07 18:26:50 +0000 |
---|---|---|
committer | bouyer <bouyer@pkgsrc.org> | 2001-11-07 18:26:50 +0000 |
commit | 48b05be9cd66966a05f869bca35010d9382360cb (patch) | |
tree | 50860530ca6e830816728c7ef5c72a43d2bcdf83 /net/mrtg/files | |
parent | f5f8b60a366205fd14a43f502772e106010ce5a9 (diff) | |
download | pkgsrc-48b05be9cd66966a05f869bca35010d9382360cb.tar.gz |
Add envstat2mrtg, a perl script which allows to use envstat output with
mrtg.
Diffstat (limited to 'net/mrtg/files')
-rwxr-xr-x | net/mrtg/files/envstat2mrtg | 73 | ||||
-rw-r--r-- | net/mrtg/files/mrtg.conf.example | 16 |
2 files changed, 88 insertions, 1 deletions
diff --git a/net/mrtg/files/envstat2mrtg b/net/mrtg/files/envstat2mrtg new file mode 100755 index 00000000000..6ded0cfeaad --- /dev/null +++ b/net/mrtg/files/envstat2mrtg @@ -0,0 +1,73 @@ +#! @PREFIX@/bin/perl +# $NetBSD: envstat2mrtg,v 1.1 2001/11/07 18:26:50 bouyer Exp $ + +if (@ARGV == 1) +{ + open(CMDOUT, "envstat -n0 -s '@ARGV[0]'|"); + $line = <CMDOUT>; + chop $line; + if ($line =~ m|^[\s\t]+(\w+)$|) + { + print "$1\n"; + } + elsif ($line =~ m|^[\s\t]+(\w+\.\w+)$|) + { + $val = $1 * 100; + print "$val\n"; + } + else + { + print "0\n"; + } + print "0\n"; + &end(); +} + +if (@ARGV == 2) +{ + open(CMDOUT, "envstat -n0 -s '@ARGV[0],@ARGV[1]'|"); + $line = <CMDOUT>; + if ($line =~ m|^[\s\t]+(\w+)[\s\t]+(\w+)$|) + { + print "$1\n"; + print "$2\n"; + } + elsif ($line =~ m|^[\s\t]+(\w+\.\w+)[\s\t]+(\w+\.\w+)$|) + { + $val = $1 * 100; + print "$val\n"; + $val = $2 * 100; + print "$val\n"; + } + else + { + print "0\n"; + print "0\n"; + } + &end(); +} + +print STDERR + "usage: envstat2mrtg sens1 [sens2]\n"; +exit(1); + +sub end +{ + open(UP, "uptime|"); + while($line = <UP>) + { + chop $line; + if ($line =~ m|^.*up\s+(.+),\s+\d+\suser.*|) + { + print "$1\n"; + } + } + close(UP); + open(HOST, "hostname -s|"); + while (<HOST>) + { + print $_; + } + exit(0); +} + diff --git a/net/mrtg/files/mrtg.conf.example b/net/mrtg/files/mrtg.conf.example index 6ae99a38363..777e608e765 100644 --- a/net/mrtg/files/mrtg.conf.example +++ b/net/mrtg/files/mrtg.conf.example @@ -1,4 +1,4 @@ -# $NetBSD: mrtg.conf.example,v 1.2 2001/06/19 12:32:17 hubertf Exp $ +# $NetBSD: mrtg.conf.example,v 1.3 2001/11/07 18:26:50 bouyer Exp $ WorkDir: @PREFIX@/share/httpd/htdocs/mrtg Refresh: 300 @@ -107,3 +107,17 @@ Legend4[load]: LegendI[load]: LegendO[load]: options[load]: nopercent,gauge + +Target[cputemp]: `@PREFIX@/libexec/envstat2mrtg Temp\ 1` +MaxBytes[cputemp]: 20000 +Title[cputemp]: CPU temperature +PageTop[cputemp]: <H1>CPU temperature</H1> +YLegend[cputemp]: deg. celius (x100) +ShortLegend[cputemp]: deg. celius (x100) +Legend1[cputemp]: CPU temperature (deg. cel. x100) +Legend2[cputemp]: +Legend3[cputemp]: Maximal 5 Minute temperature +Legend4[cputemp]: +LegendI[cputemp]: +LegendO[cputemp]: +options[cputemp]: nopercent,gauge |