воскресенье, 23 февраля 2020 г.

CentOS7. Использование syslog-ng для отправки данных в базу REDIS

CentOS7. Использование syslog-ng для отправки данных в базу REDIS

Устанавливаем REDIS:
# yum install redis
Запускаем сервис REDIS и включаем его в автозагрузку
# systemctl start redis.service
# systemctl enable redis

Удаляем сервис rsyslog, установленный по умолчанию и устанавливаем syslog-ng на сервер:
# yum -y remove rsyslog
# yum install syslog-ng
# yum install syslog-ng-redis

Редактируем конфигурации 
# nano /etc/syslog-ng/syslog-ng.conf
Добавляем в конфиг перед строчкой
@include "/etc/syslog-ng/conf.d/*.conf" следующие директивы:
################### Настройки ELIS ##########################
source net { udp(ip(0.0.0.0) port(514)); };
destination d_elis {
    redis(
        host(127.0.0.1)
        port(6379)
        command("rpush" "elislogs" "${R_YEAR}-${R_MONTH}-${R_DAY} ${R_HOUR}:${R_MIN}:${R_SEC}|${HOST}|${PRIORITY}|${MSG}")
    );
};
filter f_elis_10 {
    netmask(10.0.0.0/8);
};
filter f_elis_172 {
    netmask(172.16.0.0/12);
};
log { source(net); filter(f_elis_10); destination(d_elis); };
log { source(net); filter(f_elis_172); destination(d_elis); };
##############################################################

Запускаем syslog-ng и добавляем его в автозагрузку
# systemctl start syslog-ng.service
# systemctl enable syslog-ng.service

Все. Сервис syslog-ng работает на 514 порту и все пришедшие данные складываем в очередь ‘elislogs’ базы REDIS

1 комментарий:

  1. Look at the way my associate Wesley Virgin's autobiography launches in this SHOCKING and controversial VIDEO.

    As a matter of fact, Wesley was in the military-and soon after leaving-he unveiled hidden, "mind control" tactics that the CIA and others used to get anything they want.

    THESE are the same methods tons of famous people (especially those who "come out of nowhere") and the greatest business people used to become rich and successful.

    You probably know how you use less than 10% of your brain.

    Mostly, that's because most of your BRAINPOWER is UNTAPPED.

    Perhaps that conversation has even taken place INSIDE OF YOUR own head... as it did in my good friend Wesley Virgin's head seven years back, while riding an unlicensed, beat-up trash bucket of a car without a license and $3 in his pocket.

    "I'm so fed up with going through life paycheck to paycheck! When will I finally make it?"

    You've taken part in those types of thoughts, isn't it right?

    Your success story is waiting to be written. You just have to take a leap of faith in YOURSELF.

    CLICK HERE To Find Out How To Become A MILLIONAIRE

    ОтветитьУдалить