I tend to prefer unix-like environments, which means I love mac as a desktop and linux as a server os.
But I’m at a new job, and my desktop and laptop are Windows. Here’s a short list of things I’ve done to make windows more unixy for me. Apologies in advance to the people who wrote these programs– I’m not comparing your awesome programs to someone else’s because I think you’re derivitive, I’m doing it because it quickly helps a Mac user understand the value.
- Cygwin is a unix-like environment that runs inside of windows. Under there, you can compile most unix applications, run (native) perl, python, whatever. It’s good. It’s free. Once you have this, you have native open ssh, etc.
- While you’re at it, change the default cygwin shortcut to point to a batch file that contains the following, it’s a much nicer shell than the default windows dosbox
@echo off
C:
chdir C:\cygwin\bin
rem bash --login -i
rxvt -bg black -fg green -geometry 80x48 -e bash--login -i & |
- Rocketdock is a nice mac-like dock. Just like on the mac, it supports things like minimize-to-dock, cute hover animiations, etc. It also has “live” images of what minimized windows look like. Nicer in many respects than the XP taskbar, and similar to the Vista one.
- Launchy is a quicksilver-like hotkey launcher. It’s very, very nice. Hit alt-space and type “word” to launch Microsoft Word, etc. Speeds up application launching immensely.
We use NoCat extensively, and we have peak usages of > 1100 users actively logged in at the same time, with another good 3000 or so people actively using wireless and holding a dhcp lease.
We recently started experiencing slowdowns, where it would take minutes for NoCat gateways to actually return a page (status, capture, actually authenticate and redirect, etc). This was caused by a simple mistake in their child reaping, documented below.
It’s important to note that in a captive portal solution, the gateway is MUCH busier than the number of authenticated users suggests; authenticated users usually don’t impact the cpu much (they’re just permit rules in the underlying firewall). It’s unauthenticated users who hammer the system. Every weather widget, RSS request, twitter status update, etc, etc that’s happening automatically on port 80 is being captured (silently) by the gateway. So we need to be sure our forking is smart.
The root cause of the slowdown was that it was reaping children using the wait() call. wait() is a blocking call. This means that the software, if it had any children forked out, would block until a child (any child) exited, and then processing would continue. The server would fork off enough threads to handle any children waiting, and then come back and block again for a child to exit. This is ok at low loads, but not good when you’re at high loads (or there’s a packet loss problem, common in wireless, causing a thread to run slow, etc).
The fix: Change wait() to waitpid(-1,NOHANG). Now, it’s non blocking. Performance is much, much better.
--- Gateway.pm (revision 667)
+++ Gateway.pm (working copy)
@@ -3,6 +3,7 @@
use IO::Socket;
use IO::Select;
use IO::Pipe;
+use POSIX ":sys_wait_h";
use NoCat qw( PERMIT DENY PUBLIC MEMBER OWNER LOGIN ANY );
use vars qw( @ISA @REQUIRED @EXPORT_OK *FILE );
use strict;
@@ -93,6 +94,7 @@
my $self = shift;
my $kids = 0;
my $hup = 0;
+ my $childPid;
return unless $self->bind_socket;
@@ -143,10 +145,10 @@
}
# See if any kids have expired, reap zombies
- if ( $kids ) {
- 1 until ( wait == -1 );
- $kids = 0;
- }
+ do {
+ $childPid = waitpid(-1, WNOHANG);
+ $kids-- if $childPid>0;
+ } until $childPid<=0;
} # loop forever
} |
For the longest time, I depended on .zshrc on the target machine to set the title in my (xterm|iTerm) window title. This has one drawback– if the target host doesn’t have my .zshrc (or support zsh), no title. And this bit me nastily the other day when I did something in the wrong window.
Enter this new .zshrc function, which works by setting the xterm title sequence:
alias ssh="sshWithTitle";
function sshWithTitle(){
local newTitle=$1
print -Pn "\e]0;$newTitle \a"
\ssh $*
}
alias telnet="telnetWithTitle";
function telnetWithTitle(){
local newTitle=$1
print -Pn "\e]0;$newTitle \a"
\telnet $*
} |
Combine this with the following code to set your title to user@host before and after each command and you should always know who you are in a window.
### set title block
HOSTTITLE=${(%):-%n@%m}
TITLE=$HOSTTITLE
# make sure we're in an xterm!
case $TERM in (xterm*|rxvt|screen)
precmd () { print -Pn "\e]0;$TITLE \a" }
preexec () { print -Pn "\e]0;$TITLE \a" }
;;
esac
function title (){
if (( ${#argv} == 0 )); then
TITLE=$HOSTTITLE
return
fi
TITLE=$*
}
#### end set-title-block |
Recent Comments