1. Skip to Menu
  2. Skip to Content
  3. Skip to Footer>

พื้นที่ลงโฆษณา

Thin Client Server

พื้นที่ลงโฆษณา

Linux Authentication

พื้นที่ลงโฆษณา

PHP-Syslog-NG

PDF Print E-mail

Written by Mr. Sontaya Photibut Wednesday, 07 January 2009 22:39

Installing php-syslog-ng

Download:

http://software.susethailand.com

$ wget http://php-syslog-ng.googlecode.com/files/php-syslog-ng-2.9.8l.tgz

Install:

$ tar zxvf php-syslog-ng-2.9.8l.tgz -C /srv/www/htdocs/

$ cd /srv/www/htdocs/

$ mv php-syslog-ng syslog-ng && chown wwwrun.www syslog-ng -R

$ cd syslog-ng/scripts/

$ perl -i -pe 's/\/www\/php-syslog-ng/\/srv\/www\/htdocs\/syslog-ng/g' *

$ vi /etc/php5/cli/php.ini

max_execution_time = 60

memory_limit = 128M

$ cd ..

$ vi html/install/sql/sample_data.sql

ERT INTO `syslog`.`logs` (

`host` ,

`facility` ,

`priority` ,

`level` ,

`tag` ,

`datetime` ,

`program` ,

`msg` ,

`seq` ,

`counter` ,

`fo` ,

`lo`

)

VALUES (

'192.168.0.2', 'daemon', 'warning', 'alert', 'Tag', '2008-09-15 16:49:00', 'squid', 'test by opensuseclub.org', 'no error', '1', '2008-09-15 16:49:33', '2008-09-15 16:49:36'

);

INSERT INTO `search_cache` VALUES ('logs','HOST','as-3550-2','2006-06-15 18:25:54'),('logs','HOST','192.168.0.2','2006-06-15 18:25:54'),('logs','FACILITY','daemon','2006-06-15 18:25:54'),('logs','FACILITY','kern','2006-06-15 18:25:54'),('logs','FACILITY','mail','2006-06-15 18:25:54');


$ rcapache2 reload


Installing:

http://192.168.1.13/syslog-ng/html/install/

Step1:

Host Name: localhost

MySQL User Name: root

MySQL Password: ******

Verify MySQL Password: ******

MySQL Database Name: syslog-ng

Step2:

Site name: Centralized Log Server


Step3:

URL: http://192.168.1.13/syslog-ng/html

Install Path: /srv/www/htdocs/syslog-ng/html

Site URL: http://192.168.1.13/syslog-ng/html


Username: admin

Password: ******


$ vi /html/install/sql/sample_data.sql

ERT INTO `syslog`.`logs` (

`host` ,

`facility` ,

`priority` ,

`level` ,

`tag` ,

`datetime` ,

`program` ,

`msg` ,

`seq` ,

`counter` ,

`fo` ,

`lo`

)

VALUES (

'192.168.0.2', 'daemon', 'warning', 'alert', 'Tag', '2008-09-15 16:49:00', 'squid', 'test by opensuseclub.org', 'no error', '1', '2008-09-15 16:49:33', '2008-09-15 16:49:36'

);

INSERT INTO `search_cache` VALUES ('logs','HOST','as-3550-2','2006-06-15 18:25:54'),('logs','HOST','192.168.0.2','2006-06-15 18:25:54'),('logs','FACILITY','daemon','2006-06-15 18:25:54'),('logs','FACILITY','kern','2006-06-15 18:25:54'),('logs','FACILITY','mail','2006-06-15 18:25:54');



Installing CEMDB:

ถ้ามี Error MySQL: INSERT command denied to user 'syslogadmin'@'localhost' for table 'cemdb'

ให้ตรวจสอบ Privileges ใน phpmyadmin ที่ผู้ใช้ syslogadmin

Global privileges: INSERT, DROP, RELOAD, ALTER

*** (เพิ่ม INSERT ที่ Data)


$ rcapache2 restart


Login:

http://192.168.1.13/syslog-ng/html


USING TABLE: logs

There appear to be no hosts in the Database yet
You can generate fake ones using scripts/dbgen.pl


$ cd /srv/www/htdocs/syslog-ng

$ ./scripts/dbgen.pl


*** Ctrl+C (stop)


Configuration syslog-ng sending log to MySQL:

$ vi /etc/syslog-ng/syslog-ng.conf

## Send log everything to MySQL

destination d_mysql {

program("/usr/bin/mysql -usyslogadmin -psyslogadmin syslog-ng"

template("INSERT INTO logs (host, facility, priority, level, tag, datetime, program, msg)

VALUES ( '$HOST', '$FACILITY', '$PRIORITY', '$LEVEL', '$TAG', '$YEAR-$MONTH-$DAY $HOUR:$MIN:$SEC', '$PROGRAM', '$MSG' );\n")

template-escape(yes));

};

log {

source(src);

destination(d_mysql);

};


Crontab

$ crontab -e

#php-syslog-ng(create log table)

0 0 * * * php /srv/www/htdocs/syslog-ng/scripts/logrotate.php >> /var/log/php-syslog-ng/logrotate.log 2>&1 > /dev/null

0 0 * * * find /srv/www/htdocs/syslog-ng/html/jpcache/ -atime 1 -exec rm -f '{}' ';' 2>&1 > /dev/null

*/5 * * * * php /srv/www/htdocs/syslog-ng/scripts/reloadcache.php >> /var/log/php-syslog-ng/reloadcache.log 2>&1 > /dev/null

*/5 * * * * php /srv/www/htdocs/syslog-ng/scripts/SqueezeDB-v2.3.php >> /var/log/php-syslog-ng/squeezedb.log 2>&1 > /dev/null

#rotate syslog-ng

0 0 * * * /usr/sbin/logrotate -f /etc/logrotate.d/syslog-ng > /dev/null


Backup Database syslog-ng:

download script: http://sourceforge.net/projects/automysqlbackup/

Crontab backup MySQL:

$ crontab -e

#backup mysql

59 23 * * * sh /root/scripts/mysql-backup.sh > /dev/null

Ref: http://code.google.com/p/php-syslog-ng/downloads/list

-----------------------------------------------------------------------------------------------------------------------------------

Note: syslog-ng # Global options:

#
# Global options.
#
#options { long_hostnames(off); sync(0); perm(0640); stats(3600); };
options {
#buffer just a little for performance
   sync (1);
# The time to wait before a dead connection is reestablished (seconds)
   time_reopen (10);
# memory is cheap, buffer messages unable to write (like to loghost)
   log_fifo_size (2048);
   long_hostnames (off);
   use_dns (no);
   use_fqdn (no);
   create_dirs (no);
   keep_hostname (yes);
#doesn't actually help
   log_msg_size (8192);
# The default log a STATS line every 10 minutes.
# Change it to every 12 hours so you get a nice daily update of
# how many messages syslog-ng missed (0).
   stats(43200);

};

-------------------------------------------------------------------------------------------------------------------------------------

Note: Message length overflow, line is split, log_msg_size=4096    (syslog-ng):

***syslog defaults to 1024 byte long messages


$ vi /etc/syslog-ng/syslog-ng.conf
log_msg_size (8192);

$ rcsyslog reload

-------------------------------------------------------------------------------------------------------------------------------------

Note: php-syslog-ng | JPGraph

Error : couldn't draw any Graphs and it came up with this message: "JpGraph Error Font file "/usr/share/fonts/truetype/msttcorefonts/verdana.ttf" is not readable or does not exist..

Tips1 : Create new path
Text mode :
$ mkdir /usr/share/fonts/truetype/msttcorefonts/ -p
$ cd /usr/share/fonts/truetype/msttcorefonts/
$  wget http://www.afosteo.org/Download/Fonts/verdana.ttf


Tips2 : Edit file jpg-config.inc
GUI mode:
/usr/X11R6/lib/X11/fonts/truetype/verdana.ttf
$ vi /srv/www/htdocs/syslog/html/includes/jpgraph/jpg-config.inc

-------------------------------------------------------------------------------------------------------------------------------------

Ref: http://www.itbuzzer.net/corner/labels/monitoring.asp

------------------------------------------------------------------------------------------------------------------------------------

Note: php-syslog-ng PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted

php /srv/www/htdocs/syslog-ng/scripts/reloadcache.php >> /var/log/php-syslog-ng/reloadcache.log
PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 71 bytes) in /srv/www/ htdocs/syslog-ng/html/includes/common_funcs.php on line 203


Solution:
Plz add " if (!in_array($row['program'],$cacheProgramValues))" before array_push


$sql = "SELECT program FROM ".$table." WHERE program RLIKE
'^[a-zA-Z]+[a-zA-Z0-9/()._\-]+$'";
$result = perform_query($sql, $link);
while($row = fetch_array($result, 'ASSOC')) {
if (!in_array($row['program'],$cacheProgramValues))
array_push($cacheProgramValues, $row['program']);
}


I have >3500000 logs, if without it, will get the error "Allowed memory size of
268435456 bytes exhausted"。 Add it , none this error。

My php.ini configuration:
vi /etc/php5/apache2/php.ini
vi /etc/php5/cli/php.ini

max_execution_time = 600
     memory_limit = 256M

$ rcsyslog restart

RELOAD SEARCH CACHE:

Ref: http://code.google.com/p/php-syslog-ng/issues/detail?id=86

 


Comments (0)Add Comment

Write comment

security code
Write the displayed characters


busy
 

SUSE Linux Enterprise Cool Solutions

  • Watch the future of Retail

    On YouTube I've published a three-part video of a presentation I did in early July 2010 to IBM retail partners. The sound volume is a bit low, and this was all recorded with a little flip mino camera, so please excuse the bad quality.

    The three video snippets are mainly intended for any of you who want to use Linux in retail as a solution provider and are wondering how solutions from Novell can help you be more successful.

    Nevertheless, especially the first part about how we see the future of the Point of Service might also be interesting to you if you are a decision maker in retail or just curious about how the future in retail IT may look like.

    The new features in SUSE Linux Enterprise Point of Service 11 Service Pack 1 are only mentioned briefly in this presentation. Watch out for more blog posts to come on Service Pack 1.

    This is Joachim Werner blogging live from the SUSE offices in Nuremberg, Germany.

    http://www.youtube.com/watch?v=WdYEeLIou7s
    http://www.youtube.com/watch?v=3Awr3tPpo2Y
    http://www.youtube.com/watch?v=pwwKpoEI9GI

  • Create an Appliance with SUSE Studio -- you could win $10,000

    They're looking for inventive minds to build the most innovative software appliances. Publish your unique appliance to the new SUSE® Gallery™ and enter into a contest to win $10,000!

    The contest runs from July 27 - September 30, 2010, so brush off your mad skills and pop on over here for all the details.

    It must not be too hard.... in the past year, more than 400,000 Linux appliances were built using SUSE Studio, with nearly 3 million downloads. SUSE Gallery is the place to strut your stuff and show off the appliances you have built with SUSE Studio. It also serves as a centralized online showcase where SUSE Studio users can browse and use both commercial and community-oriented appliances.

    Good luck! Make Cool Solutions proud.

  • See us at SHARE, Boston!

    The next SHARE event is approaching quickly - it takes place in Boston from August 1-5 at Hynes Convention Center: http://www.share.org/Events/UpcomingConference/tab...

    If you are attending, don´t miss the chance to meet our experts for System z, and visit us at Booth #319. To name just a few, watch out for Kim Lorusso (IBM Alliance Marketing Manager and Cool Blogger), Patrick Quairoli (Technical Alliance Manager), Marcus Kraft (Linux on mainframe "pioneer" and Product Manager for SUSE Linux Enterprise Server for System z), David Getzin (Partner Executive for IBM), John Jolly (Sys z Architect), and others. Chat with them about the SUSE Linux Enterprise Consolidation Suite tailored for IBM Solution Edition for Enterprise Linux. Don´t know what that is? Read more here: http://www.novell.com/products/systemz/els.html
    And get the latest about the new zEnterprise System - you bet that will be one of the "ruling" topics.

    Or listen to Mike Friesenegger, one of our most experienced Technical Specialists, when he talks about "ASP.NET on zLinux: A New Workload" (Tues Aug 3, 9:30-10:30AM, Room 305) and about how to " Implement the SUSE Linux Enterprise High Availability Extension on System z" (Tues Aug 3, 11AM-12PM, Room 208). And you´ll have the opportunity to hear from customers like Nationwide Insurance why and how they use SLES for System z.

    And as a side note - for those who have travel constraints and cannot attend personally, SHARE offers the option to participate online - just check out http://www.share.org/Events/UpcomingConference/SHA...

  • IBM zEnterprise System - Get the hard facts

    This week on Thursday IBM made a ground-breaking announcement about the revolutionary zEnterprise System - you might have read my article here on Cool Solutions:
    http://www.novell.com/communities/node/11670/ibm-f...

    Curious now about getting details and some hard facts? Just download the data sheet from IBM and see how it works. Want to discuss how this new system relates to SUSE Linux Enterprise ? Leave a comment or drop me an email at chabow@novell.com

    AttachmentSize
    11394070.pdf385.48 KB
  • What do you think about this country/language selector?

    The web team at Novell is tweaking the way people choose the language they want to read the website in. (Of course, this doesn't affect this communities section, which is only provided in English. But it does affect a lot of the marketing pages on novell.com. )

    We'd like your feedback, especially if you like to read the rest of Novell.com in a language other than English. Take a look at this design, and let us know what you think by posting comments.

    Thanks for your input!

    View design here.

Sponsors List