Friday, January 31, 2014

Online expanding of a VMWare linux server LVM Volume

Add the hard drive to the running VM.

dmesg (figure out what the device name is for the new device like /dev/sdf)
parted /dev/sdf

mklabel msdos (inside parted)
quit (inside parted)

pvcreate /dev/sdf
vgextend VolGroup00 /dev/sdf
lvextend /dev/mapper/VolGroup00-LogVol00 /dev/sdf
resize2fs /dev/mapper/VolGroup00-LogVol00 

Thursday, January 30, 2014

Compress and transfer in one step

This command uses tar to compress a directory and store it into a file located on a remote system. Handy.
$ tar vzcf - /path/to/data | ssh user@remotesvr `cat - > /backups/data.tgz`

Pure command line if then without the if or then

The && and || can be used to control command flow like if then...
$ /use/bin/somecmd && echo "it worked!" || echo "epic fail!"

Process list filtering with grep

Adding the square brackets prevents the grep command from showing up in the process list.

$ ps -ef | grep proces[s]

Icinga log parsing perl command

The perl command changes unix time to human readable time in the output... Very useful for searching the check log archives.

more /usr/local/icinga/var/archives/* | perl -p -e 's/^\[(\d+)\]/"[". localtime($1) . "]"/e' | grep <what you're looking for>