Cacti

Cacti is a web-based system monitoring and graphing solution.

Installation

To use cacti, you need a working web server (e.g. Nginx or Apache HTTP Server) setup, that forwards requests to an application server (e.g. uWSGI or php-fpm).

Next, install cacti and configure MariaDB, if a local MySQL server will be used.

Note: Cacti should only be accessed over TLS (unless accessed directly from the machine running it), as it otherwise exposes passwords and user data.

Configuration

To serve cacti top level instead of under /cacti/ (i.e. https://example.tld/ instead of https://example.tld/cacti/) use the $url_path configuration option:

/etc/webapps/cacti/config.php
$url_path = '/';

PHP

Note: Due to an unresolved upstream issue, cacti is unable to stay in its own PHP environment . Required PHP modules have to be activated in the system's global /etc/php/php.ini.

Cacti requires the following PHP extensions to be enabled:

/etc/php/php.ini
extension=gd
extension=gettext
extension=gmp
extension=ldap
extension=mysqli
extension=pdo_mysql
extension=snmp
extension=sockets

Cacti needs certain directories and executables in PHP's open_basedir to function properly:

/tmp/:/usr/share/webapps/cacti:/etc/webapps/cacti:/var/cache/cacti:/var/lib/cacti:/var/log/cacti:/proc/meminfo:/usr/bin/rrdtool:/usr/bin/snmpget:/usr/bin/snmpwalk:/usr/bin/snmpbulkwalk:/usr/bin/snmpgetnext:/usr/bin/snmptrap:/usr/bin/sendmail:/usr/bin/php:/usr/bin/spine:/usr/share/fonts/TTF/

Cacti requires date.timezone to be set in /etc/php/php.ini. Check upstream documentation and time zone for reference.

SNMP

If it is necessary for cacti to monitor the machine that it is running on, configure snmpd.

MySQL

Cacti needs its own database in which to store its data, and a database user account to access the database.

Run the following commands as root:

Alternatively, use PhpMyAdmin to achieve the same results:

  • Create an empty database called .
  • Import the file into the database.
  • Create a user , and grant this user privileges to access the database.

Add the database details:

/etc/webapps/cacti/config.php
$database_type = "mysql";
$database_default = "cactidb";
$database_username = "cactiuser";
$database_password = "some_password";

Hosting

Note: Cacti needs to be run as its own user and group (i.e. cacti). It is using /etc/webapps/cacti, /var/lib/cacti, /var/log/cacti and /run/cacti for configurations, caches, logs and (potentially) sockets (respectively)!

Apache

The apache web server can serve dynamic web applications with the help of modules, such as mod_proxy_fcgi or mod_proxy_uwsgi.

php-fpm

Install and configure Apache HTTP Server with php-fpm. Use a pool run as user and group . The socket file should be accessible by the user and/or group, but needs to be located below .

Include the following configuration in your Apache HTTP Server configuration (i.e. ) and restart the web server:

The file also controls access. Configure or remove it.

Nginx

Nginx can proxy application servers such as and uWSGI, that run a dynamic web application. The following examples describe a folder based setup over a non-default port (for simplicity).

Tip: For server entry management in nginx have a look at Nginx#Managing server entries.
Note: Postfixadmin ships a configuration for uWSGI.

php-fpm

Install php-fpm. Setup nginx with php-fpm and use a pool run as user and group . The socket file should be accessible by the user and/or group, but needs to be located below . This can be achieved by adding the following lines to the php-fpm configuration and restarting it.

Add the following configuration for nginx and restart it.

uWSGI

Install , create a per-application socket for uWSGI (see UWSGI#Accessibility of uWSGI socket for reference) and activate the unit.

Add the following configuration for nginx and restart nginx.

Setup

Open a browser and go to http://your_server/cacti/. You should be welcomed with the cacti installer.

  • Login with username "admin" and password "admin".
  • Change the password as requested, click Save.
  • Follow the remaining install steps and recommendations.
  • (Optional) If you chose to install spine, follow these instructions to set it up.
    • Click on Settings, on the left panel of the Console tab.
    • Select the Poller tab.
    • Change Poller Type to spine.
    • Adjust any other settings on the page as desired, then click Save.
    • Select the Paths tab.
    • Set Spine Poller File Path to and click Save.

Tips and tricks

Spine

Optionally, install , a faster poller for cacti, from the AUR. configure it with database access details:

Systemd

Tip: The configuration for uWSGI integrates a cron based approach, that makes a separate systemd unit not necessary.

Cacti uses a poller to collect data, so create a Systemd service to run , and a timer to run the service every 5 minutes:

Tip: journalctl can be used to watch for the poller's log messages, which will resemble the following:
Sep 27 15:50:00 hoom php[4072]: OK u:0.00 s:0.01 r:0.35
Sep 27 15:50:00 hoom php[4072]: OK u:0.00 s:0.01 r:0.38
Sep 27 15:50:00 hoom php[4072]: OK u:0.00 s:0.01 r:0.40
Sep 27 15:50:01 hoom php[4072]: 09/27/2015 03:50:01 PM - SYSTEM STATS: Time:0.6176 Method:cmd.php Processes:1 Threads:N/A Hosts:5 HostsPerProcess:5 DataSources:169 RRDsProcessed:15
gollark: Actually it doesn't log running disks at all, hmm. Please remind me when I'm done refactoring the updater.
gollark: Yes, thank you for the idea.
gollark: I patch 94% of exploits I know about! And no, not presently.
gollark: Yes, potatOS is security™, sometimes.
gollark: I really do, though, need a better signatures/trust system, maybe with actual revocation capability.

See also

This article is issued from Archlinux. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.