Re: [weewx-user] Re: monitoring Weewx with Nagios

2024-01-04 Thread salinois

again me, sorry

I forgot to install the Nagios-plugins on my RPi, now is good with this 
command:


./check_nrpe -H 192.168.0.161 -c check_load
WARNING - load average per CPU: 0.17, 0.20, 
0.13|load1=0.168;0.150;0.300;0; load5=0.200;0.100;0.250;0; 
load15=0.133;0.050;0.200;0;


but no good with your script:

./check_nrpe -H 192.168.0.161 -c check_wview.txt
NRPE: Command 'check_wview.txt' not defined

is it my syntax is correct ?!!!

bye I talk to you tommorow

Patrick

sorry again.

Le 04/01/2024 à 13:37, matthew wall a écrit :



On Thursday, January 4, 2024 at 4:54:05 AM UTC-5 sali...@gmail.com wrote:

I just looked at your files, I think "tell me if it's true" that
your Nagios is on the same machine as "Weewx"; my Nagios is on a
server outside the RPi, so I think there must be something missing
in the programs to run it remotely, like I have in the other
Nagios plugins; for example: -H $HOSTADDRESS$ etc etc;

patrick,

if nagios is on the same machine, then you can run the plugin 
directly. but if nagios is on a different machine, then you must 
install the "nagios remote plugin executor" (NRPE) on the machine 
running weewx.  then NRPE will run the plugin.


if you do not want to install NRPE on the weewx machine, then you must 
talk to the weewx machine over standard network interfaces. in that 
case, your nagios plugin might do an http/https request to the weewx 
machine to see when the weewx report was last updated.  of course, 
this assumes that you are running a web server on the weewx machine to 
publish your weewx reports.  you could also run a nagios ssh plugin - 
in that case, the plugin should execute a command on the weewx machine 
that returns the information you want in nagios.  that would use the 
same approach that you see in the nagios_wview plugin (check for 
existance of weewxd process, check database timestamp, return data 
from database as performance data), but do it over an ssh connection 
with shell scripting.


another approach would be to write a weewx service, say weewx-nagios, 
that listens on a network port then provides the information about 
weewxd and report status when it is queried.


or create a weewx-snmp extension that runs on the weewx machine, 
gathers the weewx and report status, but responds to standard snmp 
queries. that would be the most generic approach, and would let you 
monitor weewx using much any tool that can do snmp - nagios, icinga, 
prtg, zabbix, etc.


m
--
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/015ce033-e6db-431e-b63b-7f08cb9291f7n%40googlegroups.com 
.


--
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/e20d225d-e0d7-487a-a0d5-824733865429%40gmail.com.


Re: [weewx-user] Re: monitoring Weewx with Nagios

2024-01-04 Thread salinois

hello again Matthew,

I am testing your script on a RPi of test " no sensors connect", as 
weewx is "/Active: active (exited) since Tue 2023-11-28 21:37:14 CET; 1 
months 6 days ago/", the error done by your script is good.


[CRITICAL - last update was 108331 minutes ago at 17:52:17 21 oct. 2023| 
lastupdate=108331.1;30;120]


I modified your script as that;

my $htfile = '/var/www/html/weewx/index.html';
my $dbfile = '/var/lib/weewx/weewx.sdb';

tell if OK.

I installed on my nagios the plugins NRPE and also on my RPI of test.

which command to test in command line with your script.

Your script must be here only my RPi (ip=192.168.0.161) ?

*I tried it : ./check_nrpe -H 192.168.0.161 -c check_wview.txt from my 
Nagios*


*result: NRPE: Command 'check_wview.txt' not defined*

Excuse for my english and I am newbie in programmation.

files on nagios: /usr/local/nagios/libexec/

 check_tcp
check_breeze check_ifstatus  check_oracle check_time
check_by_ssh check_imap  check_overcr    check_udp
check_clamd  check_ircd  check_ping  check_ups
check_cluster    check_load  check_pop check_uptime
check_dhcp   check_log   check_procs check_users
check_disk   check_mailq check_real check_wave
check_disk_smb   check_mrtg  check_rpc *check_wview.txt*

files on RPi: /usr/local/nagios/libexec
272710 drwxrwxr-x 2 nagios nagios   4096  4 janv. 22:41 .
272681 drwxr-xr-x 6 root   root 4096  4 janv. 20:44 ..
272711 -rwxrwxr-x 1 nagios nagios 106268  4 janv. 20:44 check_nrpe
272722 -rwxrwxr-x 1 nagios nagios   5783  4 janv. 22:16 check_wview.txt
272721 -rwxr-xr-x 1 nagios nagios    419  4 janv. 21:44 
secs-since-modified.sh


    /usr/local/nagios/etc

 272714 drwxrwxr-x 2 nagios nagios  4096  4 janv. 22:04 .
272681 drwxr-xr-x 6 root   root    4096  4 janv. 20:44 ..
272716 -rw-r--r-- 1 nagios nagios 12477  4 janv. 22:04 nrpe.cfg

nrpe.cfg => allowed_hosts=127.0.0.1,::1,192.168.0.200*
*



Patrick


Le 04/01/2024 à 13:37, matthew wall a écrit :



On Thursday, January 4, 2024 at 4:54:05 AM UTC-5 sali...@gmail.com wrote:

I just looked at your files, I think "tell me if it's true" that
your Nagios is on the same machine as "Weewx"; my Nagios is on a
server outside the RPi, so I think there must be something missing
in the programs to run it remotely, like I have in the other
Nagios plugins; for example: -H $HOSTADDRESS$ etc etc;

patrick,

if nagios is on the same machine, then you can run the plugin 
directly. but if nagios is on a different machine, then you must 
install the "nagios remote plugin executor" (NRPE) on the machine 
running weewx.  then NRPE will run the plugin.


if you do not want to install NRPE on the weewx machine, then you must 
talk to the weewx machine over standard network interfaces. in that 
case, your nagios plugin might do an http/https request to the weewx 
machine to see when the weewx report was last updated.  of course, 
this assumes that you are running a web server on the weewx machine to 
publish your weewx reports.  you could also run a nagios ssh plugin - 
in that case, the plugin should execute a command on the weewx machine 
that returns the information you want in nagios.  that would use the 
same approach that you see in the nagios_wview plugin (check for 
existance of weewxd process, check database timestamp, return data 
from database as performance data), but do it over an ssh connection 
with shell scripting.


another approach would be to write a weewx service, say weewx-nagios, 
that listens on a network port then provides the information about 
weewxd and report status when it is queried.


or create a weewx-snmp extension that runs on the weewx machine, 
gathers the weewx and report status, but responds to standard snmp 
queries. that would be the most generic approach, and would let you 
monitor weewx using much any tool that can do snmp - nagios, icinga, 
prtg, zabbix, etc.


m
--
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/015ce033-e6db-431e-b63b-7f08cb9291f7n%40googlegroups.com 
.


--
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/c5f9e3fc-0da1-4eff-9fd5-95d9b1836a73%40gmail.com.


Re: [weewx-user] Re: monitoring Weewx with Nagios

2024-01-04 Thread salinois

*hello Vince,*

I test first in local on my RPi.

I have an error with your scrip.

 bash secs-since-modified.sh
secs-since-modified.sh: ligne 5 : cd: $'/var/lib/weewx/weewx.sdb\r': 
Aucun fichier ou dossier de ce type


secs-since-modified.sh: ligne 8: erreur de syntaxe près du symbole 
inattendu « $'do\r' »

'ecs-since-modified.sh: ligne 8: `do


I modified your script only here

#
cd /var/lib/weewx/weewx.sdb  => here my archive sdb
echo ""

tell me if I have good for modification.


*hello Matthew,*

I modified your script and the result

perl check_wview.txt
CRITICAL - last update was 108324 minutes ago at 17:52:17 21 oct. 2023| 
lastupdate=108323.8;30;120


run in local on RPi for the moment.

patrick




Le 03/01/2024 à 21:51, vince a écrit :
Here's a quick script to print secs since a file was last modified and 
complain if it's more than 10 minutes, as an example.  You could 
alternately throw a snmp trap for nagios to listen for,  use 'logger' 
to log a syslog message, etc.  Many ways to cause something to alert 
in a way that nagios could monitor for.


FWIW - I'd check for the archive being modified 'and' the last skin in 
your typical order to complete successfully, but these days monitoring 
weewx really isn't usually needed once you have it set up and working.


This example just checks that the sdb file(s) are being updated.

#!/bin/bash
#
# ref: 
https://stackoverflow.com/questions/19463334/how-to-get-time-since-file-was-last-modified-in-seconds-with-bash

#
cd /home/pi/weewx-data/archive
echo ""
for FILE in *.sdb
do
  DIFF="$(($(date +%s) - $(date -r ${FILE} +%s)))"
  if [ ${DIFF} -gt 600 ]
  then
      echo -n "ERROR"
  else
      echo -n "OK   "
  fi
  echo "   ${FILE} was last modified ${DIFF} seconds ago"
done
echo ""

Sample output:

pi@pi4:~/weewx-data/archive$ bash /tmp/secs-since-modified.sh

OK      ecowitt.sdb was last modified 53 seconds ago
ERROR   forecast.sdb was last modified 8159 seconds ago
OK      mem.sdb was last modified 60 seconds ago
OK      purpleair.sdb was last modified 60 seconds ago
OK      vp2.sdb was last modified 60 seconds ago

On Wednesday, January 3, 2024 at 12:01:20 PM UTC-8 sali...@gmail.com 
wrote:


ok, I didn't understand everything, but I was able to put "python3
/usr/share/weewx/weewxd" in the nagios plugins, and it responds:
OK: Process exists. Running instances: 1, when I stop weewx it
responds: CRITICAL: Process python3 does not exist, it's a start.
for the archives I don't know how to do it.
THANKS Matthew

On Wednesday, January 3, 2024 at 8:51:51 PM UTC+1 matthew wall wrote:

On Wednesday, January 3, 2024 at 2:38:54 PM UTC-5
sali...@gmail.com wrote:

I would like to monitor my weather station "weewx" with my
Nagios; what process should I monitor to verify that Weewx
is active?


first order would be to check whether weewxd is running.  but
a better check would be to look at the age of the latest
report.  if that report is older than the archive interval,
then warn.  if it is older than 2 or 3 archive intervals, the
fail.

another approach is to make weewx emit status information,
then make your nagios plugin look at that.  a simple way to do
this is make a single weewx template file that emits sensor
timing/status information.  just do a bunch of name=value
pairs so its trivial to parse.  then make your nagios plugin
check the age of that file for the "is weewx emitting data
every archive interval" test, then make each of the names in
the pairs additional information for your nagios checks.

m

--
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/0f85a5ee-7a8a-4eee-9cab-50fb81233630n%40googlegroups.com 
.


--
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/c38adc5b-0e66-4684-85a9-417c0af05161%40gmail.com.


Re: [weewx-user] Re: empty week images due to end of year?

2024-01-04 Thread 'michael.k...@gmx.at' via weewx-user
https://groups.google.com/g/weewx-user/search?q=pil%20attribute%20error
Michael Waldor schrieb am Donnerstag, 4. Januar 2024 um 17:42:34 UTC+1:

> I'm trying to setup my linux laptop as a degugging station for my weewx 
> issue. I've copied all relevant files into my homedirectory resembling the 
> weewx directory structure. Did the same for /var and the like. I enabled 
> python3.11 to be /usr/bin/python. I also installed some python tools not 
> commonly available within my linux distribution (e.g. pillow or cheetha). 
> Finally my call to wee_reports is working nearly (and creates some files 
> within var/www/html/weewx, but no images):
>
> PYTHONPATH=MYROOT/weewx-debug/usr/share/weewx 
> MYROOT/weewx-debug/usr/share/weewx/wee_reports --
> config etc/weewx/weewx.conf --date 2023-12-10 --time=15:00
>
> But I encounter the error
>
> Traceback (most recent call last):
>   File "MYROOT/weewx-debug/usr/share/weewx/weewx/reportengine.py", line 
> 197, in run
> obj.start()
>   File "MYROOT/weewx-debug/usr/share/weewx/weewx/reportengine.py", line 
> 385, in start
> self.run()
>   File "MYROOT/weewx-debug/usr/share/weewx/weewx/imagegenerator.py", line 
> 42, in run
> self.gen_images(self.gen_ts)
>   File "MYROOT/weewx-debug/usr/share/weewx/weewx/imagegenerator.py", line 
> 114, in gen_images
> image = plot.render()
> ^
>   File "MYROOT/weewx-debug/usr/share/weewx/weeplot/genplot.py", line 212, 
> in render
> self._renderBottom(draw)
>   File "MYROOT/weewx-debug/usr/share/weewx/weeplot/genplot.py", line 404, 
> in _renderBottom
> bottom_label_size = draw.textsize(self.bottom_label, 
> font=bottom_label_font)
> 
> 
>   File "MYROOT/weewx-debug/usr/share/weewx/weeplot/genplot.py", line 646, 
> in textsize
> return ImageDraw.ImageDraw.textsize(self, string, **options)
>
> AttributeError: type object 'ImageDraw' has no attribute 'textsize'
> Generating for requested time 2023-12-31 15:00:00 CET (1704031200)
> Using configuration file etc/weewx/weewx.conf
>
> I modified WEEWXROOT to point onto MYROOT.
>
> I admit my current approach is a little bit unconventionally, but I seem 
> to be near to a working debugging environment.
>
> Any hint w.r.t. the above python error?
>
>
> Regards, Michael
>
> Michael Waldor schrieb am Dienstag, 2. Januar 2024 um 07:47:44 UTC+1:
>
>> Thanks for your intrest in my problem. I do have two major changes within 
>> section [imagegenerator]. I've increased the image_width from 500 to 600. 
>> And I've added a second line within some images to include forcast data 
>> from a different database like e.g.
>> [[[daybarometer]]]
>> barometer
>> forecast_barometer
>> data_type = barometer
>> data_binding = dwd_binding
>> label = ' '
>> color = blue
>> And to draw that forecast data I use my new option "time_offset = 36000 
>>  # 10 hours". It's intention is to use the additional 100pixel to be filled 
>> by forecast.
>> See my full skin.conf appended here.
>>
>> Regards, Michael
>>
>>
>> gjr80 schrieb am Montag, 1. Januar 2024 um 21:46:42 UTC+1:
>>
>>> Thank you, so that is the code, just need the plot definition. In fact, 
>>> the entire [ImageGenerator] stanza from the config file in use would be 
>>> best.
>>>
>>> Gary
>>>
>>> On Monday 1 January 2024 at 23:19:52 UTC+10 miwa...@googlemail.com 
>>> wrote:
>>>
 My code is available as a (rejected) pull request 
 https://github.com/weewx/weewx/pull/906 - but the code itself works 
 fine. It enhances the timescale some days into the future to plot forecast 
 data. See my first post for a sample (only forecast data is plotted, 
 measurement data are missing). I assume that my change has a sideeffect 
 when weewx checks if there is data to be drawn. But I have no idea why my 
 problem only arise for the measurement data. From the sample you clearly 
 see that the forecast data contains data from 2023 and 2024, and is 
 plotted. The measuretdata of course only contains data from the past. And 
 even images where no forecast data is to be plotted (e. g dayUV) are 
 missing completely, as soon as the timescale has parts in 2024 and current 
 time is 2023.

 And the problem is difficult to reproduce - as soon as the measurement 
 data has reached 2024, even images generated for old times are fine. 

 gjr80 schrieb am Montag, 1. Januar 2024 um 11:19:42 UTC+1:

> I suspect you will not get too much feedback of value until you post 
> the exact code you are using along with the plot definition from 
> skin.conf. 
> The post you linked is very general in nature and it's not clear if the 
> code you are using is that same as the PRs you submitted or otherwise. I 
> am 
> happy to have a look through your code b

Re: [weewx-user] Re: empty week images due to end of year?

2024-01-04 Thread 'Michael Waldor' via weewx-user
I'm trying to setup my linux laptop as a degugging station for my weewx 
issue. I've copied all relevant files into my homedirectory resembling the 
weewx directory structure. Did the same for /var and the like. I enabled 
python3.11 to be /usr/bin/python. I also installed some python tools not 
commonly available within my linux distribution (e.g. pillow or cheetha). 
Finally my call to wee_reports is working nearly (and creates some files 
within var/www/html/weewx, but no images):

PYTHONPATH=MYROOT/weewx-debug/usr/share/weewx 
MYROOT/weewx-debug/usr/share/weewx/wee_reports --
config etc/weewx/weewx.conf --date 2023-12-10 --time=15:00

But I encounter the error

Traceback (most recent call last):
  File "MYROOT/weewx-debug/usr/share/weewx/weewx/reportengine.py", line 
197, in run
obj.start()
  File "MYROOT/weewx-debug/usr/share/weewx/weewx/reportengine.py", line 
385, in start
self.run()
  File "MYROOT/weewx-debug/usr/share/weewx/weewx/imagegenerator.py", line 
42, in run
self.gen_images(self.gen_ts)
  File "MYROOT/weewx-debug/usr/share/weewx/weewx/imagegenerator.py", line 
114, in gen_images
image = plot.render()
^
  File "MYROOT/weewx-debug/usr/share/weewx/weeplot/genplot.py", line 212, 
in render
self._renderBottom(draw)
  File "MYROOT/weewx-debug/usr/share/weewx/weeplot/genplot.py", line 404, 
in _renderBottom
bottom_label_size = draw.textsize(self.bottom_label, 
font=bottom_label_font)


  File "MYROOT/weewx-debug/usr/share/weewx/weeplot/genplot.py", line 646, 
in textsize
return ImageDraw.ImageDraw.textsize(self, string, **options)
   
AttributeError: type object 'ImageDraw' has no attribute 'textsize'
Generating for requested time 2023-12-31 15:00:00 CET (1704031200)
Using configuration file etc/weewx/weewx.conf

I modified WEEWXROOT to point onto MYROOT.

I admit my current approach is a little bit unconventionally, but I seem to 
be near to a working debugging environment.

Any hint w.r.t. the above python error?


Regards, Michael

Michael Waldor schrieb am Dienstag, 2. Januar 2024 um 07:47:44 UTC+1:

> Thanks for your intrest in my problem. I do have two major changes within 
> section [imagegenerator]. I've increased the image_width from 500 to 600. 
> And I've added a second line within some images to include forcast data 
> from a different database like e.g.
> [[[daybarometer]]]
> barometer
> forecast_barometer
> data_type = barometer
> data_binding = dwd_binding
> label = ' '
> color = blue
> And to draw that forecast data I use my new option "time_offset = 36000  # 
> 10 hours". It's intention is to use the additional 100pixel to be filled by 
> forecast.
> See my full skin.conf appended here.
>
> Regards, Michael
>
>
> gjr80 schrieb am Montag, 1. Januar 2024 um 21:46:42 UTC+1:
>
>> Thank you, so that is the code, just need the plot definition. In fact, 
>> the entire [ImageGenerator] stanza from the config file in use would be 
>> best.
>>
>> Gary
>>
>> On Monday 1 January 2024 at 23:19:52 UTC+10 miwa...@googlemail.com wrote:
>>
>>> My code is available as a (rejected) pull request 
>>> https://github.com/weewx/weewx/pull/906 - but the code itself works 
>>> fine. It enhances the timescale some days into the future to plot forecast 
>>> data. See my first post for a sample (only forecast data is plotted, 
>>> measurement data are missing). I assume that my change has a sideeffect 
>>> when weewx checks if there is data to be drawn. But I have no idea why my 
>>> problem only arise for the measurement data. From the sample you clearly 
>>> see that the forecast data contains data from 2023 and 2024, and is 
>>> plotted. The measuretdata of course only contains data from the past. And 
>>> even images where no forecast data is to be plotted (e. g dayUV) are 
>>> missing completely, as soon as the timescale has parts in 2024 and current 
>>> time is 2023.
>>>
>>> And the problem is difficult to reproduce - as soon as the measurement 
>>> data has reached 2024, even images generated for old times are fine. 
>>>
>>> gjr80 schrieb am Montag, 1. Januar 2024 um 11:19:42 UTC+1:
>>>
 I suspect you will not get too much feedback of value until you post 
 the exact code you are using along with the plot definition from 
 skin.conf. 
 The post you linked is very general in nature and it's not clear if the 
 code you are using is that same as the PRs you submitted or otherwise. I 
 am 
 happy to have a look through your code but I don't want to be chasing my 
 tail or going down the wrong path.

 Gary
 On Monday 1 January 2024 at 18:10:10 UTC+10 miwa...@googlemail.com 
 wrote:

> As expected all images are fine as soon as current time has reached 
> the new year 2024. To be more precise - it has t

Re: [weewx-user] Re: monitoring Weewx with Nagios

2024-01-04 Thread salinois

thanks Matthew,

that is I think, as windows machine. I will try it.

bye

patrick

Le 04/01/2024 à 13:37, matthew wall a écrit :



On Thursday, January 4, 2024 at 4:54:05 AM UTC-5 sali...@gmail.com wrote:

I just looked at your files, I think "tell me if it's true" that
your Nagios is on the same machine as "Weewx"; my Nagios is on a
server outside the RPi, so I think there must be something missing
in the programs to run it remotely, like I have in the other
Nagios plugins; for example: -H $HOSTADDRESS$ etc etc;

patrick,

if nagios is on the same machine, then you can run the plugin 
directly. but if nagios is on a different machine, then you must 
install the "nagios remote plugin executor" (NRPE) on the machine 
running weewx.  then NRPE will run the plugin.


if you do not want to install NRPE on the weewx machine, then you must 
talk to the weewx machine over standard network interfaces. in that 
case, your nagios plugin might do an http/https request to the weewx 
machine to see when the weewx report was last updated.  of course, 
this assumes that you are running a web server on the weewx machine to 
publish your weewx reports.  you could also run a nagios ssh plugin - 
in that case, the plugin should execute a command on the weewx machine 
that returns the information you want in nagios.  that would use the 
same approach that you see in the nagios_wview plugin (check for 
existance of weewxd process, check database timestamp, return data 
from database as performance data), but do it over an ssh connection 
with shell scripting.


another approach would be to write a weewx service, say weewx-nagios, 
that listens on a network port then provides the information about 
weewxd and report status when it is queried.


or create a weewx-snmp extension that runs on the weewx machine, 
gathers the weewx and report status, but responds to standard snmp 
queries. that would be the most generic approach, and would let you 
monitor weewx using much any tool that can do snmp - nagios, icinga, 
prtg, zabbix, etc.


m
--
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/015ce033-e6db-431e-b63b-7f08cb9291f7n%40googlegroups.com 
.


--
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/bd4b6941-1f2c-418c-90b1-f964ab4a230b%40gmail.com.


Re: [weewx-user] Re: monitoring Weewx with Nagios

2024-01-04 Thread cric...@pobox.com
Here's another idea.  I don't know anything about Nagios, but I'm running 
this screwy setup where I made up my own
thermostat(s), and in the living room, the one has a small OLED display for 
set point, current temp, and also outside
temp and wind chill that gets sent from my weather station's weewx via 
MQTT.  I'm sending a few observations along
with the current time from weewx.  The receivers track to make sure the 
values are changing, and I get a text message
when things are askew.  In any case, if Nagios can listen to MQTT messages, 
this is pretty easy to set up.
Chris

On Thursday, January 4, 2024 at 5:37:45 AM UTC-7 matthew wall wrote:

> On Thursday, January 4, 2024 at 4:54:05 AM UTC-5 sali...@gmail.com wrote:
>
> I just looked at your files, I think "tell me if it's true" that your 
> Nagios is on the same machine as "Weewx"; my Nagios is on a server outside 
> the RPi, so I think there must be something missing in the programs to run 
> it remotely, like I have in the other Nagios plugins; for example: -H 
> $HOSTADDRESS$ etc etc;
>
> patrick,
>
> if nagios is on the same machine, then you can run the plugin directly. 
> but if nagios is on a different machine, then you must install the "nagios 
> remote plugin executor" (NRPE) on the machine running weewx.  then NRPE 
> will run the plugin.
>
> if you do not want to install NRPE on the weewx machine, then you must 
> talk to the weewx machine over standard network interfaces. in that case, 
> your nagios plugin might do an http/https request to the weewx machine to 
> see when the weewx report was last updated.  of course, this assumes that 
> you are running a web server on the weewx machine to publish your weewx 
> reports.  you could also run a nagios ssh plugin - in that case, the plugin 
> should execute a command on the weewx machine that returns the information 
> you want in nagios.  that would use the same approach that you see in the 
> nagios_wview plugin (check for existance of weewxd process, check database 
> timestamp, return data from database as performance data), but do it over 
> an ssh connection with shell scripting.
>
> another approach would be to write a weewx service, say weewx-nagios, that 
> listens on a network port then provides the information about weewxd and 
> report status when it is queried.  
>
> or create a weewx-snmp extension that runs on the weewx machine, gathers 
> the weewx and report status, but responds to standard snmp queries. that 
> would be the most generic approach, and would let you monitor weewx using 
> much any tool that can do snmp - nagios, icinga, prtg, zabbix, etc.
>
> m
>

-- 
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/162086cb-b1e1-4fbb-9c4c-6371dbe46292n%40googlegroups.com.


Re: [weewx-user] Re: monitoring Weewx with Nagios

2024-01-04 Thread matthew wall


On Thursday, January 4, 2024 at 4:54:05 AM UTC-5 sali...@gmail.com wrote:

I just looked at your files, I think "tell me if it's true" that your 
Nagios is on the same machine as "Weewx"; my Nagios is on a server outside 
the RPi, so I think there must be something missing in the programs to run 
it remotely, like I have in the other Nagios plugins; for example: -H 
$HOSTADDRESS$ etc etc;

patrick,

if nagios is on the same machine, then you can run the plugin directly. but 
if nagios is on a different machine, then you must install the "nagios 
remote plugin executor" (NRPE) on the machine running weewx.  then NRPE 
will run the plugin.

if you do not want to install NRPE on the weewx machine, then you must talk 
to the weewx machine over standard network interfaces. in that case, your 
nagios plugin might do an http/https request to the weewx machine to see 
when the weewx report was last updated.  of course, this assumes that you 
are running a web server on the weewx machine to publish your weewx 
reports.  you could also run a nagios ssh plugin - in that case, the plugin 
should execute a command on the weewx machine that returns the information 
you want in nagios.  that would use the same approach that you see in the 
nagios_wview plugin (check for existance of weewxd process, check database 
timestamp, return data from database as performance data), but do it over 
an ssh connection with shell scripting.

another approach would be to write a weewx service, say weewx-nagios, that 
listens on a network port then provides the information about weewxd and 
report status when it is queried.  

or create a weewx-snmp extension that runs on the weewx machine, gathers 
the weewx and report status, but responds to standard snmp queries. that 
would be the most generic approach, and would let you monitor weewx using 
much any tool that can do snmp - nagios, icinga, prtg, zabbix, etc.

m

-- 
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/015ce033-e6db-431e-b63b-7f08cb9291f7n%40googlegroups.com.


Re: [weewx-user] Re: monitoring Weewx with Nagios

2024-01-04 Thread salinois

hello Matthew and Vince.

I just looked at your files, I think "tell me if it's true" that your 
Nagios is on the same machine as "Weewx"; my Nagios is on a server 
outside the RPi, so I think there must be something missing in the 
programs to run it remotely, like I have in the other Nagios plugins; 
for example: -H $HOSTADDRESS$ etc etc;


tell me, because I'm not good at programming.

THANKS

Patrick

Le 03/01/2024 à 21:51, vince a écrit :
Here's a quick script to print secs since a file was last modified and 
complain if it's more than 10 minutes, as an example.  You could 
alternately throw a snmp trap for nagios to listen for,  use 'logger' 
to log a syslog message, etc.  Many ways to cause something to alert 
in a way that nagios could monitor for.


FWIW - I'd check for the archive being modified 'and' the last skin in 
your typical order to complete successfully, but these days monitoring 
weewx really isn't usually needed once you have it set up and working.


This example just checks that the sdb file(s) are being updated.

#!/bin/bash
#
# ref: 
https://stackoverflow.com/questions/19463334/how-to-get-time-since-file-was-last-modified-in-seconds-with-bash

#
cd /home/pi/weewx-data/archive
echo ""
for FILE in *.sdb
do
  DIFF="$(($(date +%s) - $(date -r ${FILE} +%s)))"
  if [ ${DIFF} -gt 600 ]
  then
      echo -n "ERROR"
  else
      echo -n "OK   "
  fi
  echo "   ${FILE} was last modified ${DIFF} seconds ago"
done
echo ""

Sample output:

pi@pi4:~/weewx-data/archive$ bash /tmp/secs-since-modified.sh

OK      ecowitt.sdb was last modified 53 seconds ago
ERROR   forecast.sdb was last modified 8159 seconds ago
OK      mem.sdb was last modified 60 seconds ago
OK      purpleair.sdb was last modified 60 seconds ago
OK      vp2.sdb was last modified 60 seconds ago

On Wednesday, January 3, 2024 at 12:01:20 PM UTC-8 sali...@gmail.com 
wrote:


ok, I didn't understand everything, but I was able to put "python3
/usr/share/weewx/weewxd" in the nagios plugins, and it responds:
OK: Process exists. Running instances: 1, when I stop weewx it
responds: CRITICAL: Process python3 does not exist, it's a start.
for the archives I don't know how to do it.
THANKS Matthew

On Wednesday, January 3, 2024 at 8:51:51 PM UTC+1 matthew wall wrote:

On Wednesday, January 3, 2024 at 2:38:54 PM UTC-5
sali...@gmail.com wrote:

I would like to monitor my weather station "weewx" with my
Nagios; what process should I monitor to verify that Weewx
is active?


first order would be to check whether weewxd is running.  but
a better check would be to look at the age of the latest
report.  if that report is older than the archive interval,
then warn.  if it is older than 2 or 3 archive intervals, the
fail.

another approach is to make weewx emit status information,
then make your nagios plugin look at that.  a simple way to do
this is make a single weewx template file that emits sensor
timing/status information.  just do a bunch of name=value
pairs so its trivial to parse.  then make your nagios plugin
check the age of that file for the "is weewx emitting data
every archive interval" test, then make each of the names in
the pairs additional information for your nagios checks.

m

--
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/0f85a5ee-7a8a-4eee-9cab-50fb81233630n%40googlegroups.com 
.


--
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/ea2d4ddd-52cc-4ce1-8181-fd33023c8ca5%40gmail.com.