So in the process of migrating our company network architecture over the paths months, I had the chance to set up Cacti for server monitoring. I followed some documentation and articles on the net but ended up making some stupid mistakes. So, let's start with this.
The host system Cacti will be running on, is Ubuntu Server 8.04.1 with no prior modifications. I just installed all pending updates as of today of course. To reproduce this I'm running it in a VMWare virtual machine (just to make sure I'm not missing something important). The configuration of the systems that are being monitored is really not that important. As long as you can run an SNMP deamon on them.
Which brings me to the first thing I didn't understand from the start. Cacti itself is the tool that is monitoring other servers. Of course you can monitor the machine that Cacti is running on as well, but the main point is, you don't have to install it on every machine that you want to monitor.
We start off by installing MySQL-Server, as the configure process for Cacti can't do that on it's own.
CODE:
-
sudo apt-get install mysql-server -y
We input a root password and that's that with the MySQL-Server.
Now let's install Cacti itself.
CODE:
-
sudo apt-get install cacti -y
I configure it to use Apache2. And I use dbconfig-common for database configuration. Give it the MySQL-Server root password and then a password for the Cacti user. And then Cacti is installed.
Now we configure Cacti via the web interface. For the initial setup process you could just use w3m:
CODE:
-
w3m http://localhost/cacti
But sooner or later you better get something with a GUI ;)
When you get to the login screen, give it the default login admin/admin. After that you have to give the admin account a new password. Congratulations, now Cacti is set up and ready to go.
So, when you click the Graphs tab now, you'll most likely see nothing, or if you already waited for the poller to run for the first time, you see 4 (almost) empty graphs for localhost. These graphs are created by running scripts on the local host. I usually use SNMP to gather the data. So now we create a new device for the local host which is SNMP enabled. But for that, we first need to install the SNMP deamon.
CODE:
-
sudo apt-get install snmpd -y;
-
sudo vi /etc/default/snmpd
What we want to change in /etc/default/snmpd is mainly the logging options. SNMDOPTS includes "-Lsd", more suitable would be "-LS 0-5 d". The original setting will log at a debug level and pollute the logfiles. The new one will only log important messages.
At the end of SNMPDOPTS there is also a 127.0.0.1, this is the listening address. To monitor our host system this would be fine. But for additional machines, make sure to either remove it or adjust it to the correct listening address.
CODE:
-
sudo vi /etc/snmp/snmpd.conf
In this file look for lines starting with com2sec. What you're gonna want to do is, comment out the first line (the one for paranoid settings) and enable the second line, which allows read-only access.
Now restart snmpd:
CODE:
-
sudo invoke-rc.d snmpd restart
We're not ready to create our new device.
In Cacti, go to the console tab. Select "create Devices" from the list in the middle. Click Add in the upper right corner.
Give the new device a proper name and supply the ip address. If you didn't adjust the ip address in /etc/default/snmpd, then make sure to use 127.0.0.1 here.
As the host template select "Generic SNMP-enabled Host" and at the bottom of the form, select "Version 1" as the SNMP Version.
Now you can select SNMP as the Downed Device Detection as well. And that's it.
Now, let's first add a few more data sources. In the "Add data query" dropdown in the lower right, select "SNMP - Get mounted partitions" then click "Add" on the right. Repeat the process for "SNMP - Get Processor Information".
Now we're ready to create some graphs.
Make sure that all the data queries have already returned successful results. The status will say "Success" and it will signal that some items have been returned. Especially the Processor information can take a while until valid data is returned. You can click the green circle to refresh the data. When you have proper data, click "Create Graphs for this Host" at the top of the page. Add all data queries for "SNMP - Get Mounted Partitions" and "SNMP - Get Processor Information". For "SNMP - Interface Statistics", select the eth interfaces you wanna monitor, then select the graph from the dropdown on the lower right. For example "Traffic (bytes/sec, Total Bandwidth)". You can come back later to this screen to create more interface related graphs. Confirm the next screen with the "Create" button.
Now select the Devices from the menu on the left. Select your newly created device from the list, select "Place on a Tree (default Tree)" from the dropdown on the bottom right and click "Add". Confirm by clicking "yes".
Now go to the "graphs" tab again. As before, you'll most likely see nothing when looking at your new device, just wait for it ;)
That should be sufficient to get you started. Have fun.