Technology Insights

How To Rotate The Cacti Logs File: cacti.log

Cacti is an open source tool that polls network devices and provides a web based interface to view historical data about these devices. It is a really great tool to monitor disk usage, network traffic, and pretty much anything else you can think of. When installing cacti it is easy to forget about the log that cacti generates and over time the log can grow in size especially if your configuration includes a logging level of DEBUG. Below I describe how to rotate the cacti log as well as turn down the logging level to LOW on a CentOS 5 server.

First lets set up logrotate to rotate the cacti log.

1. Install logrotate: yum install logrotate
2. Create Cacti config: vi /etc/logrotate.d/cacti
Add the below contents to the new file
/var/www/html/cacti/log/cacti.log {
# keep two weeks of versions online
rotate 14
# rotate the log each day
# compress the logs
# create new file with the correct user/group attributes
create 644 cactiuser cactiuser
# add a YYYYMMDD extension instead of a number
Make sure the path is the correct location for your cacti.log file.
3. Run logrotate: logrotate -f /etc/logrotate.conf