| 1 | Network Management & Monitoring |
|---|
| 2 | Using syslog-ng |
|---|
| 3 | |
|---|
| 4 | Notes: |
|---|
| 5 | ------ |
|---|
| 6 | * Commands preceded with "$" imply that you should execute the command as |
|---|
| 7 | a general user - not as root. |
|---|
| 8 | * Commands preceded with "#" imply that you should be working as root. |
|---|
| 9 | * Commands with more specific command lines (e.g. "RTR-GW>" or "mysql>") |
|---|
| 10 | imply that you are executing commands on remote equipment, or within |
|---|
| 11 | another program. |
|---|
| 12 | |
|---|
| 13 | Exercises |
|---|
| 14 | --------- |
|---|
| 15 | |
|---|
| 16 | 1. Install syslog-ng |
|---|
| 17 | |
|---|
| 18 | # apt-get install syslog-ng |
|---|
| 19 | |
|---|
| 20 | 2. Edit /etc/syslog-ng/syslog-ng.conf |
|---|
| 21 | |
|---|
| 22 | Find the lines: |
|---|
| 23 | |
|---|
| 24 | # (this is equivalent to the "-r" syslogd flag) |
|---|
| 25 | # udp(); |
|---|
| 26 | |
|---|
| 27 | and change it to: |
|---|
| 28 | |
|---|
| 29 | # (this is equivalent to the "-r" syslogd flag) |
|---|
| 30 | udp(); |
|---|
| 31 | |
|---|
| 32 | At the bottom of the file, add: |
|---|
| 33 | |
|---|
| 34 | filter f_routers { facility(local5); }; |
|---|
| 35 | log { |
|---|
| 36 | source(s_all); |
|---|
| 37 | filter(f_routers); |
|---|
| 38 | destination(routers); |
|---|
| 39 | }; |
|---|
| 40 | destination routers { |
|---|
| 41 | file("/var/log/network/$YEAR/$MONTH/$DAY/$HOST-$YEAR-$MONTH-$DAY-$HOUR.log" |
|---|
| 42 | owner(root) group(root) perm(0644) dir_perm(0755) create_dirs(yes) |
|---|
| 43 | template("$YEAR $DATE $HOST $MSG\n")); |
|---|
| 44 | }; |
|---|
| 45 | |
|---|
| 46 | 3. Create the directory /var/log/network/ |
|---|
| 47 | |
|---|
| 48 | # mkdir /var/log/network/ |
|---|
| 49 | |
|---|
| 50 | 4. Restart syslog-ng: |
|---|
| 51 | |
|---|
| 52 | # /etc/init.d/syslog-ng restart |
|---|
| 53 | |
|---|
| 54 | 5. If you haven't not already done so during the presentation: |
|---|
| 55 | |
|---|
| 56 | Configure your virtual routers to send syslog messages to your server: |
|---|
| 57 | |
|---|
| 58 | rtrX# config terminal |
|---|
| 59 | rtrX(config)# logging 10.10.X.1 |
|---|
| 60 | rtrX(config)# logging facility local5 |
|---|
| 61 | rtrX(config)# logging userinfo |
|---|
| 62 | rtrX(config)# exit |
|---|
| 63 | rtrX# write memory |
|---|
| 64 | rtrX# exit |
|---|
| 65 | |
|---|
| 66 | logout from the router (exit) |
|---|
| 67 | |
|---|
| 68 | 6. On your PC, See if messages are starting to appear under |
|---|
| 69 | |
|---|
| 70 | /var/log/network/2010/02/26/... |
|---|
| 71 | |
|---|
| 72 | 7. If not, try to login back into the router, and run some "config" commands, |
|---|
| 73 | then logout. |
|---|
| 74 | |
|---|