| 1 | Network Management & Monitoring |
|---|
| 2 | |
|---|
| 3 | Installing Cacti |
|---|
| 4 | ================ |
|---|
| 5 | |
|---|
| 6 | Notes: |
|---|
| 7 | ------ |
|---|
| 8 | * Commands preceded with "$" imply that you should execute the command as |
|---|
| 9 | a general user - not as root. |
|---|
| 10 | * Commands preceded with "#" imply that you should be working as root. |
|---|
| 11 | * Commands with more specific command lines (e.g. "RTR-GW>" or "mysql>") |
|---|
| 12 | imply that you are executing commands on remote equipment, or within |
|---|
| 13 | another program. |
|---|
| 14 | |
|---|
| 15 | Exercises |
|---|
| 16 | --------- |
|---|
| 17 | |
|---|
| 18 | 1. Installing Cacti from Source |
|---|
| 19 | |
|---|
| 20 | Optional |
|---|
| 21 | -------- |
|---|
| 22 | |
|---|
| 23 | 2. Installing the Cacti Plugin Architecture |
|---|
| 24 | 3. Install the Settings and thold Plugins |
|---|
| 25 | 4. Configure the Installed Plugins |
|---|
| 26 | |
|---|
| 27 | 1. Installing Cacti from Source |
|---|
| 28 | ------------------------------- |
|---|
| 29 | |
|---|
| 30 | Connect to your PC using ssh |
|---|
| 31 | |
|---|
| 32 | Be sure we have installed the support packages required for Cacti |
|---|
| 33 | |
|---|
| 34 | Chances are most of these packages are already installed, but it's fine to |
|---|
| 35 | specify them again as the apt package management system will only install |
|---|
| 36 | new items. |
|---|
| 37 | |
|---|
| 38 | $ sudo apt-get install apache2 php5 libapache2-mod-php5 mysql-server \ |
|---|
| 39 | php5-mysql snmp php5-snmp rrdtool librrdp-perl librrds-perl php5-cli \ |
|---|
| 40 | wget |
|---|
| 41 | |
|---|
| 42 | If installing from scratch it is 110MB of additional disk space and about 61MB |
|---|
| 43 | to download. Remember that "\" simply means "newline" - Ask your instructor for help if |
|---|
| 44 | you don't understand what this means. |
|---|
| 45 | |
|---|
| 46 | Let's become root (you can use "sudo" instead if you wish). |
|---|
| 47 | |
|---|
| 48 | # sudo bash |
|---|
| 49 | # cd /var/www |
|---|
| 50 | # wget http://www.cacti.net/downloads/cacti-0.8.7g.tar.gz |
|---|
| 51 | |
|---|
| 52 | If not available remotely or connection is too slow, then: |
|---|
| 53 | |
|---|
| 54 | # wget http://noc.ws.nsrc.org/downloads/cacti/cacti-0.8.7h.tar.gz |
|---|
| 55 | |
|---|
| 56 | Next extract the file: |
|---|
| 57 | |
|---|
| 58 | # tar xvzf cacti-0.8.7h.tar.gz |
|---|
| 59 | |
|---|
| 60 | Make the directory name more friendly. |
|---|
| 61 | |
|---|
| 62 | # mv cacti-0.8.7h cacti |
|---|
| 63 | |
|---|
| 64 | Set the appropriate permissions on cacti's directories for graph/log generation. |
|---|
| 65 | |
|---|
| 66 | # chown www-data:www-data cacti |
|---|
| 67 | # cd cacti |
|---|
| 68 | # chown -R www-data:www-data * |
|---|
| 69 | |
|---|
| 70 | Create the MySQL database |
|---|
| 71 | ------------------------- |
|---|
| 72 | |
|---|
| 73 | # mysqladmin --user=root -p create cacti |
|---|
| 74 | Enter password: <class password> |
|---|
| 75 | |
|---|
| 76 | Import the default cacti database |
|---|
| 77 | |
|---|
| 78 | # mysql -uroot -p cacti < cacti.sql |
|---|
| 79 | Enter password: <class password> |
|---|
| 80 | |
|---|
| 81 | Create a MySQL username and password for Cacti (avoid using mysql root user) |
|---|
| 82 | ---------------------------------------------------------------------------- |
|---|
| 83 | |
|---|
| 84 | # mysql -uroot -p mysql |
|---|
| 85 | Enter password: <class password> |
|---|
| 86 | |
|---|
| 87 | mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY '<class password>'; |
|---|
| 88 | |
|---|
| 89 | mysql> flush privileges; |
|---|
| 90 | mysql> quit |
|---|
| 91 | |
|---|
| 92 | Edit include/config.php and specify the MySQL user, password and database for your Cacti |
|---|
| 93 | configuration. Most likely you'll only need to change the line with "$database_password" |
|---|
| 94 | in the first section: |
|---|
| 95 | |
|---|
| 96 | /* make sure these values refect your actual database/host/user/password */ |
|---|
| 97 | $database_type = "mysql"; |
|---|
| 98 | $database_default = "cacti"; |
|---|
| 99 | $database_hostname = "localhost"; |
|---|
| 100 | $database_username = "cactiuser"; |
|---|
| 101 | $database_password = "<class password>"; |
|---|
| 102 | $database_port = "3306"; |
|---|
| 103 | $database_ssl = false; |
|---|
| 104 | |
|---|
| 105 | Now add a line just under the line above and add the following: |
|---|
| 106 | |
|---|
| 107 | /* |
|---|
| 108 | Edit this to point to the default URL of your Cacti install |
|---|
| 109 | ex: if your cacti install as at http://serverip/cacti/ this |
|---|
| 110 | would be set to /cacti/ |
|---|
| 111 | */ |
|---|
| 112 | $url_path = "/cacti/"; |
|---|
| 113 | |
|---|
| 114 | Now exit and save the file. |
|---|
| 115 | |
|---|
| 116 | Create a cron process for cacti: |
|---|
| 117 | |
|---|
| 118 | # cd /etc/cron.d |
|---|
| 119 | # touch cacti |
|---|
| 120 | # vi cacti |
|---|
| 121 | |
|---|
| 122 | MAILTO=root |
|---|
| 123 | */5 * * * * www-data php /var/www/cacti/poller.php >/dev/null 2>/var/log/cacti/poller-error.log |
|---|
| 124 | |
|---|
| 125 | Now give the right permissions to the log files and create a blank log file: |
|---|
| 126 | |
|---|
| 127 | # cd /var/log |
|---|
| 128 | # mkdir cacti |
|---|
| 129 | # chown www-data:www-data cacti |
|---|
| 130 | # cd cacti |
|---|
| 131 | # touch poller-error.log |
|---|
| 132 | # chown www-data:www-data poller-error.log |
|---|
| 133 | |
|---|
| 134 | Congratuations! The Cacti base is now installed. To complete installation return to the class |
|---|
| 135 | presentation and follow the steps for completing the Cacti installation by going to: |
|---|
| 136 | |
|---|
| 137 | http://pcN.ws.nsrc.org/cacti |
|---|
| 138 | |
|---|
| 139 | In a web browser. |
|---|
| 140 | |
|---|
| 141 | |
|---|
| 142 | |
|---|
| 143 | Optional Exercises |
|---|
| 144 | ================== |
|---|
| 145 | |
|---|
| 146 | NOTE: The exercises should _only_ be done if you have installed Cacti from source. If you install |
|---|
| 147 | Cacti using "apt-get install cacti" these exercises will not work. |
|---|
| 148 | |
|---|
| 149 | |
|---|
| 150 | 2. Install the Cacti Plugin Architecture |
|---|
| 151 | ---------------------------------------- |
|---|
| 152 | |
|---|
| 153 | The Cacti Plugin Architecture is a set of patches that are made to the Cacti source that allows |
|---|
| 154 | users to write extensions to Cacti to add additional funcationality to the product. For the |
|---|
| 155 | complete, official documenation for install the Cacti Plugin Architecture (Cacti PA) you can view |
|---|
| 156 | this web page: |
|---|
| 157 | |
|---|
| 158 | http://docs.cacti.net/manual:087:1_installation.9_pia |
|---|
| 159 | |
|---|
| 160 | First we need to obtain the Plugin Architecture source: |
|---|
| 161 | |
|---|
| 162 | # cd /usr/local/src |
|---|
| 163 | # wget http://www.cacti.net/downloads/pia/cacti-plugin-0.8.7h-PA-v3.0.tar.gz |
|---|
| 164 | |
|---|
| 165 | If not available remotely or connection is too slow, then: |
|---|
| 166 | |
|---|
| 167 | # wget http://noc.ws.nsrc.org/downloads/cacti/cacti-plugin-0.8.7h-PA-v3.0.tar.gz |
|---|
| 168 | |
|---|
| 169 | Next extract the file: |
|---|
| 170 | |
|---|
| 171 | # tar xvzf cacti-plugin-0.8.7h-PA-v3.0.tar.gz |
|---|
| 172 | |
|---|
| 173 | We are going to use the patch method to install the architecture. Let's make sure that the "patch" |
|---|
| 174 | utility is installed: |
|---|
| 175 | |
|---|
| 176 | # apt-get install patch |
|---|
| 177 | |
|---|
| 178 | Copy the "diff" file to the directory where Cacti is installed: |
|---|
| 179 | |
|---|
| 180 | # cd cacti-plugin-arch |
|---|
| 181 | # cp cacti-plugin-0.8.7h-PA-v3.0.diff /var/www/cacti/. |
|---|
| 182 | |
|---|
| 183 | Let's see if the patch file we have will work against our installation: |
|---|
| 184 | |
|---|
| 185 | # cd /var/www/cacti |
|---|
| 186 | # patch -p1 -N --dry-run < cacti-plugin-0.8.7h-PA-v3.0.diff |
|---|
| 187 | |
|---|
| 188 | You should not see any FAIL statements on the screen. If you do, let your instructor know. |
|---|
| 189 | |
|---|
| 190 | Now update Cacti with the Plugin Architecture: |
|---|
| 191 | |
|---|
| 192 | # patch -p1 -N < cacti-plugin-0.8.7h-PA-v3.0.diff |
|---|
| 193 | |
|---|
| 194 | At this point you are almost done with the initial install. We need to update a couple of files |
|---|
| 195 | and add some changes to our backend Cacti MySQL database structure. |
|---|
| 196 | |
|---|
| 197 | First, let's update the MySQL database: |
|---|
| 198 | |
|---|
| 199 | # cd /usr/local/src/cacti-plugin-arch/ |
|---|
| 200 | # mysql -uroot -p cacti < pa.sql |
|---|
| 201 | Enter password: <class password> |
|---|
| 202 | |
|---|
| 203 | The Plugin Architecture is now installed. |
|---|
| 204 | |
|---|
| 205 | Now go to Cacti in your web browser: |
|---|
| 206 | |
|---|
| 207 | http://pcN.ws.nsrc.org/cacti |
|---|
| 208 | |
|---|
| 209 | Log in as the "admin" user. |
|---|
| 210 | |
|---|
| 211 | Go to User Management |
|---|
| 212 | ==> select "admin" user |
|---|
| 213 | ==> at the bottom of the page check the box in the "Realm Permissions" that says |
|---|
| 214 | "Plugin Management" |
|---|
| 215 | ==> Press "Save" |
|---|
| 216 | |
|---|
| 217 | Note on the left side of the Cacti page there is now a "Plugin Management" option under |
|---|
| 218 | Configuration. |
|---|
| 219 | |
|---|
| 220 | Now it's time to install a couple of Plugins and configure them. |
|---|
| 221 | |
|---|
| 222 | |
|---|
| 223 | 3. Install the Settings and thold Plugin |
|---|
| 224 | ---------------------------------------- |
|---|
| 225 | |
|---|
| 226 | You can find a list of plugins here: |
|---|
| 227 | |
|---|
| 228 | http://docs.cacti.net/plugins |
|---|
| 229 | |
|---|
| 230 | But, the most current version of several of the most popular plugins are available here: |
|---|
| 231 | |
|---|
| 232 | http://cactiusers.org/ |
|---|
| 233 | |
|---|
| 234 | The Settings plugin allows you to specify additional settings for sending email in Cacti. |
|---|
| 235 | This is very important (actually critical) if you wish to set up Cacti so that it can |
|---|
| 236 | send email and generate tickets in a ticketing system. |
|---|
| 237 | |
|---|
| 238 | To install the Settings plugin we do: |
|---|
| 239 | |
|---|
| 240 | # cd /var/www/cacti/plugins |
|---|
| 241 | # wget http://cactiusers.org/downloads/settings.tar.gz |
|---|
| 242 | |
|---|
| 243 | if not available remotely or connection is too slow, then: |
|---|
| 244 | |
|---|
| 245 | # wget http://noc.ws.nsrc.org/downloads/cacti/plugins/settings.tar.gz |
|---|
| 246 | |
|---|
| 247 | Next extract the file: |
|---|
| 248 | |
|---|
| 249 | # tar xvzf settings.tar.gz |
|---|
| 250 | |
|---|
| 251 | Remove the tar.gz file: |
|---|
| 252 | |
|---|
| 253 | # rm settings.tar.gz |
|---|
| 254 | |
|---|
| 255 | Next get the thold plugin: |
|---|
| 256 | |
|---|
| 257 | # wget http://cactiusers.org/downloads/thold.tar.gz |
|---|
| 258 | |
|---|
| 259 | if not available remotely or connection is too slow, then: |
|---|
| 260 | |
|---|
| 261 | # wget http://noc.ws.nsrc.org/downloads/cacti/plugins/thold.tar.gz |
|---|
| 262 | |
|---|
| 263 | Next extract the file: |
|---|
| 264 | |
|---|
| 265 | # tar xvzf thold.tar.gz |
|---|
| 266 | |
|---|
| 267 | Remove the tar.gz file: |
|---|
| 268 | |
|---|
| 269 | # rm thold.tar.gz |
|---|
| 270 | |
|---|
| 271 | Now we are ready to configure these two plugins to work with Cacti. The thold plugin will allow |
|---|
| 272 | us to set thresholds that can cause triggers, such as sending an email message to a ticketing |
|---|
| 273 | system and automatically generate a ticket when certain conditions are detected (CPU is too hot |
|---|
| 274 | in the router, max bandwidth exceeded for 10 minutes, system load is to high on a server, etc...). |
|---|
| 275 | |
|---|
| 276 | |
|---|
| 277 | 4. Configure the Settings and thold plugins |
|---|
| 278 | ------------------------------------------- |
|---|
| 279 | |
|---|
| 280 | The steps to do this are done from with the Cacti web interface. As they are graphical please |
|---|
| 281 | see the document: |
|---|
| 282 | |
|---|
| 283 | cacti-plugin-configuration.pdf |
|---|
| 284 | |
|---|
| 285 | This document is linked in to the Agenda on the wiki for your class. Ask your instructor if you |
|---|
| 286 | have questions. |
|---|