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
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
slapos.toolbox
Commits
5cf0b54a
Commit
5cf0b54a
authored
Feb 28, 2023
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check_surykatka_json: Implement tcp_server
parent
65add3a8
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
401 additions
and
14 deletions
+401
-14
slapos/promise/plugin/check_surykatka_json.py
slapos/promise/plugin/check_surykatka_json.py
+48
-0
slapos/test/promise/plugin/test_check_surykatka_json.py
slapos/test/promise/plugin/test_check_surykatka_json.py
+353
-14
No files found.
slapos/promise/plugin/check_surykatka_json.py
View file @
5cf0b54a
...
@@ -232,6 +232,53 @@ class RunPromise(GenericPromise):
...
@@ -232,6 +232,53 @@ class RunPromise(GenericPromise):
"OK resolver %s returned expected set of IPs %s"
%
(
"OK resolver %s returned expected set of IPs %s"
%
(
entry
[
'resolver_ip'
],
' '
.
join
(
sorted
(
ip_set
)),))
entry
[
'resolver_ip'
],
' '
.
join
(
sorted
(
ip_set
)),))
def
senseTcpServer
(
self
):
key
=
'tcp_server'
def
appendError
(
msg
,
*
args
):
self
.
error
=
True
self
.
appendMessage
(
key
+
': ERROR '
+
msg
%
args
)
if
key
not
in
self
.
surykatka_json
:
appendError
(
"%r not in %r"
,
key
,
self
.
json_file
)
return
url
=
self
.
getConfig
(
'url'
)
parsed_url
=
urlparse
(
url
)
hostname
=
parsed_url
.
hostname
if
parsed_url
.
port
is
not
None
:
port
=
parsed_url
.
port
else
:
if
parsed_url
.
scheme
==
'https'
:
port
=
443
else
:
port
=
80
ip_set
=
set
(
self
.
getConfig
(
'ip-list'
,
''
).
split
())
entry_list
=
[
q
for
q
in
self
.
surykatka_json
[
key
]
if
hostname
in
[
r
.
strip
()
for
r
in
q
[
'domain'
].
split
(
','
)]
and
q
[
'port'
]
==
port
]
if
len
(
entry_list
)
==
0
:
appendError
(
'No data'
)
return
if
len
(
ip_set
)
>
0
:
self
.
appendMessage
(
'%s:'
%
(
key
,))
for
ip
in
sorted
(
ip_set
):
ok
=
False
for
entry
in
entry_list
:
if
entry
[
'ip'
]
==
ip
:
if
entry
[
'state'
]
==
'closed'
:
ok
=
False
break
if
entry
[
'state'
]
==
'open'
:
ok
=
True
if
ok
:
self
.
appendMessage
(
'OK IP %s:%s'
%
(
ip
,
port
))
else
:
self
.
error
=
True
self
.
appendMessage
(
'ERROR IP %s:%s'
%
(
ip
,
port
))
def
senseElapsedTime
(
self
):
def
senseElapsedTime
(
self
):
key
=
'elapsed_time'
key
=
'elapsed_time'
surykatka_key
=
'http_query'
surykatka_key
=
'http_query'
...
@@ -306,6 +353,7 @@ class RunPromise(GenericPromise):
...
@@ -306,6 +353,7 @@ class RunPromise(GenericPromise):
self
.
senseBotStatus
()
self
.
senseBotStatus
()
elif
report
==
'http_query'
:
elif
report
==
'http_query'
:
self
.
senseDnsQuery
()
self
.
senseDnsQuery
()
self
.
senseTcpServer
()
self
.
senseHttpQuery
()
self
.
senseHttpQuery
()
self
.
senseSslCertificate
()
self
.
senseSslCertificate
()
self
.
senseElapsedTime
()
self
.
senseElapsedTime
()
...
...
slapos/test/promise/plugin/test_check_surykatka_json.py
View file @
5cf0b54a
This diff is collapsed.
Click to expand it.
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