commit d062235d748717e0d95cd4ad6f95e752abd74a44 Author: Konstantin Ryabitsev icon@mricon.com Date: Mon Mar 21 15:20:49 2005 +0000
Collapses for logins, and fix for monthmap on python-2.4
etc/modules.d/logins.conf.in | 4 ++++ modules/logins_mod.py | 12 +++++++++--- py/epylog/log.py | 4 ++-- 3 files changed, 15 insertions(+), 5 deletions(-) --- diff --git a/etc/modules.d/logins.conf.in b/etc/modules.d/logins.conf.in index 1c751d6..fa5867d 100644 --- a/etc/modules.d/logins.conf.in +++ b/etc/modules.d/logins.conf.in @@ -33,3 +33,7 @@ enable_proftpd = 0 # this off specify something like: # safe_domains = !.* safe_domains = .* +## +# If you have too many systems, wide-scale probing may turn ugly. This +# will collapse the reports. +systems_collapse = 10 diff --git a/modules/logins_mod.py b/modules/logins_mod.py index 983e203..bb64153 100644 --- a/modules/logins_mod.py +++ b/modules/logins_mod.py @@ -153,6 +153,7 @@ class logins_mod(InternalModule):
self.safe_domains = [] safe_domains = opts.get('safe_domains', '.*') + self.systems_collapse = int(opts.get('systems_collapse', '10')) for domain in safe_domains.split(','): domain = domain.strip() if domain: @@ -216,6 +217,7 @@ class logins_mod(InternalModule): self.flip = ' bgcolor="#dddddd"'
self.line_rep = '<tr%s><td valign="top" width="15%%">%s</td><td valign="top" width="15%%">%s</td><td width="70%%">%s</td></tr>\n' + self.collapsed_rep = '%s <font color="red">[%s more skipped]</font>'
## # LINE MATCHING ROUTINES @@ -673,9 +675,13 @@ class logins_mod(InternalModule): mymap = rs.get_submap((action, key, service)) key2s = [] for key2 in mymap.keys(): - field = key2[0] - key2s.append('%s(%d)' % (field, mymap[key2])) - service_rep.append([service, ', '.join(key2s)]) + loghost = key2[0] + key2s.append('%s(%d)' % (loghost, mymap[key2])) + if len(key2s) > self.systems_collapse: + loghosts = self.collapsed_rep % (key2s[0],len(key2s)-1) + else: + loghosts = ', '.join(key2s) + service_rep.append([service, loghosts]) blank = 0 for svcrep in service_rep: if blank: key = ' ' diff --git a/py/epylog/log.py b/py/epylog/log.py index 07a2557..30b2e39 100644 --- a/py/epylog/log.py +++ b/py/epylog/log.py @@ -52,8 +52,8 @@ def mkmonthmap(): pad = 2 months = [] for i in range(0, 12): - months.append(time.strftime("%b", (0, i+1, 0, 0, - 0, 0, 0, 0, 0))) + months.append(time.strftime("%b", (1, i+1, 1, 1, + 1, 1, 1, 1, 1))) basetime = time.localtime(time.time()) now_year = basetime[0] now_month = basetime[1]