# $Id$
PortSystem 1.0
name nrg
version 0.99.27
revision 1
categories net
maintainers markd
platforms darwin
description Network Resource Grapher
long_description NRG is an RRDtool front-end tool to monitor traffic and load \
on network links or any other resource utilization source. It \
automatically creates and maintains web pages and RRDtool databases, \
while providing short and long-term graph web pages just like MRTG.
homepage http://ginseng.hep.wisc.edu/NRG/
master_sites ftp://noc.hep.wisc.edu/src/nrg/ \
ftp://noc.hep.wisc.edu/pub/src/nrg/
checksums md5 c38e6b27bc99f8f7fd825bc6e1a44f68
depends_lib port:rrdtool port:p5.12-time-hires
patchfiles patch-nrg-discover-tcp.in.diff
configure.pre_args --prefix=${prefix}/var/${name}
configure.args --bindir=${prefix}/bin \
--sysconfdir=${prefix}/etc/${name} \
--datadir=${prefix}/share \
--build=powerpc-unknown-freebsd \
CFLAGS="-D__FreeBSD__"
platform i386 {
configure.args-delete --build=powerpc-unknown-freebsd
configure.args-append --build=i386-unknown-freebsd
}
variant pingd_server description {pingd daemon to graph network latency with NRG} {
startupitem.create yes
startupitem.name pingd
startupitem.executable "${prefix}/bin/pingd"
}
build.target pingd
destroot.target install.pingd install
# Maintain empty directories
destroot.keepdirs ${destroot}${prefix}/var/${name}/archive
post-patch {
### Path fixes ###
reinplace "s|@prefix@/bin|@bindir@|g" \
${worksrcpath}/examples/NRG.mconf.in \
${worksrcpath}/src/nrg-spiketrimmer.in
eval reinplace "s|@prefix@/bin|@bindir@|g" \
[glob ${worksrcpath}/templates/*.in]
#### Make NRG page title the way I want it ####
reinplace "s|Somesite's NRG Home Page|NRG Home Page|g" \
"${worksrcpath}/examples/Makefile.ops.in"
#### Fix paths for proper destrooting ####
reinplace "s|exec_prefix = @prefix@|exec_prefix = ${destroot}@prefix@|g" \
${worksrcpath}/Makefile.in
reinplace "s|prefix = @prefix@|prefix = ${destroot}@prefix@|g" \
${worksrcpath}/Makefile.in
reinplace "s|BIN_DIR = @bindir@|BIN_DIR = ${destroot}@bindir@|g" \
${worksrcpath}/Makefile.in
reinplace "s|ETC_DIR = \${prefix}/etc|ETC_DIR = ${destroot}@sysconfdir@|g" \
${worksrcpath}/Makefile.in
reinplace "s|TEMPLATE_DIR = \${prefix}/templates|TEMPLATE_DIR = ${destroot}@prefix@/templates|g" \
${worksrcpath}/Makefile.in
reinplace "s|EXAMPLE_DIR = \${prefix}/examples|EXAMPLE_DIR = ${destroot}@datadir@/doc/nrg/examples|g" \
${worksrcpath}/Makefile.in
reinplace "s|HTML_DIR = \${prefix}/html|HTML_DIR = ${destroot}@datadir@/doc/nrg/html|g" \
${worksrcpath}/Makefile.in
reinplace "s|ARCHIVE_DIR = \${prefix}/archive|ARCHIVE_DIR = ${destroot}@prefix@/archive|g" \
${worksrcpath}/Makefile.in
reinplace "s|CONTRIB_DIR = \${prefix}/contrib|CONTRIB_DIR = ${destroot}@datadir@/doc/nrg/contrib|g" \
${worksrcpath}/Makefile.in
}
post-destroot {
# Install images to \${prefix}/var/nrg/web/icons
xinstall -d -m 755 ${destroot}${prefix}/var/${name}/web/icons
eval xinstall -m 755 [glob ${worksrcpath}/images/*.*] ${destroot}${prefix}/var/${name}/web/icons
# Rename Site.mconf so graphed devices won't get rewritten on port upgrades
file rename ${destroot}${prefix}/var/${name}/Site.mconf \
${destroot}${prefix}/var/${name}/Site.mconf.sample
}
notes \
"#### To complete the NRG installation ####
1) Make an /nrg symlink in your Apache document root pointing to the ../nrg/web NRG data directory:
sudo ln -s ${prefix}/var/${name}/web /my-Apache-document-root/nrg
2) Modify your httpd.conf file for NRG graph pages:
Uncomment lines: AddHandler cgi-script .cgi
LoadModule expires_module libexec/httpd/mod_expires.so
AddModule mod_expires.c
Add directives:
Options ExecCGI
ExpiresActive On
ExpiresDefault M5
Change the Apache user and group to the NRG user and group so Apache will
have permissions to create graphs when you click an RRD file link.
User
Group
3) Change the web root variables at the top of files Makefile and Site.mconf
in directory ${prefix}/var/${name} to your Apache document root location.
4) Make NRG files and data owned by the user you'll use to run NRG
su (must be root for this operation)
find ${prefix}/var/nrg -print | xargs chown :
#### To use NRG ####
1) Set meta-configuration definitions in the Site.mconf file for each
resource you want to graph by following the example meta-configuration
definitions in ${prefix}/share/doc/nrg/examples.
2) Have NRG generate rrd files and html graph pages (and modify them after
Site.mconf changes):
cd ${prefix}/var/${name}
make rediscover
make notify
3) Schedule the script ${prefix}/var/${name}/run-nrg to run via cron every five
minutes to poll your data sources and update the rrd files.
Be sure to read the documentation in ${prefix}/share/doc/${name}/html for
creating custom graphs or for more information."