*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 <https://groups.google.com/d/msgid/weewx-user/0f85a5ee-7a8a-4eee-9cab-50fb81233630n%40googlegroups.com?utm_medium=email&utm_source=footer>.

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

Reply via email to