February 24, 2009
The cord for PowerEdge 6650, Proliant DL580 G2, and other high powered devies.
Almost all servers, desktops, UPSs, and other computing hardware uses an IEC C14 socket (which mates with an IEC C13 plug) (like the ones below).
Larger devices which draw more current, however, use a C20 socket (and C19 plug). They look like an angry slit-eyed C19 plug, they’re also square (see below).
Almost certainly, you’re now thinking the hardware manufacturer hates you. If this is used equipment, the cord is never included, and if it’s new equipment, the cord is usually a C20 to C19 cord - and you likely don’t have a C20 outlet handy.
- If you do have C20 outlets in your PDU or UPS available, you want a (or more likely two) C20 to C19 cord(s) like the one below.
- If you don’t have a C20 outlet available, and your equipment draws less than 15 amps, you likely want either a NEMA 5-15P to C19 or C14 to C19 cord
- If you’re crazy, you can swap out the C20 for C14 sockets. They generally have the same tooling. This is of course wildly out of spec.
- If you’re equipment draws more than 15 amps, and you don’t have C20 outlets handy, you likely want some form of ‘twist-lock’ style NEMA plug (like an L5 or L6 or maybe, but not likely, an L7) to C19 cord.
- If you’re equipment draws more than 15 amps, and you don’t have C20 outlets, and you don’t have NEMA ‘twist-lock’ outlets, then you maybe want a NEMA 5-20R or TT-30 to C19 cord.
- Finally, if you’re equipment draws more than 15 amps, and you don’t have C20 outlets, and you don’t have NEMA ‘twist-lock’ outlets, and you don’t have either of the (barely) normal non-locking NEMA connectors, you likely need an electrician. Either you have odd high-amperage outlets and need new outlets or an adapter or you have no high-amperage outlets and you either need new outlets or a new circuit.
Posted by spiffed at 12:14 AM | Comments (0)
February 17, 2009
Fixing bad MSS discovery across iptables based firewalls
If you have an
iptables
based firewall with differing MTUs on it's public and private interfaces, you may need to useiptables
TCPMSS
target to force proper MSS discovery.Continue reading "Fixing bad MSS discovery across iptables based firewalls"
Posted by spiffed at 9:16 PM | Comments (0)
February 10, 2009
Use molly-guard and stop rebooting the wrong server
Molly-guard is the unix admin analog to Gmail's .
Named after the physical molly-guard, the molly-guard command wraps various commands (by default the halt/reboot/shutdown/poweroff group) and performs various actions before calling them (by default, asking you which host this is). It's a life saver when you've nearly powered down the production database server in a $250/incident datacenter 2000km away thinking it was the print server in the other room.
Continue reading "Use molly-guard and stop rebooting the wrong server"
Posted by spiffed at 11:28 PM
August 25, 2008
Removing EXIF data with find and jhead
Let’s imagine you’ve got a load of pictures on a *nix box somewhere, and you’d prefer they didn’t have EXIF data attached? You’d need a way to find all the jpeg files and a way to strip their EXIF data. Thankfully, both tasks are easily solved, one with find and one with jhead.
Using jhead
A look at the jhead page shows the
--purejpg
argument will strip any EXIF data.Building the find query
We need to find files who’s name ends in
.jpg
,.jpeg
,.JPG
, or.JPEG
in a given directory tree. A quick look at the shows us the-iregex
parameter accepts a case insensitive regexp..*\.jpe?g$
looks for the following parameters:.*
- any number of characters.jp
- the literal characters.
j
andp
e?
- one or noe
characters.g
- a litteralg
character$
- and these must all be at the very end of the string
The parameter
-exec
will execute a command on any matching files, substituting the actual filename for{}
, and we must end the command with a;
.The final command
find . -iregex '.*\.jpe?g$' -exec jhead -purejpg '{}' \;
This will find any file with a .jpg or .jpeg extension (in any case) in the current directory (recursively) and strip it’s exif data.
One step further
Maybe you didn’t name all your JPEG files
something.jpg
. Maybe you named them foo_picture; how ever will you find them? Enter the unix ‘file’ command, it reads a files contents and looks for keys to it’s file type. We’ll use it here to build a command that searches the tree looking for files that look like binary jpeg files.find . -type f -exec file -i -F \0 '{}' \;
- Find actual files (-type f
) and execute the file command on them, but set file to seperate it’s data with NULLs (since you’re unlikely to have a NULL in your filename) and output the results as a mime type (because it’s easier to parse later).awk -F\0 '$2 == " image/jpeg" {printf "%s\0",$1}'
- use awk to check the type feild for the jpeg mime type, then only print the file path (followed by a NULL).xargs -0 -n 1 jhead -purejpg
- use xargs to split the input on NULLs and feed one path at a time to the jhead command.
Putting it all togeather, we get
find . -type f -exec file -i -F \0 '{}' \;|awk -F\0 '$2 == " image/jpeg" {printf "%s\0",$1}'|xargs -0 -n 1 jhead -purejpg
This is, of course, much slower than the pattern matching find command above.
time find ./public_html/ -type f -exec file -i -F \0 '{}' \; \ |awk -F\0 '$2 == " image/jpeg" {printf "%s\0",$1}'|xargs -0 -n 1 jhead -purejpg real 0m21.299s user 0m4.214s sys 0m16.290s time find ./public_html/ -iregex '.*\.jpe?g$' -exec jhead -purejpg '{}' \; real 0m7.819s user 0m0.548s sys 0m2.565s
And that’s after the entire directory tree has been pulled into memory cache!
Posted by spiffed at 2:33 PM | Comments (1)
August 20, 2008
Unfreezing Screen
I’m sure many people have done this: typed a command, then realized they’ll need root, so they hit ctrl-a for the beginning of the line, then started typing sudo. And this works wonderfully, unless your in a screen session, in which case it locks up completely.
From the screen manpage we see that ctrl-a puts screen into command mode, and the s of sudo sends an ‘xoff’ to the terminal.
What does xoff do? It’s a control signal in xon/xoff handshaking that says ‘stop sending data to me’, so the machine stops sending your terminal data.
To get your screen session back, send ctrl-a then q. This sends the matching xon. Xon ofcourse says ‘go ahead, send data, I’m ready’.
To avoid the issue in the first place, use ctrl-a followed by a to jump to the beginning of the line.
Posted by spiffed at 10:57 AM | Comments (0)
March 25, 2008
Printing Canada Post CN22 Labels
If you do alot of cross-border shipping, you no doubt have a whack of CN22 customs forms to fill-out everyday. This template should make your life just a little easier.
Continue reading "Printing Canada Post CN22 Labels"
Posted by spiffed at 2:27 PM | Comments (2)