Commit | Line | Data |
378cc40b |
1 | #!/usr/bin/perl -P |
2 | |
3 | # $Header: scan_messages,v 2.0 88/06/05 00:17:46 root Exp $ |
4 | |
5 | # This prints out extraordinary console messages. You'll need to customize. |
6 | |
7 | chdir('/usr/adm/private/memories') || die "Can't cd."; |
8 | |
9 | $maxpos = `cat oldmsgs 2>&1`; |
10 | |
11 | #if defined(mc300) || defined(mc500) || defined(mc700) |
12 | open(Msgs, '/dev/null') || die "scan_messages: can't open messages"; |
13 | #else |
14 | open(Msgs, '/usr/adm/messages') || die "scan_messages: can't open messages"; |
15 | #endif |
16 | |
17 | ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime, |
18 | $blksize,$blocks) = stat(Msgs); |
19 | |
20 | if ($size < $maxpos) { # Did somebody truncate messages file? |
21 | $maxpos = 0; |
22 | } |
23 | |
24 | seek(Msgs,$maxpos,0); # Start where we left off last time. |
25 | |
26 | while (<Msgs>) { |
27 | s/\[(\d+)\]/#/ && s/$1/#/g; |
28 | #ifdef vax |
29 | $_ =~ s/[A-Z][a-z][a-z] +\w+ +[0-9:]+ +\w+ +//; |
30 | next if /root@.*:/; |
31 | next if /^vmunix: 4.3 BSD UNIX/; |
32 | next if /^vmunix: Copyright/; |
33 | next if /^vmunix: avail mem =/; |
34 | next if /^vmunix: SBIA0 at /; |
35 | next if /^vmunix: disk ra81 is/; |
36 | next if /^vmunix: dmf. at uba/; |
37 | next if /^vmunix: dmf.:.*asynch/; |
38 | next if /^vmunix: ex. at uba/; |
39 | next if /^vmunix: ex.: HW/; |
40 | next if /^vmunix: il. at uba/; |
41 | next if /^vmunix: il.: hardware/; |
42 | next if /^vmunix: ra. at uba/; |
43 | next if /^vmunix: ra.: media/; |
44 | next if /^vmunix: real mem/; |
45 | next if /^vmunix: syncing disks/; |
46 | next if /^vmunix: tms/; |
47 | next if /^vmunix: tmscp. at uba/; |
48 | next if /^vmunix: uba. at /; |
49 | next if /^vmunix: uda. at /; |
50 | next if /^vmunix: uda.: unit . ONLIN/; |
51 | next if /^vmunix: .*buffers containing/; |
52 | next if /^syslogd: .*newslog/; |
53 | #endif |
54 | next if /unknown service/; |
55 | next if /^\.\.\.$/; |
56 | if (/^[A-Z][a-z][a-z] [ 0-9][0-9] [ 0-9][0-9]:[0-9][0-9]/) { |
57 | $pfx = ''; |
58 | next; |
59 | } |
60 | next if /^[ \t]*$/; |
61 | next if /^[ 0-9]*done$/; |
62 | if (/^A/) { |
63 | next if /^Accounting [sr]/; |
64 | } |
65 | elsif (/^C/) { |
66 | next if /^Called from/; |
67 | next if /^Copyright/; |
68 | } |
69 | elsif (/^E/) { |
70 | next if /^End traceback/; |
71 | next if /^Ethernet address =/; |
72 | } |
73 | elsif (/^K/) { |
74 | next if /^KERNEL MODE/; |
75 | } |
76 | elsif (/^R/) { |
77 | next if /^Rebooting Unix/; |
78 | } |
79 | elsif (/^S/) { |
80 | next if /^Sun UNIX 4\.2 Release/; |
81 | } |
82 | elsif (/^W/) { |
83 | next if /^WARNING: clock gained/; |
84 | } |
85 | elsif (/^a/) { |
86 | next if /^arg /; |
87 | next if /^avail mem =/; |
88 | } |
89 | elsif (/^b/) { |
90 | next if /^bwtwo[0-9] at /; |
91 | } |
92 | elsif (/^c/) { |
93 | next if /^cgone[0-9] at /; |
94 | next if /^cdp[0-9] at /; |
95 | next if /^csr /; |
96 | } |
97 | elsif (/^d/) { |
98 | next if /^dcpa: init/; |
99 | next if /^done$/; |
100 | next if /^dts/; |
101 | next if /^dump i\/o error/; |
102 | next if /^dumping to dev/; |
103 | next if /^dump succeeded/; |
104 | $pfx = '*' if /^dev = /; |
105 | } |
106 | elsif (/^e/) { |
107 | next if /^end \*\*/; |
108 | next if /^error in copy/; |
109 | } |
110 | elsif (/^f/) { |
111 | next if /^found /; |
112 | } |
113 | elsif (/^i/) { |
114 | next if /^ib[0-9] at /; |
115 | next if /^ie[0-9] at /; |
116 | } |
117 | elsif (/^l/) { |
118 | next if /^le[0-9] at /; |
119 | } |
120 | elsif (/^m/) { |
121 | next if /^mem = /; |
122 | next if /^mt[0-9] at /; |
123 | next if /^mti[0-9] at /; |
124 | $pfx = '*' if /^mode = /; |
125 | } |
126 | elsif (/^n/) { |
127 | next if /^not found /; |
128 | } |
129 | elsif (/^p/) { |
130 | next if /^page map /; |
131 | next if /^pi[0-9] at /; |
132 | $pfx = '*' if /^panic/; |
133 | } |
134 | elsif (/^q/) { |
135 | next if /^qqq /; |
136 | } |
137 | elsif (/^r/) { |
138 | next if /^read /; |
139 | next if /^revarp: Requesting/; |
140 | next if /^root [od]/; |
141 | } |
142 | elsif (/^s/) { |
143 | next if /^sc[0-9] at /; |
144 | next if /^sd[0-9] at /; |
145 | next if /^sd[0-9]: </; |
146 | next if /^si[0-9] at /; |
147 | next if /^si_getstatus/; |
148 | next if /^sk[0-9] at /; |
149 | next if /^skioctl/; |
150 | next if /^skopen/; |
151 | next if /^skprobe/; |
152 | next if /^skread/; |
153 | next if /^skwrite/; |
154 | next if /^sky[0-9] at /; |
155 | next if /^st[0-9] at /; |
156 | next if /^st0:.*load/; |
157 | next if /^stat1 = /; |
158 | next if /^syncing disks/; |
159 | next if /^syslogd: going down on signal 15/; |
160 | } |
161 | elsif (/^t/) { |
162 | next if /^timeout [0-9]/; |
163 | next if /^tm[0-9] at /; |
164 | next if /^tod[0-9] at /; |
165 | next if /^tv [0-9]/; |
166 | $pfx = '*' if /^trap address/; |
167 | } |
168 | elsif (/^u/) { |
169 | next if /^unit nsk/; |
170 | next if /^use one of/; |
171 | $pfx = '' if /^using/; |
172 | next if /^using [0-9]+ buffers/; |
173 | } |
174 | elsif (/^x/) { |
175 | next if /^xy[0-9] at /; |
176 | next if /^write [0-9]/; |
177 | next if /^xy[0-9]: </; |
178 | next if /^xyc[0-9] at /; |
179 | } |
180 | elsif (/^y/) { |
181 | next if /^yyy [0-9]/; |
182 | } |
183 | elsif (/^z/) { |
184 | next if /^zs[0-9] at /; |
185 | } |
186 | $pfx = '*' if /^[a-z]+:$/; |
187 | s/pid [0-9]+: //; |
188 | if (/last message repeated ([0-9]+) time/) { |
189 | $seen{$last} += $1; |
190 | next; |
191 | } |
192 | s/^/$pfx/ if $pfx; |
193 | unless ($seen{$_}++) { |
194 | push(@seen,$_); |
195 | } |
196 | $last = $_; |
197 | } |
198 | $max = tell(Msgs); |
199 | |
200 | open(tmp,'|sort >oldmsgs.tmp') || die "Can't create tmp file."; |
201 | while ($_ = pop(@seen)) { |
202 | print tmp $_; |
203 | } |
204 | close(tmp); |
205 | open(tmp,'oldmsgs.tmp') || die "Can't reopen tmp file."; |
206 | while (<tmp>) { |
207 | if (/^nd:/) { |
208 | next if $seen{$_} < 20; |
209 | } |
210 | if (/NFS/) { |
211 | next if $seen{$_} < 20; |
212 | } |
213 | if (/no carrier/) { |
214 | next if $seen{$_} < 20; |
215 | } |
216 | if (/silo overflow/) { |
217 | next if $seen{$_} < 20; |
218 | } |
219 | print $seen{$_},":\t",$_; |
220 | } |
221 | |
222 | print `rm -f oldmsgs.tmp 2>&1; echo $max > oldmsgs 2>&1`; |