OpenWRT script to monitor status of Channels DVR and email on outage


#1

I've had a few occasions where windows decided to update itself and reboot, leaving the Channels DVR offline until i logged into the machine. There's a variety of ways around this, including auto-login, which i decided i didn't want to do. My method was a simple monitoring script that runs every hour from my OpenWRT router.

#!/bin/ash
#
# portcheck.sh
# Port checker/alerter for Channels DVR, emails is service port is not responding.
# Tested on: OpenWrt 18.06.0 r7188-b0b5c64c22
#
# Save to /root/portcheck.sh
# chmod +x portcheck.sh
# To run hourly, add this line to System -> Scheduled tasks:
# 01 * * * * /root/portcheck.sh > /dev/null
#
# requires these packages:
# netcat
# mailsend
# Mail server with which to relay mail
#
# Use netcat to check the port... 
/usr/bin/netcat -zv --wait=10  192.168.1.100 8089
RETVAL=$?
[ $RETVAL -eq 0 ] && echo Success
[ $RETVAL -ne 0 ] && mailsend -smtp smtp.yourserver.com -port 465 -t [email protected] -f [email protected] -sub 'ChannelsDVR offline' -ssl -auth -user [email protected] -pass "<password>" -M "The ChannelsDVR is offline, please check the service"
#
# end

Make sure to adjust the email server settings, and also the IP address of your Channels DVR host. Port (8089) is the default, adjust that as needed.


#2

You can also set it to run as a service in windows and it will run logged in or not.


#3

You should look into Pushover (https://pushover.net/). You can send yourself a push notification.