-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbench.py
executable file
·34 lines (29 loc) · 999 Bytes
/
bench.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/python
import requests
import time
url_status = {"favicon.ico": 200,\
"index.html": 200,\
"js/atop.js": 200,\
"css/atop.css": 200,\
"template?type=generic": 200,\
"template?type=memory": 200,\
"template?type=disk": 200,\
"template?type=command_line": 200,\
"showsamp": 200,\
"showsamp?lables=ALL×tamp=" + str(int(time.time())): 200,\
"notexist": 404}
def bench():
for num in range(0, 100):
for url, status in url_status.items():
request = 'http://127.0.0.1:2867/' + url
result = requests.get(request)
if result.status_code != status:
sys.exit(request + " failed!")
def main():
pingurl = 'http://127.0.0.1:2867/ping'
ping = requests.get(pingurl)
if ping.status_code != 200:
sys.exit(pingurl + " failed!")
bench()
if __name__ == "__main__":
main()