Skip to content
mispy Notes from a night desk

Watching a server through its log file

When the only signal is a stream of text, presence has to be inferred. The good news is that the operating system keeps receipts.

A log file is a record of things that happened, not a declaration that the thing which wrote it is still running. That distinction matters when you are building a small status page for a server you do not control. The process may have crashed, been suspended, or simply gone quiet. The file remains.

On a Unix system, there is a useful piece of evidence: an open file descriptor. If a process is writing to a log, it usually holds the file open. Tools that list the processes attached to a file can therefore answer a narrow but valuable question. Is anyone still holding this log?

Presence, not health

An open descriptor tells you that a process exists and has the file. It does not tell you that the process is doing useful work. For a status page, that is often enough. "Online" should mean "the server is still there", not "every request is succeeding". Conflating the two produces a dashboard that panics over a slow query and misses a dead process.

The check is cheap. Ask the system which processes have the log open for writing. If the answer is empty, the server is gone. If the answer is present, it is at least alive. Cache the result for a few seconds so the status page does not turn into a load test.

Reconstructing time

Many logs have no timestamps. That is a problem for a status page, which wants to say when the last change happened. The solution is to produce time on the reading side. When a new line arrives, record the moment you saw it. When the status changes, store that moment separately. The log stays untouched, and the observer keeps its own clock.

Edge case

If the monitor starts while the server is already offline, there is no "went offline" event to observe. Treat the first reading as a baseline, not as a change.

Restarts and gaps

A restart is easier to spot than a failure. The log begins again, often with a familiar banner. A gap is subtler: the file grows, but the content repeats an old pattern. A robust monitor keeps a small amount of state, such as the last known size and the last status, and compares it with the current reading. It does not need to understand the game or the application to notice that something has changed.

This kind of monitoring is not a substitute for a proper supervisor. It is a second pair of eyes for the moments when the supervisor is the thing that failed. It is also a nice reminder that the operating system is full of small, honest signals if you know where to look.