Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
류은제
bai-monitoring-api
Commits
6d8c1a0d
Commit
6d8c1a0d
authored
Mar 07, 2023
by
류은제
Browse files
Update app.py
parent
45c6aa33
Changes
1
Hide whitespace changes
Inline
Side-by-side
app.py
View file @
6d8c1a0d
...
@@ -209,10 +209,8 @@ def extract_utilization():
...
@@ -209,10 +209,8 @@ def extract_utilization():
result_dict
=
{
"results"
:
result_dict
}
result_dict
=
{
"results"
:
result_dict
}
# convert type dict to json
# json 결과값을 Content-type: application/json으로 반환하도록 jsonify 사용
result_json
=
json
.
dumps
(
result_dict
)
result_json
=
jsonify
(
result_dict
)
print
(
result_json
)
return
result_json
return
result_json
...
@@ -227,10 +225,7 @@ app = Flask(__name__)
...
@@ -227,10 +225,7 @@ app = Flask(__name__)
def
myfunction_api
():
def
myfunction_api
():
result
=
extract_utilization
()
result
=
extract_utilization
()
return
result
# json 결과값을 Content-type: application/json으로 반환하도록 jsonify 사용
return
jsonify
(
result
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
@@ -239,11 +234,3 @@ if __name__ == "__main__":
...
@@ -239,11 +234,3 @@ if __name__ == "__main__":
# api url
# api url
# http://10.231.238.231:31000/api/getMonitoring
# http://10.231.238.231:31000/api/getMonitoring
'''
result (type: json)
"{
\"
results
\"
: {
\"
item1
\"
: {
\"
id
\"
:
\"
i-ai-1
\"
,
\"
cpu
\"
: 4.08,
\"
cuda
\"
: 53.25,
\"
mem
\"
:
\"
4.76
\"
,
\"
disk
\"
:
\"
25.02
\"
},
\"
item2
\"
: {
\"
id
\"
:
\"
i-ai-2
\"
,
\"
cpu
\"
: 5.27,
\"
cuda
\"
: 45.25,
\"
mem
\"
:
\"
7.41
\"
,
\"
disk
\"
:
\"
8.44
\"
},
\"
item3
\"
: {
\"
id
\"
:
\"
i-ai-3
\"
,
\"
cpu
\"
: 1.41,
\"
cuda
\"
: 20.62,
\"
mem
\"
:
\"
4.13
\"
,
\"
disk
\"
:
\"
8.27
\"
},
\"
item4
\"
: {
\"
id
\"
:
\"
i-ai-4
\"
,
\"
cpu
\"
: 4.16,
\"
cuda
\"
: 37.5,
\"
mem
\"
:
\"
5.46
\"
,
\"
disk
\"
:
\"
8.35
\"
},
\"
item5
\"
: {
\"
id
\"
:
\"
i-ai-5
\"
,
\"
cpu
\"
: 1.08,
\"
cuda
\"
: 33.88,
\"
mem
\"
:
\"
8.98
\"
,
\"
disk
\"
:
\"
41.02
\"
},
\"
item6
\"
: {
\"
id
\"
:
\"
i-ai-6
\"
,
\"
cpu
\"
: 0.12,
\"
cuda
\"
: 0.0,
\"
mem
\"
:
\"
1.15
\"
,
\"
disk
\"
:
\"
90.91
\"
},
\"
time
\"
:
\"
2023-03-06T19:38:45.710251+09:00
\"
}}"
'''
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment