Weewx crashing with error associated with ScalarStats.addHiLo

194 views
Skip to first unread message

Redanman

unread,
Apr 26, 2019, 6:57:48 AM4/26/19
to weewx-user
Thank you for any possible insights into what might be causing Weewx to occasionally crash.  The relevant part of the syslog is :

Apr 26 08:20:32 raspberrypi weewx[7715]:     ****    File "/usr/share/weewx/weewx/manager.py", line 1216, in _addSingleRecord
Apr 26 08:20:32 raspberrypi weewx[7715]:     ****      _day_summary.addRecord(record, weight=_weight)
Apr 26 08:20:32 raspberrypi weewx[7715]:     ****    File "/usr/share/weewx/weewx/accum.py", line 256, in addRecord
Apr 26 08:20:32 raspberrypi weewx[7715]:     ****      func(self, record, obs_type, add_hilo, weight)
Apr 26 08:20:32 raspberrypi weewx[7715]:     ****    File "/usr/share/weewx/weewx/accum.py", line 314, in add_value
Apr 26 08:20:32 raspberrypi weewx[7715]:     ****      self[obs_type].addHiLo(val, record['dateTime'])
Apr 26 08:20:32 raspberrypi weewx[7715]:     ****    File "/usr/share/weewx/weewx/accum.py", line 77, in addHiLo
Apr 26 08:20:32 raspberrypi weewx[7715]:     ****      raise ValueError("accum: ScalarStats.addHiLo expected float or int, got %s" % val)
Apr 26 08:20:32 raspberrypi weewx[7715]:     ****  ValueError: accum: ScalarStats.addHiLo expected float or int, got 645138
Apr 26 08:20:32 raspberrypi weewx[7715]:     ****  Exiting.

I have Weewx running on a Raspberry Pi Zero and my weather station is an Aercus WeatherSleuth, so I am using the interceptor driver.  The installation was very stable until I upgraded to rev 3.9.1 a few weeks ago.  Now, every few days Weewx crashes on me.

Leon Shaner

unread,
Apr 26, 2019, 9:40:01 AM4/26/19
to weewx...@googlegroups.com
Mike,

That number doesn't look too big for type int on most modern day systems.  :-/

I am on the same platform.  But my Raspian or python version could be different (I am on latest latest Raspian and python points to python2).

See if you can follow along with these tests and report back if the results differ for you.
Where I put cat, of course you need to edit those files and paste what I showed.

pi@nixie:~ $ cat /var/tmp/maxsize.py
import sys
print sys.maxsize
pi@nixie:~ $ python /var/tmp/maxsize.py
pi@nixie:~ $ python2 /var/tmp/maxsize.py
pi@nixie:~ $ python3 /var/tmp/maxsize.py
  File "/var/tmp/maxsize.py", line 2
    print sys.maxsize
            ^
SyntaxError: Missing parentheses in call to 'print'
pi@nixie:~ $ cat /var/tmp/maxsize3.py
import sys
print (sys.maxsize)
pi@nixie:~ $ python3 /var/tmp/maxsize3.py

Regards,
Leon
--
Leon Shaner :: Dearborn, Michigan (iPhone)
--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Thomas Keffer

unread,
Apr 26, 2019, 11:43:49 AM4/26/19
to weewx-user
I suspect that "number" is actually a string, emitted, somehow, by the interceptor code.

pligg...@gmail.com

unread,
Apr 26, 2019, 6:34:50 PM4/26/19
to weewx-user
I also got the issue two days ago. Strange because I've been running for quite some time now and just the other day was my first crash.

Here's my part of the log when it happened:

Apr 25 07:31:07 raspberrypi weewx[25759]: engine: Main loop exiting. Shutting engine down.
Apr 25 07:31:07 raspberrypi weewx[25759]: engine: Shutting down StdReport thread
Apr 25 07:31:07 raspberrypi weewx[25759]: engine: Caught unrecoverable exception in engine:
Apr 25 07:31:07 raspberrypi weewx[25759]:     ****  accum: ScalarStats.addHiLo expected float or int, got 2190515
Apr 25 07:31:07 raspberrypi weewx[25759]:     ****  Traceback (most recent call last):
Apr 25 07:31:07 raspberrypi weewx[25759]:     ****    File "/usr/share/weewx/weewx/engine.py", line 890, in main
Apr 25 07:31:07 raspberrypi weewx[25759]:     ****      engine.run()
Apr 25 07:31:07 raspberrypi weewx[25759]:     ****    File "/usr/share/weewx/weewx/engine.py", line 202, in run
Apr 25 07:31:07 raspberrypi weewx[25759]:     ****      self.dispatchEvent(weewx.Event(weewx.POST_LOOP))
Apr 25 07:31:07 raspberrypi weewx[25759]:     ****    File "/usr/share/weewx/weewx/engine.py", line 224, in dispatchEvent
Apr 25 07:31:07 raspberrypi weewx[25759]:     ****      callback(event)
Apr 25 07:31:07 raspberrypi weewx[25759]:     ****    File "/usr/share/weewx/weewx/engine.py", line 574, in post_loop
Apr 25 07:31:07 raspberrypi weewx[25759]:     ****      self._software_catchup()
Apr 25 07:31:07 raspberrypi weewx[25759]:     ****    File "/usr/share/weewx/weewx/engine.py", line 646, in _software_catchup
Apr 25 07:31:07 raspberrypi weewx[25759]:     ****      self.engine.dispatchEvent(weewx.Event(weewx.NEW_ARCHIVE_RECORD, record=record, origin='software'))
Apr 25 07:31:07 raspberrypi weewx[25759]:     ****    File "/usr/share/weewx/weewx/engine.py", line 224, in dispatchEvent
Apr 25 07:31:07 raspberrypi weewx[25759]:     ****      callback(event)
Apr 25 07:31:07 raspberrypi weewx[25759]:     ****    File "/usr/share/weewx/user/cmon.py", line 706, in new_archive_record
Apr 25 07:31:07 raspberrypi weewx[25759]:     ****      self.save_data(self.get_data(now, self.last_ts))
Apr 25 07:31:07 raspberrypi weewx[25759]:     ****    File "/usr/share/weewx/user/cmon.py", line 713, in save_data
Apr 25 07:31:07 raspberrypi weewx[25759]:     ****      self.dbm.addRecord(record)
Apr 25 07:31:07 raspberrypi weewx[25759]:     ****    File "/usr/share/weewx/weewx/manager.py", line 246, in addRecord
Apr 25 07:31:07 raspberrypi weewx[25759]:     ****      self._addSingleRecord(record, cursor, log_level)
Apr 25 07:31:07 raspberrypi weewx[25759]:     ****    File "/usr/share/weewx/weewx/manager.py", line 1216, in _addSingleRecord
Apr 25 07:31:07 raspberrypi weewx[25759]:     ****      _day_summary.addRecord(record, weight=_weight)
Apr 25 07:31:07 raspberrypi weewx[25759]:     ****    File "/usr/share/weewx/weewx/accum.py", line 256, in addRecord
Apr 25 07:31:07 raspberrypi weewx[25759]:     ****      func(self, record, obs_type, add_hilo, weight)
Apr 25 07:31:07 raspberrypi weewx[25759]:     ****    File "/usr/share/weewx/weewx/accum.py", line 314, in add_value
Apr 25 07:31:07 raspberrypi weewx[25759]:     ****      self[obs_type].addHiLo(val, record['dateTime'])
Apr 25 07:31:07 raspberrypi weewx[25759]:     ****    File "/usr/share/weewx/weewx/accum.py", line 77, in addHiLo
Apr 25 07:31:07 raspberrypi weewx[25759]:     ****      raise ValueError("accum: ScalarStats.addHiLo expected float or int, got %s" % val)
Apr 25 07:31:07 raspberrypi weewx[25759]:     ****  ValueError: accum: ScalarStats.addHiLo expected float or int, got 2190515
Apr 25 07:31:07 raspberrypi weewx[25759]:     ****  Exiting.

/Micael

mwall

unread,
Apr 26, 2019, 8:14:15 PM4/26/19
to weewx-user
On Friday, April 26, 2019 at 6:34:50 PM UTC-4, pliggen.is wrote:
I also got the issue two days ago. Strange because I've been running for quite some time now and just the other day was my first crash.

what kind of weather station?

what is your interceptor configuration?  (please post the [Interceptor] section from your weewx configuration file)

m

Redanman

unread,
Apr 27, 2019, 8:59:29 AM4/27/19
to weewx-user
For me it's an Aercus WeatherSleuth.  The section of my config pertaining to this device is :

[Interceptor]
    # This section is for the network traffic interceptor driver.
    
    # The driver to use:
    driver = user.interceptor
    port = 55
    device_type = observer

mwall

unread,
Apr 27, 2019, 11:28:14 PM4/27/19
to weewx-user
could you set debug=1 then let weewx run until it crashes.  we need to see the intercepted data and how those data are parsed and/or mapped to weewx database fields.  tom is probably right - somehow the data are coming in as a string instead of an integer.

m

Redanman

unread,
Apr 28, 2019, 2:29:41 AM4/28/19
to weewx-user
I had Debug=1 when it crashed.  I've gone back into the syslog archives and pulled out the section starting roughly 5 minutes before the last crash.  At that point everything seems to be running fine.  See attached.
Mike
syslog.txt

mwall

unread,
Apr 28, 2019, 7:26:02 AM4/28/19
to weewx-user
On Sunday, April 28, 2019 at 2:29:41 AM UTC-4, Redanman wrote:
I had Debug=1 when it crashed.  I've gone back into the syslog archives and pulled out the section starting roughly 5 minutes before the last crash.  At that point everything seems to be running fine.  See attached.

i do not see the value 645138 anywhere in that log snippet.  could you see if it is anywhere in the log prior to the exception you posted at the beginning of this discussion?

we're looking for it in one of the 'raw packet' lines

also, you might want to query your database to see if there are any strings in there.  if you find one, then the timestamp of the record with the string should give you some idea of when in the logs to look

m

Redanman

unread,
Apr 28, 2019, 3:37:16 PM4/28/19
to weewx-user
Sorry, negative on both counts.  I've looked back in the syslog files and I cannot see any problems with the parsing of the interceptor data, or any sign of the value 645138 or 667872.  The weewx.sdb file is full of numbers or null.  The other thing i can mention is that a restart of weewx did not clear the problem, it needed a sudo reboot to get back to normal.

Mike

pligg...@gmail.com

unread,
Apr 29, 2019, 5:07:07 PM4/29/19
to weewx-user
Not sure what interceptor means, maybe something in this?

[FineOffsetUSB]
    # This section is for the Fine Offset series of weather stations.
   
    # The station model, e.g., WH1080, WS1090, WS2080, WH3081
    model = WH1080
   
    # How often to poll the station for data, in seconds
    polling_interval = 60

   
    # The driver to use:
    driver = weewx.drivers.fousb


Redanman

unread,
May 6, 2019, 5:56:45 PM5/6/19
to weewx-user
Weewx crashed again tonight with what seems to be the same root cause.  Here is the syslog just at the moment it crashed.  Again, looking at the data, I cannot see any spurious text/numbers.  Out of interest, is accum.py run every iteration of the engine or only on an interval?  

May  6 20:20:30 raspberrypi weewx[333]: interceptor: MainThread: raw packet: {'wind_speed': 0.0, 'humidity_in': 43.0, 'temperature_in': 68.4, 'barometer': 30.15, 'windchill': 46.9, 'dewpoint': 40.5, 'battery': 0.0, 'humidity_out': 78.0, 'uv': 0.0, 'radiation': 0.15, 'rain': 0.0, 'dateTime': 1557170426, 'temperature_out': 46.9, 'wind_dir': 143.0, 'rain_total': 4.49, 'usUnits': 1, 'wind_gust': 0.0}
May  6 20:20:30 raspberrypi weewx[333]: interceptor: MainThread: mapped packet: {'barometer': 30.15, 'windchill': 46.9, 'dewpoint': 40.5, 'outHumidity': 78.0, 'UV': 0.0, 'radiation': 0.15, 'rain': 0.0, 'dateTime': 1557170426, 'windDir': 143.0, 'outTemp': 46.9, 'windSpeed': 0.0, 'txBatteryStatus': 0.0, 'inTemp': 68.4, 'windGust': 0.0, 'inHumidity': 43.0, 'usUnits': 1}
May  6 20:20:30 raspberrypi weewx[333]: manager: Added record 2019-05-06 20:20:31 BST (1557170431) to database 'cmon.sdb'
May  6 20:20:30 raspberrypi weewx[333]: engine: Main loop exiting. Shutting engine down.
May  6 20:20:30 raspberrypi weewx[333]: engine: Shutting down StdReport thread
May  6 20:20:30 raspberrypi weewx[333]: engine: StdReport thread has been terminated
May  6 20:20:30 raspberrypi weewx[333]: restx: Shut down WOW thread.
May  6 20:20:30 raspberrypi weewx[333]: restx: Shut down PWSWeather thread.
May  6 20:20:31 raspberrypi weewx[333]: restx: Shut down Wunderground-PWS thread.
May  6 20:20:31 raspberrypi weewx[333]: restx: Shut down StationRegistry thread.
May  6 20:20:31 raspberrypi weewx[333]: interceptor: MainThread: shutting down server thread
May  6 20:20:31 raspberrypi weewx[333]: interceptor: MainThread: stop tcp server
May  6 20:20:31 raspberrypi weewx[333]: engine: Caught unrecoverable exception in engine:
May  6 20:20:31 raspberrypi weewx[333]:     ****  accum: ScalarStats.addHiLo expected float or int, got 710464
May  6 20:20:31 raspberrypi weewx[333]:     ****  Traceback (most recent call last):
May  6 20:20:31 raspberrypi weewx[333]:     ****    File "/usr/share/weewx/weewx/engine.py", line 890, in main
May  6 20:20:31 raspberrypi weewx[333]:     ****      engine.run()
May  6 20:20:31 raspberrypi weewx[333]:     ****    File "/usr/share/weewx/weewx/engine.py", line 202, in run
May  6 20:20:31 raspberrypi weewx[333]:     ****      self.dispatchEvent(weewx.Event(weewx.POST_LOOP))
May  6 20:20:31 raspberrypi weewx[333]:     ****    File "/usr/share/weewx/weewx/engine.py", line 224, in dispatchEvent
May  6 20:20:31 raspberrypi weewx[333]:     ****      callback(event)
May  6 20:20:31 raspberrypi weewx[333]:     ****    File "/usr/share/weewx/weewx/engine.py", line 574, in post_loop
May  6 20:20:31 raspberrypi weewx[333]:     ****      self._software_catchup()
May  6 20:20:31 raspberrypi weewx[333]:     ****    File "/usr/share/weewx/weewx/engine.py", line 646, in _software_catchup
May  6 20:20:31 raspberrypi weewx[333]:     ****      self.engine.dispatchEvent(weewx.Event(weewx.NEW_ARCHIVE_RECORD, record=record, origin='software'))
May  6 20:20:31 raspberrypi weewx[333]:     ****    File "/usr/share/weewx/weewx/engine.py", line 224, in dispatchEvent
May  6 20:20:31 raspberrypi weewx[333]:     ****      callback(event)
May  6 20:20:31 raspberrypi weewx[333]:     ****    File "/usr/share/weewx/user/cmon.py", line 704, in new_archive_record
May  6 20:20:31 raspberrypi weewx[333]:     ****      self.save_data(self.get_data(now, self.last_ts))
May  6 20:20:31 raspberrypi weewx[333]:     ****    File "/usr/share/weewx/user/cmon.py", line 711, in save_data
May  6 20:20:31 raspberrypi weewx[333]:     ****      self.dbm.addRecord(record)
May  6 20:20:31 raspberrypi weewx[333]:     ****    File "/usr/share/weewx/weewx/manager.py", line 246, in addRecord
May  6 20:20:31 raspberrypi weewx[333]:     ****      self._addSingleRecord(record, cursor, log_level)
May  6 20:20:31 raspberrypi weewx[333]:     ****    File "/usr/share/weewx/weewx/manager.py", line 1216, in _addSingleRecord
May  6 20:20:31 raspberrypi weewx[333]:     ****      _day_summary.addRecord(record, weight=_weight)
May  6 20:20:31 raspberrypi weewx[333]:     ****    File "/usr/share/weewx/weewx/accum.py", line 256, in addRecord
May  6 20:20:31 raspberrypi weewx[333]:     ****      func(self, record, obs_type, add_hilo, weight)
May  6 20:20:31 raspberrypi weewx[333]:     ****    File "/usr/share/weewx/weewx/accum.py", line 314, in add_value
May  6 20:20:31 raspberrypi weewx[333]:     ****      self[obs_type].addHiLo(val, record['dateTime'])
May  6 20:20:31 raspberrypi weewx[333]:     ****    File "/usr/share/weewx/weewx/accum.py", line 77, in addHiLo
May  6 20:20:31 raspberrypi weewx[333]:     ****      raise ValueError("accum: ScalarStats.addHiLo expected float or int, got %s" % val)
May  6 20:20:31 raspberrypi weewx[333]:     ****  ValueError: accum: ScalarStats.addHiLo expected float or int, got 710464
May  6 20:20:31 raspberrypi weewx[333]:     ****  Exiting.

gjr80

unread,
May 6, 2019, 7:05:39 PM5/6/19
to weewx-user
So the error is arising from data coming from cmon and not the weather station:

May  6 20:20:31 raspberrypi weewx[333]:     ****    File "/usr/share/weewx/user/cmon.py", line 711, in save_data
May  6 20:20:31 raspberrypi weewx[333]:     ****      self.dbm.addRecord(record)

and

Apr 25 19:00:32 raspberrypi weewx[331]: **** File "/usr/share/weewx/user/cmon.py", line 704, in new_archive_record
Apr 25 19:00:32 raspberrypi weewx[331]: **** self.save_data(self.get_data(now, self.last_ts))
Apr 25 19:00:32 raspberrypi weewx[331]: **** File "/usr/share/weewx/user/cmon.py", line 711, in save_data
Apr 25 19:00:32 raspberrypi weewx[331]: **** self.dbm.addRecord(record)

Judging by the 'numbers' involved I would hazard a guess that the routine used by cmon to extract data from some files on the system is returning something other than a float or an int. Judging by the numbers I would be looking at the network traffic.
I recall an earlier thread where network traffic figures being read by cmon were too big for an int, though that would not appear to be the case here.

Perhaps some details of what cmon version, what operating system and WeeWX system hardware might help

Gary

Thomas Keffer

unread,
May 6, 2019, 8:35:28 PM5/6/19
to weewx-user
Or, cmon is reading a value from a /proc file, which are generally strings. Most likely, the author forgot to convert to a float.

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.

Redanman

unread,
May 7, 2019, 2:50:13 AM5/7/19
to weewx-user
My system configuration is :

Weewx version 3.9.1 running on a Raspberry Pi Zero
Aercus Weathersleuth weather station with Weewx using Interceptor driver over local network
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
Kernel = 4.14.62+ #1134 Tue Aug 14 16:58:07 BST 2018 armv6l GNU/Linux
cmon version = 0.16

Hope that helps.
Mike

gjr80

unread,
May 7, 2019, 3:28:46 AM5/7/19
to weewx-user
OK, as far as I can tell cmon 0.16 is doing what it should and it should work fine with a RPi/Stretch. Clearly though something is not working correctly. Cmon is mildly complex with not a lot of debug output so in the absence of Matthew's input could you try making a change to the cmon code. First up make a copy of cmon.py just in case:

$ sudo usr/share/weewx/user/cmon.py usr/share/weewx/user/cmon_orig.py

Then edit usr/share/weewx/user/cmon.py and around line 711 change:

    def save_data(self, record):
       
"""save data to database"""
       
self.dbm.addRecord(record)

to:

    def save_data(self, record):
       
"""save data to database"""
       
loginf("cmon archive record=%s" % (record,))
       
self.dbm.addRecord(record)

Save cmon.py and restart WeeWX. Cmon will now log the archive record it is about to save. Next time cmon causes a crash post the log and we should be able to marry up the value in the stack trace with a field in the cmon archive record.

Gary

Redanman

unread,
May 9, 2019, 1:53:56 AM5/9/19
to weewx-user
OK, that's done and I've checked that the cmon parameters are being written to the syslog.  Let's see what happens.
Mike

Luc Heijst

unread,
May 9, 2019, 4:19:00 PM5/9/19
to weewx-user
On Tuesday, 7 May 2019 03:50:13 UTC-3, Redanman wrote:
My system configuration is :
cmon version = 0.16

Hi Redanman,


For 64-bit systems the net stats values will have type bigint in python2 when they have reached their max values.
Note: Even when the net stats value is in the range of 0..maxint, the type will still be bigint in such a case.
See my solutions in the tread mentioned.

Luc 

Redanman

unread,
May 10, 2019, 2:15:41 AM5/10/19
to weewx-user
Thank you.  Problem solved (hopefully).
Mike
Reply all
Reply to author
Forward
0 new messages