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.

Reply via email to