本文共 1159 字,大约阅读时间需要 3 分钟。
#!/usr/bin/env python
import rrdtool
import timetitle = "server network traffic ("+time.strftime('%Y-%m-d%', time.localtime(time.time()))+")"
rrdtool.graph("flow.png", "--start", "-1d", "--vertical-label=Bytes/s",\ "--x-grid", "MINUTE:15:HOUR:1:HOUR:1:0:%H", \ "--width", "650", "--height", "230", "--title", title, "DEF:inoctets=Flow.rrd:eth1_in:AVERAGE", "DEF:outoctets=Flow.rrd:eth1_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 line\r", "CDEF:inbits=inoctets,8,", "CDEF:outbits=outoctets,8,", "COMMENT:\r", "COMMENT:\r", #"GPRINT:inbits:AVERAGE:Avg In traffic\: %6.21f %Sbps", "COMMENT: ", #"GPRINT:inbits:MAX:MAX In traffic\: %6.21f %Sbps", "COMMENT: ", #"GPRINT:inbits:MIN:MIN In traffic\: %6.21f %Sbps\r", "COMMENT: ", #"GPRINT:outbits:AVERAGE:Avg OUT traffic\: %6.21f %Sbps", "COMMENT: ", #"GPRINT:outbits:MAX:MAX out traffic\: %6.21f %Sbps", "COMMENT: ", #"GPRINT:outbits:MIN:MIN out traffic\: %6.21f %Sbps\r" )本文转自chenzudao51CTO博客,原文链接: http://blog.51cto.com/victor2016/2072209,如需转载请自行联系原作者