Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
surykatka
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Vincent Pelletier
surykatka
Commits
b498c212
Commit
b498c212
authored
Sep 10, 2021
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow to configure the warning period
parent
fafd25bd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
4 deletions
+13
-4
src/surykatka/bot.py
src/surykatka/bot.py
+6
-3
src/surykatka/cli.py
src/surykatka/cli.py
+5
-1
src/surykatka/configuration.py
src/surykatka/configuration.py
+2
-0
No files found.
src/surykatka/bot.py
View file @
b498c212
...
...
@@ -64,7 +64,9 @@ def rfc822(date):
return
email
.
utils
.
format_datetime
(
date
)
def
filterWarningStatus
(
status_dict
,
interval
,
not_critical_url_list
):
def
filterWarningStatus
(
status_dict
,
interval
,
not_critical_url_list
,
warning_period_duration
):
now
=
datetime
.
datetime
.
utcnow
()
if
interval
<
60
:
interval
=
60
...
...
@@ -83,7 +85,7 @@ def filterWarningStatus(status_dict, interval, not_critical_url_list):
if
(
expiration_date
is
None
)
or
(
(
expiration_date
is
not
None
)
and
(
(
60
*
60
*
24
*
14
)
(
warning_period_duration
)
<
(
parsedate_to_datetime
(
expiration_date
)
-
now
).
total_seconds
()
...
...
@@ -154,7 +156,7 @@ def filterWarningStatus(status_dict, interval, not_critical_url_list):
if
(
(
not_after
is
not
None
)
and
(
(
60
*
60
*
24
*
14
)
(
warning_period_duration
)
<
(
parsedate_to_datetime
(
not_after
)
-
now
).
total_seconds
()
)
)
or
(
...
...
@@ -640,6 +642,7 @@ class WebBot:
status_dict
,
int
(
self
.
config
.
get
(
"INTERVAL"
)),
self
.
calculateNotCriticalUrlList
(),
float
(
self
.
config
[
"WARNING_PERIOD"
]),
)
if
self
.
config
[
"FORMAT"
]
==
"json"
:
print
(
json
.
dumps
(
status_dict
))
...
...
src/surykatka/cli.py
View file @
b498c212
...
...
@@ -37,7 +37,8 @@ from .bot import create_bot
@
click
.
option
(
"--nameserver"
,
"-n"
,
help
=
"The IP of the DNS server."
)
@
click
.
option
(
"--url"
,
"-u"
,
help
=
"The url to check."
)
@
click
.
option
(
"--domain"
,
"-d"
,
help
=
"The domain to check."
)
@
click
.
option
(
"--timeout"
,
"-t"
,
help
=
"The timeout value."
)
@
click
.
option
(
"--timeout"
,
"-t"
,
help
=
"The timeout value (in second)."
)
@
click
.
option
(
"--warning"
,
"-w"
,
help
=
"The warning duration value (in days)."
)
@
click
.
option
(
"--configuration"
,
"-f"
,
help
=
"The path of the configuration file."
)
...
...
@@ -65,6 +66,7 @@ def runSurykatka(
url
,
domain
,
timeout
,
warning
,
configuration
,
reload
,
output
,
...
...
@@ -81,6 +83,8 @@ def runSurykatka(
mapping
[
"URL"
]
=
""
if
timeout
:
mapping
[
"TIMEOUT"
]
=
timeout
if
warning
:
mapping
[
"WARNING_PERIOD"
]
=
str
(
60
*
60
*
24
*
float
(
warning
))
if
sqlite
:
mapping
[
"SQLITE"
]
=
sqlite
if
nameserver
:
...
...
src/surykatka/configuration.py
View file @
b498c212
...
...
@@ -56,6 +56,8 @@ def createConfiguration(
config
[
CONFIG_SECTION
][
"URL"
]
=
""
if
"FORMAT"
not
in
config
[
CONFIG_SECTION
]:
config
[
CONFIG_SECTION
][
"FORMAT"
]
=
"json"
if
"WARNING_PERIOD"
not
in
config
[
CONFIG_SECTION
]:
config
[
CONFIG_SECTION
][
"WARNING_PERIOD"
]
=
str
(
60
*
60
*
24
*
7
)
if
"TIMEOUT"
not
in
config
[
CONFIG_SECTION
]:
config
[
CONFIG_SECTION
][
"TIMEOUT"
]
=
"1"
if
"ELAPSED_FAST"
not
in
config
[
CONFIG_SECTION
]:
...
...
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