Category Archives: Tips & Tricks

Swap Alt and Windows keys with xmodmap?

The problem: I have a Mac keyboard where the Alt/Win (i.e. Option/Command) keys are inverted compared to a regular PC keyboard, and I’d like to swap them. The answer: [codesyntax lang=”bash”] # clear all options setxkbmap -model “pc105” -layout “us,se” -option “” # set the Apple keyboard setxkbmap -rules “evdev” -model “pc105” -layout “us,se” -option … Continue reading Swap Alt and Windows keys with xmodmap?

VMware modules, Arch Linux & kernel 4.8.13

After upgrading the kernel to 4.8.13-1-ARCH some of the vmware kernel modules failed to compile: /tmp/modconfig-6BT70S/vmmon-only/linux/hostif.c:1592:47: error: ‘NR_ANON_PAGES’ undeclared (first use in this function) /tmp/modconfig-BBuLH6/vmnet-only/netif.c:468:7: error: ‘struct net_device’ has no member named ‘trans_start’; did you mean ‘mem_start’? The fix: [codesyntax lang=”bash”] cd /usr/lib/vmware/modules/source tar xf vmnet.tar tar xf vmmon.tar mv vmnet.tar vmnet.old.tar mv vmmon.tar vmmon.old.tar sed … Continue reading VMware modules, Arch Linux & kernel 4.8.13

Be notified when critical battery level is reached

Ever happened to be focused on something and miss the fact that your laptop is running out of battery? And to lose your work? Yesterday happened twice! “Really? Hmm… I need to fix this as soon as possible.” I googled a bit and this stackexchange post  popped up. Nice, great! But being notified even when you’re … Continue reading Be notified when critical battery level is reached

Marvel indices taking lot of space? Delete indices older than 7 days!

It looks like Marvel is generating some data everyday. Is there a way to reduce the amount of data generated by marvel? The short answer to the above question is Yes! [codesyntax lang=”bash”] curator –host 127.0.0.1 show indices –older-than 30 –time-unit days –timestring ‘%Y.%m.%d’ –prefix .marvel curator –host 127.0.0.1 close indices –older-than 30 –time-unit days … Continue reading Marvel indices taking lot of space? Delete indices older than 7 days!

Kill all mysql queries having query time greater than 1 minute

At this point there are two approaches to achieve this. One is using pt-kill from Percona Toolkit, and the other one is to use a bash script with a lot of pipes :) Why would someone use the second approach? I don’t know, perhaps because there is no Percona Toolkit available. [codesyntax lang=”bash”] for i … Continue reading Kill all mysql queries having query time greater than 1 minute

Which processes are swapping?!

Recently one machine was swapping. No free space on the swap partition. Hmmm… Since this machine was used as a database server, obviously I suspected mysql. But why to guess when I could knew for sure which process was swapping… [codesyntax lang=”bash”] for file in /proc/*/status ; do awk ‘/VmSwap|Name/{printf $2 ” ” $3}END{ print “”}’ $file; … Continue reading Which processes are swapping?!

Check and mark badblocks on ext4 partitions

My storage is acting weird today and I’m trying to fix it with this command: [codesyntax lang=”bash”] fsck.ext4 -vcDfty -C 0 /dev/vg0/lv0 [/codesyntax] And the result was: /dev/vg0/lv0: ***** FILE SYSTEM WAS MODIFIED ***** 6329 inodes used (0.01%, out of 107380736) 44 non-contiguous files (0.7%) 4 non-contiguous directories (0.1%) # of inodes with ind/dind/tind blocks: … Continue reading Check and mark badblocks on ext4 partitions