1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
--- syslog-summary-1.14/syslog-summary
+++ syslog-summary-1.14/syslog-summary.new
@@ -4,22 +4,22 @@
# Copyright © 2008-2009, David Paleino <d.paleino@gmail.com>
# © 2001-2008, Tommi Virtanen <tv@debian.org>
# © 1998-2000, Lars Wirzenius <liw@iki.fi>
-#
+#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
-
+
"""Summarize the contents of a syslog log file.
The syslog(3) service writes system log messages in a certain format:
@@ -139,10 +139,10 @@
return False
except:
from os.path import splitext
-
+
if not QUIET:
print "Using fallback detection... please install python-magic for better gzip detection."
-
+
if splitext(filename)[1] == ".gz":
return True
else:
@@ -154,7 +154,7 @@
ignored_count = 0
if not QUIET:
print "Summarizing %s" % filename
-
+
# If the file is a gzipped log, open it
# using the proper function from the gzip
# module.
@@ -165,7 +165,7 @@
file = open(filename, "r")
except IOError, e:
io_error(e, filename, True)
-
+
linecount = 0
shaobj = sha1()
@@ -193,13 +193,13 @@
# foo+=1
shaobj.update(line)
linecount += 1
-
+
if should_be_ignored(line):
ignored_count += 1
if DEBUG:
print "Ignoring: %s" % line
line = file.readline()
-
+
date, rest = split_date(line)
if date:
found = pidpat.search(rest)
@@ -232,7 +232,7 @@
# print foo
states[filename] = (linecount + ignored_count, shaobj.hexdigest())
# print states
-
+
if QUIET and order:
print "Summarizing %s" % filename
if not QUIET or order:
|