forked from yorkoliu/pyauto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraph.py
30 lines (29 loc) · 1.08 KB
/
graph.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
# -*- coding: utf-8 -*-
#!/usr/bin/python
import rrdtool
import time
title="Server network traffic flow ("+time.strftime('%Y-%m-%d',time.localtime(time.time()))+")"
rrdtool.graph( "Flow.png", "--start", "-1d","--vertical-label=Bytes/s","--x-grid","MINUTE:12:HOUR:1:HOUR:1:0:%H",\
"--width","650","--height","230","--title",title,
"DEF:inoctets=Flow.rrd:eth0_in:AVERAGE",
"DEF:outoctets=Flow.rrd:eth0_out:AVERAGE",
"CDEF:total=inoctets,outoctets,+",
"LINE1:total#FF8833:Total traffic",
"AREA:inoctets#00FF00:In traffic",
"LINE1:outoctets#0000FF:Out traffic",
"HRULE:6144#FF0000:Alarm value\\r",
"CDEF:inbits=inoctets,8,*",
"CDEF:outbits=outoctets,8,*",
"COMMENT:\\r",
"COMMENT:\\r",
"GPRINT:inbits:AVERAGE:Avg In traffic\: %6.2lf %Sbps",
"COMMENT: ",
"GPRINT:inbits:MAX:Max In traffic\: %6.2lf %Sbps",
"COMMENT: ",
"GPRINT:inbits:MIN:MIN In traffic\: %6.2lf %Sbps\\r",
"COMMENT: ",
"GPRINT:outbits:AVERAGE:Avg Out traffic\: %6.2lf %Sbps",
"COMMENT: ",
"GPRINT:outbits:MAX:Max Out traffic\: %6.2lf %Sbps",
"COMMENT: ",
"GPRINT:outbits:MIN:MIN Out traffic\: %6.2lf %Sbps\\r")