2012-05-28

ping tool / debugging a server from afar

hello readers,

sometimes my server is unreachable for no apparent reason. The logs don't really give a clue and my only way of reaching it again is to restart it by sending it an automatic hardware reset.
Since I have no idea whether it is locked up, just unreable *from* the network or completly disconnected from the network I wrote a little script to log pings. This way I can see in the log if it tries to ping at all and if it tries, if it can reach the network from its side or not.
Now all I have to do is to wait for it to crash. Well, I mean, to hope for the script to be a useless effort since it will never crash again ... of course ... ;)

Here's the script:


#!/bin/bash
# filename: pinglog.sh
# set logging dir here
MYDIR=/var/log/ping
# here you can choose a different format, i.e. "$1.log"
# where $1 always is the hostname given to the script
MYFILENAME="$1"
echo `date +'%Y-%m-%d %H:%M: '` `ping -c1 $1 | head -n2 | tail -n1` >>\ $MYDIR/$MYFILENAME

and here's a line for you to enter in in the crontab, if you want it to ping&log every 5minutes:

*/5 * * * * /some/directory/pinglog.sh some.server.com


I know it's not something big or difficult, but sometimes big problems need low-tech solutions. Also small scripts like these can be a good alternative to installing big software packages like nagios, if you don't really need them.

2012-05-15

Android time conversion

Good morning dear readers,

some hours ago I was shocked to noticee there was no good time (zone) conversion app on the android market. At least no good free one. I thought this was easy, but time conversion has some evil caveats, but I think I got it working fine for now. Since I'm not yet ready to invest 25$ so I can distribute an app for free I will just publish it right here. Feedback is of course welcome :)

BTW: For now the easiest way to install the little bugger is to enable installation from unkown sources and get it on the device somehow. I just moved it to dropbox, tapped it, there you go :)

Download toLocalTime.apk