Date: Fri, 23 Jul 2004 21:53:19 +0200 (CEST) From: Michael Ranner <mranner@inode.at> To: FreeBSD-gnats-submit@FreeBSD.org Cc: Volker Stolz <stolz@i2.informatik.rwth-aachen.de> Subject: ports/69504: [NEW PORT] net-mgmt/nrg: "NRG does visualizing network and resource utilization data" Message-ID: <200407231953.i6NJrJHp001124@dwarf.jawa.at> Resent-Message-ID: <200407232000.i6NK0l4g053448@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 69504 >Category: ports >Synopsis: [NEW PORT] net-mgmt/nrg: "NRG does visualizing network and resource utilization data" >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Jul 23 20:00:44 GMT 2004 >Closed-Date: >Last-Modified: >Originator: Michael Ranner >Release: FreeBSD 4.10-RELEASE i386 >Organization: >Environment: System: FreeBSD dwarf.jawa.at 4.10-RELEASE FreeBSD 4.10-RELEASE #0: Fri Jun 25 23:02:44 CEST 2004 >Description: NRG is a system for maintaining and visualizing network data and other resource utilization data. It automates the maintenance of RRDtool databases and graph web pages (that look like MRTG web pages.) NRG is primarily configured using very terse meta- configuration strings. These strings tell NRG to autodiscover network devices and verify that their current NRG configuration is correct. WWW: http://nrg.hep.wisc.edu/ Obsoletes ports/61539 fixes some issues with previous pr and incorporates some advices from vs. Generated with FreeBSD Port Tools 0.50 >How-To-Repeat: >Fix: --- nrg-0.99.22.shar begins here --- # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # nrg # nrg/files # nrg/files/nrg-apcupsdstat.patch # nrg/files/patch-examples # nrg/files/patch-nrg-apachestat # nrg/files/patch-nrg-bindstat # nrg/files/patch-nrg-rrdkeeper # nrg/files/patch-nrg-sendmailstat # nrg/files/run-nrg.sh # nrg/Makefile # nrg/distinfo # nrg/pkg-descr # nrg/pkg-message # nrg/pkg-plist # echo c - nrg mkdir -p nrg > /dev/null 2>&1 echo c - nrg/files mkdir -p nrg/files > /dev/null 2>&1 echo x - nrg/files/nrg-apcupsdstat.patch sed 's/^X//' >nrg/files/nrg-apcupsdstat.patch << 'END-of-nrg/files/nrg-apcupsdstat.patch' X--- collectors/nrg-apcupsdstat.in.orig Fri Mar 5 18:13:13 2004 X+++ collectors/nrg-apcupsdstat.in Fri Mar 5 18:13:13 2004 X@@ -0,0 +1,146 @@ X+#!@PERL@ X+# X+# nrg-apcupsdstat - a nrg collector for reporting apcupsd statistics X+# X+# options: temp and battery X+# X+# michael ranner <mranner@inode.at> X+# X+# $Id$ X+# X+ X+$mode = 'battery'; X+$server = 'localhost'; X+$port = '7000'; X+$stamp = '0'; X+$stat = '0'; X+$apcnisclient = "/usr/local/bin/apcnisclient"; X+ X+#------------------------------------------------------------------ X+# parse argv... X+ X+while ( $ARGV[0] =~ /^-/ ) { X+ $arg = $ARGV[0]; X+ if ( $arg =~ /^-d/ ) { X+ $debug = 1; X+ shift @ARGV; X+ } elsif ( $arg =~ /^-p/ ) { X+ $port = $ARGV[1]; X+ shift @ARGV; shift @ARGV; X+ } elsif ( $arg =~ /^-m/ ) { X+ $mode = $ARGV[1]; X+ shift @ARGV; shift @ARGV; X+ } else { X+ print "unknown option: \"$arg\"\n"; X+ &usage; X+ exit 1; X+ } X+ $i++; X+} X+ X+if ( $#ARGV != 0 ) { X+ print "usage: nrg-apcupsdstat [args] apc_server\n"; X+ exit; X+} X+$server = $ARGV[0]; X+ X+if ( $debug ) { X+ $date = `date`; chop $date; X+ print "nrg-apcupsdstat: started in debug mode at $date\n"; X+ print "nrg-apcupsdstat: contacting $server at $port\n"; X+} X+ X+if ( $mode ne 'load' && $mode ne 'temp' && $mode ne 'battery' X+ && $mode ne 'inv' && $mode ne 'outv' && $mode ne 'battv' ) { X+ print "unknown mode: \"$mode\"\n"; X+ &usage; X+ exit 1; X+} X+ X+#------------------------------------------------------------------ X+# get the stats from apc nis client... X+ X+if ( $port !~ /^\d+$/ ) { X+ $port = getservbyname($port,'tcp') || &abend; X+} X+ X+open(CLIENT, "$apcnisclient $server:$port status|"); X+ X+while(<CLIENT>) { X+ push(@details, $_); X+} X+close(CLIENT); X+ X+if ( ! @details ) { &abend; } X+ X+#------------------------------------------------------------------ X+# parse the stats... X+ X+foreach $_ (@details) { X+ ($n, $stamp) = split(": ") if /^DATE/; X+ X+ if ($mode eq "battery") { X+ next if !/^BCHARGE/; X+ ($k, $n, $stat) = split; X+ last; X+ } elsif ($mode eq "battv") { X+ next if !/^BATTV/; X+ ($k, $n, $stat) = split; X+ last; X+ } elsif ($mode eq "inv") { X+ next if !/^LINEV/; X+ ($k, $n, $stat) = split; X+ last; X+ } elsif ($mode eq "load") { X+ next if !/^LOADPCT/; X+ ($k, $n, $stat) = split; X+ last; X+ } elsif ($mode eq "temp") { X+ next if !/^ITEMP/; X+ ($k, $n, $stat) = split; X+ last; X+ } elsif ($mode eq "outv") { X+ next if !/^OUTPUTV/; X+ ($k, $n, $stat) = split; X+ last; X+ } X+ X+} X+ X+$stamp = time; X+ X+#------------------------------------------------------------------ X+# print out nrg collector format output... X+ X+if ( ! $stamp || ! $stat ) { X+ #print "nrg-apcupsdstat: could not get stats from $server!\n"; X+ $stamp = time; X+ $details = "no stats from $server"; X+} else { X+ $details = "$stat $mode GAUGE"; X+} X+ X+$localtime = scalar localtime($stamp); X+print "$stamp $localtime\n"; X+print "INF uptime\n"; # FIXME X+print "$details\n"; X+ X+exit; X+ X+#================================================================== X+ X+sub usage { X+ print "usage: nrg-apcupsdstat [-d] [-p port] [-m mode] apc_server\n"; X+} X+ X+#------------------------------------------------------------------ X+ X+sub abend { X+ if ( $debug) {"nrg-sendmail: connection to $server:$port failed\n";} X+ $stamp = time; X+ $localtime = scalar localtime($stamp); X+ print "$stamp $localtime\n"; X+ print "INF uptime\n"; X+ print "connection to $server port $port failed\n"; X+ exit; X+} X--- Makefile.in.orig Fri Jul 23 21:42:58 2004 X+++ Makefile.in Fri Jul 23 21:43:11 2004 X@@ -19,7 +19,7 @@ X CONTRIB_DIR = ${prefix}/contrib X X BIN_FILES = \ X- dsreport mrtg2nrg nrg-apachestat nrg-autoconf \ X+ dsreport mrtg2nrg nrg-apachestat nrg-apcupsdstat nrg-autoconf \ X nrg-bindresponse nrg-bindstat nrg-bindstatd \ X nrg-cgikeeper nrg-discover-apache nrg-discover-bind \ X nrg-discover-errors nrg-discover-ifaces nrg-discover-netdev \ X--- configure.orig Fri Jul 23 21:44:13 2004 X+++ configure Fri Jul 23 21:38:18 2004 X@@ -2019,6 +2019,7 @@ X Makefile \ X collectors/nrg-apmstat \ X collectors/nrg-apachestat \ X+ collectors/nrg-apcupsdstat \ X collectors/nrg-bindresponse \ X collectors/nrg-bindstat \ X collectors/nrg-bindstatd \ X@@ -2189,6 +2190,7 @@ X Makefile \ X collectors/nrg-apmstat \ X collectors/nrg-apachestat \ X+ collectors/nrg-apcupsdstat \ X collectors/nrg-bindresponse \ X collectors/nrg-bindstat \ X collectors/nrg-bindstatd \ X@@ -2312,6 +2314,7 @@ X X for f in \ X collectors/nrg-apachestat \ X+ collectors/nrg-apcupsdstat \ X collectors/nrg-bindresponse \ X collectors/nrg-bindstat \ X collectors/nrg-bindstatd \ END-of-nrg/files/nrg-apcupsdstat.patch echo x - nrg/files/patch-examples sed 's/^X//' >nrg/files/patch-examples << 'END-of-nrg/files/patch-examples' X--- ./examples/Makefile.ops.in.orig Sun Jul 20 20:51:10 2003 X+++ ./examples/Makefile.ops.in Fri Mar 5 18:08:03 2004 X@@ -4,8 +4,8 @@ X # $Id: Makefile.ops.in,v 1.41 2003/07/20 15:16:04 rader Exp $ X # X X-WEB_PREFIX = /usr/local/web/html X-NRG_WEB_TITLE = "Somesite's NRG Home Page" X+WEB_PREFIX = /usr/local/www/data X+NRG_WEB_TITLE = "FreeBSD NRG Homepage" X MCONF_FILES = NRG.mconf Site.mconf X NRG_WEB_DIR = nrg X END-of-nrg/files/patch-examples echo x - nrg/files/patch-nrg-apachestat sed 's/^X//' >nrg/files/patch-nrg-apachestat << 'END-of-nrg/files/patch-nrg-apachestat' X--- ./collectors/nrg-apachestat.in.orig Sun Jul 20 20:51:09 2003 X+++ ./collectors/nrg-apachestat.in Fri Mar 5 18:08:03 2004 X@@ -11,7 +11,7 @@ X $mode = "requests"; X $server = "localhost"; X $port = "80"; X-$url = "server-status"; X+$url = "server-status?auto"; X $stamp = 0; X $stat = 0; X X@@ -88,15 +88,24 @@ X # parse the stats... X X while(<SOCK>) { X+ if ( $_ =~ /Uptime: (\d+)/ ) { X+ $uptime = $1; X+ last; X+ } X if ( $_ =~ /Server uptime:/ ) { X if ( $_ =~ /(\d+) hour/ ) { $uptime += $1*60*60; } X if ( $_ =~ /(\d+) minute/ ) { $uptime += $1*60; } X if ( $_ =~ /(\d+) second/ ) { $uptime += $1; } X } X- if ( $mode eq 'requests' && $_ =~ /Total accesses: (\d+)/ ) { X+ if ( $mode eq 'requests' && $_ =~ /Total accesses: (\d+)/i ) { X $stat = $1; X &debug("$stat accesses\n"); X- last; X+ last if $url !~ /auto$/; X+ } X+ if ( $mode eq 'bytes' && $_ =~ /Total kBytes: (\d+)/ ) { X+ $stat = $1*1024; X+ &debug("$stat bytes\n"); X+ last if $url !~ /auto$/; X } X if ( $mode eq 'bytes' && $_ =~ /Total Traffic: (\d+) kB/ ) { X $stat = $1*1024; X@@ -105,6 +114,11 @@ X } X if ( $mode eq 'bytes' && $_ =~ /Total Traffic: (\d+)\.(\d) MB/ ) { X $stat = ($1*1024*1024) + (($2/10)*1024*1024); X+ &debug("$stat bytes\n"); X+ last; X+ } X+ if ( $mode eq 'bytes' && $_ =~ /Total Traffic: (\d+)\.(\d) GB/ ) { X+ $stat = ($1*1024*1024*1024) + (($2/10)*1024*1024*1024); X &debug("$stat bytes\n"); X last; X } END-of-nrg/files/patch-nrg-apachestat echo x - nrg/files/patch-nrg-bindstat sed 's/^X//' >nrg/files/patch-nrg-bindstat << 'END-of-nrg/files/patch-nrg-bindstat' X--- ./collectors/nrg-bindstat.in.orig Sun Jul 20 20:51:09 2003 X+++ ./collectors/nrg-bindstat.in Fri Mar 5 18:08:03 2004 X@@ -24,7 +24,7 @@ X $version = "4.9.6"; X $mode = "queries"; X $server = "localhost"; X-$port = "88888"; X+$port = "28888"; X $stamp = 0; X $stat = 0; X END-of-nrg/files/patch-nrg-bindstat echo x - nrg/files/patch-nrg-rrdkeeper sed 's/^X//' >nrg/files/patch-nrg-rrdkeeper << 'END-of-nrg/files/patch-nrg-rrdkeeper' X--- src/nrg-rrdkeeper.in.orig Fri Mar 5 18:04:41 2004 X+++ src/nrg-rrdkeeper.in Fri Mar 5 18:05:19 2004 X@@ -631,6 +631,12 @@ X X } X X+ $dir = $path; X+ $dir =~ s/[^\/]+.rrd//; X+ if (! -d $dir) { X+ system("mkdir -p $dir"); X+ } X+ X #print "RRDs::create @create_options \n"; X RRDs::create @create_options; X END-of-nrg/files/patch-nrg-rrdkeeper echo x - nrg/files/patch-nrg-sendmailstat sed 's/^X//' >nrg/files/patch-nrg-sendmailstat << 'END-of-nrg/files/patch-nrg-sendmailstat' X--- ./collectors/nrg-sendmailstat.in.orig Sun Jul 20 20:51:09 2003 X+++ ./collectors/nrg-sendmailstat.in Fri Mar 5 18:08:03 2004 X@@ -13,7 +13,7 @@ X X $mode = 'msgs'; X $server = 'localhost'; X-$port = '88889'; X+$port = '28889'; X $stamp = '0'; X $stat = '0'; X END-of-nrg/files/patch-nrg-sendmailstat echo x - nrg/files/run-nrg.sh sed 's/^X//' >nrg/files/run-nrg.sh << 'END-of-nrg/files/run-nrg.sh' X#!/bin/sh X XLOG=/var/log/run-nrg.log X X#renice 5 -p $$ >/dev/null 2>&1 X/usr/local/nrg/run-nrg >$LOG X#/usr/local/nrg/run-nrg.local >>$LOG END-of-nrg/files/run-nrg.sh echo x - nrg/Makefile sed 's/^X//' >nrg/Makefile << 'END-of-nrg/Makefile' X# New ports collection makefile for: nrg X# Date created: 18 January 2004 X# Whom: Michael Ranner X# X# $FreeBSD$ X# X XPORTNAME= nrg XPORTVERSION= 0.99.22 XCATEGORIES= net-mgmt sysutils XMASTER_SITES= ftp://nrg.hep.wisc.edu/pub/src/nrg/ \ X http://www.ranner.jawa.at/stuff/ X XMAINTAINER= mranner@inode.at XCOMMENT= "NRG does visualizing network and resource utilization data" X XBUILD_DEPENDS= ${SITE_PERL}/RRDp.pm:${PORTSDIR}/net/rrdtool \ X ${LOCALBASE}/bin/snmpget:${PORTSDIR}/net-mgmt/net-snmp4 XRUN_DEPENDS= ${SITE_PERL}/RRDp.pm:${PORTSDIR}/net/rrdtool \ X ${LOCALBASE}/bin/snmpget:${PORTSDIR}/net-mgmt/net-snmp4 \ X ${SITE_PERL_ARCH}/Time/HiRes.pm:${PORTSDIR}/devel/p5-Time-HiRes X XNRG_WEB_PREFIX?= ${PREFIX}/www/data XNRG_WEB_DIR?= nrg XNRG_WEB_TITLE?= FreeBSD NRG Homepage X XSITE_PERL_ARCH= ${SITE_PERL}/${PERL_ARCH} X XPKGMESSAGE= ${WRKDIR}/pkg-message XUSE_PERL5= yes XUSE_REINPLACE= yes XHAS_CONFIGURE= yes XCONFIGURE_ARGS= --prefix=${LOCALBASE}/nrg XALL_TARGET= pingd X Xpre-fetch: X @${ECHO} "" X @${ECHO} "You may use the following build options:" X @${ECHO} "" X @${ECHO} " -DWITH_APCNISCLIENT to build collector for nrg-apcupsdstat" X @${ECHO} "" X X.if defined(WITH_APCNISCLIENT) XEXTRA_PATCHES+= ${PATCHDIR}/nrg-apcupsdstat.patch XPLIST_FILES+= nrg/bin/nrg-apcupsdstat X.endif X Xpost-patch: X @${REINPLACE_CMD} -e "s,= @WEB_PREFIX@,= ${NRG_WEB_PREFIX},g" \ X -e "s,= @NRG_WEB_DIR@,= ${NRG_WEB_DIR},g" \ X -e "s,= @NRG_WEB_TITLE@,= \"${NRG_WEB_TITLE}\",g" \ X ${WRKSRC}/examples/Makefile.ops.in X @${REINPLACE_CMD} -e "s,<malloc.h>,<stdlib.h>,g" \ X ${WRKSRC}/roverpingd/send.c ${WRKSRC}/roverpingd/pingd.c \ X ${WRKSRC}/roverpingd/read_list.c X @${REINPLACE_CMD} -e "s,<values.h>,<limits.h>,g" \ X -e "s, MAXINT, INT_MAX,g" \ X ${WRKSRC}/roverpingd/write_stats.c X Xpre-install: X @${SED} 's|%%PREFIX%%|${PREFIX}|g' <${.CURDIR}/pkg-message >${PKGMESSAGE} X Xpost-install: X @${INSTALL_SCRIPT} ${FILESDIR}/run-nrg.sh ${PREFIX}/nrg/ X @${CAT} ${PKGMESSAGE} X X.include <bsd.port.mk> END-of-nrg/Makefile echo x - nrg/distinfo sed 's/^X//' >nrg/distinfo << 'END-of-nrg/distinfo' XMD5 (nrg-0.99.22.tar.gz) = 439242d8567aab1a375873128a34fc5c XSIZE (nrg-0.99.22.tar.gz) = 2889103 END-of-nrg/distinfo echo x - nrg/pkg-descr sed 's/^X//' >nrg/pkg-descr << 'END-of-nrg/pkg-descr' XNRG is a system for maintaining and visualizing network data and Xother resource utilization data. It automates the maintenance of XRRDtool databases and graph web pages (that look like MRTG web Xpages.) NRG is primarily configured using very terse meta- Xconfiguration strings. These strings tell NRG to autodiscover Xnetwork devices and verify that their current NRG configuration Xis correct. X XWWW: http://nrg.hep.wisc.edu/ END-of-nrg/pkg-descr echo x - nrg/pkg-message sed 's/^X//' >nrg/pkg-message << 'END-of-nrg/pkg-message' X X************************************************************ X XFor configuration and upgrade, please read file located at: X%%PREFIX%%/nrg/html/index.html X XAfer configuration add the next line to crontab: X*/5 * * * * %%PREFIX%%/nrg/run-nrg.sh X X************************************************************ X END-of-nrg/pkg-message echo x - nrg/pkg-plist sed 's/^X//' >nrg/pkg-plist << 'END-of-nrg/pkg-plist' Xnrg/bin/dsreport Xnrg/bin/mrtg2nrg Xnrg/bin/nrg-apachestat Xnrg/bin/nrg-autoconf Xnrg/bin/nrg-bindresponse Xnrg/bin/nrg-bindstat Xnrg/bin/nrg-bindstatd Xnrg/bin/nrg-cgikeeper Xnrg/bin/nrg-discover-apache Xnrg/bin/nrg-discover-bind Xnrg/bin/nrg-discover-errors Xnrg/bin/nrg-discover-ifaces Xnrg/bin/nrg-discover-netdev Xnrg/bin/nrg-discover-pingd Xnrg/bin/nrg-discover-pvcs Xnrg/bin/nrg-discover-sendmail Xnrg/bin/nrg-discover-snmpd Xnrg/bin/rrdmerge Xnrg/bin/nrg-discover-tables Xnrg/bin/nrg-discover-tcp Xnrg/bin/nrg-find-confs Xnrg/bin/nrg-indexmaker Xnrg/bin/nrg-rrdkeeper Xnrg/bin/nrg-pingdstat Xnrg/bin/nrg-runmaker Xnrg/bin/nrg-sendmailstat Xnrg/bin/nrg-sendmailstatd Xnrg/bin/nrg-snmpwalk Xnrg/bin/nrg-spiketrimmer Xnrg/bin/nrg-tablemaker Xnrg/bin/nrg-tcpresponse Xnrg/bin/rrdtrim Xnrg/etc/nrg-oid-names Xnrg/etc/run-star-head.pl Xnrg/etc/run-star-tail.pl Xnrg/templates/database-mrtg.rrd.tm Xnrg/templates/discover-bind.tm Xnrg/templates/discover-apache.tm Xnrg/templates/discover-errors.tm Xnrg/templates/discover-ifaces.tm Xnrg/templates/discover-netdev.tm Xnrg/templates/discover-pingd.tm Xnrg/templates/discover-pvcs.tm Xnrg/templates/discover-sendmail.tm Xnrg/templates/discover-snmpd.tm Xnrg/templates/discover-tables.tm Xnrg/templates/discover-tcp.tm Xnrg/templates/graph-current.cgi.tm Xnrg/templates/graph-longterm.cgi.tm Xnrg/templates/graph-mrtg.cgi.tm Xnrg/templates/table-df.cgi.tm Xnrg/templates/table-errors.cgi.tm Xnrg/templates/table-ifaces.cgi.tm Xnrg/templates/table-load.cgi.tm Xnrg/templates/table-mem.cgi.tm Xnrg/templates/table-ping-latency.cgi.tm Xnrg/templates/table-ping-loss.cgi.tm Xnrg/templates/table-swap.cgi.tm Xnrg/templates/table-tcp.cgi.tm Xnrg/examples/Default.conf Xnrg/examples/NRG.mconf Xnrg/examples/Site.mconf Xnrg/examples/apache.mconf Xnrg/examples/bind.mconf Xnrg/examples/cisco.mconf Xnrg/examples/ftp.mconf Xnrg/examples/http.mconf Xnrg/examples/iface-errors.mconf Xnrg/examples/ifaces.mconf Xnrg/examples/imap.mconf Xnrg/examples/ping.mconf Xnrg/examples/pop.mconf Xnrg/examples/procurve.mconf Xnrg/examples/sendmail.mconf Xnrg/examples/smtp.mconf Xnrg/examples/ssh.mconf Xnrg/examples/trunk.mconf Xnrg/examples/unix.mconf Xnrg/html/apachestat.html Xnrg/html/bindstat.html Xnrg/html/changes Xnrg/html/collectors.html Xnrg/html/conf-string-list.html Xnrg/html/conf-strings.html Xnrg/html/configuration.html Xnrg/html/contrib.html Xnrg/html/index.html Xnrg/html/install.html Xnrg/html/log2rrd.html Xnrg/html/nrg+rrd.gif Xnrg/html/metaconf-strings.html Xnrg/html/metaconf.html Xnrg/html/mrtg-vs-nrg.html Xnrg/html/mrtg2nrg.html Xnrg/html/operation.html Xnrg/html/readme.html Xnrg/html/templates.html Xnrg/html/sample-conf.html Xnrg/html/sendmailstat.html Xnrg/html/upgrade.html Xnrg/html/whats-new Xnrg/Makefile Xnrg/Default.conf Xnrg/NRG.mconf Xnrg/Site.mconf Xnrg/.VERSION Xnrg/run-nrg.sh X@dirrm nrg/templates X@dirrm nrg/html X@dirrm nrg/examples X@dirrm nrg/etc X@dirrm nrg/bin X@dirrm nrg/archive X@dirrm nrg END-of-nrg/pkg-plist exit --- nrg-0.99.22.shar ends here --- >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200407231953.i6NJrJHp001124>