# $Id$ PortSystem 1.0 name nedi version 1.0 revision 3 categories net maintainers markd platforms darwin description Network Discovery Suite long_description A low noise network discovery, management, and inventory \ system for Cisco networks with a user friendly web interface. homepage http://www.nedi.ch/ master_sites http://nedi.web.psi.ch/ extract.suffix .tgz worksrcdir ${name} checksums md5 adae0699ea6d010d6d92f807f04ca442 patchfiles patch-html-Reports-Modules.php-diff depends_lib path:bin/perl:perl5 \ port:mysql5 \ port:p5-net-snmp \ port:p5-net-ssh-perl \ port:p5-net-telnet \ port:p5-net-telnet-cisco \ port:p5-libwww-perl \ port:p5-algorithm-diff \ port:p5-dbi \ port:p5-dbd-mysql \ port:rrdtool \ port:fping variant server description {does nothing in this port, but its presence triggers mysql5 server variant} {} variant cacti description {NeDi supports the Cacti API to selectively add graphs of NeDi discovered devices to a Cacti installation on the same host} { depends_lib-append port:cacti } variant_set server # Set some useful variables set nedidir ${prefix}/share set rrdbin ${prefix}/bin/rrdtool set rrdfiles ${nedidir}/${name}/rrd set fpingpath ${prefix}/sbin set cacticlidir ${prefix}/share/cacti/cli startupitem.create yes startupitem.name nedimonitor startupitem.executable ${nedidir}/${name}/moni.pl use_configure no build {} post-patch { eval reinplace "s|__PREFIX__|${prefix}|g" \ [glob ${filespath}/*] } destroot { xinstall -m 755 -d ${destroot}${nedidir} system "cp -R ${worksrcpath} ${destroot}${nedidir}" } post-destroot { # Fix general paths eval reinplace "s|/usr/bin/perl|${prefix}/bin/perl|g" \ [glob ${destroot}${nedidir}/${name}/*.pl] \ [glob ${destroot}${nedidir}/${name}/inc/*.pl] \ [glob ${destroot}${nedidir}/${name}/html/inc/*.pl] reinplace "s|netstat|/usr/sbin/netstat|g" \ ${destroot}${nedidir}/${name}/inc/libmisc.pl reinplace "s|/etc/nedi.conf|${nedidir}/nedi/nedi.conf|g" \ ${destroot}${nedidir}/${name}/html/inc/libmisc.php # Fix rrdcmd and rrdpath variables in nedi.conf reinplace "s|rrdtool|${rrdbin}|g" \ ${destroot}${nedidir}/${name}/nedi.conf reinplace "s|/var/nedi/rrd|${rrdfiles}|g" \ ${destroot}${nedidir}/${name}/nedi.conf # Fix fping path reinplace "s|/usr/local/sbin|${fpingpath}|g" \ ${destroot}${nedidir}/${name}/html/Nodes-Toolbox.php # Fix Cacti paths in nedi.conf reinplace "s|/usr/bin/php /var/www/html/cacti/cli|${prefix}/bin/php ${cacticlidir}|g" \ ${destroot}${nedidir}/${name}/nedi.conf # Create directory for rrd files xinstall -m 755 -d ${destroot}${rrdfiles} # Keep these empty directories destroot.keepdirs \ ${destroot}${nedidir}/${name}/db/cfg \ ${destroot}${nedidir}/${name}/html/log \ ${destroot}${rrdfiles} # Rename nedi.conf to nedi.conf.sample so port upgrades don't overwrite an installed nedi.conf # Also set permissions on nedi.conf because it has passwords. file rename ${destroot}${nedidir}/${name}/nedi.conf \ ${destroot}${nedidir}/${name}/nedi.conf.sample system "chmod 600 ${destroot}${nedidir}/${name}/nedi.conf.sample" } pre-install { # MacPorts can create only one startupitem per portfile. So copy nedisyslog.plist and # snmptrapd.plist from filespath and link them into /Library/LaunchDaemons as startupitem's do. xinstall -m 755 -d ${destroot}${prefix}/etc/LaunchDaemons/org.macports.nedisyslog/ xinstall -m 755 ${filespath}/org.macports.nedisyslog.plist \ ${destroot}${prefix}/etc/LaunchDaemons/org.macports.nedisyslog/ system "cd /Library/LaunchDaemons && ln -sf \ ${prefix}/etc/LaunchDaemons/org.macports.nedisyslog/org.macports.nedisyslog.plist" xinstall -m 755 -d ${destroot}${prefix}/etc/LaunchDaemons/org.macports.snmptrapd/ xinstall -m 755 ${filespath}/org.macports.snmptrapd.plist \ ${destroot}${prefix}/etc/LaunchDaemons/org.macports.snmptrapd/ system "cd /Library/LaunchDaemons && ln -sf \ ${prefix}/etc/LaunchDaemons/org.macports.snmptrapd/org.macports.snmptrapd.plist" } post-activate { ui_msg "\n#### To complete the NeDi OS X installation #### 1) Setup MySQL (for new installs) ----------------------------------------------- -Configure MySQL: sudo -u mysql ${prefix}/lib/mysql5/bin/mysql_install_db -Start MySQL and set it to run at system boot: sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist -Set the root MySQL password (replace with your chosen password): sudo ${prefix}/lib/mysql5/bin/mysqladmin -u root password 2) Install PHP5 with SNMP support and Apache 2 ------------------------------------------------ sudo port install php5 +apache2 +mysql5 +snmp sudo ${prefix}/apache2/bin/apxs -a -e -n \"php5\" libphp5.so -Check to make sure the PHP variable \"mysql.default_socket\" is set to path ${prefix}/var/run/mysql5/mysqld.sock by viewing the output of this terminal command: php -i 3) Turn on Apache 2 ------------------------------------------------ -Turn off Apple's Apache 1.3 (Personal Web Sharing in System Preferences). Then execute these commands: cd ${prefix}/apache2/conf sudo cp httpd.conf.sample httpd.conf Edit the user/group variables in the Apache 2 httpd.conf to be your selected NeDi user/group. Start Apache 2 and set it to run at system boot: sudo launchctl load -w /Library/LaunchdDaemons/org.macports.apache2.plist 4) Configure NeDi, initialize database, and Login to NeDi ----------------------------------------------- -Set NeDi owner: sudo chown -R : ${nedidir}/${name}/ -Apache symlink: ln -s ${nedidir}/${name}/html/ ${prefix}/apache2/htdocs/nedi -Edit nedi.conf Backend/Authen/Device Access sections: sudo pico ${nedidir}/${name}/nedi.conf Leave nedi.conf permissions at 600 to protect your network passwords! backend MSQ dbpass authuser mysql comm (community string of your Cisco devices) (user/pass of your Cisco devices) -Initialize the NeDi database: cd ${nedidir}/${name} sudo ./nedi.pl -i When prompted for \"MySQL admin user:\" and enter 'root' and then MySQL root password. -Set Nedi MySQL user to use old style passwords mysql -u root -p mysql> SET PASSWORD FOR nedi@localhost = OLD_PASSWORD(''); -Verify the NeDi DB: mysql -u root -p mysql> use nedi; mysql> show tables; mysql> exit; -Login to the NeDi web interface: http://localhost/nedi/index.php Initial user/pass is 'admin'/'admin' 5) Discover Your Network with NeDi ----------------------------------------------- -Edit nedi.conf Device Acc. variables: sudo pico ${nedidir}/${name}/nedi.conf comm Optionally uncomment the 'cacticli' variable to create Cacti graphs within NeDi -Make any other desired changes in nedi.conf -Start NeDi data collection: cd ${nedidir}/${name} sudo -u nedi.pl -c -d (debug) -Put a command in the crontab to discover your network at regular intervals. A typical interval is 1 hour; to get accurate NeDi rrdtool graphs at NeDi's default settings you must run NeDi at 1 hour intervals. Otherwise, you must adjust NeDi's default rrdtool settings. To run NeDi every hour, the cron entry is: 0 * * * * cd ${nedidir}/${name} ; ./nedi.pl -c >> /dev/null 2>&1 6) Set NeDi to receive device alerts, syslogs, and SNMP traps. (optional) ----------------------------------------------- -To enable NeDi alerts sudo launchctl load -w /Library/LaunchDaemons/org.macports.nedimonitor.plist -To enable the NeDi syslog daemon: sudo launchctl load -w /Library/LaunchDaemons/org.macports.nedisyslog.plist -To enable the NeDi SNMP trap receiver, first use the snmpconf Unix utility to create an snmptrapd.conf file with the entry: traphandle default ${nedidir}/${name}/trap.pl Then load the startup script to run the Unix snmptrapd daemon: sudo load lauchctl load -w /Library/LaunchDaemons/org.macports.snmptrapd.plist \n" }