Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
perun-proxy-utils
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Perun
Perun ProxyIdP
perun-proxy-utils
Commits
ae1c2d24
Commit
ae1c2d24
authored
2 years ago
by
Johana Supíková
Browse files
Options
Downloads
Patches
Plain Diff
feat: script to check RPC availability
parent
c47c8e9f
No related branches found
No related tags found
1 merge request
!27
script to check RPC availability
Pipeline
#277954
passed
2 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
perun/proxy/utils/nagios/check_rpc_status.py
+75
-0
75 additions, 0 deletions
perun/proxy/utils/nagios/check_rpc_status.py
setup.py
+1
-0
1 addition, 0 deletions
setup.py
with
76 additions
and
0 deletions
perun/proxy/utils/nagios/check_rpc_status.py
0 → 100644
+
75
−
0
View file @
ae1c2d24
#!/usr/bin/env python3
import
argparse
import
re
import
sys
import
time
import
requests
"""
check RPC API is available
"""
def
get_args
():
"""
Supports the command-line arguments listed below.
"""
parser
=
argparse
.
ArgumentParser
(
description
=
"
Check RPC status
"
)
parser
.
add_argument
(
"
-u
"
,
"
--username
"
,
required
=
True
,
help
=
"
username for IdP
"
,
)
parser
.
add_argument
(
"
-p
"
,
"
--password
"
,
required
=
True
,
help
=
"
password for IdP
"
,
)
parser
.
add_argument
(
"
-d
"
,
"
--domain
"
,
help
=
"
RPC domain with authentication method (e.g.
'
perun.cesnet.cz/ba
'
)
"
,
required
=
True
,
)
parser
.
add_argument
(
"
-i
"
,
"
--id
"
,
type
=
int
,
help
=
"
valid userId - This id will be used in getUserById call
"
,
required
=
True
,
)
return
parser
.
parse_args
()
def
call_api
(
auth
,
url
,
user_id
):
start_time
=
time
.
time
()
try
:
response
=
requests
.
get
(
url
,
timeout
=
10
,
auth
=
auth
)
rpc_result
=
response
.
text
except
requests
.
Timeout
:
rpc_result
=
"
Request timeout
"
end_time
=
time
.
time
()
total_time
=
end_time
-
start_time
if
re
.
search
(
r
'"
id
"
:
'
+
str
(
user_id
),
rpc_result
):
print
(
f
"
0 check_rpc_status - total_time=
{
total_time
:
.
4
f
}
OK
"
)
return
0
else
:
rpc_result
=
rpc_result
.
replace
(
"
\n
"
,
"
"
)
print
(
f
"
2 check_rpc_status - total_time=
{
total_time
:
.
4
f
}
{
rpc_result
}
"
)
return
2
def
main
():
args
=
get_args
()
auth
=
(
args
.
username
,
args
.
password
)
url
=
f
"
https://
{
args
.
domain
}
/rpc/json/usersManager/getUserById?id=
{
args
.
id
}
"
return
call_api
(
auth
,
url
,
args
.
id
)
if
__name__
==
"
__main__
"
:
sys
.
exit
(
main
())
This diff is collapsed.
Click to expand it.
setup.py
+
1
−
0
View file @
ae1c2d24
...
@@ -13,5 +13,6 @@ setuptools.setup(
...
@@ -13,5 +13,6 @@ setuptools.setup(
"
asyncssh~=2.13
"
,
"
asyncssh~=2.13
"
,
"
docker~=6.0
"
,
"
docker~=6.0
"
,
"
beautifulsoup4~=4.12
"
,
"
beautifulsoup4~=4.12
"
,
"
requests~=2.31
"
,
],
],
)
)
This diff is collapsed.
Click to expand it.
Jednotné přihlášení test
@9008807
mentioned in commit
d8f3b8cc
·
2 years ago
mentioned in commit
d8f3b8cc
mentioned in commit d8f3b8ccae572112042319b5892eb3893fcf2112
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment