I'm searching through my Channels DVR Log. For each channel that is opened, it creates a 'Opened Connection...' and when we stop watching the channel, it turns into 'Closed Connection....'. We have multiple tuners, so we could have 0-8 channels going at one time and I want to display which channels are actively being watched.
I can figure out how to pull the last entry of the opened channels from the below log, but the key here is determining if the last entry for each channel is "opened" vs "closed". Said another way, I need the script to be able to determine which channels have been opened but not yet closed.
Here's the lot format:
Code: Select all
2021/07/11 20:59:50.545461 [TNR] Opened connection to 13149111/0 for ch731 AMC HD
2021/07/11 21:33:57.085945 [TNR] Opened connection to 13149111/0 for ch847 Starz! Comedy H
2021/07/11 21:33:57.626407 [TNR] Opened connection to 13149111/1 for ch731 AMC HD
2021/07/11 21:45:10.003159 [TNR] Closed connection to 13149111/0 for ch847 Starz! Comedy H
2021/07/12 07:00:00.494440 [TNR] Opened connection to 1076456B/0 for ch8.1 WGAL-TV
2021/07/12 09:00:00.012414 [TNR] Closed connection to 1076456B/0 for ch8.1 WGAL-TV
2021/07/12 09:00:00.561826 [TNR] Opened connection to 1076456B/0 for ch8.1 WGAL-TV
2021/07/12 10:00:00.045563 [TNR] Closed connection to 1076456B/0 for ch8.1 WGAL-TV
2021/07/12 10:00:00.494161 [TNR] Opened connection to 1076456B/1 for ch8.1 WGAL-TV
From programming in PHP over 15 years ago, I would imagine some form of a For i=n, do something; n++ until you run out of entries, but it's been too long and this isn't PHP so I'm not certain the best way to tackle this. Any suggestions.
I would access the logs using curl -s http://192.168.0.2:8089/logs
TIA