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

2024-01-05 Thread salinois

again me,

I can installed the paquet libdbd-sqlite3-perl, I made an error with my 
keyboard, an other one.gr


now the script is OK.

./check_wview.txt
OK - last update was 3.00 seconds ago at 17:35:16 05 janv. 2024| 
lastupdate=0.05;30;120 dewpoint=49.6823087947918 rainRate=0 
appTemp=67.3970645525476 windchill=67.4003136423159 rain=0 
heatindex=66.3327863853724 outHumidity=53.0306676345731 
altimeter=29.6960696753803 soilTemp1=66.8762681818182 
barometer=29.6316015533198 humidex=69.555285488496 
outTemp=67.4003136423159 pressure=27.3071543536385 windGust=0 windrun=0 
windSpeed=0 cloudbase=6323.41291818588


Now , I must test the script of Vince.

thank Matthew

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/ed770556-d2e3-482a-97e8-6e86e7476285%40gmail.com.


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

2024-01-05 Thread salinois

hello Matthew et Vince,

A good news;

your script , Matthew run well, I searched where I had an error, I 
forgotted to add your script inside nrpe.cfg


but now I search why I can't install "E: Impossible de trouver le paquet 
libdb-sqlite3-perl".


result:  ./check_nrpe -H 192.168.0.161 -c check_wview.txt
WARN - last update was 53.00 seconds ago at 14:25:15 05 Jan 2024 - 
perfdata requested but DBI is not installed| 
lastupdate=0.883;30;120


to be continued

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/3b14a1a7-b642--b41e-019cd0b4793d%40gmail.com.


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: 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.


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

2024-01-03 Thread salinois

thanks all

I will test that tomorrow and I will come back to you.

Bye

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/25c5a726-d65c-4432-b38a-7c32bb64d461%40gmail.com.