├── Dockerfile ├── LICENSE ├── README.md ├── circle.yml ├── container-files ├── config.php ├── config │ └── init │ │ └── start.sh ├── etc │ ├── import-cron.conf │ └── nginx │ │ └── hosts.d │ │ └── cacti.conf ├── global.php └── spine.conf └── docker-compose.yaml /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM million12/nginx-php:php70 2 | MAINTAINER Przemyslaw Ozgo 3 | 4 | ENV DB_USER=user \ 5 | DB_PASS=password \ 6 | DB_ADDRESS=127.0.0.1 \ 7 | CACTI_VERSION=1.1.12 \ 8 | TIMEZONE=UTC 9 | 10 | RUN \ 11 | rpm --rebuilddb && yum clean all && \ 12 | yum install -y rrdtool net-snmp net-snmp-devel net-snmp-utils mariadb-devel cronie dos2unix autoconf libtool libtool-ltdl-devel help2man && \ 13 | curl -L -o /tmp/cacti-${CACTI_VERSION}.tgz https://github.com/Cacti/cacti/archive/release/1.1.12.tar.gz && \ 14 | mkdir -p /cacti && tar zxvf /tmp/cacti-${CACTI_VERSION}.tgz -C /cacti --strip-components=1 && \ 15 | rm -rf /tmp/cacti-${CACTI_VERSION}.tgz && \ 16 | curl -L -o /tmp/spine-${CACTI_VERSION}.tgz https://github.com/Cacti/spine/archive/release/${CACTI_VERSION}.tar.gz && \ 17 | mkdir -p /tmp/spine && \ 18 | tar zxvf /tmp/spine-${CACTI_VERSION}.tgz -C /tmp/spine --strip-components=1 && \ 19 | rm -f /tmp/spine-${CACTI_VERSION}.tgz && \ 20 | cd /tmp/spine/ && ./bootstrap && ./configure --with-reentrant && make && make install && \ 21 | chown root:root /usr/local/spine/bin/spine && \ 22 | chmod +s /usr/local/spine/bin/spine && \ 23 | rm -rf /tmp/spine && \ 24 | yum remove -y gcc mariadb-devel net-snmp-devel && \ 25 | yum clean all 26 | 27 | COPY container-files / 28 | 29 | 30 | EXPOSE 80 81 443 -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Przemyslaw Ozgo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ###Cacti Server (CentOS7 + Supervisor) 2 | [![Circle CI](https://circleci.com/gh/pozgo/docker-cacti/tree/master.svg?style=svg&circle-token=f36545fc3efb2fa189ce90bd0cda6d19022eddc0)](https://circleci.com/gh/pozgo/docker-cacti/tree/master) 3 | [![GitHub Open Issues](https://img.shields.io/github/issues/pozgo/docker-cacti.svg)](https://github.com/pozgo/docker-cacti/issues) 4 | [![GitHub Stars](https://img.shields.io/github/stars/pozgo/docker-cacti.svg)](https://github.com/pozgo/docker-cacti) 5 | [![GitHub Forks](https://img.shields.io/github/forks/pozgo/docker-cacti.svg)](https://github.com/pozgo/docker-cacti) 6 | [![Stars on Docker Hub](https://img.shields.io/docker/stars/polinux/cacti.svg)](https://hub.docker.com/r/polinux/cacti) 7 | [![Pulls on Docker Hub](https://img.shields.io/docker/pulls/polinux/cacti.svg)](https://hub.docker.com/r/polinux/cacti) 8 | [![Docker Layers](https://badge.imagelayers.io/polinux/cacti:latest.svg)](https://hub.docker.com/r/polinux/cacti) 9 | 10 | [![Deploy to Docker Cloud](https://files.cloud.docker.com/images/deploy-to-dockercloud.svg)](https://cloud.docker.com/stack/deploy/?repo=https://github.com/pozgo/docker-cacti/tree/master) 11 | 12 | [Docker Image](https://registry.hub.docker.com/u/polinux/cacti/) with Cacti server using [million12/nginx-php]() docker image as base. (HTTP2 and HAProxy SSL termination ready.) 13 | Image is using external datbase and it's build on PHP 7.0. 14 | 15 | ### Database deployment 16 | To be able to connect to database we would need one to be running first. Easiest way to do that is to use another docker image. For this purpose we will use our [million12/mariadb](https://registry.hub.docker.com/u/million12/mariadb/) image as our database. 17 | 18 | **For more information about million12/MariaDB see our [documentation.](https://github.com/million12/docker-mariadb) ** 19 | 20 | Example: 21 | 22 | docker run \ 23 | -d \ 24 | --name cacti-db \ 25 | -p 3306:3306 \ 26 | --env="MARIADB_USER=cactiuser" \ 27 | --env="MARIADB_PASS=my_password" \ 28 | million12/mariadb 29 | 30 | ***Remember to use the same credentials when deploying cacti image.*** 31 | 32 | 33 | ### Environmental Variable 34 | In this Image you can use environmental variables to connect into external MySQL/MariaDB database. 35 | 36 | `DB_USER` = database user 37 | `DB_PASS` = database password 38 | `DB_ADDRESS` = database address (either ip or domain-name) 39 | `TIMEZONE` = timezone 40 | 41 | ### HTTP/2 Support 42 | Container is built with `http/2` support and by default it listens on port `443`. 43 | Make sure you open it on `docker run`. 44 | Port `81` is used by default for load balancing (`HAProxy`) ssl termination. 45 | 46 | ### Cacti Deployment 47 | Now when we have our database running we can deploy cacti image with appropriate environmental variables set. 48 | 49 | Example: 50 | 51 | docker run \ 52 | -d \ 53 | --name cacti \ 54 | -p 80:80 \ 55 | -p 443:443 \ 56 | --env="DB_ADDRESS=database_ip" \ 57 | --env="DB_USER=cactiuser" \ 58 | --env="DB_PASS=my_password" \ 59 | polinux/cacti 60 | 61 | ### Access Cacti web interface 62 | To log in into cacti for the first time use credentials `admin:admin`. System will ask you to change those when logged in for the firts time. 63 | 64 | Access web interface under 65 | 66 | [dockerhost.ip/install]() 67 | 68 | Follow the on screen instructions. 69 | 70 | ## Author 71 | 72 | Author: Przemyslaw Ozgo () 73 | 74 | --- 75 | 76 | -------------------------------------------------------------------------------- /circle.yml: -------------------------------------------------------------------------------- 1 | machine: 2 | services: 3 | - docker 4 | environment: 5 | DB_USER: db-user 6 | DB_PASS: db-password 7 | 8 | dependencies: 9 | pre: 10 | - docker pull million12/mariadb 11 | post: 12 | # Launch DB backend 13 | - docker run -d --name=db --env="MARIADB_USER=$DB_USER" --env="MARIADB_PASS=$DB_PASS" million12/mariadb 14 | - docker logs -f db | tee -a ${CIRCLE_ARTIFACTS}/db.log: 15 | background: true 16 | - docker build -t polinux/cacti . 17 | 18 | test: 19 | override: 20 | - while true; do if grep "You can now connect to this MariaDB Server" -a ${CIRCLE_ARTIFACTS}/db.log; then break; else sleep 1; fi done 21 | - docker run -d --name cacti --link db:cacti.db -p 80:80 --env="DB_ADDRESS=cacti.db" --env="DB_USER=$DB_USER" --env="DB_PASS=$DB_PASS" polinux/cacti 22 | - docker logs -f cacti | tee -a ${CIRCLE_ARTIFACTS}/cacti.log: 23 | background: true 24 | - while true; do if grep "Cacti Server UP" -a ${CIRCLE_ARTIFACTS}/cacti.log; then break; else sleep 1; fi done 25 | # Check Cacti Web interface status 26 | - curl -s -L --head http://127.0.0.1/ | grep "HTTP/1.1 200 OK" -------------------------------------------------------------------------------- /container-files/config.php: -------------------------------------------------------------------------------- 1 | > /etc/php.ini 76 | log "TIMEZONE set to: ${TIMEZONE}" 77 | fi 78 | } 79 | start_crond() { 80 | crond 81 | log "Started cron daemon" 82 | } 83 | # ## Magic Starts Here 84 | move_cacti 85 | move_config_files 86 | # Check Database Status and update if needed 87 | if [[ $(mysql -u "${DB_USER}" -h "${DB_ADDRESS}" -e "show databases" | grep cacti) != "cacti" ]]; then 88 | create_db 89 | import_db 90 | spine_db_update 91 | fi 92 | # Update Cacti config 93 | update_cacti_db_config 94 | # Update Spine config 95 | update_spine_config 96 | update_cron 97 | set_timezone 98 | start_crond 99 | log "Cacti Server UP." -------------------------------------------------------------------------------- /container-files/etc/import-cron.conf: -------------------------------------------------------------------------------- 1 | */5 * * * * php /data/www/cacti/poller.php > /dev/null 2>&1 2 | -------------------------------------------------------------------------------- /container-files/etc/nginx/hosts.d/cacti.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80 default_server; 3 | listen 81 default_server http2 proxy_protocol; ## Needed when behind HAProxy with SSL termination + HTTP/2 support 4 | listen 443 default_server ssl http2; 5 | 6 | ssl_certificate /etc/nginx/ssl/dummy.crt; 7 | ssl_certificate_key /etc/nginx/ssl/dummy.key; 8 | 9 | root /data/www/cacti; 10 | index index.php index.html; 11 | 12 | include /etc/nginx/conf.d/default-*.conf; 13 | include /data/conf/nginx/conf.d/default-*.conf; 14 | 15 | # PHP backend is not in the default-*.conf file set, 16 | # as some vhost might not want to include it. 17 | include /etc/nginx/conf.d/php-location.conf; 18 | 19 | # Import configuration files for status pages for Nginx and PHP-FPM 20 | include /etc/nginx/conf.d/stub-status.conf; 21 | include /etc/nginx/conf.d/fpm-status.conf; 22 | } -------------------------------------------------------------------------------- /container-files/global.php: -------------------------------------------------------------------------------- 1 |