Previously posted on blog.labrat.info on March 11, 2010
I’ve been hitting my head against a wall for the last couple of days . My Cacti install just stopped working. The UI was fine but no graphs were being created. For a couple of days I thought it was the machine’s fault. The hardware is old and I thought it was just time for the machine to kick the can. I looked though systems logs and rebooted the machine a couple of times. Ran less services on it thinking it might be there’s not enough RAM but nothing worked. It was still broken. I started to look into the cacti logs and found the following:
03/08/2009 04:10:03 AM - CMDPHP: Poller[0] ERROR: A DB Exec Failed!, Error:'1062', SQL:"insert into poller_output (local_data_id, rrd_name, time, output) values (10, 'traffic_out', '2009-03-08 04:10:03', '3677235031')'
I went online and looked for information on this error. Most posts I found just said to run a cacti script to repair the table. The scrip it cacti/cli/repair_database.php. This started to get me worried as these posts implied something had happened to the database. Looking back though the logs I went to check the database and, most importantly the poller_output table. I manually checked the poller_output table and it gave me a nasty error. Looking at the filesystem I saw that table was missing some files. Never a good thing.
I couldn’t think of any good way to fix that table and from a quick search it seems there’s no really imporant information in there anyway. The best thing was to recreate the table. I looked at the cacti install and found the DB creation file and just copied the table I needed into a file called fixme.txt.
DROP TABLE IF EXISTS `poller_output`; CREATE TABLE `poller_output` ( `local_data_id` mediumint(8) unsigned NOT NULL default '0', `rrd_name` varchar(19) NOT NULL default '', `time` datetime NOT NULL default '0000-00-00 00:00:00', `output` text NOT NULL, PRIMARY KEY (`local_data_id`,`rrd_name`,`time`) ) TYPE=MyISAM;
With that file I just fed it to mysql.
mysql cacti < fixme.txt
Just to be on the safe side I rebooted the server. Presto! Now it works!