Re: [weewx-user] Re: Database Backup File not a Database Error

2021-01-22 Thread Kevin Chapman
Thank you to everyone that offered advice.  I was able to get my system
restored.  My daily backups went sour around 12-29-2020.  I guess 2020's
final blow.  I was able to use the sqlite3 .read command to restore the
database and then pulled weather station data from wunderground for missing
days.

On Tue, Jan 19, 2021 at 9:39 PM p q  wrote:

> I don't know anything, but I can google...
>
> https://stackoverflow.com/questions/311691/importing-a-sqlite3-dump-back-into-the-database
>
>
> On Tue, Jan 19, 2021 at 7:35 PM Kevin Chapman  wrote:
>
>> Ok the file command is showing the backups to be large ASCII files.  The
>> backup command script is using the sqlite3 .dump command.  The ascii files
>> are the SQL commands to rebuild the file.  Here is the code.
>>
>>
>> echo 'stop the weewx daemon and wait 30 seconds'
>> sudo /usr/sbin/service weewx stop
>> retn_code=$?
>> if [ $retn_code -ne 0 ]; then
>>   exit 7
>> fi
>>
>> sleep 30s
>>
>> echo 'dump sqlite3 database'
>> echo '.dump' | sqlite3 $WEEWX_DB | gzip -c > $DUMP_FILE
>>
>> echo 'restart the weewx daemon'
>> sudo /usr/sbin/service weewx start
>>
>> I am not good with sqlite.  I have read a few different sites talking
>> about how to read a dump file into a database.  So far I am not having luck
>> recovering my database.  If anyone has a site they trust or have a quick
>> command for recovering sqlite dump files it would be much appreciated.  So
>> far when I run sqlite3   and then .read   It seems to run
>> but in about 30 seconds ends at the prompt with no errors on screen and the
>> database file is empty.
>>
>> Thank you all for your input and time.
>>
>> On Monday, January 18, 2021 at 9:20:59 PM UTC-6 vince wrote:
>>
>>> On Monday, January 18, 2021 at 6:47:09 PM UTC-8 kdch...@gmail.com wrote:
>>>
>>>> Now when I try to copy the unpacked sdb and pick up where I left off I
>>>> get a message that the file is not a database.  I have tried a couple of
>>>> archives from Dec and Jan.  All seem to be no good.  I did notice that when
>>>> I reinstalled weewx it is now version 4.3.0.  Could I be dealing with a
>>>> system version mismatch in the file or is there something wrong with my
>>>> backup process.
>>>>
>>>
>>> Very likely a backup process issue, although the steps you mentioned
>>> looked good to me.
>>>
>>> We'd need to see some actual logs or terminal errors to know for certain
>>> what you're actually seeing.
>>>
>>> I guess what I'd do is:
>>>
>>>- grab a recent backup, copy it to a scratch directory
>>>- uncompress it to a .sdb file
>>>- run 'file' against the .sdb file
>>>- If it shows up as a sqlite3 db, then you can validate it with the
>>>sqlite3 utility.
>>>
>>>
>>> Good output looks like
>>>
>>> # file weewx.sdb
>>> weewx.sdb: SQLite 3.x database, last written using SQLite version 3026000
>>>
>>> # echo "pragma integrity_check" | sqlite3 weewx.sdb
>>> ok
>>>
>>>
>>> --
>> 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+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/weewx-user/52eb0a6c-a7d1-4fcf-9f22-717f6bfe22fdn%40googlegroups.com
>> <https://groups.google.com/d/msgid/weewx-user/52eb0a6c-a7d1-4fcf-9f22-717f6bfe22fdn%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>
>
> --
> Peter Quinn
> (415)794-2264
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "weewx-user" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/weewx-user/7B1GyPjoDME/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> weewx-user+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/weewx-user/CAA1SM22FHfufJ-cSdUu9Msufu3U%3DpGi7UsDGeWrNOD07XUjLug%40mail.gmail.com
> <https://groups.google.com/d/msgid/weewx-user/CAA1SM22FHfufJ-cSdUu9Msufu3U%3DpGi7UsDGeWrNOD07XUjLug%40mail.gmail.com?utm_medium=email_source=footer>
> .
>


-- 
-
Kevin Chapman
(713) 245-9368

Life is a food chain.  Be at the top or be on the menu!
-

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/CACwjpb08yyEhdLZ_rhTY9j93Rn3ftOtWX7jy9iJzJVpyQZKS2g%40mail.gmail.com.


[weewx-user] Re: Database Backup File not a Database Error

2021-01-19 Thread Kevin Chapman
Ok the file command is showing the backups to be large ASCII files.  The 
backup command script is using the sqlite3 .dump command.  The ascii files 
are the SQL commands to rebuild the file.  Here is the code.


echo 'stop the weewx daemon and wait 30 seconds'
sudo /usr/sbin/service weewx stop
retn_code=$?
if [ $retn_code -ne 0 ]; then
  exit 7
fi

sleep 30s

echo 'dump sqlite3 database'
echo '.dump' | sqlite3 $WEEWX_DB | gzip -c > $DUMP_FILE

echo 'restart the weewx daemon'
sudo /usr/sbin/service weewx start

I am not good with sqlite.  I have read a few different sites talking about 
how to read a dump file into a database.  So far I am not having luck 
recovering my database.  If anyone has a site they trust or have a quick 
command for recovering sqlite dump files it would be much appreciated.  So 
far when I run sqlite3   and then .read   It seems to run 
but in about 30 seconds ends at the prompt with no errors on screen and the 
database file is empty.  

Thank you all for your input and time.  

On Monday, January 18, 2021 at 9:20:59 PM UTC-6 vince wrote:

> On Monday, January 18, 2021 at 6:47:09 PM UTC-8 kdch...@gmail.com wrote:
>
>> Now when I try to copy the unpacked sdb and pick up where I left off I 
>> get a message that the file is not a database.  I have tried a couple of 
>> archives from Dec and Jan.  All seem to be no good.  I did notice that when 
>> I reinstalled weewx it is now version 4.3.0.  Could I be dealing with a 
>> system version mismatch in the file or is there something wrong with my 
>> backup process.  
>>
>
> Very likely a backup process issue, although the steps you mentioned 
> looked good to me.
>
> We'd need to see some actual logs or terminal errors to know for certain 
> what you're actually seeing.
>
> I guess what I'd do is:
>
>- grab a recent backup, copy it to a scratch directory
>- uncompress it to a .sdb file
>- run 'file' against the .sdb file
>- If it shows up as a sqlite3 db, then you can validate it with the 
>sqlite3 utility.
>
>
> Good output looks like
>
> # file weewx.sdb
> weewx.sdb: SQLite 3.x database, last written using SQLite version 3026000
>
> # echo "pragma integrity_check" | sqlite3 weewx.sdb
> ok
>
>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/52eb0a6c-a7d1-4fcf-9f22-717f6bfe22fdn%40googlegroups.com.


[weewx-user] Database Backup File not a Database Error

2021-01-18 Thread Kevin Chapman
Hello,
I recently experienced a crash of weewx version 4.2.0.  I am still on the 
default Sqlite database.  I have been backing it up nightly since around 
November of last year.  Noob mistake is that I assumed the database file 
backups were good.  

My backup routine consisted of stopping weewx, taking a copy of the sdb 
file and gzipping it to a NAS archive.  Then starting the weewx system.  

Now when I try to copy the unpacked sdb and pick up where I left off I get 
a message that the file is not a database.  I have tried a couple of 
archives from Dec and Jan.  All seem to be no good.  I did notice that when 
I reinstalled weewx it is now version 4.3.0.  Could I be dealing with a 
system version mismatch in the file or is there something wrong with my 
backup process.  


-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/3d88da27-9fa2-43e8-82fa-825cf692cfe7n%40googlegroups.com.


Re: [weewx-user] Re: weewx-cmon doesn't read cpu_temp of Raspberri PI

2020-11-12 Thread Kevin Chapman
Ok cool. I’ll check the database. Thanks for taking the time explaining it.

On Thu, Nov 12, 2020 at 9:02 PM vince  wrote:

> I would look for values in extraTemp1 in your database, as it seems that's
> where the python code is putting it.
>
> A query that would report the last 10 readings of this sorted with most
> recent at the top is:
>
> echo "select
> datetime(dateTime,'unixepoch','localtime'),dateTime,extraTemp1 from archive
> order by rowid desc limit 10;" | sqlite3 weewx.sdb
>
> What this is doing is saying 'give me a human readable date+time, the
> dateTime element, and the extraTemp1 element' from the archive table in the
> weewx.sdb database...and reverse sort it, showing me the 10 most recent
> readings (whew).
>
> The location of weewx.sdb differs depending on how you installed weewx and
> what os you are running.   See
> http://weewx.com/docs/usersguide.htm#Where_to_find_things for what's
> where in the various variants of operating systems etc.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "weewx-user" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/weewx-user/Iny0WMj78cU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> weewx-user+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/weewx-user/8a08f5b0-73be-43ff-aaca-0ec102e5aa2dn%40googlegroups.com
> <https://groups.google.com/d/msgid/weewx-user/8a08f5b0-73be-43ff-aaca-0ec102e5aa2dn%40googlegroups.com?utm_medium=email_source=footer>
> .
>
-- 
-
Kevin Chapman
(713) 245-9368

Life is a food chain.  Be at the top or be on the menu!
-

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/CACwjpb3uUd5jPmH5yfBsce7eBHkKQs0dSGCDcz2oWkA4ZQiD1w%40mail.gmail.com.


Re: [weewx-user] Re: weewx-cmon doesn't read cpu_temp of Raspberri PI

2020-11-12 Thread Kevin Chapman
So below is the code I used from Mike Revitt.  I have no idea if it comes
from a package. I followed Mike’s instructions as well as I could.  He was
not clear what to name it or where to put it.  I created the python script
in the ‘user/share/weewx/user folder.  At first, I named it AddCpuTemp.py
but that generated errors starting weewx.  Then I named it cputemp.py and
the startup errors went away.  I hope that makes sense.



On Thu, Nov 12, 2020 at 6:23 PM vince  wrote:

> We'd have to see the code you're running to look at it in detail.
> Where did you get 'cputemp.py' and how can we get a look at the exact
> version you're running ?
>
> FWIW - you check the temperature on a pi by running "vcgencmd
> measure_temp" which reads the right thing under /proc and formats it for
> output
>
> On Thursday, November 12, 2020 at 3:19:45 PM UTC-8 kdch...@gmail.com
> wrote:
>
>> Ok,  I am not familiar with Python at all.  I managed to work through the
>> instructions above and make the changes to my weewx.conf file and then
>> create cputemp.py in my /usr/share/weewx/user directory.  This eliminated
>> the errors in the my syslog.  I am not seeing the cpu temp on the charts.
>> How would I look up the variables in python to see if they are registering
>> at all.
>>
>>
>>> On Friday, May 8, 2020 at 3:41:39 AM UTC-5, Mike Revitt wrote:
>>>>
>>>> I have this working on my Rasberry pi at
>>>> https://weather.cougar.eu.com/telemetry.html and this is how I did it
>>>>
>>>> in weewx.conf
>>>>
>>>> In
>>>> [Engine]
>>>>  [[Services]]
>>>>
>>>> set
>>>>
>>>> data_services = user.cputemp.AddCpuTemp
>>>>
>>>> Then add this Python program to the bin user directory where your
>>>> Rasberry Pi code is.
>>>>
>>>> #Copyright (c) 2009-2020 Mike Revitt
>>>>
>>>> #See the file LICENSE.txt for your rights.
>>>>
>>>> """Gets the CPU temperature on a Rasberry Pi"""
>>>>
>>>>
>>>>
>>>> *import*  weewx
>>>>
>>>> *from*weewx.engine*import*  StdService
>>>>
>>>> *from*gpiozero*import*  CPUTemperature
>>>>
>>>>
>>>>
>>>> *class* AddCpuTemp(StdService):
>>>>
>>>>
>>>>
>>>> *def* __init__(self, engine, config_dict):
>>>>
>>>>
>>>>
>>>>   # Initialize my superclass first:
>>>>
>>>>   super(AddCpuTemp, self).__init__(engine, config_dict)
>>>>
>>>>
>>>>
>>>>   # Bind to any new archive record events:
>>>>
>>>>   self.bind(weewx.NEW_ARCHIVE_RECORD, self.new_archive_record)
>>>>
>>>>
>>>>
>>>> *def* new_archive_record(self, event):
>>>>
>>>>
>>>>
>>>> cpu = CPUTemperature()
>>>>
>>>>
>>>>
>>>> *if* event.record['usUnits'] == weewx.US:
>>>>
>>>> event.record['extraTemp1'] = ( cpu.temperature * 1.8 ) + 32
>>>>
>>>> *else*:
>>>>
>>>> event.record['extraTemp1'] = cpu.temperature
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> You can then access the Rasberry Pi CPU temperature as the variable
>>>> extraTemp1 from within your HTML files
>>>>
>>> --
-
Kevin Chapman
(713) 245-9368

Life is a food chain.  Be at the top or be on the menu!
-

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/CACwjpb0H5YB6Asi%3DXDOQpFo51pnwnm%3D7wvknCHof5a0Gjy3RLA%40mail.gmail.com.


[weewx-user] Re: weewx-cmon doesn't read cpu_temp of Raspberri PI

2020-11-12 Thread Kevin Chapman
Ok,  I am not familiar with Python at all.  I managed to work through the 
instructions above and make the changes to my weewx.conf file and then 
create cputemp.py in my /usr/share/weewx/user directory.  This eliminated 
the errors in the my syslog.  I am not seeing the cpu temp on the charts.  
How would I look up the variables in python to see if they are registering 
at all.  

On Tuesday, June 9, 2020 at 9:35:28 PM UTC-5 jszit...@gmail.com wrote:

> Mike, I have updated my weewx.conf file.  Could you offer a little more 
> clarification on the new file?  To confirm this is the /usr/bin directory?  
> Does the filename matter?
>
> -Jonathan
>
>
> On Friday, May 8, 2020 at 3:41:39 AM UTC-5, Mike Revitt wrote:
>>
>> I have this working on my Rasberry pi at 
>> https://weather.cougar.eu.com/telemetry.html and this is how I did it
>>
>> in weewx.conf 
>>
>> In
>> [Engine]
>>  [[Services]]
>>
>> set
>>
>> data_services = user.cputemp.AddCpuTemp
>>
>> Then add this Python program to the bin user directory where your 
>> Rasberry Pi code is.
>>
>> #Copyright (c) 2009-2020 Mike Revitt 
>>
>> #See the file LICENSE.txt for your rights.
>>
>> """Gets the CPU temperature on a Rasberry Pi"""
>>
>>
>>
>> *import*  weewx
>>
>> *from*weewx.engine*import*  StdService
>>
>> *from*gpiozero*import*  CPUTemperature
>>
>>
>>
>> *class* AddCpuTemp(StdService):
>>
>>
>>
>> *def* __init__(self, engine, config_dict):
>>
>>
>>
>>   # Initialize my superclass first:
>>
>>   super(AddCpuTemp, self).__init__(engine, config_dict)
>>
>>
>>
>>   # Bind to any new archive record events:
>>
>>   self.bind(weewx.NEW_ARCHIVE_RECORD, self.new_archive_record)
>>
>>
>>
>> *def* new_archive_record(self, event):
>>
>>
>>
>> cpu = CPUTemperature()
>>
>> 
>>
>> *if* event.record['usUnits'] == weewx.US:
>>
>> event.record['extraTemp1'] = ( cpu.temperature * 1.8 ) + 32
>>
>> *else*:
>>
>> event.record['extraTemp1'] = cpu.temperature
>>
>>
>>
>>
>>
>>
>>
>>
>> On Thursday, May 7, 2020 at 3:48:53 PM UTC+1, Luc Heijst wrote:
>>>
>>> Recently I downloaded the latest version of weewx-cmon (v 0.20) which 
>>> was converted to use with python3.
>>> This version, and also elder versions of cmon.py, did not read the 
>>> cpu-temp of my Raspberri PI systems (models 1B, 2B, 3B and 3B+).
>>>
>>> On my raspberry PI the following statement is true: 
>>> *os.path.exists(tdir)*, still a cpu-temp could not be found in this 
>>> section
>>> The *elif os.path.exists(tfile):* statement caused the bottem section 
>>> to be skipped and that is the section that reads the RPI cpu-temp.
>>>
>>> See the modifications in yellow which fixed this problem.
>>>
>>> Luc
>>>
>>> --- snipped of cmon.py ---
>>> # read cpu temperature
>>> tdir = '/sys/class/hwmon/hwmon0/device'
>>> # rpi keeps cpu temperature in a different location
>>> tfile = '/sys/class/thermal/thermal_zone0/temp'
>>> *temp_found = False*
>>> if os.path.exists(tdir):
>>> try:
>>> for f in os.listdir(tdir):
>>> if f.endswith('_input'):
>>> s = self._readproc_line(os.path.join(tdir, f))
>>> if s and len(s):
>>> *temp_found = True*
>>> n = f.replace('_input', '')
>>> t_C = int(s) / 1000 # degree C
>>> record['cpu_' + n] = t_C
>>> except Exception as e:
>>> logdbg("read failed for %s: %s" % (tdir, e))
>>> ### elif os.path.exists(tfile):  ### original statement
>>> if* not temp_found and *os.path.exists(tfile):
>>> try:
>>> s = self._readproc_line(tfile)
>>> t_C = int(s) / 1000 # degree C
>>> record['cpu_temp'] = t_C
>>> except Exception as e:
>>> logdbg("read failed for %s: %s" % (tfile, e))
>>>
>>> ---
>>>
>>>
>> You can then access the Rasberry Pi CPU temperature as the variable 
>> extraTemp1 from within your HTML files 
>>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/849af89d-2e65-469c-a54c-d9574a0781a0n%40googlegroups.com.