-
Notifications
You must be signed in to change notification settings - Fork 3
/
httpStatusPie.py
53 lines (51 loc) · 1.66 KB
/
httpStatusPie.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import plotly.offline as py
global connection
from datetime import datetime as time
import plotly.graph_objs as go
def plot_http_status_pir(connection):
count_http_requests_count="select count (*) from http"
connection.DBquery.exec_(count_http_requests_count)
while(connection.DBquery.next()):
overall_count=int(connection.DBquery.value(0))
labels=[]
values=[]
statuses_query='select distinct status_code from http'
connection.DBquery.exec_(statuses_query)
while (connection.DBquery.next()):
labels.append(str(connection.DBquery.value(0)))
for i in labels :
count_query="select count(*) from http where status_code=%d"%int(i)
connection.DBquery.exec_(count_query)
while (connection.DBquery.next()):
values.append(str(connection.DBquery.value(0)))
fig = {
"data": [
{
"values": values,
"labels": labels,
"domain": {"x": [0, .48]},
"name": "status codes of HTTP log",
"hoverinfo":"label+percent+name",
"hole": .3,
"type": "pie"
}],
"layout": {
"autosize" : True,
"title":"status codes of HTTP log",
"annotations": [
{
"font": {
"size": 20
},
"showarrow": False,
"text": "statuses",
"x": 0.20,
"y": 0.5
}
]
}
}
now = time.now().strftime('%Y-%m-%d %H:%m:%S')
file = 'BILA-HTTP-statuscodes-%s.html' % now
py.plot(fig, filename=file, auto_open=False)
return file