Archive für Juli 2007

Hibernate examples

some small examples covering various hibernate issues.

devhouse cologne

devhouse colognefinally, a friend lend me his old laptop so I just needed to excgange the disk . but the internal wlan card didn’t work. Lucky me, another friend offered me to take his pcmcia card, so I’m now kinda prepared to attend the devhouse cologne event. What’s this? take a look by yourself. A couple of people I met at the last barcamp/plogbar event(s) are attending, it seems to be a bit more technical directed than the last barcamp, but anyway, I expect fun, getting in contact with nice people, a various information exchanges. It’s amazing getting in touch with recent achievements made in differet technical fields. And on top of this, a warmup on Friday at “Gottes Grüne Wiese” and if weather is fine BBQ on Saturday eve. Sounds cool. More about it to come.

tcp_echo

even the echo service is disabled on Linux machines, it’s nevertheless an easy way to figure out spurios network delays. TIn perl the basics are already written in the NET::PING module. I only added some timing to it. If you don’t have the perl modules installed, a workaround is creating a script containing the line

echo $2 | /usr/bin/netcat -v $1 7

which you could than invoke with time scriptname host.domain.dmn string_to_use
here ist the other way

#!/usr/bin/perl
# simple tcp echo programm
# sample usage (verbose mode)
# /xxx/bin/tcp_echo.pl -v 1 -h host.domain.dmn
# /xxx/bin/tcp_echo.pl: host.domain.dmn 2
# res = 1 host host.domain.dmn time: 0.012088
# sample usage (normal mode)
# /root/bin/tcp_echo.pl -h host.domain.dmn
# res = 1 host host.domain.dmn time: 0.010903
#
use strict;
use Getopt::Long;
use Net::Ping;
use Time::HiRes;
use Time::HiRes qw(gettimeofday tv_interval);

my $program_name = $0;
my $timeout = 2;
my $hostname = “localhost”;
my $debug = 0;

sub helpMessage()
{
print “$program_name [-h|-?] [-v #] [-t #] [-h FQDM] [\n”;
print “-help|? this message\n”;
print “-v[erbose] enables debug messages \n”;
print “-t[imeout] timeout (default: 2)\n”;
print “-h[ost] hostname FQDN (default: localhost) \n”;
exit 1;
}

sub run()
{
my $t0 = [gettimeofday];
my $res = pingecho( $hostname, $timeout );
my $t1 = [gettimeofday];
my $elapsed = tv_interval $t0, $t1;
print “res = $res host $hostname time: $elapsed\n”;
}

Getopt::Long::Configure (”bundling”);
my $l_result = GetOptions (
‘help|?’ => sub { helpMessage() },
‘verbose|v=n’ => \$debug,,
‘host|h=s’ => \$hostname,
‘timeout|t=n’ => \$timeout);

print “$program_name: $hostname $timeout \n” if $debug;

&run();

proc/net/netstat monitor

I recently grabbed a little tcl script which you can use for process monitoring. Can’t remember the actual URL where I took it from, and it had no comments in it. Nevertheless, even it’s about a decade ago i worked with tcl, i changed it to print out which TCPext: fields of the netstat command changed. perhaps somebody can use it

#!/usr/bin/tclsh
#
# small utility to print the tcpext. flags that changed.
# Free to use, no warranty etc….
#
# ./mon_linux_netstat
# CTRL-C to stop
#
# Pit 03.07.07

cd /proc/net

set tcp_arr {
TCPEXTFAKE
SyncookiesSent
SyncookiesRecv
SyncookiesFailed
EmbryonicRsts
PruneCalled
RcvPruned
OfoPruned
OutOfWindowIcmps
LockDroppedIcmps
ArpFilter
TW
TWRecycled
TWKilled
PAWSPassive
PAWSActive
PAWSEstab
DelayedACKs
DelayedACKLocked
DelayedACKLost
ListenOverflows
ListenDrops
TCPPrequeued
TCPDirectCopyFromBacklog
TCPDirectCopyFromPrequeue
TCPPrequeueDropped
TCPHPHits
TCPHPHitsToUser
TCPPureAcks
TCPHPAcks
TCPRenoRecovery
TCPSackRecovery
TCPSACKReneging
TCPFACKReorder
TCPSACKReorder
TCPRenoReorder
TCPTSReorder
TCPFullUndo
TCPPartialUndo
TCPDSACKUndo
TCPLossUndo
TCPLoss
TCPLostRetransmit
TCPRenoFailures
TCPSackFailures
TCPLossFailures
TCPFastRetrans
TCPForwardRetrans
TCPSlowStartRetrans
TCPTimeouts
TCPRenoRecoveryFail
TCPSackRecoveryFail
TCPSchedulerFailed
TCPRcvCollapsed
TCPDSACKOldSent
TCPDSACKOfoSent
TCPDSACKRecv
TCPDSACKOfoRecv
TCPAbortOnSyn
TCPAbortOnData
TCPAbortOnClose
TCPAbortOnMemory
TCPAbortOnTimeout
TCPAbortOnLinger
TCPAbortFailed
TCPMemoryPressures
}

#
# read in the values from the netstat file
proc scan_net { _dat} {
upvar $_dat dat
global tcp_arr

set in [open “netstat” “r”]
set l [gets $in]
set l [gets $in]
close $in

set a [split $l ” “]

foreach x $a n $tcp_arr {
if {[string match “TcpExt:” $x]} {
continue
}
set dat($n) $x
#puts “dat von n($n) = $dat($n) ”
}
}

#
# set inital data array and fill it
array set dat {}
scan_net dat

# forever
# sleep 1 second, read in second array
# loop and compare values, if different print the sum
# reset the initial array and copy new to old
while {1} {
after 1000

array set new_dat {}
scan_net new_dat

set somechange 0
foreach a $tcp_arr {
if {[string match “TCPEXTFAKE” $a]} {
continue
}
if {$new_dat($a) != $dat($a)} {
set res [expr {$new_dat($a) - $dat($a)}]
#puts “attribute ‘$a’ from $dat($a) to $new_dat($a) $res”
puts “‘$a’ $res”
set somechange 1
}
}

if {$somechange} {
puts “”
}

array set dat {}
array set dat [array get new_dat]
}

|