{"id":5260,"date":"2023-07-05T13:01:03","date_gmt":"2023-07-05T18:01:03","guid":{"rendered":"https:\/\/www.incredigeek.com\/home\/?p=5260"},"modified":"2023-07-05T15:04:26","modified_gmt":"2023-07-05T20:04:26","slug":"setup-librenms-as-syslog-server","status":"publish","type":"post","link":"https:\/\/www.incredigeek.com\/home\/setup-librenms-as-syslog-server\/","title":{"rendered":"Setup LibreNMS as Syslog Server"},"content":{"rendered":"\n<p>Using the LibreNMS documentation for setting up syslog-ng so LibreNMS can ingest logs from Cisco, Mikrotik, Ubiquiti etc. equipment.<\/p>\n\n\n\n<p><a href=\"https:\/\/docs.librenms.org\/Extensions\/Syslog\/\">https:\/\/docs.librenms.org\/Extensions\/Syslog\/<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Enable Syslog in LibreNMS settings<\/h2>\n\n\n\n<p>First thing we need to do is enable syslog for LibreNMS.  Edit the \/opt\/librenms\/config.php and add or enable<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$config['enable_syslog'] = 1;<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Install and Configure syslog-ng<\/h2>\n\n\n\n<p>Install syslog-ng with dnf or yum.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo dnf install -y syslog-ng<\/pre>\n\n\n\n<p>Create a config file for LibreNMS<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vi \/etc\/syslog-ng\/conf.d\/librenms.conf<\/pre>\n\n\n\n<p>Put the following in the config file<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">source s_net {\n        tcp(port(514) flags(syslog-protocol));\n        udp(port(514) flags(syslog-protocol));\n};\n\ndestination d_librenms {\n        program(\"\/opt\/librenms\/syslog.php\" template (\"$HOST||$FACILITY||$PRIORITY||$LEVEL||$TAG||$R_YEAR-$R_MONTH-$R_DAY $R_HOUR:$R_MIN:$R_SEC||$MSG||$PROGRAM\\n\") template-escape(yes));\n};\n\nlog {\n        source(s_net);\n        source(s_sys);\n        destination(d_librenms);\n};<\/pre>\n\n\n\n<p>Restart and enable syslog-ng<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo systemctl restart syslog-ng\nsudo systemctl enable syslog-ng<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">SELinux<\/h2>\n\n\n\n<p>If we are running SELinux, we&#8217;ll need to make and apply a module to let the logs show up in the web interface.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vi librenms-rsyslog.te<\/pre>\n\n\n\n<p>Put the following in the file<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">module mycustom-librenms-rsyslog 1.0;\n\nrequire {\n        type syslogd_t;\n        type httpd_sys_rw_content_t;\n        type ping_exec_t;\n        class process execmem;\n        class dir { getattr search write };\n        class file { append getattr execute open read };\n}\n\n#============= syslogd_t ==============\nallow syslogd_t httpd_sys_rw_content_t:dir { getattr search write };\nallow syslogd_t httpd_sys_rw_content_t:file { open read append getattr };\nallow syslogd_t self:process execmem;\nallow syslogd_t ping_exec_t:file execute;<\/pre>\n\n\n\n<p>Now run the following commands to make and apply our SELinux module.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">checkmodule -M -m -o librenms-rsyslog.mod librenms-rsyslog.te\nsemodule_package -o librenms-rsyslog.pp -m librenms-rsyslog.mod\nsudo semodule -i librenms-rsyslog.pp<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Using the LibreNMS documentation for setting up syslog-ng so LibreNMS can ingest logs from Cisco, Mikrotik, Ubiquiti etc. equipment. https:\/\/docs.librenms.org\/Extensions\/Syslog\/ Enable Syslog in LibreNMS settings First thing we need to do is enable syslog for LibreNMS. Edit the \/opt\/librenms\/config.php and &hellip; <a href=\"https:\/\/www.incredigeek.com\/home\/setup-librenms-as-syslog-server\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[352],"tags":[353,7,134,389,565,207,564,1526],"class_list":["post-5260","post","type-post","status-publish","format-standard","hentry","category-librenms","tag-librenms","tag-linux-2","tag-monitoring","tag-nms","tag-rsyslog","tag-selinux","tag-syslog","tag-syslog-ng"],"_links":{"self":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/5260","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/comments?post=5260"}],"version-history":[{"count":7,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/5260\/revisions"}],"predecessor-version":[{"id":5270,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/5260\/revisions\/5270"}],"wp:attachment":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/media?parent=5260"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/categories?post=5260"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/tags?post=5260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}