I am starting btmon as root with the following (IP and password obfuscated):
/home/ecm1240/btmon/btmon.py --quiet --buffer-size=2592000 --serial --serial-port=/dev/ttyS0 --mysql --mysql-host=192.168.n.n --mysql-passwd=********* --mysql-insert-period=60 &
It runs successfully without issue with the following observation and exception (debug mode used to see why the behavior was occurring):
- The buffer info never decrements after successfully writing to mysql. I would expect this to reset to 0 of 2592000 once a mysql write has occured.
- If the mysql service is ever restarted/stopped or the server rebooted (even when btmon is not attempting the write), at the next mysql write cycle, I get the following error, "MySQL server has gone away" and no data is ever again written to MySQL even though btmon continues to collect data.
- Since the buffer info never decrements, what happens when btmon reaches the buffer-size (even though it may have been successfully writing the data out to the db every minute)?
- Why does btmon not attempt to reconnect to MySQL, I thought that was the whole point of the buffer?
Code: Select all
2013/12/09 11:42:30 SERIAL: waiting for data
2013/12/09 11:42:30 reading 1 of 1 packets
2013/12/09 11:42:31 buffering packet ts:1386618151 sn:404774
2013/12/09 11:42:31 buffer info:
2013/12/09 11:42:31 404774: 175 of 2592000 (1386618151)
2013/12/09 11:42:31 processing with MySQLProcessor
2013/12/09 11:42:31 waiting 7 seconds to process packets for 404774
2013/12/09 11:42:31 SERIAL: waiting for data
2013/12/09 11:42:31 reading 1 of 1 packets
2013/12/09 11:42:32 buffering packet ts:1386618152 sn:404774
2013/12/09 11:42:32 buffer info:
2013/12/09 11:42:32 404774: 176 of 2592000 (1386618152)
2013/12/09 11:42:32 processing with MySQLProcessor
2013/12/09 11:42:32 waiting 6 seconds to process packets for 404774
2013/12/09 11:42:32 SERIAL: waiting for data
2013/12/09 11:42:32 reading 1 of 1 packets
2013/12/09 11:42:33 buffering packet ts:1386618153 sn:404774
2013/12/09 11:42:33 buffer info:
2013/12/09 11:42:33 404774: 177 of 2592000 (1386618153)
2013/12/09 11:42:33 processing with MySQLProcessor
2013/12/09 11:42:33 waiting 5 seconds to process packets for 404774
2013/12/09 11:42:33 SERIAL: waiting for data
2013/12/09 11:42:33 reading 1 of 1 packets
2013/12/09 11:42:34 buffering packet ts:1386618154 sn:404774
2013/12/09 11:42:34 buffer info:
2013/12/09 11:42:34 404774: 178 of 2592000 (1386618154)
2013/12/09 11:42:34 processing with MySQLProcessor
2013/12/09 11:42:34 waiting 4 seconds to process packets for 404774
2013/12/09 11:42:34 SERIAL: waiting for data
2013/12/09 11:42:34 reading 1 of 1 packets
2013/12/09 11:42:35 buffering packet ts:1386618155 sn:404774
2013/12/09 11:42:35 buffer info:
2013/12/09 11:42:35 404774: 179 of 2592000 (1386618155)
2013/12/09 11:42:35 processing with MySQLProcessor
2013/12/09 11:42:35 waiting 3 seconds to process packets for 404774
2013/12/09 11:42:35 SERIAL: waiting for data
2013/12/09 11:42:35 reading 1 of 1 packets
2013/12/09 11:42:36 buffering packet ts:1386618156 sn:404774
2013/12/09 11:42:36 buffer info:
2013/12/09 11:42:36 404774: 180 of 2592000 (1386618156)
2013/12/09 11:42:36 processing with MySQLProcessor
2013/12/09 11:42:36 waiting 2 seconds to process packets for 404774
2013/12/09 11:42:36 SERIAL: waiting for data
2013/12/09 11:42:36 reading 1 of 1 packets
2013/12/09 11:42:37 buffering packet ts:1386618157 sn:404774
2013/12/09 11:42:37 buffer info:
2013/12/09 11:42:37 404774: 181 of 2592000 (1386618157)
2013/12/09 11:42:37 processing with MySQLProcessor
2013/12/09 11:42:37 waiting 1 seconds to process packets for 404774
2013/12/09 11:42:37 SERIAL: waiting for data
2013/12/09 11:42:37 reading 1 of 1 packets
2013/12/09 11:42:38 buffering packet ts:1386618158 sn:404774
2013/12/09 11:42:38 buffer info:
2013/12/09 11:42:38 404774: 182 of 2592000 (1386618158)
2013/12/09 11:42:38 processing with MySQLProcessor
2013/12/09 11:42:38 61 buffered packets sn:404774
2013/12/09 11:42:38 60 calculated packets sn:404774
2013/12/09 11:42:38 DB: query: INSERT INTO ecm.ecm1240bin_counters (time_created,serial,secs,volts,ch1_a,ch2_a,ch1_aws,ch2_aws,ch1_pws,
ch2_pws,aux1_ws,aux2_ws,aux3_ws,aux4_ws,aux5_ws,aux5_volts) VALUES (1386618099,'404774',173706,118.1,15.7,0.58,67201859,168494,9535
,21831,50,175,276,117,6564,510)
2013/12/09 11:42:38 Exception in MySQLProcessor: (2006, 'MySQL server has gone away')
Traceback (most recent call last):
File "/home/ecm1240/btmon/btmon.py", line 1986, in process
p.process_compiled(self.packet_collector.packet_buffer)
File "/home/ecm1240/btmon/btmon.py", line 2556, in process_compiled
self.process_calculated(packets)
File "/home/ecm1240/btmon/btmon.py", line 2605, in process_calculated
cursor.execute(''.join(sql))
File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in execute
self.errorhandler(self, exc, value)
File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
OperationalError: (2006, 'MySQL server has gone away')
2013/12/09 11:42:38 SERIAL: waiting for data
2013/12/09 11:42:38 reading 1 of 1 packets
2013/12/09 11:42:39 buffering packet ts:1386618159 sn:404774
2013/12/09 11:42:39 buffer info:
2013/12/09 11:42:39 404774: 183 of 2592000 (1386618159)
2013/12/09 11:42:39 processing with MySQLProcessor
2013/12/09 11:42:39 waiting 59 seconds to process packets for 404774
2013/12/09 11:42:39 SERIAL: waiting for data
2013/12/09 11:42:39 reading 1 of 1 packets
2013/12/09 11:42:40 buffering packet ts:1386618160 sn:404774
2013/12/09 11:42:40 buffer info:
2013/12/09 11:42:40 404774: 184 of 2592000 (1386618160)
2013/12/09 11:42:40 processing with MySQLProcessor
2013/12/09 11:42:40 waiting 58 seconds to process packets for 404774