Syslog-ng: Porovnání verzí

Z Wiki UnArt Slavičín
Skočit na navigaciSkočit na vyhledávání
(Založena nová stránka: Instalace: apt-get install syslog-ng destination d_mysql { sql(type(mysql) host("localhost") username("syslogwriter") password("syslogwriter-password") ...)
 
Bez shrnutí editace
 
(Nejsou zobrazeny 2 mezilehlé verze od stejného uživatele.)
Řádek 1: Řádek 1:
Instalace:
Instalace:


  apt-get install syslog-ng
  apt-get install syslog-ng libdbd-mysql


destination d_mysql {
Konfigurační soubor (/etc/syslog-ng/syslog-ng.conf) obsahuje zakomentované takřka všechny příklady použití.
        sql(type(mysql)
        host("localhost") username("syslogwriter") password("syslogwriter-password")
        database("syslog")
        table("logs")
        columns("host", "facility", "priority", "level", "tag", "datetime", "program", "msg")
        values("$HOST_FROM", "$FACILITY", "$PRIORITY", "$LEVEL", "$TAG", "$YEAR-$MONTH-$DAY $HOUR:$MIN:$SEC", "$PROGRAM", "$MSG")
        indexes("host", "facility", "priority", "datetime", "program"));
};


CREATE DATABASE `syslog` DEFAULT CHARACTER SET utf8 COLLATE utf8_czech_ci;
=== Logování do databáze ===


CREATE USER 'syslogwriter'@'localhost' IDENTIFIED BY 'syslogwriter-password';
Vytvořte databázi a uživatele:


GRANT USAGE ON * . * TO 'syslogwriter'@'localhost' IDENTIFIED BY '***' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
CREATE DATABASE `syslog` DEFAULT CHARACTER SET utf8 COLLATE utf8_czech_ci;
CREATE USER 'syslogwriter'@'localhost' IDENTIFIED BY 'syslogwriter-password';
GRANT USAGE ON * . * TO 'syslogwriter'@'localhost' IDENTIFIED BY '***' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
GRANT ALL PRIVILEGES ON `syslog` . * TO 'syslogwriter'@'localhost';


GRANT ALL PRIVILEGES ON `syslog` . * TO 'syslogwriter'@'localhost';
Do /etc/syslog-ng/syslog-ng.conf přidejte:
 
# Zdroj bude sit
source s_network {
        udp(ip("0.0.0.0") port(514));
};
# Cil bude MySQL databaze - staci vytvorit databazi, pokud ma uzivatel prava, tabulka se vytvori sama
destination d_mysql {
        sql(type(mysql)
        host("localhost") username("syslogwriter") password("syslogwriter-password")
        database("syslog")
        table("logs")
        columns("host", "facility", "priority", "level", "tag", "datetime", "program", "msg")
        values("$HOST_FROM", "$FACILITY", "$PRIORITY", "$LEVEL", "$TAG", "$YEAR-$MONTH-$DAY $HOUR:$MIN:$SEC", "$PROGRAM", "$MSG")
        indexes("host", "facility", "priority", "datetime", "program"));
};
log { source(s_network); destination(d_mysql); };

Aktuální verze z 15. 8. 2012, 09:36

Instalace:

apt-get install syslog-ng libdbd-mysql

Konfigurační soubor (/etc/syslog-ng/syslog-ng.conf) obsahuje zakomentované takřka všechny příklady použití.

Logování do databáze

Vytvořte databázi a uživatele:

CREATE DATABASE `syslog` DEFAULT CHARACTER SET utf8 COLLATE utf8_czech_ci;

CREATE USER 'syslogwriter'@'localhost' IDENTIFIED BY 'syslogwriter-password';

GRANT USAGE ON * . * TO 'syslogwriter'@'localhost' IDENTIFIED BY '***' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ; 

GRANT ALL PRIVILEGES ON `syslog` . * TO 'syslogwriter'@'localhost';

Do /etc/syslog-ng/syslog-ng.conf přidejte:

# Zdroj bude sit
source s_network {
        udp(ip("0.0.0.0") port(514));
};

# Cil bude MySQL databaze - staci vytvorit databazi, pokud ma uzivatel prava, tabulka se vytvori sama
destination d_mysql {
        sql(type(mysql)
        host("localhost") username("syslogwriter") password("syslogwriter-password")
        database("syslog")
        table("logs")
        columns("host", "facility", "priority", "level", "tag", "datetime", "program", "msg")
        values("$HOST_FROM", "$FACILITY", "$PRIORITY", "$LEVEL", "$TAG", "$YEAR-$MONTH-$DAY $HOUR:$MIN:$SEC", "$PROGRAM", "$MSG")
        indexes("host", "facility", "priority", "datetime", "program"));
};

log { source(s_network); destination(d_mysql); };