Archive

Archive for the ‘Am a Geek’ Category

Quick memory usage check by thread

June 29th, 2011 1 comment

Saved for posterity. Possibly there is an easier way.

$# root@mt:/var/log# bash memreport 
Name:   bash:   10588
Name:   bash:   10600
Name:   bash:   20548
Name:   cron:   22420
Name:   getty:  5928
Name:   init:   8352
Name:   ntpd:   38332
Name:   rsyslogd:       54144
Name:   sort:   59840
Name:   sshd:   49168
Name:   sshd:   70452
Name:   udevd:  16864
Name:   udevd:  16864
Name:   udevd:  16868
 
$# cat memreport 
#!/bin/bash
for i in /proc/[123456789]*/status; do 
 size=$(grep VmSize $i | awk '{print $2}')
 (( size > 0 )) && echo -e "$(grep Name: $i): \t$size"
done | sort -n;
Categories: Am a Geek, Quick cuts Tags: , , ,

Debian squeeze with xen (link-dump)

March 31st, 2011 Comments off

Getting started with Xen http://wiki.debian.org/Xen

Xen and qcow on lvm is a pain, use kpartx to present file-systems and test boot of those before migrating to raw lvm images

Fix for annoying messages about network bridge still present in stableĀ http://xenbits.xensource.com/xen-unstable.hg/rev/b0fe8260cefa7

 

Categories: Am a Geek, Linux Tags: , , , , ,

Working with raw and sparse filesystem images

February 24th, 2011 Comments off

A while back I started using KVM on my home pc to make it easier to build and tear down sandboxes.

More recently I’ve been playing with file-systems and sparse images, and looking for ways make a quick deployment possible rather than going through an entire distro install each time. I got to wanting a small image that I could boot from quickly to help get a deployment started. This is how I went about making a ‘golden-image’ for just that purpose.

Sparse files are interesting because they help reduce the storage space needed for data sets that may be mostly full of zeros, but for various reasons you don’t want to compress. Used properly they can significantly reduce data-transfer usage during large scale deployments.
Read more…

Enabling the CVS Id Tag for SVN

November 18th, 2010 Comments off

From: Yeah, right. Okay. Whatever!: Enabling the CVS Id Tag for SVN. Thanks for the tips dude.

The CVS Id tag which adds file information on the file itself upon commit is enabled by default on CVS but not on SVN. To have it enabled you need to add/modify the following on your local SVN configuration file (on UN*X: <HOME>/.subversion/config):

[...]
enable-auto-props = yes

[...]
[auto-props]
[...]
*.java = svn:keywords=Author Date Id Revision;svn:eol-style=native

Complete list of keywords: Author, Date, Header, Id, Log, Locker, Name, RCSFile, Revision, Source, State.

Of course, you need to add a line for every file type you want to configure for a fine grained control over that. Otherwise use *.

This works for all files committed from now on. If you already have files in the repository, you need to tell SVN to add them too:

# Make sure that everything is up to date
> svn up
# Add keywords and commit
> svn propset svn:keywords "Author Date Id Rev" file_name
> svn commit -m "Adding Id and Rev property to all files"
Categories: Am a Geek, Linux Tags: , , ,

OpenOffice headless mode

October 12th, 2010 Comments off

There are some quite specific cases where it is desirable to have OpenOffice.org run in headless mode on servers, mainly for document conversion. But typically its a bit harder to make that convenient. There are a few places that provide ways to start that and a couple of init scripts, but nothing with much polish. Hopefully the following script will fill that gap for some…

Combined from scripts and tips found at the following pages…

http://chrisschuld.com/2008/10/rhel5-init-initd-script-for-openoffice-org/

https://code.google.com/p/openmeetings/wiki/OpenOfficeConverter

http://wiki.debian.org/LSBInitScripts

#!/bin/bash
# openoffice.org  headless server script
#
# chkconfig: 2345 80 30
# description: headless openoffice server script
# processname: openoffice
#
# Author: Vic Vijayakumar
# Modified by Federico Ch. Tomasczik
# Lsb + compatibility for rhel and debian added by Glenn Enright
#
### BEGIN INIT INFO
# Provides:          openoffice-headless
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Manage openoffice document conversion daemon
# Description:       Enable service provided by daemon.
### END INIT INFO
 
[ -e /etc/init.d/functions ] && . /etc/rc.d/init.d/functions
 
OOo_HOME=/usr/bin
SOFFICE_PATH=$OOo_HOME/soffice
PIDFILE=/var/run/openoffice-server.pid
 
set -e
 
function start {
if [ -f $PIDFILE ]; then
echo "OpenOffice headless server has already started."
return
fi
echo "Starting OpenOffice headless server"
$SOFFICE_PATH -headless -nologo -nofirststartwizard -accept="socket,host=127.0.0.1,port=8100;urp" &> /dev/null 2>&1
touch $PIDFILE
}
 
function stop {
if [ -f $PIDFILE ]; then
echo "Stopping OpenOffice headless server."
killall -9 soffice &&; killall -9 soffice.bin
rm -f $PIDFILE
return
fi
echo "Openoffice headless server is not running."
}
 
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
echo "Pausing a moment to allow full shutdown" && sleep 5
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
esac