# $Id: Portfile 125738 2014-09-25 14:43:03Z mf2k@macports.org $ PortSystem 1.0 name nedi version 1.0.7 revision 3 categories net maintainers nomaintainer 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://www.nedi.ch/pub extract.mkdir yes extract.suffix .tgz checksums md5 7eb73bfc687c8efbd833b1f8f3fbd749 \ rmd160 3b7895f80697f6f4a0b53e348874a8c4044e6ed4 depends_lib port:perl5.12 \ path:bin/mysql_config5:mysql5 \ port:p5.12-net-snmp \ port:p5.12-net-ssh-perl \ port:p5.12-net-telnet \ port:p5.12-net-telnet-cisco \ port:p5.12-libwww-perl \ port:p5.12-algorithm-diff \ port:p5.12-dbi \ port:p5.12-dbd-mysql \ port:rrdtool \ port:fping # Set some useful variables set nedidir ${prefix}/share/${name} set rrdbin ${prefix}/bin/rrdtool set rrdfiles ${nedidir}/rrd set fpingpath ${prefix}/sbin set cacticlidir ${prefix}/share/cacti/cli startupitem.create yes startupitem.name nedimonitor startupitem.executable ${nedidir}/moni.pl use_configure no build {} destroot { file mkdir ${destroot}${nedidir} system "cp -R ${worksrcpath}/* ${destroot}${nedidir}" } post-destroot { # Fix general paths eval reinplace "s|/usr/bin/perl|${prefix}/bin/perl5.12|g" \ [glob ${destroot}${nedidir}/*.pl] \ [glob ${destroot}${nedidir}/html/inc/*.pl] \ [glob ${destroot}${nedidir}/contrib/*.pl] reinplace "s|netstat|/usr/sbin/netstat|g" \ ${destroot}${nedidir}/inc/libmisc.pm reinplace "s|/etc/nedi.conf|${nedidir}/nedi.conf|g" \ ${destroot}${nedidir}/html/inc/libmisc.php # Fix rrdcmd location in nedi.conf reinplace "s|rrdtool|${rrdbin}|g" \ ${destroot}${nedidir}/nedi.conf # Fix fping path reinplace "s|/usr/local/sbin|${fpingpath}|g" \ ${destroot}${nedidir}/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}/nedi.conf # Create directory for rrd files xinstall -m 755 -d ${destroot}${rrdfiles} # Keep these empty directories destroot.keepdirs \ ${destroot}${nedidir}/db/cfg \ ${destroot}${nedidir}/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}/nedi.conf \ ${destroot}${nedidir}/nedi.conf.sample system "chmod 600 ${destroot}${nedidir}/nedi.conf.sample" } pre-install { # MacPorts can create only one startupitem per portfile. So copy nedisyslog.plist # from filespath and link it 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" } notes \ "**** 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 MacPorts Apache ------------------------------------------------ sudo port install php5 +apache2 +mysql5 +snmp sudo ${prefix}/apache2/bin/apxs -a -e -n \"php5\" libphp5.so NOTE: 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 MacPorts Apache ------------------------------------------------ -Turn off Apple's built-in Apache (Personal Web Sharing in System Preferences). Then execute these commands: cd ${prefix}/apache2/conf sudo cp httpd.conf.sample httpd.conf -Edit your httpd.conf Change the user/group variables in the Apache httpd.conf to be the Unix user/group that you'll use to run the NeDi executable Add an alias statement: Alias /nedi \"${prefix}/share/nedi/html\" -Start Apache and set it to run at system boot: sudo launchctl load -w /Library/LaunchdDaemons/org.macports.apache2.plist 4) Configure NeDi, initialize NeDi database, and Login to NeDi ----------------------------------------------- -Set NeDi owner: sudo chown -R : ${nedidir} -Edit nedi.conf Backend/Authen/Device Access sections: sudo pico ${nedidir}/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} sudo ./nedi.pl -i When prompted for \"MySQL admin user:\" and enter 'root' and then MySQL root 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 Initial user/pass is 'admin'/'admin' 5) Discover Your Network with NeDi ----------------------------------------------- -Edit nedi.conf Device Acc. variables: sudo pico ${nedidir}/nedi.conf comm -Make any other desired changes in nedi.conf -Start NeDi data collection: cd ${nedidir} sudo -u nedi.pl -pr (options shown set CDP and routing tables for discovery) -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} ; ./nedi.pl -pr >> /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"