当一组脚本的一个版本运行时,应用RRDTool,您可以尝试更多相同的。。。。。
制作了一个版本的lua脚本,现在它收集电力/能源信息,相关文件create_pipower1A_graph.sh是RRDTool中描述的无错误运行sh文件的直接派生文件,如何通过操作系统从lua脚本中执行调用来获取png文件?
导数sh文件应生成一个包含3个逆变器输出和并联消耗的图形。用于图形输出的sh文件如下。
#!/bin/bash
rrdtool graph /home/pi/pipower1.png
DEF:Pwr_MAC=/home/pi/pipower1.rrd:Power0430:AVERAGE
DEF:Pwr_SAJ=/home/pi/pipower1.rrd:Power1530:AVERAGE
DEF:Pwr_STECA=/home/pi/pipower1.rrd:Power2950:AVERAGE
DEF:Pwr_Cons=/home/pi/pipower1.rrd:Power_Cons:AVERAGE
LINE1:Pwr_MAC#ff0000:Output Involar
LINE1:Pwr_SAJ#0000ff:Output SAJ1.5
LINE1:Pwr_STECA#5fd00b:Output STECA
LINE1:Pwr_Cons#00ffff:Consumption
COMMENT:"ttttttl"
COMMENT:"ttttttl"
GPRINT:Pwr_MAC:LAST:"Output_Involar Latest: %2.1lf"
GPRINT:Pwr_MAC:MAX:" Max.: %2.1lf"
GPRINT:Pwr_MAC:MIN:" Min.: %2.1lf"
COMMENT:"ttttttl"
GPRINT:Pwr_SAJ:LAST:"Output SAJ1.5k Latest: %2.1lf"
GPRINT:Pwr_SAJ:MAX:" Max.: %2.1lf"
GPRINT:Pwr_SAJ:MIN:" Min.: %2.1lf"
COMMENT:"ttttttl"
GPRINT:Pwr_STECA:LAST:"Output STECA Latest: %2.1lf"
GPRINT:Pwr_STECA:MAX:" Max.: %2.1lf"
GPRINT:Pwr_STECA:MIN:" Min.: %2.1lf"
COMMENT:"ttttttl"
GPRINT:Pwr_Cons:LAST:"Consumption Latest: %2.1lf"
GPRINT:Pwr_Cons:MAX:" Max.: %2.1lf"
GPRINT:Pwr_Cons:MIN:" Min.: %2.1lf"
COMMENT:"ttttttl"
--width 700 --height 400
--title="Graph B: Power Production & Consumption for last 24 hour"
--vertical-label="Power(W)"
--watermark "`date`"
lua脚本再次运行,没有出现错误,因此rrd文件会定期更新,生成图形输出,但没有显示任何图形!在2种不同的树莓上进行了测试,但反应没有差异。从命令行运行sh文件create_pipower1A_graph会产生以下错误。
pi@raspberrypi:~$ sudo /home/pi/create_pipower1A_graph.sh
ERROR: 'I' is not a valid function name
pi@raspberrypi:~$ ./create_pipower1A_graph.sh
ERROR: 'I' is not a valid function name
问题:很困惑,因为在sh文件中没有一个I被用作函数命令。解释纠正这个错误的提示?
您的问题在这里:
LINE1:Pwr_MAC#ff0000:Output Involar
LINE1:Pwr_SAJ#0000ff:Output SAJ1.5
LINE1:Pwr_STECA#5fd00b:Output STECA
LINE1:Pwr_Cons#00ffff:Consumption
这些行需要加引号,因为它们包含空格和散列符号。
LINE1:"Pwr_MAC#ff0000:Output Involar"
LINE1:"Pwr_SAJ#0000ff:Output SAJ1.5"
LINE1:"Pwr_STECA#5fd00b:Output STECA"
LINE1:"Pwr_Cons#00ffff:Consumption"