Last seen threshold warning notification with Pushover

Hello all!

I’m posting a bash script I’ve made for my own purposes that checks when the devices specified were last seen connecting to the device where this script is being run from:

syncthing-check.sh (2.9 KB)

Feel free to adapt it to your needs, but please use at your own risk. You can also add it to your crontab to be run on a schedule, should you so desire.

NOTE: You need jq for the script to parse properly.

3 Likes

Thanks for sharing that @vaupo !

I did something like that on one of my Win11 Devices with Task Scheduler and a batch file. I don’t care to use PowerShell.

for /f “delims=” %%i in (‘curl -sk -H “X-API-Key: %MONAPIKEY%” https://%MONTAILIP%:8384/rest/stats/device ^| jq .““%MONDEVID%”.lastSeen”’) do set “SLSMON=%%i”
if “%SLSMON:~21,5%” == “05:00” SET TZ=CDT
if “%SLSMON:~21,5%” == “06:00” SET TZ=CST
SET LSMONDATE=%SLSAPH:~1,10%
SET LSMONTIME=%SLSAPH:~12,8%
SET CXNMON=DOWN - Last Seen %LSMONDATE% at %LSMONTIME% %TZ%


Mine requires jq as well.

1 Like

@chaos I think the forum software has messed up your quotes, and the script won’t work without fixing them first.

1 Like

Sir, I went through it character by character. The quotes from this snippet are correct. The mixture of weird batch file limitations with jq make it look funky.

What I mean is that the forum has changed all vertical " and ' quotation marks to their curly alternatives and , and and , which I doubt will work in an actual batch script :sweat_smile:.

2 Likes

I missed that! Thank you!