Syslog Plugin issue

General discussion about Plugins for Cacti

Moderators: Developers, Moderators

Post Reply
User avatar
DeeL
Cacti User
Posts: 71
Joined: Thu May 14, 2009 5:12 pm
Location: Paris

Syslog Plugin issue

Post by DeeL »

Hi guys,

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' 
Since the database is created and updated by rsyslog I guess that mysql.conf is OK
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
It looks like config.php is OK too but trully I think there is something wrong with the way that syslog plugin handles those informations.
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;
Last but not least here is the script I've made and used to install the plugin:

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
}
Hope someone can help.

Regards,

Deel
JohnYYC
Cacti User
Posts: 58
Joined: Thu Apr 22, 2010 1:23 pm

Re: Syslog Plugin issue

Post by JohnYYC »

181 views and nobody wants to help. I have been trying for months to get the syslog plugin to work on my dev server with no luck :(
Visionary
Posts: 1
Joined: Fri Oct 07, 2011 12:24 pm

Re: Syslog Plugin issue

Post by Visionary »

Had you solved the problem?
User avatar
TheWitness
Developer
Posts: 17061
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Syslog Plugin issue

Post by TheWitness »

You must use Syslog 1.22. Also, you must create the empty database ahead of time and grant the permissions. Once done, you can setup the config.php and reperform the install. At that point, you should be all set. Make sure you have imported the correct column names as well.

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
vomijwlm
Posts: 5
Joined: Thu Oct 21, 2010 12:55 am

Re: Syslog Plugin issue

Post by vomijwlm »

:D
#mkdir -p /home/update
#cd /home/update
#wget http://docs.CACTI.net/_media/plugin:syslog-v1.22-1.tgz
#mv plugin\:syslog-v1.22-1.tgz aaa.tgz
#tar zxvf aaa.tgz
#mv syslog /var/www/cacti/plugins
#cd /var/www/cacti/plugins/syslog
#mysql -uroot -pdbadmin syslog < syslog.sql
#mysql -uroot -pdbadmin
use syslog;
show tables;
GRANT ALL PRIVILEGES ON syslog.* TO _CACTIuser@localhost IDENTIFIED BY '_CACTIpassw' ;
flush privileges;
exit

#vi /var/www/CACTI/plugins/syslog/config.php
29: $use_CACTI_db = false;
30:
31: if (!$use_CACTI_db) {
32: $syslogdb_type = 'mysql';
33: $syslogdb_default = 'syslog';
34: $syslogdb_hostname = 'localhost';
35: $syslogdb_username = '_CACTIuser';
36: $syslogdb_password = '_CACTIpassw';
37: $syslogdb_port = 3306;

#apt-get install rsyslog rsyslog-mysql

#vi /etc/rsyslog.conf
1: $ModLoad ommysql
2: $template CACTI_syslog,"INSERT INTO syslog_incoming(facility, priority, date, time, host, message) values (%syslogfacility%, %syslogpriority%, '%timer eported:::date-mysql%', '%timereported:::date-mysql%', '%HOSTNAME%', '%msg%')", SQL
3: *.* >localhost,syslog,_CACTIuser,_CACTIpassw;CACTI_syslog

24: $ModLoad imudp
25: $UDPServerRun 514

#reboot

Then Install/Enable syslog plugins Service
:D
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests