summaryrefslogtreecommitdiff
path: root/net/mrtg
diff options
context:
space:
mode:
authorbouyer <bouyer@pkgsrc.org>2001-11-07 18:26:50 +0000
committerbouyer <bouyer@pkgsrc.org>2001-11-07 18:26:50 +0000
commit48b05be9cd66966a05f869bca35010d9382360cb (patch)
tree50860530ca6e830816728c7ef5c72a43d2bcdf83 /net/mrtg
parentf5f8b60a366205fd14a43f502772e106010ce5a9 (diff)
downloadpkgsrc-48b05be9cd66966a05f869bca35010d9382360cb.tar.gz
Add envstat2mrtg, a perl script which allows to use envstat output with
mrtg.
Diffstat (limited to 'net/mrtg')
-rw-r--r--net/mrtg/Makefile6
-rwxr-xr-xnet/mrtg/files/envstat2mrtg73
-rw-r--r--net/mrtg/files/mrtg.conf.example16
3 files changed, 92 insertions, 3 deletions
diff --git a/net/mrtg/Makefile b/net/mrtg/Makefile
index f9f1d4b5ce0..e939cc355fa 100644
--- a/net/mrtg/Makefile
+++ b/net/mrtg/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.28 2001/06/20 14:21:52 wiz Exp $
+# $NetBSD: Makefile,v 1.29 2001/11/07 18:26:50 bouyer Exp $
#
DISTNAME= mrtg-2.9.17
@@ -41,6 +41,8 @@ post-build:
>${WRKDIR}/netstat2mrtg
${SED} s#@PREFIX@#${PREFIX}#g <${FILESDIR}/sys2mrtg \
>${WRKDIR}/sys2mrtg
+ ${SED} s#@PREFIX@#${PREFIX}#g <${FILESDIR}/envstat2mrtg \
+ >${WRKDIR}/envstat2mrtg
do-install:
${INSTALL_DATA_DIR} ${PREFIX}/etc/mrtg
@@ -60,7 +62,7 @@ do-install:
${INSTALL_DATA} $$FILE ${PREFIX}/share/mrtg; \
done
${INSTALL_DATA} ${WRKDIR}/mrtg.conf.example ${PREFIX}/etc/mrtg
- for FILE in netstat2mrtg sys2mrtg; do \
+ for FILE in netstat2mrtg sys2mrtg envstat2mrtg; do \
${INSTALL_SCRIPT} ${WRKDIR}/$$FILE ${PREFIX}/libexec; \
done
${INSTALL_DATA_DIR} ${PERL5_SITELIB}
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]: &nbsp;
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]: &nbsp;
+LegendO[cputemp]:
+options[cputemp]: nopercent,gauge