My linux world » srv-syslog

srv-syslog


Installation

You can copy/paste this script and use it to configure automatically your server.

  1. ##################################
  2. # RSYSLOG
  3. ##################################
  4.  
  5. echo "install rsyslog"
  6. dnf -y install rsyslog*
  7.  
  8. echo "start nfs on startup"
  9. systemctl enable rsyslog.service
  10.  
  11. echo "configure rsyslog"
  12. mysql --user=root --password=root < /usr/share/doc/rsyslog-*/mysql-createDB.sql
  13.  
  14. mysql --user=root --password=root -e "CREATE USER 'rsyslog'@'localhost' IDENTIFIED BY 'rsyslog';"
  15. mysql --user=root --password=root -e "use Syslog; GRANT ALL PRIVILEGES ON Syslog.* TO 'rsyslog'@'localhost' WITH GRANT OPTION;"
  16.  
  17. sed -i "s/#\(\$ModLoad imudp\)/\1/" /etc/rsyslog.conf
  18. sed -i "s/#\(\$UDPServerRun 514\)/\1/" /etc/rsyslog.conf
  19.  
  20. sed -i "s/#\(\$ModLoad imtcp\)/\1/" /etc/rsyslog.conf
  21. sed -i "s/#\(\$InputTCPServerRun 514\)/\1/" /etc/rsyslog.conf
  22.  
  23. cat >> /etc/rsyslog.conf << "EOF"
  24. $ModLoad ommysql
  25. *.* :ommysql:127.0.0.1,Syslog,rsyslog,rsyslog
  26. EOF
  27.  
  28. echo "open port 514/tcp and 514 udp"
  29. firewall-cmd --permanent --add-port=514/tcp
  30. firewall-cmd --permanent --add-port=514/udp
  31.  
  32. echo "start service"
  33. systemctl start rsyslog.service
  34.  
  35.  
  36. ##################################
  37. # LOG ANALYZER
  38. ##################################
  39.  
  40. echo "install prerequistes"
  41. dnf -y install php
  42.  
  43. echo "download loganalyzer"
  44. wget http://download.adiscon.com/loganalyzer/loganalyzer-4.1.5.tar.gz -O /tmp/loganalyzer-4.1.5.tar.gz
  45.  
  46. echo "configure loganalyzer"
  47. cd /tmp
  48. tar xvfz loganalyzer-4.1.5.tar.gz
  49.  
  50. mkdir -p /var/www/html/loganalyzer
  51. mv /tmp/loganalyzer-4.1.5/src/* /var/www/html/loganalyzer
  52. touch /var/www/html/loganalyzer/config.php
  53. chown apache:apache /var/www/html/loganalyzer/config.php
  54. chmod 755 /var/www/html/loganalyzer/config.php
  55.  
  56. touch /var/log/syslog
  57. chown apache:apache /var/log/syslog
  58. chmod 755 /var/log/syslog
  59.  
  60. # restart httpd
  61. systemctl restart httpd.service
  62.  
  63. myip=`hostname -I`
  64. echo "Now meet you here: http://$myip/loganalyzer"
  65.  

That’s all 🙂


Copyright © 2023 My linux world - by Marc RABAHI
Design by Marc RABAHI and encelades.

Fork me on GitHub