Archive for category Linux

Cucumber-Nagios on Ubuntu 10.04 LTS

Well for those of you who don’t now what Cucumber is: Cucumber in general is a behaviour driven development system, which uses native language to explain whats going on. Cucumber-Nagios adapts this and turns your monitoring in a tool where you can express different behaviours for your applications, e.g.:

Feature: google.com
It should be up
And I should be able to search for things

Scenario: Searching for things
When I go to "http://www.google.com.au/"
And I fill in "q" with "wikipedia"
And I press "Google Search"
Then I should see "www.wikipedia.org"

It took me some time so figure out that the RubyGems from the Ubuntu Repo is a pain in the ass, but finally Cucumber-Nagios is now working on my Ubuntu boxes …


root@sbxx:~# aptitude install ruby rdoc ruby-dev irb libxslt-dev libxslt-ruby libopenssl-ruby
root@sbxx:~# wget http://rubyforge.org/frs/download.php/75309/rubygems-1.8.10.tgz
root@sbxx:~# tar xfz rubygems-1.8.10.tgz
root@sbxx:~# cd rubygems-1.8.10/
root@sbxx:~# ruby setup.rb
root@sbxx:~# ln -s /usr/bin/gem1.8 /usr/bin/gem
root@sbxx:~# gem install cucumber-nagios

Damn slow Solaris 10

Ich bin heute mal wieder darüber gestolpert, dass einpaar Server ziemlich langsam von einem unserer Monitoring-Server erreichbar sind. Eigentlich nichts wildes, aber es stört zeitweise, wenn es um Latenz und Prozessanzahl geht.

root@monitor1:~$ time ssh -o GSSAPIAuthentication=yes app-node1 "uptime"
4:42pm up 227 day(s), 19:32, 1 user, load average: 0.14, 0.12, 0.15
real 0m15.878s
user 0m0.012s
sys 0m0.012s

Also habe ich etwas debugged, zuerst mal einpaar Server gleicher Bauart (SUN X4100 mit Solaris 10) getestet, nichts zu finden. Dann mal die SSH-Verbindung im Verbose-Mode angeschaut und die TCP-Connection geht auch schnell, nur bleibt der Prozess bei einer GIS… stehen und wartet dort. Mal gesucht und die falsche Einstellung im SSH-Client gefunden.


root@monitor1:~$ time ssh -o GSSAPIAuthentication=no app-node1 "uptime"
4:42pm up 227 day(s), 19:32, 1 user, load average: 0.16, 0.13, 0.15
real 0m0.714s
user 0m0.020s
sys 0m0.004s

Und hier dann der generelle Fix in der Globalen /etc/ssh/ssh_config:

root@monitor1:~$grep GSSAPIAuthentication /etc/ssh/ssh_config
GSSAPIAuthentication no

New Year, New Oneliner

So fangen wir mal an, ich mußte gerade kurz einpaar dateien aus 2 Verzeichnissen abgleichen mein erster Einfall war das hier:

root@server:/usr/local/nagios-x64/libexec# for i in *; do [[ -f ../../nagios/libexec/$i ]] || echo "$i not available"; done
check_http_status not available
check_md not available
check_memory not available
check_smart not available
root@server:/usr/local/nagios-x64/libexec#

Ist eigentlich ganz geschmeidig :) man könnte es natürlich auch mit rsync –dry-run machen oder 2 Textfiles und diff, die Möglichkeiten sind unendlich ;)

December Oneliner

Want to make all files in your current directory lower case?

for i in * ; do mv $i $(echo $i | tr [A-Z] [a-z]); done

Want to sum the size of all directorys in one folder?

for i in * ; do if [ -d $i ]; then du -sh $i; fi; done

or shorter

for i in * ; do [[ -d $i ]] && du -sh $i; done

Want the Top10 Referer of your Website?

gzip -cd access_log.*.gz |  awk '{print $11}' | grep -v "\"-\"" | sort | uniq -c | sort -nr | head

Want to adjust an IP in all of your Apache virtual host files?

for i in *; do sed -e "s/80.3/81.3/" $i > $i.new; mv $i.new $i; done

Want to know the speed while filling a directory?

b=$(du -sm|awk '{print $1}'); sleep 60; e=$(du -sm|awk '{print $1}'); echo "$b $e" | awk '{ printf("%4.2fMB/s\n", ($2-$1)/60 )}'

Want to know if there are any critical/sercurity updates available for your Debian/Ubuntu?

apt-get -s upgrade | grep "^Inst" | egrep -i "(Debian-Security:|Ubuntu:[^/]*/[^-]*-security)" | wc -l | awk '{print "Critical Updates:", $1}'

Bash Oneliner

Ich habe mir gedacht fasse ich mal alle Bash Oneliner des Monats zusammen :) die ich so im Tagesgeschäft finde