Jump to content
Jcloud

[Support] Cacti

25 posts in this topic Last Reply

Recommended Posts

Application Name: Cacti   --  a complete network graphing solution designed to harness the power of RRDTool's data storage and graphing functionality. 

Application Site: https://www.cacti.net

Docker Hub: https://hub.docker.com/r/quantumobject/docker-cacti/

Template-Repository: https://github.com/Jcloud67/Docker-Templates

 

SETUP AND CONFIGURATION:
---------------------------------------------
     0.  SNMP poller default port is 161UDP. 
     1.  If you have an SNMP poller plug-in already installed on your unRAID host, you'll find it will conflict with this Docker. Either uninstall the SNMP plugin you are using, or make the changes to have both work (author assumes you know what you're doing).
     2.  Has a webui, default set at 8180, adapt as needed to work on your host.
     3.  During initial setup the path to SPINE is incorrect. Change it to:
          /usr/local/spine/bin/spine
     4. First login  --  userid: admin    
                         password: admin

FIRST RUN (Recommendation):
---------------------------------------------
   On left hand menu, Under "Automation" click on, "Networks"  THEN "Test Network" on right-side main frame.  In Subnet Range change this to fit your network. Click "Save" THEN "Return" at the bottom.
   Next click on the checkbox for "Test Network" THEN in "Choose an action" box click ENABLE --> GO 
  Check the checkbox for "test Network" again THEN choose "Discover now"

Share this post


Link to post

hi, just playing with this now. Looks good

 

i have a vlan that is the other side of my firewall, looking at logs on firewall i got some blocked traffic on UDP23 (its pinging) 

 

So, i needed to edit the template and add UDP23 to the container template, which ive done, but as soon as i did that and applied, the app rebuilt, and so i have to go through the initial config again, and wiped all my settings out!

 

Maybe need to have a look at this, cause if you update the template, it will clear everything out and make you start again

Share this post


Link to post
4 hours ago, rorton said:

Maybe need to have a look at this, cause if you update the template, it will clear everything out and make you start again

I'll see what can be done. Full disclosure, I just made the template and the instructions are sum of things I found so far, to get it working with the Docker container I found.

 

For future, you can make any changes without Docker remaking the whole thing by clicking on, "save" button instead of, "apply." (ver 6.4.1) and it will keep your current image/configs. The container will have to be restarted for the change to take effect. 

Share this post


Link to post

No worries, looks great from what you’ve managed to pull together so far

 

thanks for the tip on the save/apply thing too. Been a long time unraid user and only really used it for “a bit of storage” and a couple of download dockers, but found some time to play with it a bit more recently

Share this post


Link to post

I don't actually see a save button on 6.4.1 ( https://i.imgur.com/dygrjzB.png ) and it is definitely wiping the entire system every 'apply' of the docker.

 

I think we simply need to figure out where cacti is storing the db/conf shit and make sure that goes in an appdata mount rather than in the normal image.

Edited by anethema

Share this post


Link to post
12 hours ago, anethema said:

I don't actually see a save button on 6.4.1 ( https://i.imgur.com/dygrjzB.png ) and it is definitely wiping the entire system every 'apply' of the docker.

Sorry about confusion, you definitely don't have one there. Here's mine: https://i.imgur.com/EUpZqzl.jpg

And, yeah 'apply' definitely re-builds it each time. I think the save button is activated, by going to

 

://YourBox/Apps/ca_settings 

Advanced "Enable Template Developer Mode?"  --> Change to Yes and apply.

Share this post


Link to post

Ya I can't risk losing all that work by clicking the wrong button anyways. Too risky! I'll have to keep running it in a VM for now.

Share this post


Link to post

Wow, this is a fantastic package, so far from what i can tell it stores all of its data in /var/lib/mysql/cacti

 

once this is squared away it will be good to go, i need to get into creating docker images.

 

i hooked this up to my PFsense box, cisco switch, and ubuntu box... it graphed it all perfectly after some tweaking.

Share this post


Link to post

All I'm getting is empty graphs.  Looks like my RRDs are getting NaN values.  But all the troubleshooting steps are showing the right things.  Suggestions on what to look at?

 

I've been through all of these, except the MySQL and RRDtool update steps, because I don't understand the instructions.

https://docs.cacti.net/manual:087:4_help.2_debugging#debugging

Edited by koyaanisqatsi

Share this post


Link to post

Huh, OK.  Data started showing up in my graphs at 9:40 this morning, which is 7 hours after I posted above, or the same offset as my time zone.  So I seem to have a TZ issue. I did set -e TZ=America/Los_Angeles (In fact I just saw that it's set twice, and removed one.). But the graphs are slid off the data itself. So it seems like the TZ isn't getting to all the components.

 

From php.ini (both):

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = "America/Los_Angeles"

 

System time, according to the container, is correct:

sh-4.3# date
Fri Aug  3 23:46:43 PDT 2018
sh-4.3#

 

my.cnf:

default-time-zone = America/Los_Angeles

 

Container startup:

root@localhost:# /usr/local/emhttp/plugins/dynamix.docker.manager/scripts/docker run -d --name='Cacti' --net='bridge' -e TZ="America/Los_Angeles" -e HOST_OS="unRAID" -p '8180:80/tcp' -v '/mnt/cache/appdata/Cacti':'/config':'rw' 'quantumobject/docker-cacti' 
ccddc228f9e6c3c454c8197a797d32d292ad2a2f3b9fe6e0306adc9f17432e2a

The command finished successfully!

 

What else can I check?

 

Thanks!

Share this post


Link to post

Last stage of a pre-clear (the Post-Read) on a pair of 6TB WD Reds. The yellow before it was the end of the zeroing pass. I pre-cleared two disks at once, and one of them was noticeably slower overall. That curve show the data transfer speed variance across the disk.

Disk Speed J.png

Disk Speed I.png

Share this post


Link to post
On 8/4/2018 at 8:04 AM, koyaanisqatsi said:

Huh, OK.  Data started showing up in my graphs at 9:40 this morning, which is 7 hours after I posted above, or the same offset as my time zone.  So I seem to have a TZ issue. I did set -e TZ=America/Los_Angeles (In fact I just saw that it's set twice, and removed one.). But the graphs are slid off the data itself. So it seems like the TZ isn't getting to all the components.

 

From php.ini (both):

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = "America/Los_Angeles"

 

System time, according to the container, is correct:

sh-4.3# date
Fri Aug  3 23:46:43 PDT 2018
sh-4.3#

 

my.cnf:

default-time-zone = America/Los_Angeles

 

Container startup:

root@localhost:# /usr/local/emhttp/plugins/dynamix.docker.manager/scripts/docker run -d --name='Cacti' --net='bridge' -e TZ="America/Los_Angeles" -e HOST_OS="unRAID" -p '8180:80/tcp' -v '/mnt/cache/appdata/Cacti':'/config':'rw' 'quantumobject/docker-cacti' 
ccddc228f9e6c3c454c8197a797d32d292ad2a2f3b9fe6e0306adc9f17432e2a

The command finished successfully!

 

What else can I check?

 

Thanks!

 

On 8/4/2018 at 8:35 AM, koyaanisqatsi said:

K, looks like adding:

 

putenv('TZ=America/Los_Angeles');

 

just beaneath the <?php line in /opt/cacti/graph_image.php has resolved the issue.  (https://forums.cacti.net/viewtopic.php?f=2&amp;t=47931)

 

Now I just need to figure out the persistent storage issue.  If anyone is working on that, I'd love to see your notes!  :)

 

 

Thank you for updating and posting this!! I'm trying to get this same docker running (quantumobject/docker-cacti) and I have the same timezone issue. I'm not within unRaid, just bare Ubuntu.  This was the only result that showed up though.

 

Could you explain how you fixed the timezone issue? I'm unsure how to put

putenv('TZ=America/Los_Angeles');

into the docker system (persistently).

 

I've also been wondering how this system copes with a reboot. I've not specified any persistent volumes, so do all the stats wipe when the container restarts?

Share this post


Link to post

If you run it as documented, it's completely volatile, and you lose everything if you delete the container. unRAID always deletes containers when they are stopped.  I'm still working (slowly) on addressing that in my installation.  Last night I discovered the backup and restore commands are robust, though not enough to establish a persistent storage set up.  But they do allow for easily not losing your data history.  I've set up a cron task inside the container to run a backup every hour.  And the backups are kept on persistent storage.  Then when I have to restart the container or reboot, I just run the restore command and the new container comes back to life. Next step for me is to pick apart the backups and see what is in them, which will tell me what I need to capture and mount as external volumes, for a truly persistent and self-healing configuration.

 

Here's how I'm starting (actually unRAID is starting) the container right now, which just uses the backup/restore commands:

docker run -d \
--name='Cacti' \
--net='bridge' \
-e TZ="America/Los_Angeles" \
-e HOST_OS="unRAID" \
-p '8180:80/tcp' \
-v '/mnt/cache/appdata/Cacti/config':'/config':'rw' \
-v '/mnt/cache/appdata/Cacti/backups':'/var/backups':'rw' \
'quantumobject/docker-cacti'
What this looks like in unRAID:
cacti-in-unraid.png.8e0a4d5a1660eeec782b0d39d5ab3f53.png
 
Then in an unRAID terminal, run:
docker exec -it Cacti /sbin/restore
Log into the container:
docker exec -it Cacti /bin/bash
Edit the crontab:
crontab -e
And paste in the schedule:
4 * * * * /sbin/backup
This runs a backup at :04 minutes after the hour, every hour.
 
I'll post the final setup once I get fully persistent storage working.
 
EDIT: Regarding the time zone edit to /opt/cacti/graph_image.php; I haven't addressed that yet, and it's apparently not always necessary.  You'll need to edit the file every time you start a new container, if you're seeing the issue.  I needed it on one container, but not another, even though both were running on the same host.
Edited by koyaanisqatsi

Share this post


Link to post
1 hour ago, koyaanisqatsi said:

If you run it as documented, it's completely volatile, and you lose everything if you delete the container. unRAID always deletes containers when they are stopped.  I'm still working (slowly) on addressing that in my installation.  Last night I discovered the backup and restore commands are robust, though not enough to establish a persistent storage set up.  But they do allow for easily not losing your data history.  I've set up a cron task inside the container to run a backup every hour.  And the backups are kept on persistent storage.  Then when I have to restart the container or reboot, I just run the restore command and the new container comes back to life. Next step for me is to pick apart the backups and see what is in them, which will tell me what I need to capture and mount as external volumes, for a truly persistent and self-healing configuration.

 

Here's how I'm starting (actually unRAID is starting) the container right now, which just uses the backup/restore commands:


docker run -d \
--name='Cacti' \
--net='bridge' \
-e TZ="America/Los_Angeles" \
-e HOST_OS="unRAID" \
-p '8180:80/tcp' \
-v '/mnt/cache/appdata/Cacti/config':'/config':'rw' \
-v '/mnt/cache/appdata/Cacti/backups':'/var/backups':'rw' \
'quantumobject/docker-cacti'
What this looks like in unRAID:
cacti-in-unraid.png.8e0a4d5a1660eeec782b0d39d5ab3f53.png
 
Then in an unRAID terminal, run:

docker exec -it Cacti /sbin/restore
Log into the container:

docker exec -it Cacti /bin/bash
Edit the crontab:

crontab -e
And paste in the schedule:

4 * * * * /sbin/backup
This runs a backup at :04 minutes after the hour, every hour.
 
I'll post the final setup once I get fully persistent storage working.
 
EDIT: Regarding the time zone edit to /opt/cacti/graph_image.php; I haven't addressed that yet, and it's apparently not always necessary.  You'll need to edit the file every time you start a new container, if you're seeing the issue.  I needed it on one container, but not another, even though both were running on the same host.

 

That's odd about the timezone. I actually found that my host was on UTC rather than London time, so that might help my situation. Haven't tested yet.

 

I'm struggling with persistence too. I found that /var/lib/mysql and /opt/cacti are where the configs are stored and if they can be passed as a volume then that would work. However, when I pass them through as volumes the container stops working. The following command, in my eyes, should start the container with persisted volumes:

 

docker run --name cacti -d -p 9123:80 -p 161:161 --restart always -e TZ=Europe/London \
   -v /home/x/cacti/cacti:/opt/cacti -v /home/x/cacti/mysql:/var/lib/mysql quantumobject/docker-cacti

 

I must be missing something about the writing of the volumes as it just stops working with this change. I found https://hub.docker.com/r/idle/cacti-1-minute/ which should have persistence, but this also fails to start up. Note that the cacti config here is said to be /var/lib/cacti.

 

Let us know if you figure out persistence. I'll update you too if anything works for me.

 

Edited by Kallb123

Share this post


Link to post

The issue with persistent storage is that the container starts up with the expectation that the mysql database already exists, because mysql is preinstalled.  You can't point /var/lib/mysql at an empty folder.  But I'm hoping I can point it at a folder with all the right mysql data in it already.    I'm working right now on starting up a generic container, then making a copy of the mysql data location before anything is done to it.  THEN, I'll attach that as a volume to a new container and configure from there.  All said and done, I'd like to offer the "starter pack" as a download so others can just get going with just unpacking the download to a folder that holds all the sub-folders below.

 

Since my last post, I've identified (most of the?) the volumes I'll be mounting, for optimum customization:

-v '/mnt/cache/appdata/Cacti/mysql-data':'/var/lib/mysql':'rw' \
-v '/mnt/cache/appdata/Cacti/mysql-conf':'/etc/mysql':'rw' \
-v '/mnt/cache/appdata/Cacti/cacti-data':'/opt/cacti/rra':'rw' \
-v '/mnt/cache/appdata/Cacti/apache-conf':'/etc/apache2':'rw' \
-v '/mnt/cache/appdata/Cacti/php-conf':'/etc/php':'rw' \

 

Share this post


Link to post

I might have managed it... though I can't see any data yet, maybe it'll show up in an hour (my timezone offset).

 

I firstly ran:

 

sudo docker run --name cacti -d -p 9123:80 -p 161:161 --restart always -e TZ=Europe/London \
     -v /home/x/cacti/cacti:/data/cacti -v /home/x/cacti/mysql:/data/mysql quantumobject/docker-cacti

then access the container terminal with

sudo docker exec -it cacti bash

I gave it ~10 minutes to start and gather some data. I then transferred all the files:

rsync -a /var/lib/mysql/* /data/mysql/
rsync -a /opt/cacti/* /data/cacti/

I then removed the container and started it with the new volumes:

sudo docker run --name cacti -d -p 9123:80 -p 161:161 --restart always -e TZ=Europe/London \
     -v /home/x/cacti/cacti:/opt/cacti -v /home/x/cacti/mysql:/var/lib/mysql quantumobject/docker-cacti

 

 

It seems to have booted and there's no errors. But I'll have to wait for data to show up. You could do the same with more volumes for maximum customisability I suppose. I haven't tested multiple restarts, I'll wait for data first.

 

EDIT: Folder ownership seems to have been messed up, but the files seem ok. Too early to tell whether the permissions are going to screw it up.

Edited by Kallb123

Share this post


Link to post

It works! The data showed up (an hour late), so I removed the container and ran it again. The same data is still visible.

 

Thank you for your help koyaanisqatsi, your idea of creating a starter database is spot on!! :)

 

The timezone issue doesn't seem to be fixed even after editing that php file :(

Share this post


Link to post

Awesome!  Glad you got it working.  I'm still messing around with mine.  I had some things to do today, so haven't been working on it most of the afternoon.

 

I want to stop MySQL before taking a copy of the initial data, just to make sure there are no data consistency issues.  Then I'm going to try and package it all up so it's easy for others to use.

 

The time zone thing seems really inconsistent.  I'm not sure what to make of that.

Share this post


Link to post

Well, I have a great solution to the persistent storage, as long as you're in the Pacific timezone. ?

 

I was able to grab the mysql data and configs from a container I had started, but not configured yet, and clean them up a it.  I created a nifty little starter package that you extract into your Cacti appdata folder before starting the container in unRAID. But the way the container sets the timezone when it starts up is not working with the starter data.  I should be able to figure it out, though.

 

I'm determined to either make this work the way I want, or just build my own container.  Depends on how much of a rabbit hole this turns into.

Share this post


Link to post

It was too much of a rabbit hole, so I built my own container.  It aims to be fully fault-tolerant, self-healing and modular.  And it's a bit smaller than the other leading brand, running on Alpine Linux rather than Ubuntu.  ;)

 

I haven't figured out the unRAID template thing to make a Docker container work natively with unRAID yet, so please offer some tips on that.  I read the docs on it a while back, and I need to go over them again.

 

But here's how it works on the command line, for now.

 

DISCLAIMER: This is a work-in-progress. It may have significant bugs, and lacks a certain level of fit and finish.  I use it, but I have not exercised it very much to shake out more than obvious issues.

docker run -d --rm \
--net='bridge' \
-p 1984:80/tcp \
-v '/mnt/cache/appdata/cacti/backups':'/var/backups':'rw' \
-v '/mnt/cache/appdata/cacti/mysql-data':'/var/lib/mysql':'rw' \
-v '/mnt/cache/appdata/cacti/mysql-conf':'/etc/mysql':'rw' \
-v '/mnt/cache/appdata/cacti/cacti-data':'/var/lib/cacti/rra':'rw' \
-v '/mnt/cache/appdata/cacti/apache-conf':'/etc/apache2':'rw' \
-v '/mnt/cache/appdata/cacti/php-conf':'/etc/php7':'rw' \
-e TZ="America/Los_Angeles" \
-e MYSQL='mysql root password' \
-e CACTI='cacti user db password' \
--name cacti \
chestersgarage/cacti:latest

The settings are intentionally a little different from the QuantumObject container in order to avoid conflicts.

 

Being able to easily maintain configs and data outside of the container are key improvements. The container will look for existing configs and data at each startup, and if some are missing or not recognized, it will initialize those elements of the application from defaults.   What I like to do is let it start up fresh, then manipulate the configs after that point.  The migration instructions take that approach as well.

 

Take a look at the source here:

https://github.com/ChestersGarage/cacti

https://hub.docker.com/r/chestersgarage/cacti/

 

Migration instructions provided in the source repos linked above.

 

I'm hoping to have the container fully compliant with the unRAID Docker implementation in a week or two.

 

Enjoy!

Share this post


Link to post
On 2/17/2018 at 11:27 PM, Jcloud said:

Application Name: Cacti   --  a complete network graphing solution designed to harness the power of RRDTool's data storage and graphing functionality. 

Application Site: https://www.cacti.net

Docker Hub: https://hub.docker.com/r/quantumobject/docker-cacti/

Template-Repository: https://github.com/Jcloud67/Docker-Templates

 

SETUP AND CONFIGURATION:
---------------------------------------------
     0.  SNMP poller default port is 161UDP. 
     1.  If you have an SNMP poller plug-in already installed on your unRAID host, you'll find it will conflict with this Docker. Either uninstall the SNMP plugin you are using, or make the changes to have both work (author assumes you know what you're doing).
     2.  Has a webui, default set at 8180, adapt as needed to work on your host.
     3.  During initial setup the path to SPINE is incorrect. Change it to:
          /usr/local/spine/bin/spine
     4. First login  --  userid: admin    
                         password: admin

FIRST RUN (Recommendation):
---------------------------------------------
   On left hand menu, Under "Automation" click on, "Networks"  THEN "Test Network" on right-side main frame.  In Subnet Range change this to fit your network. Click "Save" THEN "Return" at the bottom.
   Next click on the checkbox for "Test Network" THEN in "Choose an action" box click ENABLE --> GO 
  Check the checkbox for "test Network" again THEN choose "Discover now"

Hello,
the whole package works very well. when I restart the Cacti in the Docker, I start again at the beginning. there is no longer any device to configure. Do you have an idea.

Share this post


Link to post

After installing I'm getting the following error.  

 

FATAL: Connection to Cacti database failed. Please ensure:

the PHP MySQL module is installed and enabled.

the database is running.

the credentials in config.php are valid.

 

Is there a config file I need to modify?  

Share this post


Link to post
Posted (edited)

If you have recently rebooted unRAID or restarted your Cacti container, this can happen.  I have worked around it so far by enabling Advanced View in the Docker screen, and then force-update the Cacti container.  This causes it to go through an initial setup that reestablishes the DB connection properly.  It's a bug in the image I'm working on.  But I've had some life changes that tore me away from this project for a long time.  I have every intention to come back to it and refine the image.

 

To be clear, this workaround only works with my image: chestersgarage/cacti

Edited by koyaanisqatsi

Share this post


Link to post

I never installed SNMP but I keep getting t he 0.0.0.0:161 error when trying to install docker. I have tried looking up everywhere and cant even see anything using the port

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.