Death and Taxes

25 Jan

This is a comment I posted on Paul Gregory’s Forbes post about Mr. Buffet’s Secretary’s salary– saying that for her to be paying less than him (assuming a 15% rate) then she’d have to be making over $200k, meaning she’s not such a poster child for injustice after all. (I guess God only has pity for those making more or less than $200-500k?)

There is some confusion as to whether you’re talking about percentage of AGI, how much Mr. Buffet actually pays, whether to include other taxes besides Federal payroll tax, etc. My comment speaks to that and to what I believe most Americans feel is fair.

Paul, when I put my modest salary into TurboTax’s free tax calculator (I have no special situations or deductions, just a single guy) it comes back with me owing 16% to the Federal Government. That doesn’t include state tax, social security, 401k, insurance, or any of the other things that come out of my paycheck, which when added up come closer to 30%.

Americans have always wanted a sense of basic fairness, the no-nonsense end-of-the-day gut check. If the government takes less than about 30% of Mr. Buffet or Mr. Romney’s “paycheck” every month, that offends a basic sense of decency.

I’m a hardworking guy who manages the occasional roadtrip or vacation, and I’m way luckier than most. But I always tip 20%, and although taxes are a bastard, I’d gladly pay more tax if that meant less tax for those struggling to put food on the table.

10% more on my taxes means maybe I vacation in Hawaii instead of Japan. 10% more on my employee’s means the difference between buying a house versus renting, or buying a car versus keeping his clunker running, and again– he’s got it better than most. That a multi-millionaire couldn’t afford a 10% tax increase strikes me as ludicrous, because I CAN.

Footnote: it’s entirely likely that everyone who makes more than me pays a higher percentage in taxes than me. If so, then that’s fine. But if not, if there are huge loopholes and tax shelters and special treatment for people who can afford to live much nicer than me, then again that offends a basic sense of decency.

Nagios Notification Customizations

24 Jan

Getting notified by SMS is better than via email, I think, because then you can tell the difference between midnight spam and a server fire. Here’s my command for sending a shortened message (to #yournumber#@YourCarrierSMSGateway.com)

Add these to your commands.cfg and then change your contact settings (usually contacts_nagios2.cfg) to use the appropriate command.


define command{
command_name notify-service-by-sms
command_line /usr/bin/printf "%b" "$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ ($SERVICEOUTPUT$)." | /usr/bin/mail -s "$NOTIFICATIONTYPE$" $CONTACTEMAIL$
}

define command{
command_name notify-host-by-sms
command_line /usr/bin/printf "%b" "$HOSTALIAS$ is $HOSTSTATE$ ($HOSTOUTPUT$)." | /usr/bin/mail -s "$NOTIFICATIONTYPE$" $CONTACTEMAIL$
}

See my earlier Nagios Setup post

Whiteline iconset for Nagios – 40px

24 Jan

I like the Whiteline icon set for Nagios’ statusmap cgi, but it’s too big; here it is resized to 40px wide and I added an Ubuntu icon as well.

Download: whiteline.zip

See my earlier Nagios post

RFID Interlock (Web enabled)

12 Jan

Sometimes padlocks, zip ties, sternly-worded signs and keyed ignitions just don’t cut it. Maybe what you’re looking for is something more like…

…a web-enabled RFID interlock loosely based on 23b’s Open Access Control system?

Indeed! This is a horrible photo, but inside the lovingly-crafted cardboard box is a custom-made Arduino shield, an Arduino Ethernet, some wiring, and then the visible RFID reader, buttons, and LEDs. Also there’s a piezo speaker in there.

Off to the side is a relay board with a transistor and 120V 10A relay that switches stuff off and on to its heart’s content.

Its purpose? To get spliced in between the critical wiring of whatever you want to control, and then you can control its usage via a separate web server and database.

For example, effective parent control over an Xbox; keeping noobs out of the pantry; making sure only certified people use the laser cutter; having the coolest high-tech bouncer for your party ever, etc.

 

For code, schematics and circuitry, check out https://github.com/zyphlar/open-access-control-minimal-http
WARNING, there is an error in the circuitry here. One of the pins from the shift register isn’t going to the LCD screen as intended.
The webserver component isn’t uploaded yet either; the interface simply relies on  a webserver (in the code at http://10.1.1.1/~access/access?id=YOURID&device=THISDEVICE ) which returns ^username|OK$ when YOURID is a valid ID for accessing THISDEVICE. The username is then displayed on the LCD.

The code is also useful for its Wiegand26 Arduino library, which lets you use any Wiegand-compatible RFID readers/keypads desired.

Here are some photos:

Old version of the Eagle board layout for the shield

Prototyping the shield on our laser; didn't work out.

Shield fabricated by Seeed

Prototyping the relay board on the laser; worked well!

Selecting relays to use

Assembled relay board

Assembled shield

Assembled shield and Arduino Ethernet

Laser-Cut Custom-Fabric Dress Shirt

13 Dec

The Minecraft release party, MineCon, was this year in Las Vegas. In a flash of inspiration, I knew I’d found my first cosplay opportunity. Most people would wear cardboard boxes, which isn’t very Vegas. What Minecraft-themed costume would fit Vegas, aside from old people in sweatpants gambling their retirement checks away? A suit, of course! With a Notch-inspired Fedora, and Creeper-print fabric to tie it back to Minecraft. Hours of sewing later, I’m the proud owner of a Creeper shirt (and fedora.)

Turns out there’s a website that will print on fabric any image you upload to them, so I grabbed the Creeper texture straight out of the videogame, blew it up, and uploaded it to SpoonFlower.com (click for texture) — there was a slight tiling issue in the version I printed, causing a white line to appear every few feet, but otherwise came out quite well! The fabric is somewhat expensive, but then again considering there’s no minimum quantity I still consider Spoonflower a great deal. Plus, what’s the alternative? Hand-painting fabric isn’t my idea of a fun time.

The shirt pattern was based on existing shirt I had, tore apart, scanned using a large copier, and traced in Inkscape. Saved it into a DXF file format and used HeatSync‘s laser to cut the fabric. Finally, I uploaded the shirt design to Thingiverse (click for DXF design files & instructions). I’m pretty sure it’s the first free dress shirt pattern available online, especially in DXF format.

Finally, I sewed it using normal sewing machine techniques (see Thingiverse for sewing instructions.)

What can you make?

Arduino Nagios Display (aka LED Whiteboard)

12 Dec

The movie ‘Hackers’ came out in 1995, when I was still in elementary school. So by the time I grew up and watched it (along with the Matrix and Tron) I knew that the kinds of computer visualization depicted in those movies was something I wanted. I’m a very visual person (and I think computers are generally way more cerebral than visual) so I’ve always wanted a more visual, physical representation of computer systems. Imagine if we had a tricorder or sick bay analyzer that could show you every little invisible detail of complex systems like the environment, human bodies, or networks? This is one small step towards that.

Rather than simply get email alerts and have a website you can visit to get status information, why not some kind of persistent, physical display that was available to see whether you intended to see it or not? Like a clock, thermometer, or smoke detector, always on with little or no effort required to maintain it. Computer screens kinda work, but in practice break way too often and waste tons of energy.

So enter the Arduino Nagios display, or as I was calling it, my LED status whiteboard. On the outside, it’s a 5×8 LED grid poked into a foamcore board and mounted inside of a glass box painted white on the backside. So the LEDs shine through what’s effectively a glass whiteboard. The idea being that you can then have it output basic status info on whatever you want, and annotate/draw on it how you like, and it’s just there 24/7 being constantly updated automatically.

In the guts, the Arduino updates the grid with 5 daisy chained shift registers (8-bit) which are super cheap. This way the Arduino doesn’t need 40 data pins. The wiring is still a mess, but hey someone would still have to solder them all up, why not do it quick n dirty? The Arduino itself runs a program I cobbled together by combining the Arduino ShiftOut example with the WiServer wifi shield example code. (I’m using an Arduino Diamondback, which is basically an Arduino with a built in wifi shield. You could use an Arduino Ethernet too, slightly cheaper.) The WiServer code queries my Nagios server for status info, which it returns in a condensed Arduino-friendly manner via a PHP script I also cobbled together. Then some code I wrote myself interprets the Nagios stuff into LED stuff (i.e. a 0 in Nagios should actually turn the LED on, and a 1 or 2 should turn the LED off, and you’ve gotta parse the string of numbers into a binary array.) It updates itself every 15 seconds or so.

The code is all on GitHub if you’d like to do something similar yourself (and who wouldn’t?)

And that’s really it! It sounds simple in retrospect, but if you’ve never done this before it can be quite a banging-head-against-desk experience finding the right examples and getting them to work together without ending up all crappy. So I’m quite proud of myself and hope to see more awesome persistent visualization stuff coming out in the future, hopefully hackable and not too expensive.

The whole thing cost under $100, considering the $73 Arduino Diamondback, 40 LEDs, glass and wood for the whiteboard, wire, and resistors. Not bad considering the cheapest computer you can get is still around $400, plus this is all nice and self contained and pretty looking.

What other displays could you create with just a network-connected Arduino?
Shout out to HeatSync Labs for being awesome and having the tools/expertise/space necessary to get this done without spending thousands of bucks at local hardware/electronics stores. You probably have a hackerspace near you; check it out!

Quick n Dirty Digital Signage – with Flickr!

17 Sep

People want lots of money these days for digital signage, but lots of it is mediocre at best and especially lacking in third-party data sources. How much money is it worth to edit HTML by hand? About the cost of decent digital signage software! So I made my own with pure Javascript and JQuery goodness:

The “sign” or iframe rotator which rotates through the below pages… sign.html:

The splash page with our logo and a welcome:

The slideshow, which uses JQuery and a jQuery Flickr plugin called jFlickrFeed:

The “ad” page that gives shoutouts to other points of interest nearby:

The code is very hackish but is designed to not rely heavily on stuff that might disappear or closed-source. If you want to change the sizes of anything, the type of flickr feed, etc, it should be relatively straightforward. Also since everything should get loaded in memory the first iteration, it shouldn’t die if the internet cuts out on you a day later. Tested in Chrome. You can (hopefully) see a working version at http://live.heatsynclabs.org/sign.html

Monitoring Remote Hosts with Nagios

13 Sep

So you’ve got Ubuntu 11.04 and think you’ll use Nagios and its fun plugin, NRPE, to monitor your cloud servers, right? Sure! There are some gotchas though. Note: You may want to check out check_mk instead of NRPE as it is reportedly sexier.

For readability I’ll start with the remote server. It doesn’t matter so much except that obviously the last command where you connect to the remote server won’t work until you’ve set up the remote server.

On the remote server:

apt-get install nagios-nrpe-server
vim /etc/nagios/nrpe.cfg

Edit the allowed_hosts line as follows, replacing 1.2.3.4 with your monitoring server’s IP. Be mindful of the lack of spaces:

allowed_hosts=127.0.0.1,1.2.3.4

Edit the command lines at the bottom:

command[check_hda1]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/hda1

You may want to change both instances of hda1 above to sda1 depending on your config. Run the df command to see your partitions.

service nagios-nrpe-server restart

On the monitoring server:

apt-get install nagios3

It’ll ask you to choose a password and email method. I chose Internet server for mail method and a random password.

vim /var/www/index.html

# You may want to clear out this file or change it to a more suitable index. Default splash pages annoy me.

cd /etc/nagios3/conf.d/
cp localhost_nagios2.cfg REMOTESERVER_nagios2.cfg

Replace REMOTESERVER with the remote server’s hostname.

vim REMOTESERVER_nagios2.cfg

REMOTESERVER_nagios2.cfg

define host{
use generic-host
host_name REMOTESERVER.EXAMPLE.COM ; Change to the remote server's hostname and domain name.
alias REMOTESERVER    ; Change to the remote server's hostname
address 5.6.7.8    ; Change to the remote server's IP address (WAN?)
}

define service{
use generic-service
host_name REMOTESERVER.EXAMPLE.COM ; Change to the remote server's hostname and domain name.
service_description Disk Space 1
check_command check_nrpe!check_sda1
}

define service{
use generic-service
host_name REMOTESERVER.EXAMPLE.COM    ; Change to the remote server's hostname and domain name.
service_description Current Users
check_command check_nrpe!check_users
}

define service{
use generic-service
host_name REMOTESERVER.EXAMPLE.COM    ; Change to the remote server's hostname and domain name.
service_description Total Processes
check_command check_nrpe!check_total_procs
}

define service{
use generic-service
host_name REMOTESERVER.EXAMPLE.COM    ; Change to the remote server's hostname and domain name.
service_description Current Load
check_command check_nrpe!check_load
}

#### End REMOTESERVER_nagios2.cfg

vim hostgroups_nagios2.cfg

hostgroups_nagios2.cfg

You likely have ssh running on your remote server, so go ahead and add it to the ssh-servers hostgroup. You can add it to others too.

define hostgroup {
hostgroup_name ssh-servers
alias SSH servers
members localhost, REMOTESERVER.EXAMPLE.COM    ; Change to the remote server's hostname and domain name, being careful to keep the space after the comma
}

#### End hostgroups_nagios2.cfg

service nagios3 restart

/usr/lib/nagios/plugins/check_nrpe -H REMOTESERVER.EXAMPLE.COM

Ideally it’ll respond with NRPE v2.12 or similar.

And you should be done!

Open http://MONITORINGSERVER.EXAMPLE.COM/nagios3 and login with the password you created when you installed Nagios, username is nagiosadmin.

There are a ton of customizations you can do, such as setting parents, customizing icons, installing pnp4nagios, and changing the notifications.

Cheap disk duplication using dd (actually dcfldd)

8 Sep

Why buy an expensive disk or flash drive duplicator when you can make one yourself with Linux for free or cheap?

Here are the cloning scripts you can use to copy a disk and then write it back to a large number of target disks. Modify the IMAGE.img and /dev/DEVICE as desired. It even beeps when it’s done! Make sure to mark the scripts as executable (chmod +x) so you can double click them, or run them by typing ./SCRIPT.sh in terminal.

Reading:

#!/bin/sh
echo "about to read from DEVICE to IMAGE.img -- READY?"
sudo dd if=/dev/DEVICE of=IMAGE.img bs=4096
echo -e "\a"
read -p "Done" nothing

Writing:

#!/bin/sh
echo "about to write from IMAGE.img to DEVICE,  DEVICE and DEVICE -- READY?"
sudo dcfldd if=IMAGE.img of=/dev/DEVICE of=/dev/DEVICE of=/dev/DEVICE bs=4096
echo -e "\a"
read -p "Done" nothing

 

Automated WinSCP file transfers

1 Sep

This is the line I put in a Scheduled Task to download a remote directory and save it locally. You should be able to use it in reverse to upload something.

"C:\Program Files\WinSCP\WinSCP.exe" /console /log=winscp.log /command "option batch on" "option confirm off" "open USERNAME:PASSWORD@EXAMPLE.com -hostkey=""ssh-rsa 2048 00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF"" " "get /home/backups/* c:\backups\*" "exit"

Separated for readability:

"C:\Program Files\WinSCP\WinSCP.exe"
/console
/log=winscp.log
/command "option batch on" "option confirm off"
"open USERNAME:PASSWORD@EXAMPLE.com -hostkey=""ssh-rsa 2048 00:11:...:EE:FF"" "
"get /home/backups/* c:\backups\*"
"exit"

Note that you must replace USERNAME, PASSWORD, EXAMPLE.com, and the host key of 00:11…EE:FF with real values.

You can get the host key by ssh-ing into EXAMPLE.com and noting the key fingerprint displayed the first time you’ve connected to it.
If you’ve already connected, it’s likely stored in *nix under ~/.ssh/known_hosts (delete its line to force it to show you the fingerprint upon next connect) or for Windows/PuTTY in the registry at HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\SshHostKeys