Deutsch Lieber auf Deutsch? Hier lang.

Today I learned a cool new trick, made possible by the Item Preprocessing that is available since Zabbix 3.4. This is not a Zabbix blog, but I consider this so useful and so not-intuitive that I just have to write it down.

For the occasional visitor: Zabbix is an open source enterprise class monitoring solution. I use it not only at work, but also at home — not only to monitor the meat on my BBQ. :-)

In my opinion, Zabbix is really great when it comes to anything that can be expressed in numerics. It can also handle string data, but having had minor problems with that I try to avoid strings whenever it is possible. States can be expressed numerically and stored in integer values, using value mapping it is possible to show the states in a meaningful way.

Today I came across a problem that I wasn’t able to implement at first. A web service told me the state of an application, which could be either RUNNING, STOPPING or STOPPED. It’s easy to create a string-item to handle this, and to implement a trigger that notifies if the service is STOPPED. However, in this case I had to create a trigger that tells if the service is in the state STOPPING for more than a certain time, indicating that it might have a problem shutting down. I couldn’t find a solution to this, since the trigger function str("STOPPING",15m) would trigger if at least one of the values during the last 15 minutes was “STOPPING”.

Item Preprocessing to the rescue!

Three steps

Three steps

Zabbix 3.4 brought a feature called Item Preprocessing. A value can be fetched, and before it gets stored it can be dissected or converted in several ways. One of these is, to apply regular expressions to the fetched value, in a “find and replace” kind of way.

It turned out that I needed a fairly complex expression, but in the end I was able to convert the states from the webservice to simple integers. Searching the web, i found something about “conditional replacement”, and using this great online regex tester I was able to come up with this beauty:

Using this, I can convert the string that is extracted from the web service’s output using a JSON path in two further steps:

  • First, attach a “dictionary” to the value: replace the full value (.*) with with itself, followed by the replacement values: \1:STOPPED=0:STOPPING=1:RUNNING=2.
  • Then, replace the regex (STOPPED|STOPPING|RUNNING)(?=.*:\1=(\d)) by the value of the second capturing group \2.

In this way the item can be configured as an unsigned integer, since there are only the numbers 0, 1 or 2 that have to be stored. And I can apply the usual trigger-function-magic to notify if the value is 1 for a certain length of time. Added benefit: I can use the graph view of this item to see if there were any deviations from the wanted “RUNNING” state, when they occured and how long they lasted.

Better ideas?

I’m pretty enthusiastic about this way of processing the values. But I’m also very interested in opinions: is there a better way to deal with this problem? Something obvious that I haven’t seen?

What's wrong with this?

What’s wrong with this?

This is another old project, dating back to about 2004. I had it covered on the old Schatenseite, and I want to give a short presentation on the blog to preserve it.

I was given an old Commodore C64 that somebody decided to dispose of. The first version, in germany this case is dubbed ‘Brotkiste’ (bread box). It didn’t turn on anymore, and lacking any personal Commodore history I didn’t hesitate long before taking it apart.

Unfortunately, I didn’t know about microcontrollers at that time, otherwise I would have been able to save the functionality of the keyboard. I wasn’t able to, so parts of the underside of the keyboard had to go, to make space for CPU cooler and RAM. :-(

I inserted a VIA EPIA M10000b, so the C64 ran at 1GHz. The system was completed by 256MB RAM, a 2,5″-20GB-harddisk, a CD-ROM from a notebook and an external power brick.

The C64-PC

The C64-PC

Built like this I could attach the unit to my TV set, mainly for playing some games on it. But to be honest: this was one of the projects that made more fun during the build than afterwards…

Nowadays I would build this in a different way. A Raspberry would look great in the case. Needing much less space it would even be possible to keep the keyboard in a working condition. And running the Retropie distribution you could even have this certain 80’s feeling… :-D

See also…

I mentioned this project in an article (german only) on this blog, it dates back from November 2012. Somehow I never showed it, I don’t really know why.

Those who read this blog for a while know that I have a deep faible for computer keyboards. You don’t get the full picture from my english language articles, but in german you can find many keyboard related articles on this site.

Amongst others, my collection contains two vintage Apple keyboards. There’s a — really not too shabby — Apple Extended Keyboard II, which was built between 1990 and 1994. Many enthusiasts claim that this is the best keyboard ever produced by Apple, partly of course because of it’s mechanical nature with the Alps switches.

Even more original — and in my eyes it’s a typical Apple product — is the Apple Adjustable Keyboard, 1993 vintage. Typical Apple? As I said, in my eyes: it was expensive for its time, and above all the visual appearance of the product is more important than functionality. Even though there are arrow-keys on the main keyboard, I personally wouldn’t want to miss function- and navigation-keys (Home, End, PgUp, PgDown). And if you connect the additional keypad, you really have to have long arms to reach your mouse… :-/

However, I wanted to give both a try. And since I don’t have access to a computer with ADB interface — Apple killed it in 1999 — I needed a converter. You can buy this stuff, but you don’t have to.

On geekhack.org, there’s a japanese developer called hasu, who is tmk on Github. He created and published the TMK Keyboard Firmware Collection. That’s a firmware that can be run on several AVR-based platforms, notably the Teensy 2.0 which is well known in keyboard communities. The firmware is able to ‘talk’ several different keyboard protocols. Of course, USB in one direction, to be connected to any modern computer. In the other direction there are protocols like PS/2, Sun or Apple Desktop Bus. The custom firmware is loaded with features even expensive modern high end boards fail to deliver. It’s possible to program macros, use media keys or control the mouse pointer with the keyboard.

Unfortunately, I didn’t have a Teensy at home. But I had all the parts to build something compatible, and all the tools to etch a fitting PCB. So I fired up KiCad and designed a minimal circuit, from that it wasn’t too difficult to create a PCB layout:

(The KiCad files need a bit of a workover, so I won’t publish them here. But it should be easy to recreate the circuit following the two screenshots.)

ADB USB Converter

ADB USB Converter

The finished converter measures in at 2x5cm, that’s really tiny. But the important thing is: it works!

I could probably use the ADB mouse with an off-the-shelf converter. But honestly: even a hardcore fanboy would prefer a modern pointing device without the ball in it. That is: a while ago I had the opportunity to play a bit with System 7.5 (the Apple operating system from the same era as the two keyboards), and I have to confess that the Adjustable Keyboard did its part for the authentic user experience… :-D

Shellprogrammierung

Shellprogrammierung

My apologies, this PDF I wrote is german only.

I’m sure you’ll be able to find plenty of information about shell scripting on the net. When I wrote this text (started 1999, with some updates until 2005) there wasn’t a good german introduction.

:arrow: If you can read german: here’s the download.

Initially, I wrote this text for a school project. It quickly became too long to be a handout, so I published it on my page.

Distribution

From my page, the text was included into SelfLinux. With SelfLinux being a part of the Knoppix distribution, my text has been pressed to thousands of CDs. :-)

The Wikibooks project took the text from SelfLinux.

Both of those sites enhanced my text on their own, I see them as forks of my project.