You are here

Human-readable json-output with a python one-liner

I was trying to get some metrics from a service that outputs in json and copy-pasted the output into an editor and used a json-plugin to order the output in a human-readable way. While this works fine, I thought it would be easier to write a one-liner that parses the json-output and pretty-prints it on my screen.

That way it would be easier for me to read. Also I can now use grep on the output to search for specific metrics.

The one-liner uses python to read and dump json-output. Here it is:

Tmux-integratie iTerm2

Leuk, thuis inloggen op een machine via ssh met gebruikersnaam, wachtwoord en een tijdelijke token.
Dan een nog een sessie openen, weer je wachtwoord en een token intikken.
En nog een keer, en nog een keer... onhandig!

Wat blijkt? iTerm2 (ja ik werk op een Mac) kan prima integreren met Tmux!
Wat is Tmux? Nou, da's net zoiets als screen, dus meerdere sessies kunnen draaien binnen 1 login... maar screen heeft zo zijn beperkingen zoals standaard geen scrollback en 't uit je hoofd moeten kennen van toetscombinaties om van sessie naar sessie te schakelen.

IP-adressen sorteren met 'sort'

Leuk, ip-adressen listen... als je normaal gesproken bijvoorbeeld ip-adressen .1 t/m .10 op een server hebt en je probeert ze te sorteren dan krijg je iets als dit:
10.1.2.1
10.1.2.10
10.1.2.2
10.1.2.3
10.1.2.4
10.1.2.5
10.1.2.6
10.1.2.7
10.1.2.8
10.1.2.9

Maar die 10 zie je toch liever netjes onder de 9, niet?
Wat je kunt doen is sort inlichten over het feit dat de punt een scheidingsteken is en vervolgens per veld sorteren. bijvoorbeeld als volgt:

Monitoring java memory-usage with Check_MK

After running out of memory with a Java application, I wanted to monitor the internal Java memory usage.

It cost me quite some time trying to get the information I seeked from JMX, still have not figured that out. Suddenly I ran into a simple Nagios-plugin that utilizes the jstat-command to just get the heap- and permgen usage from a java-process. The original plugin can be found here: https://github.com/Ericbla/check_jstat.

Looking-up PHP sessions in memcached

If, like me, you use memcached primarily for storing php-sessions using the php-module 'memcache' or 'memcached', then you probably have no idea what's actually happening inside memcached. It took me some time to figure out simply how to lookup a php-session.

Like most things in life, the answer is actually pretty simple.

You need two things:
- The session name (can be found in php.ini / phpinfo()), usually just "PHPSESSID".
- The session id (I've used Firefox add-on "view cookies" to see mine).

Running a second MySQL-instance on the same Linux box

Sometimes it can be useful to be able to start a second mysqld-instance on the same machine, for example when you need to restore some innodb-tables but only have a file back-up available of the MySQL-instance on the machine.

When searching the Internet, many people offer solutions for this that use a chroot. Well... I don't like to build-up a whole chroot just to run a second MySQL-daemon! ;-)

Make sendmail deliver messages in Maildir-format

This is very easy. As sendmail uses procmail to deliver messages locally, you just have to let procmail know you'd like to deliver messages in a directory instead of in a single file.

For this, create a file /etc/procmailrc and add the following line to it:

DEFAULT=$HOME/Maildir/

Now all messages will be delivered into a directory called "Maildir" in the users' homedir. No service restart required. As soon as the first e-mail message comes in the Maildir-directory and its contents will be automatically generated. :-)

~/.ssh/config

I just found that it's possible to configure your ssh-client on a per-host basis. So, use this for host-a and that for host-b. For a while now, I was using "ServerAliveInterval 60" in my ~/.ssh/config, to make sure ssh connections don't die after a while.

Auto-configure vmware-tools at boottime on CentOS 6

So, a few years ago I wrote a simple script to configure the vmware-tools at boot after a kernel upgrade. This worked well for us ever since. However, on CentOS 6 machines I noticed there's no vmware-tools service anymore after the latest vmware-tools upgrade (version 8.6.11 on our machines).

Pages

Subscribe to HighKing's Website RSS