Free shell account anyone?

October 31, 2007

For a time, I’m offering a free shell account to anyone who would like one on http://navi.eight7.org. Email me if you would like an account.

Details:

  • FreeBSD 6.2-RELEASE
  • UltraSPARC IIe 650 Mhz processor (speeeeedy :P)
  • 1GB of RAM
  • SSH login from anywhere that can get to navi.eight7.org:22
  • lighttpd w/fastcgi & SSL for web serving
  • Ajaxterm to access console login from http
  • 78%+ uptime! (I jest, more uptime than that)

Like I said, if you’re interested, email me, I’m curious to know what you would do with it also :)

[UPDATE]: Due to the amount of requests I am receiving about this software, I would prefer if you were not going to use the account to host psybnc or eggdrop, I would prefer you use the account for something a bit more constructive :)

[UPDATE 2]: Someone with an account was rude enough to attempt to install backdoor software, this offer is no longer in effect for the time being.

PHFOS update – more than 20 threads useable

October 29, 2007

[UPDATE 10/30/07]: In the below post, use the link to the text file to get the latest version, I can’t edit the actual text on the page every time I update the script. The most up-to-date script can be found here.

Just a small update, you *can* actually use more than ~20 threads when using the phfos script. The key is to make sure you are using the --readstop option so the thread doesn’t sit there waiting for rand(maxTime-minTime+1) + minTime seconds keeping the file open. I was successfully able to run it with 1500 threads on my MacBook Pro and again with 1500 threads on my desktop Ubuntu machine.

Hopefully this will make the script infinitely more useful, as a lot more connections can be simulated now.

PHFOS – Perl Hold File Open Script for stressing disk access like a customer environment

October 25, 2007

[UPDATE 10/29/07]: You can now use phfos with lots more threads, read this post

It’s quick, it’s dirty, but here it is “PHFOS” (Note to self: get better at naming scripts). So here’s what it does.

Basically, you specify a directory with some kind of files in it, the script then spawns <n> threads that each keep a random file open for a random amount of time (to simulate customers accessing files in a random manner). There are options to change the maximum number of threads, the minimum time to keep a file open, the maximum time to keep a file open, whether to read the contents of the file, or to shortcircuit and immediately close after reading the file, etc. Take a look at the “-h” option to see what they do.

***WARNING ***
Don’t run this from a production machine, it can (and will, if you aren’t careful) take down an entire machine in a matter of seconds depending on the command-line options. I accidently ran this with the number of threads=1550 and killed my MacBook Pro laptop immediately. Experiment with low settings on the numbers until you reach the sweet spot, if you run into bus errors or kernel protection errors, try decreasing the numbers. Here are some good starter numbers:

If you have small (<10mb) files, try this:
./phfos.pl -r -v -d <dir> -n 20 --min=2 --max=3 --readstop

If you have larger files, you might try this:
./phfos.pl -r -v -d <dir> -n 15 --min=10 --max=30

Of course, you can take out the -r if you don’t want the files actually read, just opened. Read past the end if you want to read a bit about how it works and the problems you might run into.

Download the script here if you can’t copy it from below (and because WordPress mangles indentions).


#!/usr/bin/perl

use warnings;
use strict;

# PHFOS – Perl Hold File Open Script
use Getopt::Long;
use threads;
use threads::shared;
use POSIX;

sub print_usage {
print “Flags:\n”;
print ” -d <directory>\t\tDirectory to read files from (REQUIRED)\n”;
print ” -n <number>\t\tMaximum number of threads to spawn (default 10)\n”;
print ” -r\t\t\tRead the contents of the files in addition to opening\n”;
print ” –min=<seconds>\tMinimum number of seconds to keep a file open (default 5)\n”;
print ” –max=<seconds>\tMaximum number of seconds to keep a file open (default 10)\n”;
print ” –readstop\t\tIf set, immediately exit thread after reading contents of the file\n”;
print ” -v\t\t\tVerbose mode, tell me what files are open and for how long\n”;
print ” -h\t\t\tDisplay this usage\n”;
exit(0);
}

my %options = ();
my $verbose = 0;

GetOptions(“verbose!” => \$verbose, # verbose option
“d:s” => \$options{dir}, # directory to read files from
“n:i” => \$options{numOpen}, # number of threads to open at the same time
“min:i” => \$options{minTime}, # minimum time to keep a file open
“max:i” => \$options{maxTime}, # maximum time to keep a file open
“readstop” => \$options{readStop},
“r” => \$options{readFile}, # display usage
“h” => \$options{help} # display usage
);

if ($options{help}) { print_usage(); } # if help is set, display usage and exit
if (!defined($options{dir})) { print_usage(); }
if (!defined($options{numOpen})) { $options{numOpen} = 10; }

my $dir = $options{dir};
my @threadList;
my $maxThreads = $options{numOpen} || 10;
my $minTime = $options{minTime} || 5;
my $maxTime = $options{maxTime} || 10;
my @filelist = get_dir_list($dir);
my $index = 0;
our $readfile : shared = $options{readFile};
our $readstop : shared = $options{readStop};

while (0 == 0) {
my $file = $filelist[ rand @filelist ];
my $time = int( rand($maxTime-$minTime + 1)) + $minTime;
if (!$readstop) {
print “Randomly selected file: $file will be opened for $time seconds\n” if $verbose;
}
my $filename = $dir . “/” . $file;

my $newthread = threads->new(\&hold_file_open, $filename, $time);
$newthread->detach;
$index++;

if ($index >= $maxThreads) {
# give the OS a chance to recover
sleep(int(($minTime+$maxTime)/2));
$index = int($index / 2);
}

}

sub get_dir_list {
my $dirname = shift;
opendir(DIR, $dirname) || die “can’t opendir $dirname: $!”;
my @files = grep { /[^\.]/ && -f “$dirname/$_” } readdir(DIR);
closedir DIR;
return @files;

}

sub hold_file_open {
my $filename = shift; # which file to hold open
my $openlength = shift; # the length in seconds to keep it open
my $data;
my $size = 0;
my $bytesread = 0;
my $FIN = POSIX::open($filename);
if (!defined($FIN)) { die “Unable to open $filename\n”; }
if ($readfile) {
my $starttime = time();
while (($bytesread = POSIX::read($FIN,$data,65536)) > 0) {
$size = $size + $bytesread;
#print “[” . $data . “]”;
}
my $endtime = time();
my $readtime = $endtime – $starttime;
print “thread[” . threads->self->tid . “] read $size bytes from $filename in $readtime seconds\n” if $verbose;
if ($readstop) {
sleep(1); # give the OS a bit of time to play catchup
POSIX::close($FIN);
return 0;
}
my $newsleeptime = $openlength – $readtime;
if ($newsleeptime < 1) { exit(0); }
$openlength = $newsleeptime;
}
sleep($openlength);
POSIX::close($FIN);
return 0;
}

Okay, so basically, how it works is that it traverses the directory, looking for file and adding them to an array, if then randomly spawning a thread to open/read the file (up to “n” number of threads). Once it reaches the max number of threads as specified, it waits for ((minTime+maxTime)/2) seconds before halving the thread counter. Basically it waits the average amount of time (assuming true randomness) because by then, statistically half of the threads *should* have finished (I can’t keep track of this because of the thread->detach). At some times you will have slightly larger than “n” threads and sometimes slightly less.

Let’s also talk about a problem I’ve run into that I can’t seem to figure out, here’s the crashdump from Perl:

Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_PROTECTION_FAILURE (0x0002) at 0x00000038

Thread 0 Crashed:
0 libSystem.B.dylib 0x90025c82 flockfile + 18
1 libSystem.B.dylib 0x900017c5 fileno + 37
2 libperl.dylib 0x97035b03 PerlIOStdio_dup + 159
3 libperl.dylib 0x970374da PerlIO_fdupopen + 156
4 libperl.dylib 0x96fd6bce Perl_fp_dup + 102
5 libperl.dylib 0x97037789 PerlIO_clone + 442
6 libperl.dylib 0x96fdb246 perl_clone + 1979
7 threads.bundle 0x0000e8bb Perl_ithread_create + 557
8 threads.bundle 0x0000ef01 XS_threads_new + 351
9 libperl.dylib 0x96fc11ad Perl_pp_entersub + 897
10 libperl.dylib 0x96fb8277 Perl_runops_standard + 19
11 libperl.dylib 0x96f4b5d8 perl_run + 724
12 perl 0x000020d2 0x1000 + 4306
13 perl 0x00001f92 0x1000 + 3986
14 perl 0x00001eb9 0x1000 + 3769

For some reason, after a random amount of time, the dispatch thread dies because it attempts to access bad memory. I’ve run ktrace and kdump to see if I could figure it out and it *looks* like it might be a file descriptor problem, however, I can’t figure out why. You shouldn’t run into the problem unless you run the program with a high thread count and a small min/max time (which you’re welcome to do, if you are masochistic).

Anyone out there that’s better at perl than I am, do you know what could be causing this problem? Send me an email or leave a comment!

Short link

October 15, 2007

One more quick thing:

To any hardcore SysAdmin web developers out there looking for some awesome hosting, check out http://www.slicehost.com. They do Xen-based hosting where you can buy a slice and pretty much do whatever you want to do on it (including doing the OS install, etc, all the nitty-gritty stuff). Definitely not for the beginner, but if you demand total control over your hosting machine and want some awesome packages without signing a ridiculous contract, check them out.

The fact they hang out on IRC is even more awesome. These are the kinds of people that should be in the business.

An update on the Sun Blade 150

October 15, 2007

Well, I finally got around to finishing doing all the installs and setup on the Blade 150 I had laying around. In the end, since it only had 1gb of RAM and only 1 600 Mhz UltraSPARC II processor, I decided to go with FreeBSD instead of Solaris.

Initially, Solaris worked great serving up a webpage, however, the fact that I did a whole install and the fact that solaris is not exactly speedy on older hardware made working with it a little painful. If unattended, the next time I accessed the machine it would take a few seconds to spin up before allowing a login or serving a webpage. The fact that I left mostly all of the daemons running didn’t help. Yea, I know I could have disabled them all, I just like started clean rather than having to clean up.

Enter FreeBSD. I decided to stay away from Linux also, short of a Gentoo install (which would be painfully slow to compile everything), it’s an extremely easy way to get a minimal install with the smallest amount of effort. That and I enjoy using different things, time to brush up on the BSD knowledge since it’s been a couple of years since I’ve used it. Anyhow, now the machine is running FreeBSD 6.2-RELEASE with a pretty vanilla install. I set up Lighttpd, MySQL, PHP for a web service so I can teach Delilah PHP one of these days. I also set up ajaxterm so I can access a command-line from places where SSH is blocked completely *cough*work*cough* in the event of an emergency.

Overall, I’m liking it more than Solaris, it’s certainly a lot more snappy and much easier to get all the things I want using ports than trying to mess with doing a build from source on Solaris.

You can check out my extremely weaksauce main page here:

http://navi.eight7.org

Anyone have any suggestions for what else I should use it for? Let me know in the comments!

How I do GTD

September 18, 2007

Well, thought I’d take a little break from technical discussions to describe how I handle the “GTD” mentality that seems to be so popular in many many blogs these days. In case you are unfamiliar with GTD, you can read the encyclopedic definition of it from wikipedia or take a look at some of the articles that lifehacker has under the GTD label.

For simplicity purposes, I don’t follow the stringent GTD process that the actual author of the book (David Allen) about it explains, his way is waaay more complex than I currently need, I’m not some crazy CEO that gets >300 emails a day.I tend to get anywhere between 30-70 emails a day regarding work and anywhere between 5-40 emails a day from personal/mailinglist traffic. I just figured that I’d outline how I handle all my todo and work items.

Let’s start with the requests that we get, we use a ticket tool called Mantis to manage our system administration bugs. Requests come in and are sent to us (Myself and Bar-El) via email, we can also browse our tickets from the Mantis web interface which normally looks something like this (click for larger picture):

Mantis

I have the Mantis emails filter into a separate mail folder (more on email later) so they don’t clutter up my inbox. Using this interface, I normally add the TODO items to my handy-dandy Moleskine notebook. I use a todo setup that I found on a persons blog (sorry person, I can’t remember who you are!) That involves the following:

– New items come in with a “-” to the left of them, this means a task to be done
– When I am done with a task, I cross the – with a vertical line, to make it a “+
– If an item is no longer needed or needs to be deleted from the list, I add a couple of lines to make it a “*
– If an item is deferred for a different person to handle it, it is preceded by a “<“, making it looks like “<-
– If an item has been moved on the list to perhaps a different list (or a different page), I circle the -

Here’s a couple of pictures of what my notebook normally looks like:

moleskine2

moleskine1

I use the Moleskine from the front for only todo items. Then, when I need to note something or jot down a phone number or other notes, I flip the entire moleskine upside down so that I am essentially writing backwards (and upside down so it’s still left-to-right like a regular book) for notes, I feel this makes a nice balance between todo and notes without getting the two mixed up. When the two sides eventually meet, it’s time to buy a new one.

I normally write in pen using my (sweet) $5 copy of a $200 mont-blanc pen made using these instructions. I really like the way this pen writes, very smooth and easy to write with, not that I would actually pay $200 for one, but I’d definitely pay $5 for one. Highly recommended!

So that’s how I handle our daily requests that come in through Mantis, next, I’ll talk a little bit about how I handle email and requests from different accounts using Mutt.

First, let me starting with a screenshot showing how my email is laid out (makes it easier to talk about) (click for larger picture):

GTDDesktop

I am using Mutt 1.5.16 with the sidebar patch to show mailboxes on the left-hand side. I fetch mail every 3 minutes using fetchmail, process it with procmail to separate it into separate mailboxes, I then use msmtp to send email out. I have different scripts to change mail fetch and smtp preferences based on whether I am at work or at home (gmail pop3 and smtp are blocked at work, and I can’t access work email from home). I also have fetchmail hooked up to Growl so that I receive updates when new mail arrives. If you are interested in setting up Mutt/Fetchmail/etc, I highly recommend checking out Vincent Danen’s excellent “Using Mutt on OS X” article (even if you don’t use OSX it’s extremely useful).

Anyhow, back to GTD, email comes in, is either dealt with immediately, or pushed to the “ACTION” box (which has 0 messages in the screenshot). Gmail comes into Inbox, Work email goes into EMC, Mantis tickets go into mantis, all my old CU email goes into CU, everything from the securityfocus mailing lists goes into securityfocus, keys for some software go into key and spam goes into Spam. mairix-search contains the latest search results from mairix (a mail searching program that can be integrated into Mutt). Additionally, I keep archives of all sent mail, but you can’t see that on this screen.

I have attachments setup through the ~/.mailcap file that automatically open attachments with the right application, in this case, I open all of Microsoft Outlook’s .ics files with iCal, essentially tying in with the calendar system that EMC uses. Here’s a screenshot of what my iCal looks like (very sparse, I don’t have too many meetings on there right now):

ical

I set it up to alert me 5 minutes before a meeting (normally all I need) and I typically don’t use it for much else.

That pretty much finishes up how I use email and a moleskine for my daily GTD. Hopefully you found it not too terribly boring.

And to anyone that reads this, how do you organize your daily tasks and email? I’m always looking for ways to improve mine, let me know in the comments!

Questions? Feel free to email me (see bar on the right) :)

Sun rebrands itself as Java…

August 27, 2007

…at least, that’s what Jonathan makes it sound like in his post here. Looks like Sun is going to be changing its stock symbol from SUNW to JAVA in an effort to appeal to people who don’t know what “SUN” is about, but have heard about “Java” in all their daily use.

While I agree with the fact that many many more people have heard of the “Java” brand on just about every technical device made, those people are also not exactly the kind of people who I would imagine spending their money buying stock in a large computer corporation. Yes, you might appeal to the 14 year old with the cell phone because he/she knows that Java is what runs the games on his/her phone, but will that same 14 year old actually be purchasing stock in Sun?

Another thing that worries me slightly about this change is the face that Sun is presenting to its corporate and business clients, it sort of seems like they are shifting their complete focus into the Java/software industry, and perhaps diminishing their focus on Solaris and hardware (I know this isn’t true, but for someone who doesn’t keep up with the company, it could seem that way).

I really hope for the best for Sun in this case, it would be nice if their stock price tripled and they gained more market share, maybe then more people would switch to Solaris :D. As more me though, I think this is more of a marketing gimmick than anything else (but hey, companies have to market, right?).

What do you think of the ticker change, is Sun changing their priorities and direction, or are they just making an attempt to grab media attention?

[edit]: Hahahaha…reading the comments, I would have to agree with some of the commenters about what most people first think of when they hear Java: It’s Slow.

How to compile ettercap NG 0.7.3 on Mac OSX when you get that annoying pthread error

August 10, 2007

[Update]: If you’re trying to compile Ettercap on Leopard, check here.

I’ve been trying to get this compiled for 2 days now, finally found out how to do it. Figured I’d share for everyone else.

If you try this without making the change to the configure file it will complain about you not having support for pthreads, so here’s what you do:

Open the configure script, search for the line that say something like "$OS" != "MACOSX", you need to change this line to say "$OS" != "DARWIN", voila!
./configure && make && make install away! Enjoy ettercap!

Now if I could only get dsniff working as well… :-/

Enabling IPv6 on Cisco 3750 and Solaris/Linux/Windows

July 30, 2007

Alright, lately one of my goals for this quarter is to get our lab working over IPv6 in addition to IPv4 for testing some of our software. Here’s a quick rundown on how to enable ipv6 on *most* cisco switches and Solaris, Linux and Windows.

Enable IPv6 on *most* Cisco switches (I used a 3750):
1. Telnet to the switch
2. Use “enable” to escalate privledges
3. configure terminal
4. sdm prefer dual-ipv4-and-ipv6 routing
5. end
6. reload (this will reboot the switch)

If you need to make sure it’s set correctly, telnet into the switch, enable and then run “show sdm prefer” and verify that it’s running ipv4-and-ipv6.

Enabling IPv6 on Solaris:
1. touch /etc/hostname6.<interfacename>
<interfacename> is the name of the hardware interface, something like ce0 or e1000g0, etc.

Enabling IPv6 on RedHat Linux
1. system-config-network, select the interface, edit the properties and check the box that says “Enable IPv6 on this interface”

Enabling IPv6 on Windows
1. ipv6 install at a command prompt.

You can test it using ping on Solaris and ping6 on Linux and Windows. Good luck!

Recent home project: ZFS NAS server

July 2, 2007

I apologize for not posting for the last week, it was a very hectic week for myself because of a certain request for a Solaris 9 machine with tape that took the greater part of a week to get working properly. All I have to say about that is that I much prefer Solaris 10 over Solaris 9.

Anyhow, on to the project. Lately I’ve been working on an old Blade 150 that I have at home trying to get it to recognize the IDE controller card and old hard drives attached. Below you can see a picture of what I’m working with:

Blade 150

I have an UltraSPARC II processor in there running at 650Mhz as well as a gig of RAM (hopefully enough for my purposes). I found an extremely old IDE RAID controller card, switched it to JBOD mode and stuck it connected to 2 spare hard drives. At this time the hard drives are each only 40GB and I haven’t figured out a way for them to stay in the case (not enough space in there). I ran the IDE cables through the PCI slot opening and set the drives on top.

One of the problems I ran into was powering the hard drives, in this case the 150 didn’t have enough spare power hookups for 2 additional drives (in addition to the one inside the machine for the OS), so I ended up gutting another machine of mine for the power supply to power only the hard drives. Slightly out of the picture on the left the power supply is sitting with a paper-clip jammed into the motherboard connector to manually switch it to “always on”. Not a very elegant solution, but for the time being it works. Hopefully I’ll be getting a case for the hard drives and additional power supply so it doesn’t look nearly as ugly.

Anyhow, after installing OpenSolaris build 65, the machine booted up and was able to see the additional 2 hard drives, but panicked and rebooted when I actually selected them, upon rebooting they acted alright. I proceeded to create a mirrored zpool in case of drive failure. At this point it’s only 40GB, but I plan on getting some 300-500 GB drives for the data. Eventually I want this to be shared across the network for Delilah and I to store our important documents on (and it will be backed up also). Definitely a very cheap solution for our simple home.

Does anyone out there have a home server running Solaris? What do you use it for? How does it work out?

Thanks to my beautiful wife Delilah for taking the picture while I was at work!

 
Powered by Wordpress and MySQL. Theme by Shlomi Noach, openark.org