2016-08-24 08:12:20 +01:00
source: Extensions/Syslog.md
2015-04-05 02:01:06 +01:00
# Setting up syslog support
This document will explain how to send syslog data to LibreNMS.
### Syslog server installation
2016-03-04 16:29:02 -07:00
#### syslog-ng
2015-04-05 02:01:06 +01:00
For Debian / Ubuntu:
```ssh
apt-get install syslog-ng
```
For CentOS / RedHat
```ssh
yum install syslog-ng
```
Once syslog-ng is installed, edit the relevant config file (most likely /etc/syslog-ng/syslog-ng.conf) and paste the following:
2017-12-31 10:03:10 -06:00
```bash
@version:3 .5
2015-06-01 06:42:32 +10:00
@include "scl.conf"
2017-12-31 10:03:10 -06:00
# syslog-ng configuration file.
#
# This should behave pretty much like the original syslog on RedHat. But
# it could be configured a lot smarter.
#
# See syslog-ng(8) and syslog-ng.conf(5) for more information.
#
# Note: it also sources additional configuration files (*.conf)
# located in /etc/syslog-ng/conf.d/
2015-04-05 02:01:06 +01:00
options {
2015-06-01 06:42:32 +10:00
chain_hostnames(off);
2015-04-05 02:01:06 +01:00
flush_lines(0);
2015-06-01 06:42:32 +10:00
use_dns(no);
2015-06-01 06:44:58 +10:00
use_fqdn(no);
2015-06-01 06:42:32 +10:00
owner("root");
group("adm");
2015-04-05 02:01:06 +01:00
perm(0640);
stats_freq(0);
2015-06-01 06:42:32 +10:00
bad_hostname("^gconfd$");
2015-04-05 02:01:06 +01:00
};
2016-01-30 21:06:58 -05:00
2018-01-29 14:56:04 -06:00
2015-04-05 02:01:06 +01:00
source s_sys {
2017-12-31 10:03:10 -06:00
system();
internal();
2018-01-29 14:56:04 -06:00
2015-04-05 02:01:06 +01:00
};
2016-01-30 21:06:58 -05:00
2015-04-05 02:01:06 +01:00
source s_net {
2015-06-01 06:39:25 +10:00
tcp(port(514) flags(syslog-protocol));
2015-06-01 06:42:32 +10:00
udp(port(514) flags(syslog-protocol));
2015-04-05 02:01:06 +01:00
};
2018-01-29 14:56:04 -06:00
2017-12-31 10:03:10 -06:00
2015-06-01 06:42:32 +10:00
########################
# Destinations
########################
2015-04-05 02:01:06 +01:00
destination d_librenms {
2018-01-29 14:56:04 -06:00
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));
2015-04-05 02:01:06 +01:00
};
2016-01-30 21:06:58 -05:00
2017-12-31 10:03:10 -06:00
filter f_kernel { facility(kern); };
filter f_default { level(info..emerg) and
not (facility(mail)
or facility(authpriv)
or facility(cron)); };
filter f_auth { facility(authpriv); };
filter f_mail { facility(mail); };
filter f_emergency { level(emerg); };
filter f_news { facility(uucp) or
(facility(news)
and level(crit..emerg)); };
filter f_boot { facility(local7); };
filter f_cron { facility(cron); };
2015-06-01 06:42:32 +10:00
########################
# Log paths
########################
2015-04-05 02:01:06 +01:00
log {
source(s_net);
source(s_sys);
destination(d_librenms);
};
2016-01-30 21:06:58 -05:00
2017-12-31 10:03:10 -06:00
# Source additional configuration files (.conf extension only)
2015-06-01 06:42:32 +10:00
@include "/etc/syslog-ng/conf.d/*.conf"
2017-12-31 10:03:10 -06:00
# vim:ft=syslog-ng:ai:si:ts=4:sw=4:et:
2015-04-05 02:01:06 +01:00
```
2015-06-01 06:39:25 +10:00
Next start syslog-ng:
2015-05-31 22:13:38 +10:00
```ssh
2015-06-01 06:39:25 +10:00
service syslog-ng restart
2015-05-31 22:13:38 +10:00
```
2017-06-17 15:21:21 +01:00
Add the following to your LibreNMS `config.php` file to enable the Syslog extension:
2016-03-04 16:29:02 -07:00
```ssh
$config['enable_syslog'] = 1;
```
#### rsyslog
If you prefer rsyslog, here are some hints on how to get it working.
2016-03-04 16:35:05 -07:00
Add the following to your rsyslog config somewhere (could be at the top of the file in the step below, could be in `rsyslog.conf` if you are using remote logs for something else on this host)
2016-03-04 16:29:02 -07:00
```ssh
# Listen for syslog messages on UDP:514
$ModLoad imudp
$UDPServerRun 514
```
2016-03-04 16:35:05 -07:00
Create a file called something like `/etc/rsyslog.d/30-librenms.conf` containing:
2016-03-04 16:29:02 -07:00
```ssh
# Feed syslog messages to librenms
$ModLoad omprog
2017-10-20 10:25:26 -05:00
$template librenms,"%fromhost%||%syslogfacility%||%syslogpriority%||%syslogseverity%||%syslogtag%||%$year%-%$month%-%$day% %timegenerated:8:25%||%msg%||%programname%\n"
2016-03-04 16:29:02 -07:00
2016-09-21 09:48:38 +02:00
*.* action(type="omprog" binary="/opt/librenms/syslog.php" template="librenms")
2016-03-04 16:29:02 -07:00
& stop
```
Ancient versions of rsyslog may require different syntax.
2016-07-31 19:12:07 +02:00
This is an example for rsyslog 5 (default on Debian 7):
```bash
2016-08-05 14:42:46 +02:00
# Feed syslog messages to librenms
$ModLoad omprog
$template librenms,"%FROMHOST%||%syslogfacility-text%||%syslogpriority-text%||%syslogseverity%||%syslogtag%||%$YEAR%-%$MONTH%-%$DAY% %timegenerated:8:25%||%msg%||%programname%\n"
$ActionOMProgBinary /opt/librenms/syslog.php
2016-07-31 19:12:07 +02:00
*.* :omprog:;librenms
```
2016-03-04 16:35:05 -07:00
If your rsyslog server is recieving messages relayed by another syslog server, you may try replacing `%fromhost%` with `%hostname%` , since `fromhost` is the host the message was received from, not the host that generated the message. The `fromhost` property is preferred as it avoids problems caused by devices sending incorrect hostnames in syslog messages.
2016-03-04 16:29:02 -07:00
2016-03-04 16:35:05 -07:00
Add the following to your LibreNMS `config.php` file to enable the Syslog extension:
2015-06-01 06:42:32 +10:00
```ssh
$config['enable_syslog'] = 1;
```
2017-10-31 15:33:17 -05:00
#### Syslog Clean Up
Can be set inside of `config.php`
```php
$config['syslog_purge'] = 30;
```
The cleanup is run by daily.sh and any entries over X days old are automatically purged. Values are in days.
See here for more Clean Up Options [Link ](https://docs.librenms.org/#Support/Configuration/#cleanup-options )
2015-06-01 06:42:32 +10:00
2015-04-05 12:08:42 +01:00
### Client configuration
Below are sample configurations for a variety of clients. You should understand the config before using it as you may want to make some slight changes.
Replace librenms.ip with IP or hostname of your LibreNMS install.
Replace any variables in < brackets > with the relevant information.
#### syslog
```config
*.* @librenms .ip
```
#### rsyslog
```config
*.* @librenms .ip:514
```
#### Cisco ASA
```config
logging enable
logging timestamp
logging buffer-size 200000
logging buffered debugging
logging trap notifications
logging host < outside interface name > librenms.ip
```
#### Cisco IOS
```config
logging trap debugging
logging facility local6
logging librenms.ip
```
#### Cisco NXOS
```config
logging server librenms.ip 5 use-vrf default facility local6
```
2015-06-01 06:42:32 +10:00
If you have permitted udp and tcp 514 through any firewall then that should be all you need. Logs should start appearing and displayed within the LibreNMS web UI.
2017-06-17 15:21:21 +01:00
2017-11-05 12:55:04 -06:00
### Windows
By Default windows has no native way to send logs to a remote syslog server.
Using this how to you can download Datagram-Syslog Agent to send logs to a remote syslog server (LibreNMS).
#### Note
keep in mind you can use any agent or program to send the logs. We are just using this Datagram-Syslog Agent for this example.
[Link to How to ](http://techgenix.com/configuring-syslog-agent-windows-server-2012/ )
You will need to download and install "Datagram-Syslog Agent" for this how to
[Link to Download ](http://download.cnet.com/Datagram-SyslogAgent/3001-2085_4-10370938.html )
2017-06-17 15:21:21 +01:00
### External hooks
Trigger external scripts based on specific syslog patterns being matched with syslog hooks. Add the following to your LibreNMS `config.php` to enable hooks:
```ssh
$config['enable_syslog_hooks'] = 1;
```
2017-09-01 18:37:01 +01:00
The below are some example hooks to call an external script in the event of a configuration change on Cisco ASA, IOS, NX-OS and IOS-XR devices. Add to your `config.php` file to enable.
#### Cisco ASA
```ssh
$config['os']['asa']['syslog_hook'][] = Array('regex' => '/%ASA-(config-)?5-111005/', 'script' => '/opt/librenms/scripts/syslog-notify-oxidized.php');
```
2017-06-17 15:21:21 +01:00
#### Cisco IOS
```ssh
$config['os']['ios']['syslog_hook'][] = Array('regex' => '/%SYS-(SW[0-9]+-)?5-CONFIG_I/', 'script' => '/opt/librenms/scripts/syslog-notify-oxidized.php');
```
#### Cisco NXOS
```ssh
$config['os']['nxos']['syslog_hook'][] = Array('regex' => '/%VSHD-5-VSHD_SYSLOG_CONFIG_I/', 'script' => '/opt/librenms/scripts/syslog-notify-oxidized.php');
```
#### Cisco IOSXR
```ssh
$config['os']['iosxr']['syslog_hook'][] = Array('regex' => '/%GBL-CONFIG-6-DB_COMMIT/', 'script' => '/opt/librenms/scripts/syslog-notify-oxidized.php');
```