Monthly Archives: August 2013

Die richtige Technik für die eigene Website: eine Übersicht

In diesem Artikel möchte ich auf verschiedene Wege eingehen, die man bis zur eigenen Website gehen kann. Der Artikel erhebt keinen Anspruch auf Vollständigkeit, soll aber doch eine Übersicht über dieses komplexe Thema bieten. Er konzentriert sich auf technische Aspekte, denn in erster Linie ist eine Website die technische Implementierung eines abstrakten Konzepts. Damit das Konzept aufgeht, muss die Technik stets unter Kontrolle sein. Eine gute Übersicht über die zahlreichen technischen Finessen ist Pflicht, ansonsten überraschen auf lange Sicht diverse Probleme — wahrscheinlich auch den Nutzer. Allgemein gilt: bei der Implementierung einer Website ist ein besonders großes Spektrum verschiedener technischer Aspekte zu berücksichtigen. Ist die eigene Website von Bedeutung (privat oder für das Geschäft), sollte man auf professionellen Rat nicht verzichten.
Continue reading

(Free)NAS: simple auto-shutdown revisited

There are several blog posts and forum entries out there about automatically shutting down a NAS machine depending on environment changes. The solutions I have seen either are too simple or dallying overcomplex.

The use case requires a simple solution that behaves predictably, solid, and stable under real-world conditions. The shutdown condition I want to have implemented: shut down (or send to sleep, does not matter at this point) the NAS machine if no host of a pre-defined list of hosts is reachable for a given time period (a few minutes). Obviously, within this time period, the reachability of the hosts must be tested periodically. The whole check system should be repeated every 15 minutes or so via cronjob. Each test run is to be aborted as soon as at least one host responds. Each single test for responsiveness is to be executed by the ping program, whereas the target machine must miss more than one ICMP request and not answer for at least a few seconds until it is considered unreachable. Reachability is evaluated via ping‘s return code, a reliable measure — it always exits with code 0 if the host has responded at least once (others are parsing ping‘s standard output, which only adds uncertainty).

Implementing this the right way is simple, but still serious engineering and not just a scripting exercise. The system needs to be reliable and maintainable, and needs to have a solid logging facility. While one could do this in any shell language, I think it is difficult to get the edge cases right and to not create nasty traps one did not think of. Python provides an ideal framework for fulfilling the above-mentioned criteria and its control flow allows for writing highly predictable code. However, one needs to understand and properly deal with Popen objects, exceptions, logging, and ping, which — as always — requires careful study of the corresponding documentations. Continue reading