# $Id: Portfile 111384 2013-09-19 21:52:20Z markd@macports.org $ PortSystem 1.0 name cacti version 0.8.8b revision 1 categories net license GPL-2+ maintainers markd openmaintainer platforms darwin supported_archs noarch description Cacti is a complete RRDtool network graphing solution. long_description Cacti is a complete network graphing solution designed \ to harness the power of RRDtool's data storage and \ graphing functions. homepage http://www.cacti.net master_sites http://www.cacti.net/downloads checksums md5 acb40deae073ca22e5c01a8e3ba389fb \ rmd160 a2c88961565c6b5d593b4f2603514139800c9145 depends_lib path:bin/mysql_config5:mysql5 port:rrdtool ## http://bugs.cacti.net/view.php?id=2261 patchfiles patch-cacti-r7304.diff patch-cacti-r7331.diff use_configure no build {} set cactidir ${prefix}/share/cacti post-patch { reinplace "s|/usr/local/bin/rrdtool|${prefix}/bin/rrdtool|g;s|/usr/bin/php|${prefix}/bin/php55|;s|/usr/bin/snmp|${prefix}/bin/snmp|g" ${worksrcpath}/install/index.php } post-configure { addgroup cactiuser add_users cactiuser gid=[existsgroup cactiuser] home=${cactidir} shell=/sbin/nologin realname=Cacti\ user } destroot { # Copy Cacti files xinstall -d ${destroot}${cactidir} system "cp -R ${worksrcpath}/* ${destroot}${cactidir}" xinstall -d ${destroot}${prefix}/Library/LaunchAgents/ copy ${filespath}/org.macports.${name}.plist ${destroot}${prefix}/Library/LaunchAgents/ reinplace "s|%%PREFIX%%|${prefix}|g;s|%%CACTIDIR%%|${cactidir}|g" ${destroot}${prefix}/Library/LaunchAgents/org.macports.${name}.plist xinstall -d ${destroot}${prefix}/share/examples/${name} move ${destroot}${cactidir}/include/config.php ${destroot}${prefix}/share/examples/${name}/ copy ${filespath}/nginx-cacti.conf ${destroot}${prefix}/share/examples/${name}/ reinplace "s|%%PREFIX%%|${prefix}|g" ${destroot}${prefix}/share/examples/${name}/nginx-cacti.conf copy ${filespath}/mp-cacti.conf ${destroot}${prefix}/share/examples/${name}/ reinplace "s|%%PREFIX%%|${prefix}|g" ${destroot}${prefix}/share/examples/${name}/mp-cacti.conf xinstall -d -m 755 -o cactiuser ${destroot}${prefix}/var/log/${name} destroot.keepdirs ${destroot}${prefix}/var/log/${name} } post-activate { if ![file exists ${cactidir}/include/config.php ] { copy ${prefix}/share/examples/${name}/config.php ${cactidir}/include/ } if { ! [file exists ${prefix}/etc/nginx/nginx-cacti.conf ] && [file exists ${prefix}/etc/nginx] } { copy ${prefix}/share/examples/${name}/nginx-cacti.conf ${prefix}/etc/nginx/nginx-cacti.conf } } notes " **** To complete the Cacti installation **** The full documentation may be found at http://www.cacti.net/documentation.php. 1) Install PHP and MySQL 5 (not covered). These instructions assume MySQL 5 was installed from MacPorts. 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 If not, locate the php.ini file for your version of PHP and type the path there. 2) Set Cacti permissions for the scheduled task $ sudo chown -R cactiuser:cactiuser ${cactidir}/rra/ ${cactidir}/log/ 3) prepare MySQL for Cacti. Create a cacti MySQL user and cacti database. mysql5 -u root -p (login with root password set above when prompted) mysql> GRANT ALL ON cacti.* to cacti@localhost; mysql> SET PASSWORD FOR cacti@localhost = PASSWORD(''); mysql> flush privileges; mysql> create database cacti; mysql> exit; Import the cacti database. cat ${cactidir}/cacti.sql | mysql5 -u root -p cacti (cacti is the db name) Verify the Cacti Database. mysql5 -u cacti -p cacti mysql> show tables; mysql> exit; 4) If not existing, edit ${cactidir}/include/config.php to match your MySQL information and url path. \$database_type = \"mysql\"; \$database_default = \"cacti\"; \$database_hostname = \"localhost\"; \$database_username = \"cacti\"; \$database_password = \"\"; If using socket file, remember to check php.ini as said in 1) 5) Include in your webserver If Apache, Place a symlink for Cacti inside your Apache document root. # ln -s ${cactidir} /cacti If Nginx, include appropriate config. Example is included and copied in ${prefix}/etc/nginx if existing 6) Add poller.php scheduled task. A default plist has been installed to use w php55. Adjust depending on your setup # ln -s ${prefix}/Library/LaunchAgents/org.macports.${name}.plist /Library/LaunchAgents/ # launchctl load -w /Library/LaunchAgents/org.macports.${name}.plist Poller log files are ${prefix}/var/log/cacti/poller*.log You can enable log rotation by using template for system newsyslog # cp ${prefix}/share/examples/${name}/mp-cacti.conf /private/etc/newsyslog.d/ 7) If you wish to use Cacti plugins, you must perform these additional steps. a) Download the Cacti plugin(s) you want to use and copy the unzipped directory to ${cactidir}/plugins/ For example: ${cactidir}/plugins/weathermap/ b) In the Cacti web GUI, go to Configuration -> Plugin Management and you should see your plugin(s) listed. Under 'Actions', click the the install icon to install each plugin. c) Ensure that your Cacti user has permissions to manage the plugins User Management - select a Cacti user and set Configure/Manage or View options as desired 8) Go to http://localhost/cacti/install/index.php. The default user/password is admin/admin. Select 'New Install', enter the paths for SNMP / RRDtool / PHP (adjusted to macports), and click 'Finish'. You may now use Cacti at http://localhost/cacti/index.php. 9) Create interface traffic graphs a) Devices -> Add -Fill out form for the switch or router -Make sure to include the SNMP community string of the device -Click the 'Create' button to add device b) In the devices pane, click on the newly added device to open the edit pane -Click 'Create Graphs for this Host' link -An SNMP query is made and interfaces listed; check the interface(s) to be graphed -Select a graph type from the menu in the bottom right and click the 'Create' button beside it c) Place some or all a device's graphs on a graph tree from the Devices or Graph Management section 10) If you want to use snmp on your mac, you can either use * Apple default SNMP # /usr/bin/snmpconf -g basic_setup $ sudo launchctl load -w /System/Library/LaunchDaemons/org.net-snmp.snmpd.plist * Macports $ sudo port install net-snmp +server # ${prefix}/bin/snmpconf -g basic_setup # mv snmpd.conf ${prefix}/etc/ $ sudo port load net-snmp " ## http://wotsit.thingy.com/haj/cacti/superlinks-plugin.html variant superlinks description { plugin superlinks } { distfiles-append http://wotsit.thingy.com/haj/cacti/superlinks-0.8.zip } ## http://www.network-weathermap.com/manual/latest/pages/cacti-plugin.html variant weathermap description { plugin weathermap } { depends_lib-append port:pcre port:gd distfiles-append http://www.network-weathermap.com/files/php-weathermap-0.97c.zip destroot-append { ## unpack in cactidir/plugins/weathermap ## chown -R cactiuser cactidir/plugins/weathermap/output } notes-append " As a reminder, you will need php*-pcre php*-gd corresponding to your PHP release target. You will need to enable the plugin in ${cactidir}/includes/config.php. Add the following line: \$plugins\[\] = 'weathermap'; " } ## http://forums.cacti.net/viewtopic.php?p=173542#p173542 variant advancedping description { template advancedping } { depends_run-append port:fping distfiles-append http://forums.cacti.net/download/file.php?id=18479 \ http://forums.cacti.net/download/file.php?id=18480 reinplace "s|/usr/sbin/fping|${prefix}/sbin/fping|g" ss_fping.php } ## include Mac template ? ## cpu snmp removed by apple. no but some random conditions can happen, it seems ## http://macosx.com/forums/mac-os-x-system-mac-software/273289-net-snmp-cpu-stats.html