1 | Network Management Workshop |
---|
2 | |
---|
3 | Using Swatch |
---|
4 | |
---|
5 | 1. Let's enable logging of everything to a single file: |
---|
6 | |
---|
7 | - Edit /etc/syslog-ng/syslog-ng.conf, and add this at the end: |
---|
8 | |
---|
9 | destination everything { |
---|
10 | file("/var/log/everything" |
---|
11 | template("$DATE <$FACILITY.$PRIORITY> $HOST $MSG\n") template_escape(no) |
---|
12 | ); |
---|
13 | }; |
---|
14 | log { source(s_all); destination(everything); }; |
---|
15 | |
---|
16 | |
---|
17 | ... this will enable logging of ALL messages to a single file, so that we |
---|
18 | can run a monitoring script on the messages. |
---|
19 | |
---|
20 | 2. Enable a daily automated script to truncate the log file so it doesn't |
---|
21 | grow too big: |
---|
22 | |
---|
23 | Create the file /etc/logrotate.d/everything |
---|
24 | |
---|
25 | /var/log/everything { |
---|
26 | daily |
---|
27 | copytruncate |
---|
28 | rotate 1 |
---|
29 | postrotate |
---|
30 | /etc/init.d/swatch restart |
---|
31 | endscript |
---|
32 | } |
---|
33 | |
---|
34 | |
---|
35 | 2. Install swatch |
---|
36 | |
---|
37 | # apt-get install swatch |
---|
38 | |
---|
39 | 3. Create the file /etc/swatch.conf, and put this in it: |
---|
40 | |
---|
41 | watchfor /PRIV_AUTH_PASS/ |
---|
42 | mail=mgmt,subject=Enable mode entered |
---|
43 | threshold type=limit,count=1,seconds=3600 |
---|
44 | |
---|
45 | watchfor /CONFIG_I/ |
---|
46 | mail=mgmt,subject=Router config |
---|
47 | threshold type=limit,count=1,seconds=3600 |
---|
48 | |
---|
49 | watchfor /LINK-3-UPDOWN/ |
---|
50 | mail=mgmt,subject=Link state change |
---|
51 | threshold type=limit,count=1,seconds=3600 |
---|
52 | |
---|
53 | 4. Start swatch: |
---|
54 | |
---|
55 | # swatch -c /etc/swatch.conf --daemon |
---|
56 | |
---|
57 | Check that it is running: |
---|
58 | |
---|
59 | # ps ax | grep swatch |
---|
60 | |
---|
61 | 5. Log in to your router, and run some "config" commands |
---|
62 | |
---|
63 | 6. Check that mails are coming in: |
---|
64 | |
---|
65 | # mutt -f /var/mail/mgmt |
---|
66 | |
---|
67 | |
---|