Friday, May 17, 2024

May 17 (Fri) – Network Monitoring #5

Another dog in the house. Sort of. Maybe.

The phone book parser is done, only took two tries. As I got closer to finishing the thing I got to thinking. It tests everything and reports errors but there’s no easy way for me to know it’s running. What if the monitor didn’t start when the computer started? What if the computer woke up from sleep or hibernate and the monitor didn’t start running again? What if the monitor hangs up and stops working because of an issue out on the internet?

.

The solution is ‘use a watchdog’. A watchdog is a small program that keep an eye on an important process. It notifies or takes action if stuff misbehaves. I think I need one for my network monitor.

.

I coded a watchdog once before and I remember it was tricky to design. Here’s a high-level for checking if the monitor is running:

.

Inside every running computer are hundreds of processes, every one doing something different. The operating system assigns a Process IDentificaion number (known as a Process ID or PID (rhymes with lid) to every process. My monitor will be assigned a PID when it launches. If the monitor should, for whatever reason, ‘close’ or ‘turn off’ then the PID will be erased from the list.

.

All the watchdog needs to do, then, is periodically ask for my monitor’s PID. If there’s no PID then the monitor ain’t running. In that case the watchdog will start the monitor. Seems like a simple way to ensure that my monitor is always running.

.

If there’s a problem on the internet that stalls my monitor (for example: my chosen phone book servers aren’t running or are overloaded with queries) I want to know about that, too. That’s harder for the watchdog to catch. Here’s a high level for checking if the monitor is stalled or waiting for something on the internet:

.

Every second, my monitor will write the current time into a small file. Every second, the watchdog will read that time stamp. If it’s older than three seconds (to cover internet hiccups - I’ll adjust this number if needed) then the watchdog knows my monitor is running (there’s a PID) but it’s ’stalled’ (the time stamp is old).

.

The last piece of the puzzle is notification. I want to be able to glance somewhere on the monitor whenever I feel like it and check on the monitor. Sorta like a lamp that turns red when something’s wrong. It needs to be unobtrusive and always visible on the monitor no matter what I’m doin’. Here’s an idea:

.

24-05-17-watchdog-notification-idea.pngOn the computer’s task bar I could design a widget that displays one of three symbols:

.

The letter “P” means I’ve paused the monitor. The P would appear then disappear, cycling every second. This would remind me that I paused the VPN and forgot to turn it back on.

.

The symbols “<” and “>” mean everything’s groovy. The symbols would alternate every second, like an unobtrusive little heartbeat. The watchdog will freeze the symbol if there’s an issue.

.

I can add some color to the symbols if necessary. I want it to be unobtrusive yet there so I can glance at it and know what’s what. I’ll prototype my notification idea and see if it’s irritating.

.

Oh. One other thing. Why would I pause the monitor? Well, there’s a few web sites I go to that get very nervous if someone logs into my account and their computer or cell phone is ‘from out of town’. My bank is one, my cell phone carrier is another. They make me go through an authentication process if I forget to pause the VPN.

.

Last 8 comments

Admin