Mal wieder die Endlers

Ja, die gibts auch noch :)

2013-02-05 - Endlers 2:

2013-02-05 - Endlers 1:

05 February 2013 | #aquarium


Quick monitoring script for commandline using google graph

So, you need to setup a graph for something you maintain, for instance response time of a webserver, memory consumption of some process or open database handles. Fast.

You could use MRTG, if you've got it already running. But either way - to add a new graph there isn't really done fast. And what if you don't have MRTG? What about GNU Plot or Google Graph? Every tool like this needs handwork to be done before being able to produce usefull output. One needs more than the other.

Enter quickmon. This is a small script I wrote for the very purpose. It doesn't have any dependencies and therefore runs out-of-the-box. You supply it one or more shell commands and it generates a google graph page and a logfile where it maintains history. It is really not possible to create monitoring graphs any faster!

And as a plus, the tool itself doesn't require internet access. It can run anywhere, inside some protected DMZ or the like. Only the browser which is used to view the output page needs internet access to fetch the google graph JS-library. That's it.

So, first of all, grab a copy of the script from here.

Now, let's take a look at some examples: -n "google mx lookup responsetime" \
            -t "google millisecs" \
            -c "host -v -t MX | grep Received | awk '{print \$7}'" \

In this example we monitor the response time of googles nameserver (when asked for its mx-record) in milliseconds. As you can see, there's one -t and one matching -c parameter. -t tells us what we are actually monitoring and -c is the shell command to be executed. In this example we're using host -v which prints the responsetime of a query in milliseconds. We fetch this value using the grep + awk after the pipe. Here's the output:

Here's another example: -n "google webserver response" \
            -t "" \
            -c "wget -4 -q -O /dev/null" \

Note the difference to the previous one: we didn't put some grep + awk parser stuff into our shell command. If you do that, the script measures the time it takes to execute the command itself.

This is how it looks after some time:

How about having multiple items in a graph? No problem, you can pass multiple -t and -c parameters to the script. However, be careful to have always one -t for every -c. And: order matters. -n "webserver comparision" \
            -t ""     -c "wget -4 -q -O /dev/null" \
            -t ""   -c "wget -4 -q -O /dev/null" \
            -t ""      -c "wget -4 -q -O /dev/null" \

Ok, quite a long commandline. Watch the matching -t and -c parameters. And here's the output:

One last thing: You might have noticed the -l flag. If supplied, the script runs forever and executes the given commands once every second. That's enough for some quick graphing but sometimes you might need to create graphs for longer timescales, say some days or weeks. In such cases running once per second might be overkill. And executed this way, the script doesn't survive reboots. In such cases just add a cronjob, which executes the script once every 5 minutes (or whatever you like) and leave the -l parameter. Example:

*/5 * * * * cd /home/user/tmp/ && /usr/local/bin/ -t "title" -c "command"

Beware the chdir call: uses the current directory to write its logfile and the output page (index.html).

In case you want to take a look at a live sample, here you go: it is the webserver comparision described above, run every 5 minutes by cron.

Well. While this all might sound very cool, there's still one usecase where could be too complicated. Let's recall: for every painted line in the output graph you have to provide a shell command which returns its value. What if you already have a source which returns such values all at once? Given the examples above it might look like we have to provide one -c parameter per value but each command has to split the same input source differently. That's odd. To say the least.

Take a look at this command output:

$ netstat -w 1 -I bge0 -q 1 
            input         (bge0)           output
   packets  errs idrops      bytes    packets  errs      bytes colls
         9     0     0        828          8     0       9108     0

We've entered the netstat command which printed some stats about a specific network interface. Wouldn't it be good to feed quickmon directly with that output? The good news is: it's possible! Here's a quickmon call which catches some of those values - in and out bytes - to generate a graph from it:

while :; do netstat -w 1 -I bge0 -q 1 | egrep -v "(input|packets)"; done \
     | -t in-bytes -t out-bytes -p -n bge0 -f 3,6

There's a lot new stuff here, let's dig into it:

  • We're calling the netstat command inside an infinite while loop, because otherwise it doesn't print to stdout but to our controlling terminal (which quickmon doesn't catch). This is freebsd specific. Behavior maybe different on other OSes.
  • The egrep filters out the headings.
  • We provide only 2 titles using -t, because we catch only field #3 and #6 (count starts from 0) by using the -f option.
  • Option -p tells quickmon to watch a file. Since we didn't specify a filename, it uses STDIN, which is actually the output of our while loop.

And this is the output of the above after a while:

Nice, isn't it?

By default quickmon splits the input using whitespace. You might alter this behavior by supplying a different field-separator using the -F option.

Update 2015-10-18:

The script is now available on Github.

The switch -l now has an optional parameter, the time in seconds to wait between loops, a float (i.e. .1 or 2.5 would be legal)
Also, in pipe mode (-p) it’s now possible to specify one title with a timestamp using format characters. So if your input file already contains a timestamp you can use that instead of generated ones.

04 February 2013 | #source


Krimskrams, Goggelmoggel und Muggefugg

Update 2013-05-06:

Der beste Spruch über Merkel, den ich je gelesen hab:<blockquote>Nächstes Mal: Angela Merkel (obligatorisches Foto, wo sie diese Handgeste von ihrem Heimatplaneten macht</blockquote><p>Update 2013-04-23:</p>Freiheit<p>Update 2013-04-12:</p>Schöne Geschichte über den <blink> HTML tag von dem Mann, dessen Idee das war (der ihn aber letztlich nicht berbrochen hat) :)<p>Update 2013-04-11:</p>Die Würde des Menschen ist unauffindbar.<p>Update 2013-03-23:</p>Defcon 20: Bruce Schneier answers your questions. Sehr gut. </p>

Der beste Spruch kam, als er auf die Zunehmende Übermacht der Regierungen und Konzerne angesprochen wurde:

Manchmal ist das beste, das wir tun können, langsamer zu verlieren

Update 2013-02-13:

Ein wirklich cooles Projekt: Widerstand Zwecklos:

Update 2013-02-04:

Haha, jemand hat einen Weg gefunden, der GEZ zu entkommen! Sehr schön. Obs klappt, steht allerdings auf einem anderen Blatt...

Update 2013-02-04:

Realität ist das, was nicht verschwindet, wenn man aufhört daran zu glauben.
Philip K. Dick

04 February 2013 | #geschwätz


Modemtöne - jemand hat eine schöne Seite für die Geschichtsbücher hinzugefügt

Jeder, der schon in den 90ern online war, kennt diesen Sound, den das analoge Modem damals gemacht hat. Man wusste zwar, dass sich da die 2 Modems "unterhalten" über irgendwelche Verbindungsparameter, aber was genau die da reden - keine Ahnung.

Oona Räisänen hat sich der Aufgabe angenommen, das ganze mal zu visualisieren. Und WIE ihr das gelungen ist, ich bin völlig von den Socken.

Das waren noch Zeiten, hach! Was waren wir frei! Keine faschistischen Innenminister, keine Datensammler, keine Abmahner. Was ich nicht alles mit diesem Sound assoziiere :)

Sehr schön - dort in den Kommentaren gefunden - ist auch ein Chat-Transscript so einer Modemsession, auf modern gestylt:

Modem A: hey babe, you dtmf?
Modem B: u know it
Modem A: what u up 4 2nite? wanna v.8?
Modem B: i wanna ack u like my daddy net2phone use 2 ack me
Modem A: um ok... v.8 then
Modem B: lol jk, u comin?
Modem A: brt just gotta turn off echo suppressors n cancellers
Modem B: ok i wait
Modem B: my pcm is so modulated
Modem A: lol rly? u think u can handle V.90/V.92?
Modem B: D/A?
Modem A: ...D?
Modem B: wtf no, im not into that
Modem A: lol jk we can do V.42 LAPM if u want im down 4 nething
Modem A: up to 3429 o/c
Modem A: u know i give as good as i get, ne way u want it, loud or soft, high or low, fast or slow, i got all the time in the world 4 u babe, my clock source is internal
Modem B: of course no 3429. and same 4 me. except i might lose track of time, lol
Modem B: and honey if u with me we gon be makin sum NOISE
Modem B: 6db at LEAST u know how i like it
Modem A: lol i hear ya, 3200 all nite long, the way u get me goin maybe we even go 2 4800 lol
Modem A: set ur pre-emphasis filter params n put on that 1920 hz carrier frequency i got u
Modem A: im here baby

Ich bin jedenfalls völlig begeistert!

01 February 2013 | #gefunden


Der kleine Sexismus

Ist ja allerorten heuer viel zum Thema #aufschrei zu lesen. Eben im Mikrocontrollerforum fiel mir der Spruch hier auf:

Kommentare sind was für Mädchen

Auf den ersten Blick nur eine unbedeutende Kleinigkeit. Aber wenn man genauer drüber nachdenkt, insbesondere dass man selbst hier und da mal solche Sprüche gebracht hat.

2013-02-01 - was für Mädchen:

01 February 2013 | #gesellschaft