root / plugins / zope / zope_conflict_errors @ a7139bca
Historique | Voir | Annoter | Télécharger (2,04 ko)
| 1 | a7139bca | Lars Kruse | #!/usr/bin/env python |
|---|---|---|---|
| 2 | 93b0f4f3 | Logilab | # |
| 3 | # Copyright (c) 2008 LOGILAB S.A. (Paris, FRANCE). |
||
| 4 | # http://www.logilab.fr/ -- mailto:contact@logilab.fr |
||
| 5 | # |
||
| 6 | # This program is free software; you can redistribute it and/or modify it under |
||
| 7 | # the terms of the GNU General Public License as published by the Free Software |
||
| 8 | # Foundation; either version 2 of the License, or (at your option) any later |
||
| 9 | # version. |
||
| 10 | # |
||
| 11 | # This program is distributed in the hope that it will be useful, but WITHOUT |
||
| 12 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
||
| 13 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details |
||
| 14 | # |
||
| 15 | # You should have received a copy of the GNU General Public License along with |
||
| 16 | # this program; if not, write to the Free Software Foundation, Inc., |
||
| 17 | # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||
| 18 | #%# family=contrib |
||
| 19 | #%# capabilities=autoconf suggest |
||
| 20 | |||
| 21 | # this should really go in plugins.conf |
||
| 22 | # logs = ['/var/lib/zope/plone-site/event.log',] |
||
| 23 | logs = [] |
||
| 24 | date_format = '%Y-%m-%dT%H:%M:%S' |
||
| 25 | #end config |
||
| 26 | |||
| 27 | from sys import argv |
||
| 28 | from datetime import datetime |
||
| 29 | import time |
||
| 30 | |||
| 31 | |||
| 32 | if len(argv) > 1: |
||
| 33 | if argv[1] == 'config': |
||
| 34 | |||
| 35 | 17f78427 | Lars Kruse | print """graph_title Zope Conflict Errors |
| 36 | graph_vlabel Count |
||
| 37 | 68bb709d | dipohl | graph_category appserver |
| 38 | 93b0f4f3 | Logilab | graph_info The number of conflict errors in event logs over the past 24h""".replace("\n ","\n")
|
| 39 | for i in range(0,len(logs)): |
||
| 40 | print """error_count%(i)s.label %(n)s error count"""% dict(i=i, |
||
| 41 | n=logs[i]) |
||
| 42 | elif argv[1] == 'autoconf': |
||
| 43 | print 'yes' |
||
| 44 | else: |
||
| 45 | for i in range(0,len(logs)): |
||
| 46 | log = logs[i] |
||
| 47 | error_count = 0 |
||
| 48 | for line in file(log): |
||
| 49 | f776b7e0 | Lars Kruse | tokens = line.split() |
| 50 | if 'ConflictError' in tokens: |
||
| 51 | logdate = datetime(*time.strptime(tokens[0], date_format)[:-3]) |
||
| 52 | 93b0f4f3 | Logilab | delta = datetime.now() - logdate |
| 53 | if delta.days >= 1: |
||
| 54 | continue |
||
| 55 | 17f78427 | Lars Kruse | error_count += 1 |
| 56 | 93b0f4f3 | Logilab | id = dict(i=i) |
| 57 | print 'error_count%(i)s.value' % id, error_count |
