diff options
author | bouyer <bouyer@pkgsrc.org> | 1999-05-18 14:16:53 +0000 |
---|---|---|
committer | bouyer <bouyer@pkgsrc.org> | 1999-05-18 14:16:53 +0000 |
commit | 147ae6dd80e19bbb1c246ab801b385d560877754 (patch) | |
tree | c750f54e0c3a2944a4c284b7990752e5f807b0a3 /net/mrtg | |
parent | 27933be85cc0adfa2fd072e15ce4de74c771fe0c (diff) | |
download | pkgsrc-147ae6dd80e19bbb1c246ab801b385d560877754.tar.gz |
Add 2 perl scripts to collect datas on a NetBSD 1.4 system from netstat,
iostat, systat and a sample config file to use these. Also update the
MESSAGE to stats there is a sample config file.
Result can be seen at http://www.antioche.eu.org/mrtg/.
Diffstat (limited to 'net/mrtg')
-rw-r--r-- | net/mrtg/Makefile | 13 | ||||
-rw-r--r-- | net/mrtg/files/mrtg.conf.example | 107 | ||||
-rw-r--r-- | net/mrtg/files/netstat2mrtg | 26 | ||||
-rw-r--r-- | net/mrtg/files/sys2mrtg | 185 | ||||
-rw-r--r-- | net/mrtg/pkg/MESSAGE | 5 | ||||
-rw-r--r-- | net/mrtg/pkg/PLIST | 5 |
6 files changed, 338 insertions, 3 deletions
diff --git a/net/mrtg/Makefile b/net/mrtg/Makefile index 44de81ca7b4..e5cde9db5cf 100644 --- a/net/mrtg/Makefile +++ b/net/mrtg/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.5 1999/05/03 20:25:37 tv Exp $ +# $NetBSD: Makefile,v 1.6 1999/05/18 14:16:53 bouyer Exp $ # FreeBSD Id: Makefile,v 1.7 1997/12/16 19:42:17 vanilla Exp # @@ -15,6 +15,13 @@ USE_PERL5= YES ALL_TARGET= rateup substitute +post-build: + ${SED} s#@PREFIX@#${PREFIX}#g <${FILESDIR}/mrtg.conf.example \ + >${WRKDIR}/mrtg.conf.example + ${SED} s#@PREFIX@#${PREFIX}#g <${FILESDIR}/netstat2mrtg \ + >${WRKDIR}/netstat2mrtg + ${SED} s#@PREFIX@#${PREFIX}#g <${FILESDIR}/sys2mrtg \ + >${WRKDIR}/sys2mrtg do-install: ${INSTALL_DATA_DIR} ${PREFIX}/etc/mrtg ${INSTALL_DATA_DIR} ${PREFIX}/share/mrtg @@ -25,6 +32,10 @@ do-install: for file in ${WRKSRC}/*.gif; do \ ${INSTALL_DATA} $$file ${PREFIX}/share/mrtg/; \ done + ${INSTALL_DATA} ${WRKDIR}/mrtg.conf.example ${PREFIX}/etc/mrtg + for file in netstat2mrtg sys2mrtg; do \ + ${INSTALL_SCRIPT} ${WRKDIR}/$$file ${PREFIX}/libexec/; \ + done ${INSTALL_PROGRAM} ${WRKSRC}/rateup ${PREFIX}/libexec/ ${INSTALL_SCRIPT} ${WRKSRC}/mrtg ${PREFIX}/bin/ ${INSTALL_SCRIPT} ${WRKSRC}/BER.pm ${WRKSRC}/SNMP_Session.pm \ diff --git a/net/mrtg/files/mrtg.conf.example b/net/mrtg/files/mrtg.conf.example new file mode 100644 index 00000000000..cb4e0c8c7ac --- /dev/null +++ b/net/mrtg/files/mrtg.conf.example @@ -0,0 +1,107 @@ +WorkDir: @PREFIX@/share/httpd/htdocs/mrtg +Refresh: 300 +Interval: 5 +WriteExpires: Yes + +Target[network]: `@PREFIX@/libexec/netstat2mrtg de0` +Title[network]: Traffic Analysis for my host +PageTop[network]: <H1>Stats for my host </H1> +MaxBytes[network]: 12500000 + +Target[phys]: `@PREFIX@/libexec/sys2mrtg phys` +MaxBytes[phys]: 85000000 +Title[phys]: physical memory (active and free) +PageTop[phys]: <H1>physical memory (active and free)</H1> +YLegend[phys]: Bytes +ShortLegend[phys]: Bytes +Legend1[phys]: active physical memory in bytes +Legend2[phys]: free physical memory in bytes +Legend3[phys]: Maximal 5 Minute active physical memory +Legend4[phys]: Maximal 5 Minute active free memory +LegendI[phys]: active: +LegendO[phys]: free: +options[phys]: nopercent,gauge + +Target[swap]: `@PREFIX@/libexec/sys2mrtg swap` +MaxBytes[swap]: 512000000 +Title[swap]: swap usage +PageTop[swap]: <H1>swap usage</H1> +YLegend[swap]: Bytes +ShortLegend[swap]: Bytes +Legend1[swap]: swap usage in bytes +Legend2[swap]: +Legend3[swap]: Maximal 5 Minute swap usage +Legend4[swap]: +LegendI[swap]: swap: +LegendO[swap]: +options[swap]: nopercent,gauge + +Target[pages]: `@PREFIX@/libexec/sys2mrtg pages` +MaxBytes[pages]: 10000 +Title[pages]: Paging operations +PageTop[pages]: <H1>Paging operations</H1> +YLegend[pages]: Paging operations per seconds +ShortLegend[pages]: Ops/s +Legend1[pages]: pages in per seconds +Legend2[pages]: pages out per seconds +Legend3[pages]: Maximal 5 Minute pages in per seconds +Legend4[pages]: Maximal 5 Minute pages out per seconds +LegendI[pages]: In: +LegendO[pages]: Out: +options[pages]: nopercent + +Target[irq]: `@PREFIX@/libexec/sys2mrtg irq` +MaxBytes[irq]: 50000 +Title[irq]: Interrupt requests +PageTop[irq]: <H1>Interrupt requests</H1> +YLegend[irq]: Interrupt requests per seconds +ShortLegend[irq]: Irq/s +Legend1[irq]: Interrupt requests per seconds +Legend2[irq]: +Legend3[irq]: Maximal 5 Minute interrupt requests per seconds +Legend4[irq]: +LegendI[irq]: Irq: +LegendO[irq]: +options[irq]: nopercent + +Target[forks]: `@PREFIX@/libexec/sys2mrtg forks` +MaxBytes[forks]: 500000 +Title[forks]: Forks +PageTop[forks]: <H1>Forks</H1> +YLegend[forks]: Forks per seconds +ShortLegend[forks]: Forks/s +Legend1[forks]: Forks per seconds +Legend2[forks]: +Legend3[forks]: Maximal 5 Minute forks per seconds +Legend4[forks]: +LegendI[forks]: Forks: +LegendO[forks]: +options[forks]: nopercent + +Target[disks]: `@PREFIX@/libexec/sys2mrtg disks` +MaxBytes[disks]: 100 +Title[disks]: Disks transfers +PageTop[disks]: <H1>Disks transfers</H1> +YLegend[disks]: Kilobytes per seconds +ShortLegend[disks]: KB/s +Legend1[disks]: Disks transfers in kilobytes per seconds +Legend2[disks]: +Legend3[disks]: Maximal 5 Minute Disks transfers +Legend4[disks]: +LegendI[disks]: Disks: +LegendO[disks]: +options[disks]: nopercent + +Target[load]: `@PREFIX@/libexec/sys2mrtg load` +MaxBytes[load]: 10000 +Title[load]: Load average +PageTop[load]: <H1>Load average</H1> +YLegend[load]: load * 100 +ShortLegend[load]: load * 100 +Legend1[load]: load average +Legend2[load]: +Legend3[load]: Maximal 5 Minute load average +Legend4[load]: +LegendI[load]: +LegendO[load]: +options[load]: nopercent,gauge diff --git a/net/mrtg/files/netstat2mrtg b/net/mrtg/files/netstat2mrtg new file mode 100644 index 00000000000..9fdabae68a7 --- /dev/null +++ b/net/mrtg/files/netstat2mrtg @@ -0,0 +1,26 @@ +#! @PREFIX@/bin/perl + +$if = $ARGV[0]; +open(NET, "netstat -I $if -b|"); +while ($line = <NET>) +{ + chop $line; + if ($line =~ m|^.+<Link>[\s\t]+\S+[\s\t]+(\w+)[\s\t]+(\w+)$|) + { + print "$1\n"; + print "$2\n"; + } +} +close(NET); + +open(UP, "uptime|"); +while($line = <UP>) +{ + chop $line; + if ($line =~ m|^.*up\s+(.+),\s+\d+\suser.*|) + { + print "$1\n"; + } +} +close(UP); +print "$if\n"; diff --git a/net/mrtg/files/sys2mrtg b/net/mrtg/files/sys2mrtg new file mode 100644 index 00000000000..46776492f56 --- /dev/null +++ b/net/mrtg/files/sys2mrtg @@ -0,0 +1,185 @@ +#! @PREFIX@/bin/perl + + +if (@ARGV < 1) +{ + goto usage; +} + +$cmd = @ARGV[0]; + +if ($cmd eq phys) +{ + &vmstat("pages active", "pages free", "bytes per page"); +} +if ($cmd eq swap) +{ + &vmstat("swap pages in use", "", "bytes per page"); +} +if ($cmd eq pages) +{ + &vmstat("pagein requests", "pageout requests"); +} +if ($cmd eq forks) +{ + &vmstat("forks total"); +} + +if ($cmd eq disks) +{ + if (@ARGV < 2) + { + $diskname = "Total" + } + else + { + $diskname = @ARGV[1]; + } + $total = 0; + open(CMDOUT, "iostat -xI|"); + while (<CMDOUT>) + { + chop $_; + if (m|^(\w+)[\t\s]+[\d\.]+[\t\s]+[\d\.]+[\t\s]+[\d\.]+[\t\s]+([\d\.]+)|) + { + if ($1 eq $diskname) + { + $val = $2 * 1000; + print "$val\n"; + print "0\n"; + &uptime; + print "$diskname\n"; + exit(0); + } + $total = $total + $2 * 1000; + } + } + print "$total\n"; + print "0\n"; + &end; +} + +if ($cmd eq irq) +{ + if (@ARGV < 2) + { + $irqname = "Total" + } + else + { + $irqname = @ARGV[1]; + } + open(CMDOUT, "vmstat -i|"); + while (<CMDOUT>) + { + chop $_; + if (m|^(\w+)[\t\s]+(\d+)|) + { + if ($1 eq $irqname) + { + print "$2\n"; + } + } + } + print "0\n"; + if (@ARGV < 2) + { + &end; + } + else + { + &uptime; + print "$irqname\n"; + } +} + +if ($cmd eq load) +{ + open(UP, "uptime|"); + while($line = <UP>) + { + chop $line; + if ($line =~ m|^.*up\s+(.+),\s+\d+\suser.*load averages:[\s\t]+([\d\.]+),[\s\t]+[\d\.]+,[\s\t]+[\d\.]+$|) + { + printf("%d\n", $2 * 100); + print "0\n"; + print "$1\n"; + } + } + close(UP); + open(HOST, "hostname -s|"); + while (<HOST>) + { + print $_; + } + close(HOST); + exit(0); +} + +&usage(); + +sub usage +{ + print STDERR + "usage: sys2mrtg (phys|swap|pages|irq [name]|forks|disks[name])|load\n"; + exit(1); +} + +sub vmstat +{ + local($f1, $f2,$fmult) = @_; + $mult=1; + $val1=0; + $val2=0; + open(CMDOUT, "vmstat -s|"); + while (<CMDOUT>) + { + chop $_; + if (m|(\d+)[\t\s]+(.+)|) + { + $val = $1; + $field = $2; + if ($field eq $fmult) + { + $mult = $val; + } + if ($field eq $f1) + { + $val1 = $val * $mult; + } + if ($field eq $f2) + { + $val2 = $val * $mult; + } + } + } + print "$val1\n"; + print "$val2\n"; + &end; +} + +sub uptime +{ + open(UP, "uptime|"); + while($line = <UP>) + { + chop $line; + if ($line =~ m|^.*up\s+(.+),\s+\d+\suser.*|) + { + print "$1\n"; + } + } + close(UP); +} + + +sub end +{ + &uptime; + open(HOST, "hostname -s|"); + while (<HOST>) + { + print $_; + } + exit(0); +} diff --git a/net/mrtg/pkg/MESSAGE b/net/mrtg/pkg/MESSAGE index 9ee211d55e9..bceb2bc06fc 100644 --- a/net/mrtg/pkg/MESSAGE +++ b/net/mrtg/pkg/MESSAGE @@ -1,6 +1,6 @@ ============================================================================= -$NetBSD: MESSAGE,v 1.2 1998/08/07 11:10:47 agc Exp $ +$NetBSD: MESSAGE,v 1.3 1999/05/18 14:16:53 bouyer Exp $ The Multi Router Traffic Grapher is now installed. Do note that three programs have changed names to more readily reflect their MRTG-specific @@ -13,4 +13,7 @@ function; make sure to prefix them with "mrtg": The documentation can be found at $PREFIX/share/doc/mrtg/readme.html (where $PREFIX is typically /usr/pkg); there is a .txt version there as well. +A sample config file collecting various datas from a NetBSD machine can +be found in $PREFIX/etc/mrtg/. + ============================================================================= diff --git a/net/mrtg/pkg/PLIST b/net/mrtg/pkg/PLIST index 5a7524c6680..f32d98f5f21 100644 --- a/net/mrtg/pkg/PLIST +++ b/net/mrtg/pkg/PLIST @@ -1,4 +1,5 @@ -@comment $NetBSD: PLIST,v 1.2 1998/07/13 17:56:28 tv Exp $ +@comment $NetBSD: PLIST,v 1.3 1999/05/18 14:16:53 bouyer Exp $ +etc/mrtg/mrtg.conf.example bin/mrtgcfgmaker bin/mrtgconvert bin/mrtgindexmaker @@ -6,6 +7,8 @@ bin/mrtg lib/perl5/site_perl/BER.pm lib/perl5/site_perl/SNMP_Session.pm libexec/rateup +libexec/netstat2mrtg +libexec/sys2mrtg share/mrtg/mrtg-l.gif share/mrtg/mrtg-m.gif share/mrtg/mrtg-r.gif |