Extended MRTG format

Every tech geek has his/her preferred tools and one of mine is without doubt Tobi Oetiker’s MRTG (Multi Router Traffic Grapher), which I’ve used to make pretty trend lines of much more than routers or traffic.

MRTG is a Perl program that grabs some measurement values (typically via SNMP) and plots them as time series. It creates ‘daily’, ‘weekly’,’monthly’ and ‘yearly’ graphs and the HTML page that shows the graphs and some min/max/average statistics to accompany the graphs. You’ve probably seen the typical MRTG output images before:

Example of MRTG

But MRTG can do more than just SNMP. In fact MRTG can plot any trend, as long as it gets its input in the form of 4 text lines:

[I value]
[O Value]
[server name]

The I value becomes the green bar graph, the O value becomes the blue line, and the rest is only used to generate the following line in the generated HTML pages:

The statistics were last updated Tuesday, 13 October 2015 at 10:40, at which time ‘[server name]’ had been up for [uptime].

Continue reading Extended MRTG format

Getting rid of “Google Play Services has stopped” on OnePlus

One week after complete reinstallation of my OnePlus I started getting one “Unfortunately, Google Play Services has stopped” error message after the other. I tried a lot of solutions proposed online (“clear the app cache”/Goto Privacy guard/…) but none worked. Until I found this one from ‘ianyeo’:

Seems like lots of users getting this annoying pop up. Here is the fix. No data will be lost.
1. Go to “Settings”
2. Select “Apps”
3. Swipe left until you in the ‘All’ column
4. Click on the 3 dots in top right
5. Select “Reset app preferences”
6. Reboot OnePlus
7. Reselect preferred launcher
8. Thank me
9. Done! Enjoy!

via https://forums.oneplus.net/

Reset your OnePlus One to factory settings

About half a year ago I switched from an iPhone to an Android smartphone: the OnePlus One. In the beginning it was splendid and super fast and everything. But recently it has become flaky. I suspect the apps ‘Swiftkey’ and ‘Atooma’ have something to do with it. Swiftkey seemed to drain the battery really fast (5hrs of battery life max – charging requyired 3 or more times a day), and when I started testing Atooma instead of Tasker (for automation), a lot of programs started crashing, including the essential ‘Messages’ and ‘Dialer’ applications. Even after uninstalling a bunch of other applications, I still couldn’t pick up phone calls half of the time. And I got the error message ‘Unfortunately, Google Play Services has stopped‘ once every 10 to 30 minutes. So I decided, I need to reinstall Android on my phone!

Continue reading Reset your OnePlus One to factory settings

Wifi in my car: proof of concept

Some drivers love fancy chrome wheel rims, some add a huge wing spoiler on their car, or fuzzy dice hanging from their rear-view mirror. Me, when I bought my new car, I decided that I wanted a Wifi network in my car. So that any passenger with a laptop/iPod could read his email. And I imagined driving to distant holiday locations while my passenger where watching movies streamed from a NAS disk built into the car.

This weekend I finished episode one: Internet in the car. I used the following components:

The important details here are:

  • The Huawei stick is compatible with the TP-Link router.
  • The Huawei stick can be configured with ‘Save my PIN’, so that when it starts up, it connects to the 3G network without any manual intervention.
  • The TP-Link router runs on 12V DC (which is what a car has)

For the rest, the exercise was quite straight-forward: I configured the Huawei stick on my laptop with the right PIN code, popped it in myTP-Link router, configured the right 3G settings for Telenet (see here). Then I took an old 12V power transformer, chopped off the connector and linked it up to an old car cigarette lighter type of plug (sometimes it’s good to have an archive of obsolete cables and power supplies). I then hid the router under the base plate of my trunk, where there is also the battery (the BMW X1 stores the battery in the back, where you would normally have the spare tyre). I switch on the car and 20 seconds later, I have a Wifi network “OnTheRoadAgain” that is connected to the Internet. Proof of concept is OK!

The next step now is to add a (Synology) NAS, which also runs on 12V, and hook up my iPad to the car Wifi to view my collection of backed-up DVDs from that disk. And maybe run some extra programs (e.g. MRTG for monitoring) on that NAS. To be continued!

Convert Black/White footage to thermographic-like video

I am doing some really cool research lately concerning video conversion and one of the issues I ran into concerns infrared imaging. In short: all the ‘cool’ thermographic (colour is dependent on radiated temperature) images are in color, and the images you get from cheap IR cameras is black and white. How do you convert the B/W into colour?

First of all: we’re talking about two different imaging technologies: the ‘real’ thermographic cameras measure only infra-red (not visible) light, are very precise, expensive and are created by companies like FLIR. They make the cameras that you might have seen in CSI.

On the other hand, you have the cheaper webcam/IP-cam devices that have ‘night-vision’. This means that, in addition to all visible light, the cameras are also sensitive to a part of the IR spectrum, and with some additional IR-lighting, one is capable of seeing in very dark places. They produce B/W images or colour, but then sometimes they show green grass as a bit purple/pink.

What I was trying to do is convert a ‘cheap’ B/W video into the coloured thermographic equivalent, but without expecting that e.g. orange will always mean 38°-39°. Since we start from a mixed visible/IR light video, brightness does not correlate perfectly with temperature. Still, the end result might be easier to interpret.

So this is my source material: a Foscam FI8918W video from Youtube: two cats playing in a kitchen.

I find some inspiration from a guy who did something similar with ImageMagick. The dark/cold areas are supposed to be black/blue, the medium areas more green, then going to yellow, orange, red and white. This seems like a job for the FFMPEG video filter.

I use the ‘curves’ filter and try first with really strong contrast colours:

The color scheme is kind of OK, but we lose a lot of detail (the cats become hard to distinguish). So then I try a more gradual approach:

And this is rather OK. I like it. The cats come out nice.

For the record: the curves used are approximately this:

curves=r='0.4/0 0.6/1':g='.25/1 .75/.5 .9/0 1/1':b='0/1 .25/0 .75/0 1/1'

All scripts and parameters are on my GitHub account: https://github.com/pforret/pfor_ffmpeg/tree/master/thermography


Status page for telecom/internet providers

My mobile provider Telenet had a partial outage today. Sometimes calls would go though, sometimes not. Same things with SMS and 3G. I wanted to check if there was a page I could check to see if it was just for me, just for that location on globally in Belgium. You know, a proper status page like Google and Apple have. Or in Belgium, like Combell. It appears Telenet has one, but it’s for the Internet division. They also have a Twitter account that is well followed up. How does this compare to the other providers? Here is an overview of who offers what:

Mobile Telephony/Data

Belgacom Proximus


Telenet (on Mobistar network)

Base (part of KPN)

Mobile Vikings (on Base network)

Broadband Internet



Scarlet (part of Belgacom)

Kudos to http://www.ionasj.com/welk-netwerk-voorziet-de-beste-dekking/

Cleaning up an infected PHP server (Mal/Badsrc-M – Troj/PHPShll-B)

I recently discovered that a number of sites of mine were considered unsafe by Google, Firefox, Yandex … The reason was they had detected malware being served to visitors of the site. I checked a bit further and I discovered it was the Mal/Badsrc-M – Troj/PHPShll-B trojan. In each of my (WordPress and other) PHP files, the first line had been changed to

<?php /* */ eval(base64_decode("...(bad stuff)"));?><?php ...
The file is easy to clean up: you remove the eval statement and that’s it. Only, on this server several hundreds of PHP files (WordPress, MediaWiki, …) were affected. So I made a script to go through all of them and clean up. It uses the fact that

  • the whole injected statement is on 1 line
  • no ‘decent’, trustworthy program uses eval(base64_decode(" ... ")) in its PHP code
  • it moves the second <?php to the second line and then removes the whole first line

So if you have the same problem, use a bash script like this and run it in the root of all your websites:

iOS6 losing its 3G cellular data settings – fix for Belgium

I upgraded my iPhone 4S to the new iOS6 the day it came out. As I expected, I had to reconfigure the cellular data settings (‘APN’). For some reason they always get lost during major OS updates. However, I have noticed the last weeks that, every now and then, my 3G connection stops working, and when I check the APN settings, they have disappeared. My colleagues, with iPhones and iPads on different cellular operators also have this problem. So for them, for me, and for anyone else who has this problem: here are the settings for the Belgian operators.

APN: internet.proximus.be
Username: (empty)
Password: (empty)
APN: APN: iphone.mobistar
Username: (empty)
Password: (empty)
APN: gprs.base.be
Username: base
Password: base
APN: web.be
Username: web
Password: web
APN: telenetwap.be
Username: (empty)
Password: (empty)
APN: internet.bmbpartner.be
Username: (empty)
Password: (empty)

These are the most common ones.

The procedure is: goto General/Cellular/Cellular Data Network, verify they are all empty, fill in the correct values, leave the Cellular menu, switch your phone to “Airplane Mode” for 10 seconds, and then switch that back off. You should see the 3G logo appear again.

Emoticon for innuendo: &-)

Do you often find yourself in a situation where you are using some kind of word play in a written (chat or text message) conversation, but feel that you need to make this second level of comprehension clear? This is why emoticons exist: pictorial representations of a facial expression using punctuation marks and letters, written to express a person’s mood. Emoticons were already used in the 18th century and adopted with mucho gusto in electronic communication since 1982. These days, if you don’t know that a “:-)” means that the writer is happy, you’re missing a lot of the meaning of SMS or emails.

It doesn’t stop there, there is also the :-p tongue-sticking-out, the %-) I’m-so-drunk and even *<|:-) Santa Claus. But there is one often-used ironical level that I find is not well covered by the ;-) I’m-only-joking emoticon, and that is the dangerous stylistical weapon called innuendoan indirect remark about somebody or something, usually suggesting something bad, mean or rude. We need an emoticon that says if-you-know-what-I-mean-wink-wink-nudge-nudge in 3 characters. I hereby propose the …

&-)   = if-you-know-what-I-mean

  • “My parents are coming over tomorrow and I still have to dust off the silverware &-)” = have to clean up dishes for the last 2 weeks and remove all clothes from the living room
  • “Can’t talk right now, my girlfriend is here and we’re studying &-)” = no actual studying is done
  • “Is your wife a goer? &-)” = say no more

What could be a proper response to a &-) ? Depending the recipient’s sense of humor:

  • &-D oh-I-*know*-what-you-mean
  • &-O OMG-you-didn’t-just-say-that-did-you
  • &-? not-really-sure-what-you-mean
  • &-/ I-get-it-but-am-not-that-amused
  • &-( this-is-totally-inappropriate-and-I-am-disappointed-in-you

I think there is also one variation necessary for the most versatile joke on earth: that’s what she said! This is expressed with &-)! – as in “make sure it’s long enough” > “&-)!

And to end, I leave you with this: Uncyclopedia’s definition for sexual innuendo. Just don’t read it aloud in the office.


  • &-) if-you-know-what-I-mean
  • &-D oh-I-know-what-you-mean
  • &-)! that’s-what-she-said!!

Company cars in Belgium: your new taxes

January 2012 marks the beginning of a new calculation of the ‘Benefit in kind’ – the value an employee is calculated to get from a company car. It has a big effect on your taxes. Do you pay taxes in Belgium? Do you have a company car? Read on!

The actual formula can be found here: Arval: Benefit in kind (FR: Avantage de toute nature / NL: Voordeel van alle aard). I simulated this for my own car (Saab 9.3 Cabrio from 2005). It’s clear I need to sell it ASAP. Then I started calculating some other ‘common’ company cars to see what car to buy next. A hybrid? Diesel? Start-stop? So here are some numbers for the ‘cheap’ cars:


VVA: goedkope autos

And because you’re right to worry about your company Range Rover:

VVA: dure autos


  • There is a minimum benefit: 1200€/year. Some cars would have been able to go lower than that, like some electric/hybrid ones, the Volvo V40, the Audi A3, the Smart, but no, you are still going to be taxed for those 1200. 1200, so the state considers you to make 100€/month more.
    Concretely: for an electric car, you are going to be taxed as if it costed 30.000€. For the most economic petrol/diesel car: as if it costs 21.818€. If your company has 22K to spend on a car, use it. You can’t save on your tax filing anyway.
  • Accessories and options: they are also taken into account for the price of your car. The leather seats, the GPS pack, the xenon lights… They all count.
  • CO2 coefficient is important, but don’t overdo it. The treshold for petrol (benzine) cars is 115 g/km, and for diesel it’s 95 g/km. You pay more if it’s worse, but you don’t pay less if it’s better.
    For diesel cars: stay under 115 g/km. For petrol cars, stay under 130.
  • Electric cars: you would be surprised. Apart from the Renault Twizzy, which is more of a toy, there are not that many options, and you’re not even sure of the minimum benefit. If the car costs more than 30K, you’re screwed. Hybrid cars: if they cost more than 22K, you will feel it.
  • SUVs: if you have a big SUV (BMW X5, Mercedes M, Porsche Cayenne) or a big jeep (Landcruiser, Pajero), you’re gonna feel the pain. Nissan Qashqai, Toyota RAV4, not so much.
  • Second hand: there is a discount for the age of your car: 6% per year, with 5 years max. So if your car is 6 to 25 years old (after which it becomes an old-timer), the state will take into account 70% of the price it was bought for the first time. But if you bought it second hand? You might buy a 2 year old car for 50% of the price, but it will still be counting for 88% of the price-for-a-new-one. Concretely: if you buy a second hand Maserati, don’t buy it in the company.
  • Super cars“. I know you love to watch Top Gear and dream about that Lamborghini, but I’m guessing that has become something even more of the happy few. If you buy/lease it as a company car, you will bleed in your personal taxes. 20K for that Porsche Carrera (so you will pay +- 50% of that in taxes). 10K for that Range Rover.

As far as I understand it, this is for new ànd second-hand cars, bought or leased by a company for a manager or employee. Let’s wait until some accountants come up with new schemes for expensive cars.

In the mean time: what individual wants to buy a Saab Cabrio?