Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
picomon
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
glucas
picomon
Commits
0735e600
Commit
0735e600
authored
Jul 20, 2014
by
Jonathan Michalon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only report checks that have failed before last report (act as a reminder)
parent
478e2627
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
6 deletions
+14
-6
lib/checks.py
lib/checks.py
+2
-0
picomon.py
picomon.py
+12
-6
No files found.
lib/checks.py
View file @
0735e600
...
...
@@ -2,6 +2,7 @@ from .subprocess_compat import TimeoutExpired, Popen, PIPE
import
re
from
.
import
mails
from
collections
import
Iterable
from
datetime
import
datetime
class
Host
(
object
):
...
...
@@ -61,6 +62,7 @@ class Check(object):
self
.
retry_count
=
min
(
self
.
retry_count
+
1
,
self
.
retry
)
if
self
.
retry_count
==
self
.
retry
or
immediate
:
if
self
.
ok
:
self
.
failure_date
=
datetime
.
now
()
self
.
ok
=
False
mails
.
send_email_for_check
(
self
)
else
:
...
...
picomon.py
View file @
0735e600
...
...
@@ -5,19 +5,23 @@ from time import sleep
import
config
as
user_config
from
lib
import
config
from
lib
import
mails
from
datetime
import
datetime
,
timedelta
def
create_report
():
def
create_report
(
only_old
=
False
):
has_error
=
False
report
=
''
report
+=
"
\n
Checks in error:
\n
"
now
=
datetime
.
now
()
delta
=
timedelta
(
seconds
=
config
.
emails
.
report
.
every
)
for
check
in
config
.
checks
:
if
not
check
.
ok
:
if
not
check
.
ok
and
(
not
only_old
or
now
-
check
.
failure_date
>
delta
)
:
has_error
=
True
report
+=
'-+'
*
40
+
'
\n
'
report
+=
"%s: %s
\n\t
%s
\n
"
%
(
check
.
target_name
,
check
,
check
.
errmsg
.
strip
())
report
+=
'-+'
*
40
+
"
\n\n
Other checks (usually OK but may be in retry mode):
\n
"
report
+=
"%s: %s
\n
Since %s
\n\t
%s
\n
"
%
(
check
.
target_name
,
check
,
check
.
failure_date
,
check
.
errmsg
.
strip
())
report
+=
'-+'
*
40
+
"
\n\n
"
report
+=
" Other checks (usually OK but may be in retry mode):
\n
"
for
check
in
config
.
checks
:
if
check
.
ok
:
report
+=
"Check %s is %s
\n
"
%
(
check
,
...
...
@@ -33,8 +37,10 @@ def usr1_handler(signum, frame):
def
alarm_handler
(
signum
,
frame
):
(
report
,
err
)
=
create_report
()
(
report
,
err
)
=
create_report
(
only_old
=
True
)
if
err
:
report
=
"Following entries have failed for more than %ss:
\n
"
%
\
config
.
emails
.
report
.
every
+
report
mails
.
send_email_report
(
report
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment