Dockerhub Repo: https://hub.docker.com/r/MoellerDi/cacti/
Cacti is a complete network graphing solution designed to harness the power of RRDTool's data storage and graphing functionality. Cacti provides following features:
- remote and local data collectors
- network discovery
- device management automation
- graph templating
- custom data acquisition methods
- user, group and domain management
- C3 level security settings for local accounts
- strong password hashing
- forced regular password changes, complexity, and history
- account lockout support
All of this is wrapped in an intuitive, easy to use interface that makes sense for both LAN-sized installations and complex networks with thousands of devices. Developed in the early 2000's by Ian Berry as a high school project, it has been used by thousands of companies and enthusiasts to monitor and manage their Networks and Data Centers. More information around this opensource product can be located at the following website.
This container contains Cacti v1+ and is not compatible with older version of cacti. It does rely on an external MySQL database that can be already configured before initial startup or having the container itself perform the setup and initialization. If you want this container to perform these steps for you, you will need to pass the root password for mysql login or startup will fail. This container automatically incorporates Cacti Spine's multithreaded poller.
The following ports are important and used by Cacti
Port | Notes |
---|---|
80 | HTTP GUI Port |
443 | HTTPS GUI Port |
It is recommended to allow at least one of the above ports for access to the monitoring system. This is translated by the -p hook. For example
docker run -p 80:80 -p 443:443
The main cacti poller settings, these are required for single cacti and multi cacti host installations.
Environment Variable | Function |
---|---|
DB_NAME | The MySQL database name, this is used for both cacti settings and spine poller configurations. |
DB_USER | MySQL database user cacti should use. Both cacti and spine poller will share these settings. |
DB_PASS | MySQL database password assigned to DB_USER Both cacti and spine poller will share these settings. |
DB_HOST | The IP address, FQDN/hostname, or linked container name that cacti would use as a database. |
DB_PORT | What TCP port is the MySQL database listening on, by default its 3306. |
DB_ROOT_PASS | This is only needed if the INITIALIZE_DB is set to 1. This is required if you want the cacti container to setup remote MySQL user accounts and Databases for use. |
INITIALIZE_DB | Can be 0 for false or 1 for true. If true the container will require DB_ROOT_PASS to the target database. The container will attempt to create usernames/passwords and Databases required on the remote system for Cacti to funtion. |
TZ | TimeZone, please select a format Centos understands, a list can be generated by running ls /usr/share/zoneinfo . |
BACKUP_RETENTION | Number of backup files to keep. |
BACKUP_TIME | How often Cacti should back itself up in minutes - currently not working |
REMOTE_POLLER | Can be 0 for false (default) or 1 for true. |
PHP_MEMORY_LIMIT | PHP memory limit adjust, by defaults its 128M |
PHP_MAX_EXECUTION_TIME | PHP max execution time adjust, by defaults its 30 second |
Remote cacti poller containers require the following, the major differance here is the inclusion of RDB (remote database) variables which should be pointed at the master cacti installation settings.
Environment Variable | Function |
---|---|
DB_NAME | The MySQL database, this is used for both cacti settings and spine poller configurations. |
DB_USER | MySQL database user cacti should use. Both cacti and spine poller will share these settings. |
DB_PASS | MySQL database password assigned to DB_USER Both cacti and spine poller will share these settings. |
DB_HOST | The IP address, FQDN/hostname, or linked container name that cacti would use as a database. |
DB_PORT | What TCP port is the MySQL database listening on, by default its 3306. |
INITIALIZE_DB | Can be 0 for false or 1 for true. If true the container will require DB_ROOT_PASS to the target database. The container will attempt to create usernames/passwords and Databases required on the remote system for Cacti to funtion. |
TZ | TimeZone, please select a format Centos understands, a list can be generated by running ls /usr/share/zoneinfo . |
BACKUP_RETENTION | Number of backup files to keep |
BACKUP_TIME | How often Cacti should back itself up in minutes - currently not working |
REMOTE_POLLER | Can be 0 for false (default) or 1 for true. If true the container is setup as a remote poller. |
RDB_NAME | The master Cacti instance MySQL database name, this is used for both cacti settings and spine poller configurations. |
RDB_USER | MySQL database user used by the master Cacti container should use. |
RDB_PASS | MySQL database password assigned to RDB_USER that is used by the master Cacti container. |
RDB_HOST | The IP address, FQDN/hostname, or linked container name that the master Cacti instance uses |
RDB_PORT | What TCP port is the MySQL database listening on, by default its 3306. |
Included is a backup script that will backup cacti (including settings/plugins), rrd files, and spine. This is accomplished by taking a complete copy of the root spine and cacti directory and performing a MySQL dump of the cacti database which stores all the settings and device information. To manually perform a backup, run the following exec commands:
docker exec <docker image ID or name> ./backup.sh
This will store compressed backups in a tar.gz format within the cacti docker container under /backups directory. Its recommended to map this directory using volumes so data is persistent. By default it only stores 7 most recent backups and will automatically delete older ones, to change this value update BACKUP_RETENTION
environmental variable with the number of backups you wish to store.
To restore from an existing backup, run the following docker exec command with the backup file location as an argument.
docker exec <docker image ID or name> ./restore.sh /backups/<filename>
To get a list of backups, the following command should display them:
docker exec <docker image ID or name> ls /backups
You can now update the Cacti/Spine version of this container using the included script. By default this will update to the latest version.
docker exec <docker image ID or name> ./upgrade.sh
If you want to specify a specific version please update the /upgrade.sh
values.
#!/bin/bash
# script to upgrade a cacti instance to latest, if you want a specific version please update the following download links
cacti_download_url=http://www.cacti.net/downloads/cacti-latest.tar.gz
spine_download_url=http://www.cacti.net/downloads/spine/cacti-spine-latest.tar.gz
With the recent update to version 1+, Cacti has introduced the ability to have remote polling servers. This allows us to have one centrally located UI and information system while scaling out multiple datacenters or locations. Each instance, master or remote poller, requires its own MySQL based database. The pollers also have an addition requirement to access the Cacti master's database with read/write access.
Some docker-compose examples can be found in the following readme
There are a few customizations you can do if you are building the container locally. During the build process Plugins and Device Templates can be added to folders where at startup, scripts will import and install.
Dropping device templates in the /templates/
folder using the following structure:
├── templates
│ ├── template_name.xml
│ ├── resource
│ │ └── script_queries
│ │ └── ...
│ │ └── script_server
│ │ └── ...
│ │ └── snmp_queries
│ │ └── ...
│ ├── scripts
│ │ └── ...
At buld/first boot you will see some log messages that they were imported to the underlying Cacti system
2017-03-24_19:22 [New Install] Installing supporting template files.
2017-03-24_19:22 [New Install] Installing template file /templates/cacti_host_template_juniper_networks.xml
To have plugins automatically loaded on boot, simply have the uncompressed plugin in the plugins
folder within the main directory. Upon build/run, the startup script will automatically install them to the appropriate directory. Please understand that you will need to enable any plugins via Cacti GUI for them to become active.
To add plugins after the container is built, for example if pulling directly form dockerhub, mount the /cacti/plugins
directory using docker volumes.
Settings can be passed through to cacti at initial install by placing the SQL changes in the form of filename.sql under the settings folder. start.sh will automatically merge all *.sql files during install. For example the folling is there to enable spine by default:
--
-- Enable spine poller from docker installation
--
REPLACE INTO `%DB_NAME%`.`settings` (`name`, `value`) VALUES('path_spine', '/spine/bin/spine');
REPLACE INTO `%DB_NAME%`.`settings` (`name`, `value`) VALUES('path_spine_config', '/spine/etc/spine.conf');
REPLACE INTO `%DB_NAME%`.`settings` (`name`, `value`) VALUES('poller_type', '2');