cordump.com

A manual version of killall

by daven on Jan.01, 2008, under General System Administration

Sometime you don’t want to use the killall or maybe you work at a site with Solaris servers where getting used to killall is a Bad,Bad Idea. Either way it can be handy to have another method to terminate all copies of a process, or even a related set of processes, with extreme prejudice .
So here we go a little pipe love and we are on our way

$ ps auxww | grep -i "SOMETHING UNIQUE I WAN'T TO KILL" | xargs -i kill -9 {}

The ps and grep parts should be fairly obvious xargs will run whatever you specified substituting {} for STDIN and will repeat on it has processed everything on STDIN, it does use return to separate STDIN so now CSV here.
Have fun killing stuff just use it wisely and if you do decide to try killall on a Solaris machine will you will probably kill what you wanted to as well.

Leave a Comment more...

TIP: using BASH for loops on the command line

by daven on Dec.07, 2007, under Automation, General System Administration, Quick Tips

Sometime you want to run a command or a series of commands in a loop to say shutdown all the nfs daemons via their init scripts. Now we could do them one at a time like:

$ /etc/init.d/nfs stop
Shutting down NFS mountd: [ OK ]
Shutting down NFS daemon: [ OK ]
Shutting down NFS quotas: [ OK ]
Shutting down NFS services: [ OK ]
$ /etc/init.d/nfslock stop
Stopping NFS locking: [ OK ]
Stopping NFS statd: [ OK ]

Or we could use a bash for loop with a little copy & paste

$ for i in /etc/init.d/nfs /etc/init.d/nfslock
> do
> $i stop
>done
Shutting down NFS mountd: [ OK ]
Shutting down NFS daemon: [ OK ]
Shutting down NFS quotas: [ OK ]
Shutting down NFS services: [ OK ]
Stopping NFS statd: [ OK ]

Or just completely automate it and get it down quick and easy

$ for i in `ls /etc/init.d/nf*`
> do
> $1 stop
>done
Shutting down NFS mountd: [ OK ]
Shutting down NFS daemon: [ OK ]
Shutting down NFS quotas: [ OK ]
Shutting down NFS services: [ OK ]
Stopping NFS statd: [ OK ]

It’s that simple and you saved your self a bunch of typing.

Leave a Comment more...

TIP: VIM — displaying line numbers

by daven on Nov.05, 2007, under General System Administration, Quick Tips

Sometimes in VIM it is useful to display line numbers, for example you want to be really accurate when deleting to line number X. Fortunaly, VIM includes a mode to display line numbers
To enable the display of lines numbers in command mode type:

:set number

To disable the display in command mode type:

:unset number

Now if you decide you would like line numbers to always be displayed simply add set number to your ~/.vimrc and you are all set

2 Comments more...

What to install on a Fresh Macbook

by daven on Oct.15, 2007, under Life in General

I recently had the hard drive fail on my macbook and now received a new drive with a fresh install of Tiger here is what I am going to download and install on it.

Seemed like this list was going to be much longer, I will just add to this post as I remember additional apps to install.

Leave a Comment more...

Installing mytop on OS X

by daven on Oct.08, 2007, under DataBases, General System Administration, Quick Tips

install via CPAN DBI & DBD::mysql & Time::HiRes
CPAN install fails for Term::ReadKey & Term::ANSIColor so install via fink
then hack mytop to
use lib ‘/sw/lib/perl5/5.8.8/darwin-thread-multi-2level’;
then run
mytop -u username -p passwd -h hostname -d any real DB on the host

Leave a Comment more...

qshape realtime traffic analysis tool for postfix

by daven on Sep.20, 2007, under General System Administration

I was looking for something more useful mailq to help me analyze which domains where most responsible for the sudden explosion in the size of my mail processing queue. qshape to the rescue and it even ships with most newer releases of postfix.

% qshape deferred

Prints out a list of email messages in the deferred queue by recipient
domain in a table format like below

T 5 10 20 40 80 160 320 640 1280 1280+
TOTAL 548 3 1 7 134 8 19 24 74 4 274
example1.com 128 0 0 2 118 2 1 5 0 0 0
example2.net 41 0 0 0 0 0 0 1 6 0 34
example3.com 18 0 0 0 0 0 0 0 6 0 12
...

For a complete explanation of the tool and its usefulness see the official README from the author here

Leave a Comment more...

Oh No he is coming to get me :)

by daven on Sep.18, 2007, under Life in General

Leave a Comment more...

postfix username wildcarding

by daven on Aug.30, 2007, under General System Administration

A lot of people who own their own domain like to setup new email addresses for every site they are forced to register with. This allow you to determine which sites are evil and reselling your e-mail address and provides another way to figure out who those emails are from. The problem I sometimes run into with this method is I want to register with a new site, but do can’t get to my email system to create a new email address. Once again postfix can come to the rescue of the lazy, um I mean motivated.
Check the value of recipient_delimiter in your main.cf by it will probably look like

recipient_delimiter = +

What this means are postfix will strip anything after the delimiter and just deliver as if it did not exist i.e.
trash+evilespammer@cordump.com will end up being delivered to trash@cordump.com. It will still show as to trash+evilespammer@cordump.com for filtering or recognition purposes.
Documented briefly here

Leave a Comment more...

Tip: Using lsof to find unlinked files

by daven on Aug.24, 2007, under General System Administration, Quick Tips

Every once in a while you will get an alert from your monitoring system claiming that some file system in full (generally /tmp). You go ahead and login run df and it confirms what your monitoring system discovered and you start looking to see whats eating all your disk space on the file system. However, you can’t find any large file or files which might be responsible to the lose of diskspace . At this point I usually cd into the mount point and do

du -sk * | awk '{list=list""$1"+"}END{print list}' | sed 's/.$//g' | bc -q

The adds up all the totals you get from du -sk so you can confirm that it doesn’t equal what df is reporting, or that you just can’t find the culprit.
Once you are reasonably certain that problem that number do not add up the most likely issue and an unlicked file consuming an inode and hence disk space until the process controlling it releases the filehandle. Next you are confronted with how do I find the process the are causing this to happen. Well it is deceptively simple just a quick little lsof with the right options.

lsof +L1

This will show you all open files that do not have a link, don’t show in the filesystem. Like so

COMMAND PID USER FD TYPE DEVICE SIZE NLINK NODE NAME
mysqld 1815 mysql 8u REG 104,5 0 0 736012 /tmp/ib5liVDV (deleted)
mysqld 1815 mysql 9u REG 104,5 1182 0 736013 /tmp/ibUyHflw (deleted)
mysqld 1815 mysql 10u REG 104,5 0 0 736014 /tmp/ibrgt626 (deleted)
mysqld 1815 mysql 14u REG 104,5 0 0 736015 /tmp/iba8ihXH (deleted)

Just locate the file(s) on your problematic file system and restart or kill the controlling PID.

Leave a Comment more...

Nagiosgraph, adding trending to your Nagios monitoring

by daven on Aug.22, 2007, under General System Administration, Monitoring & alerting

I recently completed a project to upgrade our Nagios installation from 2.5 to 3.0b1 (Yes, I know thats a beta). As part of this upgrade I decide to include nagiosgraph to provide trending information via rrdtool.
Here is an example of an hourly cpu load graph from a test system
cpu_load_hourly.png

(continue reading…)

1 Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...