Search This Blog

Thursday, October 17, 2013

Using Cacti on Debian Wheezy for SNMP Monitoring and Trend Analysis



Once upon a time...  well, in 1999, Tobi Oetiker released Round Robin Database Tool (rrdtool), a graphing application used with MRTG.  Software tools often come and go, but rrdtool is still around and used by many applications that automate data graphing.  MRTG was a great tool when first released (it still is), and the ecosystem of trend analysis and monitoring systems that utilize rrdtool has grown over the years.  This article discusses the deployment and configuration of Cacti, a system that looks somewhat like MRTG, but presents much more data.

The underlying protocol for many (but certainly not all) of these tools is the Simple Network Monitoring Protocol -- SNMP.  There have been three major releases,each with additional features and security, but the underlying principal is much the same among all.  A set of hierarchically-defined values -- the Management Information Base Object Identifiers or MIB OIDs -- record and report system information.  The information may be queried by a remote system, or the device itself may send information as "traps".  Systems that utilize SNMP to collect data from devices typically query a defined set of devices at predetermined intervals. 


MRTG saves its collected data in files  -- and generates graphs -- from a script that reads them.  Cacti saves its data to a MySQL database, improving performance and offering developers a platform with more easily queried data.

Debian provides three packages (one installed by default) to configure SNMP:  apt-get install snmp snmpd snmp-mibs-downloader.  SNMP provides the basic software and SNMPD provides the configurable daemon to query the MIBs.  SNMP-MIBS-DOWNLOADER provides a large set of MIBs that may be queried.  Install all three and modify the /etc/snmp/snmpd.conf file:

comment "agentAddress udp:127.0.0.1:161"
uncomment "agentAddress udp:161,udp:[::1]:161" to listen on all interfaces at udp port 161
comment "rocommunity public default     -V systemonly"
add "ro community public default"
comment "rouser     AuthOnlyUser"

This is an insecure configuration suitable only for testing.  Deployment in a production environment requires assigning authentication mechanisms available under SNMP versions 2 and 3.  However, it saves a bit of configuration for testing.


Cacti installation on Debian Wheezy is straightforward:  apt-get install apache2 mysql-server mysql-client cacti.  The apt application will get the required dependencies and install the software.


The MySQL server installation will prompt to set the database root users password.


A php warning will appear,but Debian Wheezy has applied the necessary changes.


Cacti can run on Apache or lighttpd; select Apache.


The Cacti installation on Debian Wheezy will automatically create and populate the Cacti database from several username and password prompts.


Enter the database root user password that was previously set.


Then supply and confirm a password for the Cacti database admin user.



Upon completion, log in to the web server at http://<servername>/cacti with the user name "admin" and password assigned to the cacti database user above.



Assure all the software has been installed and click Finish to complete the installation.


At first login, you will be prompted again for the "admin" and the password, then prompted to change the password.  You may do so, or re-enter the original password.



The application is ready for configuration.  Select Devices in the left frame to begin.  The host "localhost" is included at installation but the name may be changed to conform with the networks DNS addresses.  Cacti supports SNMP versions 1, 2 and 3 and provides fields to authenticate to the host as needed.


The default Linux localhost graph and data templates at installation query Linux Memory Usage, UNIX Load Average, Logged in users, Processes and Mounted Partitions.  If the Cacti does not return successful queries, check the server's /etc/snmp/snmpd.conf configuration.  If correct, clicking the "Verbose Query" link will return Items and Rows.



It may take some experimentation to determine which Templates and Data Queries are supported by the installed systems, but SNMP queries tend to be well supported.  Upon selecting and saving, click the Create Graphs link at the top of the page.  This takes you to another page upon which graphs may be selected for inclusion in reporting for each host.


Some fields, such as partition /dev and traffic on the loopback interface, may not be useful and may be deselected.  Click Create upon finalizing selections.


Before finalizing the hosts graphs, you may be prompted to change the default color for the output.  Click Create to save the graph definitions.


A brief report of successes and failures (if any) is presented upon completion.



Select Graph Trees in the left frame to define the order and grouping of presentation.  There are several options, but they will not be reviewed in this article.


There are only two hosts configured: pit-monitor.pittsburgh.mydomain.com, the former "localhost" and san.pittsburgh.mydomain.com.  the Monitoring server has already been added to the Graph Tree, so it is time to add the SAN server.



Change the Tree Item Type to Host and select the desired host from the drop-down menu.  Use the Graph Template and Hourly (1 Minute Average) options and click Create.


You may manually or automatically sort hosts.



Click the Graphs tab and let the graphing begin.



Over time, even a laptop with virtual machines that is periodically shut down will accumulate information, albeit with gaps.





Cacti is easily deployed and configured, has relatively low system resource requirements and provides graphical trending information useful for identifying system bottlenecks and spare capacity.  Disk, CPU, Memory and network available from a convenient web-based console.  Identifying bottlenecks is beyond the scope of this article.

Cacti is not an alerting system.  Experienced systems engineers will be able to identify future capacity problems, but identifying and reporting systems failures and disasters is not what Cacti was designed to do.  But its simplicity of deployment and configuration along with its range of capabilities recommends this as one of the tools systems engineers can incorporate into a comprehensive systems monitoring program.

No comments :

Post a Comment