Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Łukasz Nowak
slapos.toolbox
Commits
cba31c82
Commit
cba31c82
authored
Feb 12, 2024
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
XXX
parent
48726608
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
1 deletion
+51
-1
slapos/promise/plugin/check_surykatka_json.py
slapos/promise/plugin/check_surykatka_json.py
+51
-1
No files found.
slapos/promise/plugin/check_surykatka_json.py
View file @
cba31c82
...
...
@@ -29,7 +29,7 @@ class RunPromise(GenericPromise):
self
.
getConfig
(
'failure-amount'
,
self
.
getConfig
(
'failure_amount'
,
1
)))
self
.
enabled_sense_list
=
self
.
getConfig
(
'enabled-sense-list'
,
'dns_query tcp_server http_query ssl_certificate elapsed_time'
).
split
()
'dns_query tcp_server http_query ssl_certificate elapsed_time
whois
'
).
split
()
self
.
result_count
=
self
.
failure_amount
self
.
error
=
False
self
.
message_list
=
[]
...
...
@@ -260,6 +260,55 @@ class RunPromise(GenericPromise):
else
:
self
.
appendError
(
'IP %s:%s'
%
(
ip
,
port
))
def
senseWhois
(
self
):
key
=
'whois'
self
.
appendMessage
(
'%s:'
%
(
key
,
))
url
=
self
.
getConfig
(
'url'
)
parsed_url
=
urlparse
(
url
)
hostname
=
parsed_url
.
netloc
if
not
hostname
:
self
.
appendError
(
'url is incorrect'
)
return
domain_expiration_days
=
self
.
getConfig
(
'domain-expiration-days'
,
'30'
)
try
:
domain_expiration_days
=
int
(
domain_expiration_days
)
except
ValueError
:
self
.
appendError
(
'domain-expiration-days %r is incorrect'
%
(
self
.
getConfig
(
'domain-expiration-days'
)))
return
if
key
not
in
self
.
surykatka_json
:
self
.
appendError
(
"%r not in %r"
%
(
key
,
self
.
json_file
))
return
entry_list
=
[
q
for
q
in
self
.
surykatka_json
[
key
]
if
hostname
.
endswith
(
q
[
'domain'
])]
if
len
(
entry_list
)
==
0
:
self
.
appendError
(
'No data'
)
return
if
len
(
entry_list
)
>
1
:
self
.
appendError
(
'Bad data'
)
return
entry
=
entry_list
[
0
]
expiration_date
=
entry
[
'expiration_date'
]
if
expiration_date
is
None
:
self
.
appendError
(
'Expiration date not avaliable'
)
timetuple
=
email
.
utils
.
parsedate
(
expiration_date
)
if
timetuple
is
None
:
self
.
appendError
(
"Can't parse date %s"
%
(
expiration_date
,))
domain_expiration_time
=
datetime
.
datetime
.
fromtimestamp
(
time
.
mktime
(
timetuple
))
if
domain_expiration_time
-
datetime
.
timedelta
(
days
=
domain_expiration_days
)
<
self
.
utcnow
:
self
.
appendError
(
'domain expires in < %s days'
%
(
domain_expiration_days
,))
else
:
self
.
appendOk
(
'domain expires in > %s days'
%
(
domain_expiration_days
,))
def
senseElapsedTime
(
self
):
key
=
'elapsed_time'
self
.
appendMessage
(
'%s:'
%
(
key
,
))
...
...
@@ -326,6 +375,7 @@ class RunPromise(GenericPromise):
(
'http_query'
,
self
.
senseHttpQuery
),
(
'ssl_certificate'
,
self
.
senseSslCertificate
),
(
'elapsed_time'
,
self
.
senseElapsedTime
)
(
'whois'
,
self
.
senseWhois
),
]:
if
check_name
in
self
.
enabled_sense_list
:
check_method
()
...
...
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