HomeHome ArchiveArchive

munin plugin multi_http_responsetime doesn’t recognize dead servers

Here’s a patch:

# diff -u multi_http_responsetime.orig multi_http_responsetime
--- multi_http_responsetime.orig        2010-02-01 10:13:22.000000000 +0100
+++ multi_http_responsetime     2010-02-01 10:30:23.000000000 +0100
@@ -16,6 +16,9 @@
 use Time::HiRes qw( time );
 use IO::Socket;

 # ----- config -----
 push(@url_array, "http://www.google.de");
 push(@url_array, "http://www.t-online.de");
@@ -34,7 +37,7 @@
                                        PeerPort => 80,
                                        Proto => 'tcp'
-       return(0) unless ($sock);
+       return($FAILED) unless ($sock);
        print $sock "GET $baseurl HTTP/1.1\nHost: $vhost\nConnection: close\n\n";
        while (<$sock>) {
                $data .= $_;
@@ -63,11 +66,16 @@
                $baseurl =~ s@^\w+://.+?(/)@\1@;

                $tick1 = time();
-               geturl;
+               $retval = geturl;
                $tick2 = time();

-               $tspent = $tick2-$tick1;
-               $msecs = ($tspent * 1000);
+               if ($retval == $FAILED) {
+                       $msecs = $INFINITE;
+                       }
+               else {
+                       $tspent = $tick2-$tick1;
+                       $msecs = ($tspent * 1000);
+                       }

                printf "timespent$i.value %.3f\n", $msecs;

Chopped up SIP

Since upgrading to Karmic I had the problem under Ubuntu that SIP calls under Twinkle would start get all chopped up every few minutes.

Turns out it’s NetworkManager that scans the wireless spectrum every two minutes for networks even if you are allready connected to some AP.

While people seem to be fixing the problem in the proper way, by making scanning interfere less with an active connection, there’s a good soul that provides patched versions of NetworkManager that gives up scanning while there’s an active connection to an AP.

See https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/373680

removing gnome-screensaver

In https://bugs.launchpad.net/bugs/509411 I had the problem, that locking the screen would just not work any more. It turned out that gnome-screensaver must be perpetualy runnung in the background in order to be able to lock the screen.

Also this would affect the computer not locking the screen when suspending.

It might be that Gnome/Ubuntu are user-friendly, however the bloat is starting to annoy me. Why do I need to be running 214 processes, when the only thing that is actually being used is firefox and a terminal? Why do I need a process (gnome-screensaver) that is using up CPU cycles and virtual memory, when it’s actually never doing anything useful?

Thus I purged gnome-screensaver (8MB) and installed i3lock.

There are three things missing:

​1) Make the laptop lock the screen when suspending:

$ cat /etc/pm/sleep.d/01_screenlock
# 01_screenlock: lock screen at suspend with i3lock
# based on http://bbs.archlinux.org/viewtopic.php?id=68158

IS_ACTIVE="$( pidof i3lock )"

lock_screen() {
  # skip if i3lock is allready running
  if [ ! "$IS_ACTIVE" ]; then
       su - $USER -c "/bin/sh -c 'DISPLAY=$DISPLAY /usr/bin/i3lock'" &

case $1 in
       # not required.
       # not required.
   *) exit $NA

​2) Add it to the panel:

$ cat ~/.gnome2/panel2.d/default/launchers/i3lock.desktop
#!/usr/bin/env xdg-open

[Desktop Entry]
Name=Lock the Screen

​3) integrate it into package management, so that I don’t accidentaly remove packages on which the screen locking depends:

$ cat control
Section: misc
Priority: optional
Standards-Version: 3.6.2

Package: lock-screen
Maintainer: Tomas Pospisek 
Depends: i3lock, pm-utils, gnome-icon-theme
Files: 01_screenlock /etc/pm/sleep.d/01_screenlock
 i3lock.desktop /home/henry/.gnome2/panel2.d/default/launchers/i3lock.desktop
Description: lock screen on suspend/hybernate
$ equivs-build control
$ sudo dpkg -i lock-screen_1.0_all.deb

Of course, it's a hack. However it works and is easy to adapt. Let me know at tpo at sourcepole.ch in case you get to make it more generic.

That's it. Saved runtime bloat. Saved disk space (i3lock is 60K large).


It can be integrated in any Rack based appication. Sample configuration for Ruby on Rails:

 config.middleware.use Rack::Monitor, :url => '/rack_status', :watch => ['/', '/ping']

The collected statistical values can be accessed at /rack_status. It is recommended to limit access to this path with our contributed middleware Rack::Access from rack-contrib.

Sample munin output:

rack_memory-day rack_requests-day rack_status_codes-day