Critical CDVR Log Alerts via E-Mail

I've added a feature to OliveTin-for-Channels to support getting "critical" (whatever that means to you :slight_smile:) CDVR log alerts via e-mail. There are 3 filters (let me know if more are needed) available that work in a this-or-this-or-this style. Basically any text you find in your CDVR server log where you'd like to get an e-mail the next time that same text string is found.

Matches to your filters will be continuously collected, and then sent at whatever frequency you choose. Find strings you'd like to use in the server log, and then you can test them using the "Generate Filtered Channels DVR Log" Action button to see how often they've occurred in the last x lines if you like.

You can monitor for failed recordings, Comskip failures, or pretty much whatever. You'll need to pull the most recent bnhf/olivetin:latest, use the docker-compose posted here, and add values to several newly required environment variables.

If you don't already have one you'll want to create an "app password" on your GMail or Yahoo Mail account to use for your password. You'll also need to identify the absolute path to your Channels DVR logs, if OliveTin is on the same host. Or, if that directory is on a different host, you can share it via Samba or NFS, and create a Docker-Volume to connect to it. It's basically the same process as setting up the DVR_SHARE variable, but this one is called LOGS_SHARE.

Multiple DVRs are supported. Be sure to run the basic "OliveTin Post-Install Healthcheck" to confirm you have everything set up correctly:

screenshot-htpc6-2024.04.09-08_50_51

Updated docker-compose:

version: '3.9'
services:
  olivetin: # This docker-compose requires little or no editing. Set the Environment variables section of Portainer.
    # GitHub home for this project: https://github.com/bnhf/OliveTin.
    # Docker container home for this project with setup instructions: https://hub.docker.com/repository/docker/bnhf/olivetin.
    image: bnhf/olivetin:${TAG} # Add the tag like latest or test to the environment variables below.
    container_name: olivetin
    hostname: olivetin
    dns_search: ${DOMAIN} # For Tailscale users using Magic DNS, add your Tailnet (tailxxxxx.ts.net) to use hostnames for remote nodes, otherwise use your local domain name.
    ports:
      - ${HOST_PORT}:1337
    environment:
      - CHANNELS_DVR=${CHANNELS_DVR_HOST}:${CHANNELS_DVR_PORT} # Add your Channels DVR server in the form CHANNELS_DVR_HOST=<hostname or ip> and CHANNELS_DVR_PORT=<port>.
      - CHANNELS_DVR_ALTERNATES=${CHANNELS_DVR2_HOST}:${CHANNELS_DVR2_PORT} # Space separated list of alternate Channels DVR servers to choose from in the form hostname:port or ip:port.
      - CHANNELS_CLIENTS=${CHANNELS_CLIENTS} # Space separated list of Channels DVR clients you'd like notifications sent to in the form hostname or IP.
      - ALERT_SMTP_SERVER=${ALERT_SMTP_SERVER} # SMTP server to use for sending alert e-mails. smtp.gmail.com:587 for example.
      - ALERT_EMAIL_FROM=${ALERT_EMAIL_FROM} # Sender address for alert e-mails.
      - ALERT_EMAIL_PASS=${ALERT_EMAIL_PASS} # SMTP "app" password established through GMail or Yahoo Mail. Do not use your everyday e-mail address.
      - ALERT_EMAIL_TO=${ALERT_EMAIL_TO} # Recipient address for alert e-mails.
      - UPDATE_YAMLS=${UPDATE_YAMLS} # Set this to true to update config.yaml.
      - UPDATE_SCRIPTS=${UPDATE_SCRIPTS} # Set this to true to update all included scripts.
      - TZ=${TZ} # Add your local timezone in standard linux format. E.G. US/Eastern, US/Central, US/Mountain, US/Pacific, etc.
      - PORTAINER_TOKEN=${PORTAINER_TOKEN} # Generate via <username> dropdown (upper right of WebUI), "My account", API tokens.
      - PORTAINER_HOST=${PORTAINER_HOST} # Hostname or IP of the Docker host you're running Portainer on.
    volumes:
      - ${HOST_DIR}/olivetin:/config # Add the parent directory on your Docker you'd like to use.
      - ${DVR_SHARE}:/mnt/${CHANNELS_DVR_HOST}-${CHANNELS_DVR_PORT} # This can either be a Docker volume or a host directory that's connected via Samba or NFS to your Channels DVR network share.
      - ${LOGS_SHARE}:/mnt/${CHANNELS_DVR_HOST}-${CHANNELS_DVR_PORT}_logs # This can either be a Docker volume or a host directory that's connected via Samba or NFS to your Channels DVR logs network share.
      #- ${DVR2_SHARE}:/mnt/${CHANNELS_DVR2_HOST}-${CHANNELS_DVR2_PORT} # Note that these volume mounts should always be to /mnt/hostname-port or /mnt/ip-port (dash rather than a colon between).
      #- ${LOGS2_SHARE}:/mnt/${CHANNELS_DVR2_HOST}-${CHANNELS_DVR2_PORT}_logs # This can either be a Docker volume or a host directory that's connected via Samba or NFS to your Channels DVR logs network share.
    restart: unless-stopped

  static-file-server:
    image: halverneus/static-file-server:latest
    container_name: static-file-server2
    dns_search: ${DOMAIN}
    ports:
      - ${HOST_SFS_PORT}:8080
    environment:
      - FOLDER=${FOLDER}
    volumes:
      - ${HOST_DIR}/olivetin/data:${FOLDER}
    restart: unless-stopped

#volumes: # use this section if you've setup a docker volume named channels-dvr, with CIFS or NFS, to bind to /mnt/${HOST_DIR}-${HOST_PORT} inside the container. Set ${HOST_DIR} to channels-dvr (HOST_DIR=channels-dvr) in this example.
  #channels-dvr:
    #external: true
  #channels-dvr-logs:
    #external: true

And, sample environment variables:

TAG=latest
DOMAIN=tailxxxxx.ts.net
HOST_PORT=1337
CHANNELS_DVR_HOST=local-server
CHANNELS_DVR_PORT=8089
CHANNELS_DVR2_HOST=another-server
CHANNELS_DVR2_PORT=8089
CHANNELS_CLIENTS=appletv4k-den firestick-bedroom
ALERT_SMTP_SERVER=smtp.gmail.com:587
[email protected]
ALERT_EMAIL_PASS=xxxxxxxxxxxxxxxx
[email protected]
UPDATE_YAMLS=true
UPDATE_SCRIPTS=true
TZ=US/Mountain
HOST_DIR=/data
DVR_SHARE=/mnt/dvr
LOGS_SHARE=/mnt/channelsdvr
HOST_SFS_PORT=8080
FOLDER=/web
PORTAINER_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
PORTAINER_HOST=htpc6
2 Likes

Hello,
Can you please offer the simplest steps to take to update to the latest Olivetin for Channels?
Shall I stop the running container, delete both container image and portainer stack and recreate from scratch. Or is there an easier way?
Thanks,

In Portainer-Stacks, stop the olivetin stack. Go into the editor and paste in the new docker-compose, and then the new env vars (in Advanced mode). When you're done customizing the variables, click "Update the stack", followed by using the "Re-pull and redeploy" slider.

2 Likes

Thanks! I will give it a try shortly.

Sweet! Worked like a charm!

Are these the only new variables?


ALERT_SMTP_SERVER=smtp.gmail.com:587
[email protected]
ALERT_EMAIL_PASS=xxxxxxxxxxxxxxxx
[email protected]
LOGS_SHARE=/mnt/channelsdvr

Yes, for this Action. But, don't forget they need to be defined in the compose as well:

environment section:

      - ALERT_SMTP_SERVER=${ALERT_SMTP_SERVER} # SMTP server to use for sending alert e-mails. smtp.gmail.com:587 for example.
      - ALERT_EMAIL_FROM=${ALERT_EMAIL_FROM} # Sender address for alert e-mails.
      - ALERT_EMAIL_PASS=${ALERT_EMAIL_PASS} # SMTP "app" password established through GMail or Yahoo Mail. Do not use your everyday e-mail address.
      - ALERT_EMAIL_TO=${ALERT_EMAIL_TO} # Recipient address for alert e-mails.

volumes section:

      - ${LOGS_SHARE}:/mnt/${CHANNELS_DVR_HOST}-${CHANNELS_DVR_PORT}_logs # This can either be a Docker volume or a host directory that's connected via Samba or NFS to your Channels DVR logs network share.

Assuming the compose you're using is fairly recent, you should already have CHANNELS_DVR_HOST and CHANNELS_DVR_PORT separated in the env vars section. This removes a need to edit the compose directly, which is an ongoing goal.

Is there a way to test if it is working ? maybe a filter you know will cause an alert ? that I can use 1 time then remove.

Try just [DVR], that should give you some matches pretty quickly.

on windows my log is in C:/ProgramData/ChannelsDVR/data/channels-dvr.log that is what I have in LOGS_SHARE ... but I see this ....

tail: cannot open '/mnt/192.168.50.68-8089_logs/data/channels-dvr.log' for reading: Not a directory
tail: no files remaining
Background E-Mail Log Alerts process running for 192.168.50.68:8089

Rather than the specific file, the idea is for the variable to be for the part of the path that's different on different OS's. So, in your example, LOGS_SHARE should be C:\ProgramData\ChannelsDVR.

Having said that, assuming you have a WSL default distro of Ubuntu or Debian (and integration enabled in Docker Desktop), I'd suggest your path be relative to that default distro. Should be the same in both, but from Debian it'd be:

/mnt/c/programdata/channelsdvr

I find it's cleaner, and more reliable, to use your WSL Linux paths with Docker. Typically you can mix and match, but since Docker is Linux at heart, I'd recommend a 100% Linux-compatible path.

EDIT: When you run the Post-Install Healthcheck, you should see a few directories listed in the check for your logs path, including data and latest:

Here's mine as an example:

Checking your OliveTin installation...
(extended_check=false)

----------------------------------------

Checking that your selected Channels DVR server (media-server6:8089) is reachable by URL:
HTTP Status: 200 indicates success...

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  1276  100  1276    0     0   311k      0 --:--:-- --:--:-- --:--:--  311k
HTTP Status: 200
Effective URL: http://media-server6:8089/

----------------------------------------

Checking that your selected Channels DVR server's data files (/mnt/media-server6-8089) are accessible:
Folders with the names Database, Images, Imports, Logs, Movies, Streaming and TV should be visible...

total 20
drwxr-xr-x 2 1000 1000 8192 Apr  2 20:17 .
drwxr-xr-x 1 root root 4096 Apr  9 09:48 ..
-rwxr-xr-x 1 1000 1000 6148 Mar 31 17:34 .DS_Store
drwxr-xr-x 2 1000 1000    0 Dec 24 11:45 .config
drwxr-xr-x 2 1000 1000    0 Dec 24 03:07 .pki
drwxr-xr-x 2 1000 1000    0 Apr  8 21:04 Database
drwxr-xr-x 2 1000 1000    0 Apr  8 10:57 Images
drwxr-xr-x 2 1000 1000    0 Apr  2 20:17 Imports
drwxr-xr-x 2 1000 1000    0 Apr  9  2023 Logs
drwxr-xr-x 2 1000 1000    0 Apr  3 21:54 Movies
drwxr-xr-x 2 1000 1000    0 Dec 15 02:54 PlayOn
drwxr-xr-x 2 1000 1000    0 Apr  8 21:59 Streaming
drwxr-xr-x 2 1000 1000    0 Apr  8 10:57 TV

----------------------------------------

Checking that your selected Channels DVR server's log files (/mnt/media-server6-8089_logs) are accessible:
Folders with the names data and latest should be visible...

total 12
drwxr-xr-x 2 1000 1000 4096 Mar 29 21:03 .
drwxr-xr-x 1 root root 4096 Apr  9 09:48 ..
drwxr-xr-x 2 1000 1000    0 Sep 28  2023 2023.09.27.0340
drwxr-xr-x 2 1000 1000    0 Nov 13 18:14 2023.11.13.2159
drwxr-xr-x 2 1000 1000    0 Dec 27 23:15 2023.12.28.0146
drwxr-xr-x 2 1000 1000    0 Jan  8 13:16 2024.01.08.1431
drwxr-xr-x 2 1000 1000    0 Feb  8 16:29 2024.02.08.0626
drwxr-xr-x 2 1000 1000    0 Feb 10 21:15 2024.02.11.0311
-rwxr-xr-x 1 1000 1000  829 Mar 29 17:48 Channels DVR Server.lnk
drwxr-xr-x 2 1000 1000    0 Apr  9 15:44 data
drwxr-xr-x 2 1000 1000    0 Mar 29 17:48 latest

----------------------------------------

Here's a list of your current OliveTin-related settings:

HOSTNAME=olivetin
CHANNELS_DVR=media-server6:8089
CHANNELS_DVR_ALTERNATES=utheater-pc:8089
CHANNELS_CLIENTS=appletv4k firestick-master
ALERT_SMTP_SERVER=smtp.gmail.com:587
ALERT_EMAIL_FROM=[Redacted]@gmail.com
ALERT_EMAIL_PASS=[Redacted]
ALERT_EMAIL_TO=[Redacted]@gmail.com
UPDATE_YAMLS=false
UPDATE_SCRIPTS=false
PORTAINER_TOKEN=[Redacted]
PORTAINER_HOST=htpc6

----------------------------------------

Here's the contents of /etc/resolv.conf from inside the container:

# Generated by Docker Engine.
# This file can be edited; Docker Engine will not make further changes once it
# has been modified.

nameserver 127.0.0.11
search tail[Redacted].ts.net
options ndots:0

# Based on host file: '/etc/resolv.conf' (internal resolver)
# ExtServers: [100.100.100.100]
# Overrides: [search]
# Option ndots from: internal

----------------------------------------

Here's the contents of /etc/hosts from inside the container:

127.0.0.1	localhost
::1	localhost ip6-localhost ip6-loopback
fe00::0	ip6-localnet
ff00::0	ip6-mcastprefix
ff02::1	ip6-allnodes
ff02::2	ip6-allrouters
192.168.16.2	olivetin

The below worked I tested and got an Email Alert ... I am using Docker Desktop ....

OliveTin Log Alert
Inbox


The following CDVR log lines match your filters:

2024/04/09 14:39:12.473353 [DVR] Rule 'Godzilla' (33) found 1 new airings
2024/04/09 14:39:12.478572 [DVR]   queued recording job for pluto/6181860d436116001a0bcb77/1954-11-03T00:00:00.000Z @ Wed Apr 10 1:59:30PM on ch=[9084] (1712782770-33)
2024/04/09 14:39:12.518778 [DVR] Waiting 15m17.4812219s until next job 1712699670-15 The World Is Not Enough (1999)
2024/04/09 14:54:30.008483 [DVR] Starting job 1712699670-15 The World Is Not Enough (1999) on ch=[855]
2024/04/09 14:54:30.008483 [DVR] Waiting 49m59.9915163s until next job 1712702670-33 Godzilla vs. Spacegodzilla (1994)
2024/04/09 14:54:39.216340 [DVR] Recording for job 1712699670-15 from M3U-GraceNote ch855 into "Movies\The World Is Not Enough (1999) 2024-04-09-1454.mpg" for 2h10m29.9915163s

@bnhf Is there a way to send Alerts to multiple emails ... I have it set to text my phone at the moment and that works would also like to email.

Not at the moment, but it wouldn't be difficult to add. I'll include a field in the Action for a second "to" address. That way you can add a second destination or not, e-mail or text gateway.

Turns out you can put multiple addresses in the ALERT_EMAIL_TO variable. Comma separated, no spaces. Just tested it, and appears to work fine.

That worked thanks ... see you underestimated your coding ... :clap:

Great stuff! Indeed, very useful to know about failed/corrupted recordings. :+1:

Or also if the DVR fails to tune to a channel.
Many uses for it. :slightly_smiling_face:

An idea for improvement: offer a selection of predefined key words for common situations that people may be interested in. Maybe with check boxes.
Just an idea and I know not all ideas are good. :person_shrugging:

1 Like

I could definitely do something along those lines.

For anybody who speaks "grep", post your favorite pattern matches for CDVR logs in this thread. And, if they seem useful to others, we'll add them to this Action one way or another.

Alternatively, for those that don't know grep from a gripe, post a sample CDVR log line of something you'd like to be alerted about, and I'll work one up.

1 Like

I'll start:

[ERR] Failed to start stream on channel

1 Like

EDIT: Added [DVR] Deleting job no longer in the guide:

Category-Corrupted/Failed recording
ended prematurely:
[DVR] Deleting job no longer in the guide:
[DVR] Error running job
[DVR] Job cancelled:
[DVR] Marking expired job
[DVR] Skipping job
[ERR] Could not start stream
[ERR] Error during stream
[ERR] Failed to start stream
[ERR] Probe failed for live stream
[HLS] Couldn't generate stream playlist
[MTS] Rewriting video timestamps
[TNR] Cancelling stream

Category-DVR critical
panic recovered
runtime error
[ERR] Could not start server

2 Likes

If you decide to make check marks, can you allow a way to add your own.... the way it is now. Can we be able to keep filters 2 and 3 when set right now after a restart they go back to default.

This sends me the number of channels after a scan is complete.

[TVE] Channel scan finished