The code of graph.py is :
# -*- coding: utf-8 -*-
#!/usr/bin/python
import rrdtool
import time
# Define the headline above the chart
title="Server network traffic flow ("+time.strftime('%Y-%m-%d',time.localtime(time.time()))+")"
# Generate a Flow.png file
rrdtool.graph("Flow.png", "--start", "-1d", "--vertical-label=Bytes/s",\
"--x-grid", "MINUTE:12:HOUR:1:0:%H",\
"--width", "650", "--height", "230", "--title", title,
"DEF:inoctets=Flow.rrd:eth0_in:AVERAGE", #Specify the NIC inflow data source DS and CF
"DEF:outoctets=Flow.rrd:eth0_out:AVERAGE", #Specify the network card outgoing traffic data source DS and CF
"CDEF:total=inoctets,outoctets,+", #Combine the incoming and outgoing traffic through the CDEF to get the total traffic total
"LINE1:total#FF8833:Total traffic", #Draw total flow in lines
"AREA:inoctets#00FF00:In traffic", #Draw inflow in area
"LINE1:outoctets#0000FF:Out traffic", #Draw outflow in lines
"HRULE:6144#FF0000:Alarm value\\r", #Draw a horizontal line as an alarm line with a threshold of 6.1K
"CDEF:inbits=inoctets,8,*", #Convert incoming traffic to bit, ie *8, calculate the result to inbits
"CDEF:outbits=outoctets,8,*", #Convert the outgoing traffic to bit, ie *8, and calculate the result to outbits
"COMMENT:\\r", #Output a line break below the grid
"COMMENT:\\r",
"GPRINT:inbits:AVERAGE:Avg In traffic\: %6.21f %Sbps", #Draw inflow average
"COMMENT: ",
"GPRINT:inbits:MAX:Max In traffic\: %6.21f %Sbps", #Draw inflow maximum
"COMMENT: ",
"GPRINT:inbits:MIN:MIN In traffic\: %6.21f %Sbps\\r", #Draw inflow minimum
"COMMENT: ",
"GPRINT:outbits:AVERAGE:Avg Out traffic\: %6.21f %Sbps", #Draw outflow average
"COMMENT: ",
"GPRINT:outbits:MAX:Max Out traffic\: %6.21f %Sbps", #Draw outflow maximum
"COMMENT: ",
"GPRINT:outbits:MIN:MIN Out traffic\: %6.21f %Sbps\\r") #Draw outflow minimum
When I execute " python graph.py "
The error report :
Traceback (most recent call last):
File "graph.py", line 31, in
"GPRINT:outbits:MIN:MIN Out traffic\: %6.21f %Sbps\\r")
rrdtool.OperationalError: invalid x-grid format
How can I slove this problem ?