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
# keep two weeks of versions online
# 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
As long as cron is installed on your server then by default logrotate will run once daily which you can check out in /etc/cron.daily. Modify any of the paramters above such as “rotate 14” which keeps two weeks of backup log files on the local server.
Now lets make sure that the logging level is not turned up to DEBUG.
1. Visit Cacti Install: In your browser visit your cacti installation such as http://example.com/cacti
2. Go to Console: Click the console tab at the top of the browser
3. Visit Settings: In the left nav near the bottom click on Settings. The settings page will look like the below.
4. Change Log Level: As you can see in the example above click the Poller Logging Level drop down and switch to LOW. This will show only statistics and errors as described in the drop down.
Now not only will your logs be rotated but they will be much smaller in size. Check out the book below for more tools to use for Linux server administration.