I've been struggling with the Syslog plugin for several weeks now, I can't make it work on an external database.
I use cacti 0.8.7g (+ latest patches) and PA 2.9
This is the kind of logs Cacti sends:
Code: Select all
01/23/2011 06:50:02 PM - SYSTEM SYSLOG STATS:Time:0.11 Deletes:0 Incoming:3 Removes:0 XFers:0 Alerts:0 Alarms:0 Reports:0
01/23/2011 06:50:02 PM - CMDPHP: Poller[0] ERROR: A DB Exec Failed!, Error:'1044', SQL:"USE syslogdb'
01/23/2011 06:50:02 PM - CMDPHP: Poller[0] ERROR: A DB Exec Failed!, Error:'1146', SQL:"INSERT INTO `syslogdb`.`syslog_hosts` (host) (SELECT DISTINCT host FROM `syslogdb`.`syslog_incoming`) ON DUPLICATE KEY UPDATE host=VALUES(host)'
01/23/2011 06:50:02 PM - CMDPHP: Poller[0] ERROR: A DB Exec Failed!, Error:'1044', SQL:"USE syslogdb'
01/23/2011 06:50:02 PM - CMDPHP: Poller[0] ERROR: A DB Exec Failed!, Error:'1044', SQL:"USE syslogdb'
01/23/2011 06:50:02 PM - CMDPHP: Poller[0] ERROR: A DB Exec Failed!, Error:'1146', SQL:"INSERT INTO `syslogdb`.`syslog` (logtime, priority_id, facility_id, host_id, message) SELECT TIMESTAMP(`date`, `time`), priority_id, facility_id, host_id, message FROM (SELECT date, time, priority_id, facility_id, host_id, message FROM syslog_incoming AS si INNER JOIN syslog_facilities AS sf ON sf.facility=si.facility INNER JOIN syslog_priorities AS sp ON sp.priority=si.priority INNER JOIN syslog_hosts AS sh ON sh.host=si.host WHERE status=17) AS merge'
content of /etc/rsyslog.d/mysql.conf:
Code: Select all
$ModLoad ommysql
$template cacti_syslog,"INSERT INTO syslog_incoming(facility, priority, date, time, host, message) values (%syslogfacility%, %syslogpriority%, '%timereported:::date-mysql%', '%timereported:::date-mysql%', '%HOSTNAME%', '%msg%')", SQL
*.* >localhost,syslogdb,_sysloguser,_syslogpwd;cacti_syslog
content of /var/www/cacti/plugins/syslog/config.php
Code: Select all
$use_cacti_db = false;
if (!$use_cacti_db) {
$syslogdb_type = 'mysql';
$syslogdb_default = 'syslogdb';
$syslogdb_hostname = 'localhost';
$syslogdb_username = '_sysloguser';
$syslogdb_password = '_syslogpwd';
$syslogdb_port = 3306;
Code: Select all
## Syslog plugin installation
#
install_syslog(){
SyslogVersion="1.05-1" # Syslog plugin version to be installed
MySQLRootPwd="dbadmin" # Password for MYSQL user "root"
MySQLSyslogDbName="syslogdb" # MYSQL database name for cacti/syslog plugin
MySQLSyslogDbUser="_sysloguser" # MYSQL user for cacti/syslog plugin database
MySQLSyslogDbPwd="_syslogpwd" # Password for the user of the cacti/syslog plugin database
cd /usr/src/
wget http://docs.cacti.net/_media/plugin:syslog-v$SyslogVersion.tgz
mv plugin:syslog-v$SyslogVersion.tgz syslog-v$SyslogVersion.tgz
tar zxvf ./syslog-v$SyslogVersion.tgz
mv /usr/src/syslog /var/www/cacti/plugins/
rm -f /usr/src/syslog-v$SyslogVersion.tgz
apt-get install rsyslog-mysql -y
mysqladmin -u root -p$MySQLRootPwd create $MySQLSyslogDbName
echo "GRANT ALL ON $MySQLSyslogDbName.* TO $MySQLSyslogDbUser@localhost IDENTIFIED BY '$MySQLSyslogDbPwd';"|mysql -u root -p$MySQLRootPwd mysql
mysql -u $MySQLSyslogDbUser -p$MySQLSyslogDbPwd $MySQLSyslogDbName < /var/www/cacti/plugins/syslog/syslog.sql
sed -i -e 's/use_cacti_db = true/use_cacti_db = false/' /var/www/cacti/plugins/syslog/config.php
sed -i -e 's/syslogdb_default = '\''syslog'\''/syslogdb_default = '\'$MySQLSyslogDbName''\''/' /var/www/cacti/plugins/syslog/config.php
sed -i -e 's/syslogdb_username = '\''cactiuser'\''/syslogdb_username = '\'$MySQLSyslogDbUser''\''/' /var/www/cacti/plugins/syslog/config.php
sed -i -e 's/syslogdb_password = '\''cactiuser'\''/syslogdb_password = '\'$MySQLSyslogDbPwd''\''/' /var/www/cacti/plugins/syslog/config.php
echo '
$ModLoad ommysql
$template cacti_syslog,"INSERT INTO syslog_incoming(facility, priority, date, time, host, message) values (%syslogfacility%, %syslogpriority%, '\''%timereported:::date-mysql%'\'', '\''%timereported:::date-mysql%'\'', '\''%HOSTNAME%'\'', '\''%msg%'\'')", SQL
*.* >localhost,'$MySQLSyslogDbName','$MySQLSyslogDbUser','$MySQLSyslogDbPwd';cacti_syslog' > /etc/rsyslog.d/mysql.conf
/etc/init.d/rsyslog restart
}
Regards,
Deel