Entenda de forma prática como configurar um servidor de SyslogNG

Por Thiago Marques

O pai ta on!!

O syslog é uma importante ferramenta para administração e análise de qualquer ambiente de infraestrutura.

A maioria dos SO Linux já vem com o RSsyslog instalados, contudo eu prefiro trabalhar com o Syslog-ng por uma questão familiaridade.

Neste documento mostrarei como efetuar uma configuração para instalar o deamon syslog-ng para sistemas operacionais baseados em RHEL (RedHat,CentOS e Fedora).

O syslog nesse caso é uma das soluções para logs que pode ser útil se sua infraestrutura for pequena, para estruturas maiores ter uma estrutura descentralizada de logs como o Elastic acaba sendo uma opção melhor.

Pré-requisitos

  1. Desinstalar o SELINUX
    1. vim /etc/sysconfig/selinux
    2. Na linha onde esta o “SELINUX=enforcing”, alterar para:
    3. SELINUX=disabled
  2. Reiniciar a máquina.
  3. Validar com o comando: sestatus
  4. Instalar o repositório EPEL;
    1. wget http://dl.fedoraproject.org/pub/epel/6Server/i386/epel-release-6-8.noarch.rpm
  5. Instalar com: rpm -Uvh /root/epel-release-6-8.noarch.rpm
  6. Validar com: yum repolist
  7. Instalar o pacote wget;
  8. Instalar o pacote logrotate;

Instalando

  1. Iremos instalar 2 pacotes:
    1. syslog-ng;
    2. syslog-ng-libdbi;

Desabilitar o Rsyslog e habilitar o Syslog

    Como o padrão de syslog é o rsyslog teremos que desabilita-lo para habilitar o syslog-ng, fazemos isso da seguinte forma:
    chkconfig rsyslog off
    Ou
    systemctl disable rsyslog
    E depois habilitamos o syslog-ng
    chkconfig syslog-ng off
    Ou
    service syslog-ng start
    Por fim iniciaremos o serviço de syslog:
    service syslog-ng start

Configurando o syslog

    Abaixo mostrarei um arquivo de configuração para o syslog.
    É importante frisar que esta configuração deve estar sempre no final do arquivo:
    /etc/syslog-ng/syslog-ng.conf
    #--Criamos um source, de qual ip e qual porta o servidor vai ouvir
    #-----Neste caso o servidor vai receber syslog de qualquer IP na porta 514
    source net {udp(ip(0.0.0.0)port(514));};
    #–Criamos um destination, que relata para onde iremos mandar o log.
    #—– aqui podemos colocar todos os logs em um arquivo só (não recomento)
    #—— ou colocar um log para cada equipamento (AI SIM!!)
    #—— Como o arquivo aceita wildcards e variáveis, iremos criar o seguinte padrão:
    #——- Mes_-//--.log
    #——- Exemplo: Mes_02-2018/10.0.0.1/15-02-2017.log
    #——- Assim sera criado os arquivos automaticamente conforme os equipamentos forem enviando os logs
    destination d_cisco
         {file("/var/log/net/Mes_$MONTH-$YEAR/$HOST/$DAY-$MONTH-$YEAR.log"
               create_dirs(yes) #cria os diretorios se eles nao existirem
               dir_perm(0755) #da permissao 755 no diretorio
               dir_owner(root) #coloca o usuario root como proprietario da pasta
               dir_group(root)
               perm(0755) #da permissao 775 nos arquivos
               group(root)
               owner(root)
               );
               };
    log{ source(net); destination(d_cisco);};

Criando um link simbólico para visualização web

    Agora vamos criar um link simbólico para a pasta web, cito-a:
    /var/www/html/
    Como esta pasta é a padrão para web, iremos colocar os arquivos nela para faciliar a visualização, fazemos isso com o seguinte comando:
    ln –s /var/log/net /var/www/html/
    Será criado uma pasta chamada net dentro de html, depois é só acessar o web da seguinte forma:
    http://< ip_do_servidor>/net
    Com isso conseguiremos acessar os logs via http, facilitando o consumo.
    Novamente, essa implementação é indicada para pequenos ambientes (algo entre 5 e 10 servidores), para ambientes maiores gerenciar os logs dessa forma gera um trabalho desnecessário visto as aplicações disponíveis hoje.
    That’s all folks! Be Happy!!!
foto-thiago-marques
Thiago Marques Technical Account Manager
thiago.marques@darede.com.br

Technical Account Manager da Darede, formato em Rede de Computadores, e pós graduado em Segurança da Informação. Possui ampla experiência em Datacenters e Service Providers, além de ser um entusiasta em DevOps e mercado financeiro.

OUTRAS PUBLICAÇÕES

AWS Console-to-Code

Já imaginou transformar todas as ações e cliques realizados na Console da AWS em código? O AWS Console-to-Code consegue fazer isto dentro do serviço de EC2. Vamos entender melhor no Blog abaixo.

Darede – AWS Consulting Partner of the Year 2021 (English Version)

The APN Awards is Amazon Web Services’ recognition of the top partners in different regions around the world who in 2020 helped their customers build technology solutions for their organizations, driving digital transformation and innovation using AWS cloud services. The winners of this award have demonstrated practically how it is possible to provide the best experience in the world of cloud computing and turn it into a positive impact on businesses worldwide. And in this year’s edition, Darede was awarded as the AWS Consulting Partner of the year. This is a proof of the quality of the service provided by the company, which has been working every day since 2013 to transform companies through technological solutions, always appreciating the good service and high level of its professionals. About the award, the CTO, and co-founder of Darede, Flávio Rescia said: “We are thrilled and very happy with this award, because we work hard every day to provide the best for our customer. We would like to thank our whole team for all their effort and dedication, because without them none of this would be possible. We also thank the people at AWS who provided all the support and gave us all the freedom to do what we love most, provide the best service to our customers”. CEO and co-founder Muriel Arneiro also thanked everyone about this recognition, “It’s a pride to receive this recognition, so we thank a lot all our team that works night and day, sparing no efforts, to bring the best to our customer. It is also important to thank our customers who believe every day in our project and without them, we would be absolutely nothing. And of course, to AWS that gives us all the conditions to bring the best to our clients, we are very happy with this partnership, and we want you to know that we are just at the beginning of this journey that will be very successful”. The CMO and one of Darede’s partners, Marcelo Carazato emphasized the total support from AWS for winning this award: “We received this news with a lot of emotion, and this is the result of constant work from our entire team, since the first contact we provide a totally differentiated and personalized service to our customers. Here we look for all the alternatives to provide the best service for them, and for this I am very proud of our team. And I would like to give a special thanks to the people at AWS, because they give us all the conditions to offer the best service, it’s no wonder that the company is the main platform in the world, they really are trusted partners for all times”. Read the story on the AWS website: https://aws.amazon.com/pt/blogs/apn/announcing-the-aws-partner-network-regional-2021-partners-of-the-year/

Novidades da AWS – 21 a 25 de setembro

Todos os dias a AWS lança uma série novidades e atualizações em seus produtos que visam melhorar a vida de seus usuários. Veja as novidades da semana de 21 a 25 de setembro.

Nós usamos cookies para garantir e oferecer a melhor experiência de navegação em nosso site! Mais informações