Plan Zero

Hello, there!

Blog

Showing posts from January 2012. Filter to Thursday 26th.

System uptime in Python, a better way

Published

I've been working on a system monitoring tool which needs determine whether the uptime of a Linux slave machine has changed since it last reported in. I looked through Python's online documentation and it turns out that there isn't a function among the standard modules for doing this (not even in the handy os module).

I did some searching around to see how people were getting the uptime of a host in Python and a surprising number of people advocate launching a subprocess and calling Linux's uptime command, then parsing the output. But there's a much better way!