Network Management & Monitoring Installing Cacti ================ Notes: ------ * Commands preceded with "$" imply that you should execute the command as a general user - not as root. * Commands preceded with "#" imply that you should be working as root. * Commands with more specific command lines (e.g. "RTR-GW>" or "mysql>") imply that you are executing commands on remote equipment, or within another program. Exercises --------- 1. Installing Cacti from Source Optional -------- 2. Installing the Cacti Plugin Architecture 3. Install the Settings and thold Plugins 4. Configure the Installed Plugins 1. Installing Cacti from Source ------------------------------- Connect to your PC using ssh Be sure we have installed the support packages required for Cacti Chances are most of these packages are already installed, but it's fine to specify them again as the apt package management system will only install new items. $ sudo apt-get install apache2 php5 libapache2-mod-php5 mysql-server \ php5-mysql snmp php5-snmp rrdtool librrdp-perl librrds-perl php5-cli \ wget If installing from scratch it is 110MB of additional disk space and about 61MB to download. Remember that "\" simply means "newline" - Ask your instructor for help if you don't understand what this means. Let's become root (you can use "sudo" instead if you wish). # sudo bash # cd /var/www # wget http://www.cacti.net/downloads/cacti-0.8.7g.tar.gz If not available remotely or connection is too slow, then: # wget http://noc.ws.nsrc.org/downloads/cacti/cacti-0.8.7h.tar.gz Next extract the file: # tar xvzf cacti-0.8.7h.tar.gz Make the directory name more friendly. # mv cacti-0.8.7h cacti Set the appropriate permissions on cacti's directories for graph/log generation. # chown www-data:www-data cacti # cd cacti # chown -R www-data:www-data * Create the MySQL database ------------------------- # mysqladmin --user=root -p create cacti Enter password: Import the default cacti database # mysql -uroot -p cacti < cacti.sql Enter password: Create a MySQL username and password for Cacti (avoid using mysql root user) ---------------------------------------------------------------------------- # mysql -uroot -p mysql Enter password: mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY ''; mysql> flush privileges; mysql> quit Edit include/config.php and specify the MySQL user, password and database for your Cacti configuration. Most likely you'll only need to change the line with "$database_password" in the first section: /* make sure these values refect your actual database/host/user/password */ $database_type = "mysql"; $database_default = "cacti"; $database_hostname = "localhost"; $database_username = "cactiuser"; $database_password = ""; $database_port = "3306"; $database_ssl = false; Now add a line just under the line above and add the following: /* Edit this to point to the default URL of your Cacti install ex: if your cacti install as at http://serverip/cacti/ this would be set to /cacti/ */ $url_path = "/cacti/"; Now exit and save the file. Create a cron process for cacti: # cd /etc/cron.d # touch cacti # vi cacti MAILTO=root */5 * * * * www-data php /var/www/cacti/poller.php >/dev/null 2>/var/log/cacti/poller-error.log Now give the right permissions to the log files and create a blank log file: # cd /var/log # mkdir cacti # chown www-data:www-data cacti # cd cacti # touch poller-error.log # chown www-data:www-data poller-error.log Congratuations! The Cacti base is now installed. To complete installation return to the class presentation and follow the steps for completing the Cacti installation by going to: http://pcN.ws.nsrc.org/cacti In a web browser. Optional Exercises ================== NOTE: The exercises should _only_ be done if you have installed Cacti from source. If you install Cacti using "apt-get install cacti" these exercises will not work. 2. Install the Cacti Plugin Architecture ---------------------------------------- The Cacti Plugin Architecture is a set of patches that are made to the Cacti source that allows users to write extensions to Cacti to add additional funcationality to the product. For the complete, official documenation for install the Cacti Plugin Architecture (Cacti PA) you can view this web page: http://docs.cacti.net/manual:087:1_installation.9_pia First we need to obtain the Plugin Architecture source: # cd /usr/local/src # wget http://www.cacti.net/downloads/pia/cacti-plugin-0.8.7h-PA-v3.0.tar.gz If not available remotely or connection is too slow, then: # wget http://noc.ws.nsrc.org/downloads/cacti/cacti-plugin-0.8.7h-PA-v3.0.tar.gz Next extract the file: # tar xvzf cacti-plugin-0.8.7h-PA-v3.0.tar.gz We are going to use the patch method to install the architecture. Let's make sure that the "patch" utility is installed: # apt-get install patch Copy the "diff" file to the directory where Cacti is installed: # cd cacti-plugin-arch # cp cacti-plugin-0.8.7h-PA-v3.0.diff /var/www/cacti/. Let's see if the patch file we have will work against our installation: # cd /var/www/cacti # patch -p1 -N --dry-run < cacti-plugin-0.8.7h-PA-v3.0.diff You should not see any FAIL statements on the screen. If you do, let your instructor know. Now update Cacti with the Plugin Architecture: # patch -p1 -N < cacti-plugin-0.8.7h-PA-v3.0.diff At this point you are almost done with the initial install. We need to update a couple of files and add some changes to our backend Cacti MySQL database structure. First, let's update the MySQL database: # cd /usr/local/src/cacti-plugin-arch/ # mysql -uroot -p cacti < pa.sql Enter password: The Plugin Architecture is now installed. Now go to Cacti in your web browser: http://pcN.ws.nsrc.org/cacti Log in as the "admin" user. Go to User Management ==> select "admin" user ==> at the bottom of the page check the box in the "Realm Permissions" that says "Plugin Management" ==> Press "Save" Note on the left side of the Cacti page there is now a "Plugin Management" option under Configuration. Now it's time to install a couple of Plugins and configure them. 3. Install the Settings and thold Plugin ---------------------------------------- You can find a list of plugins here: http://docs.cacti.net/plugins But, the most current version of several of the most popular plugins are available here: http://cactiusers.org/ The Settings plugin allows you to specify additional settings for sending email in Cacti. This is very important (actually critical) if you wish to set up Cacti so that it can send email and generate tickets in a ticketing system. To install the Settings plugin we do: # cd /var/www/cacti/plugins # wget http://cactiusers.org/downloads/settings.tar.gz if not available remotely or connection is too slow, then: # wget http://noc.ws.nsrc.org/downloads/cacti/plugins/settings.tar.gz Next extract the file: # tar xvzf settings.tar.gz Remove the tar.gz file: # rm settings.tar.gz Next get the thold plugin: # wget http://cactiusers.org/downloads/thold.tar.gz if not available remotely or connection is too slow, then: # wget http://noc.ws.nsrc.org/downloads/cacti/plugins/thold.tar.gz Next extract the file: # tar xvzf thold.tar.gz Remove the tar.gz file: # rm thold.tar.gz Now we are ready to configure these two plugins to work with Cacti. The thold plugin will allow us to set thresholds that can cause triggers, such as sending an email message to a ticketing system and automatically generate a ticket when certain conditions are detected (CPU is too hot in the router, max bandwidth exceeded for 10 minutes, system load is to high on a server, etc...). 4. Configure the Settings and thold plugins ------------------------------------------- The steps to do this are done from with the Cacti web interface. As they are graphical please see the document: cacti-plugin-configuration.pdf This document is linked in to the Agenda on the wiki for your class. Ask your instructor if you have questions.