Wednesday, 12 March 2014

Amazon EC2 experiences

Recently I was reading about Arscoins and the usage they made of the free Amazon EC micro instances. Intrigues I decided to take a look.

Amazon have a free tier of services. Minimal devices with enough hours to run all month. I chose an Ubuntu Linux instance and after running through a simple sign up had an instance ready to go. Using shared keys I could ssh to it (the only way to go) and I had set firewall rules so that only a couple of static addresses could get to it. Amazing! It was all up and going in about 15 minutes. Only a barebones server of course but enough for testing and the obligatory oooh from my co-workers.

The instance is free for 12 months and I've set alarms so that in the case of exceeding usage I will be notified of any billing. They also offer Windows servers too and a variety of different operating systems. For the minimal amount of time involved it was a great experience. I strongly recommend treating the instance like a server and keeping it updated and secured.

Saturday, 8 March 2014

Hubsan X4 H107C 2.4GHz Quad Copter Adventures

Recently I acquired from eBay one of these:


It's a little tiny quadcopter! I first became interested, not so much in RC, but in quads after watching the TEDTalk by Raffaello D'Andrea - The astounding athletic power of quadcopters. I found this amazing and further found it amazing watching this from TEDTalks by Andreas Raptopoulos: No roads? There's a drone for that. These devices are pretty awesome and could revolutionise the way we do so many things - from deliveries to rescue, precision work in the air, even video recording at the Winter Olympics!

Given the X4's small size I've been constantly surprised by it's speed and stability - even under fairly strong wind conditions. Throughout our house we have ducted air and when the A/C is up high the breeze is really quite strong. The X4 handles it quite well - I never use more that 60% of power to push against the air currents and can keep it fairly steady. Comparatively my much larger RC helicopters struggle mightily and frequently can do no more than skim along the floor.

Bravely (I thought) I took my little X4 out yesterday afternoon. Our small yard is quite sheltered, but the breeze we do get swirls through the area, generating all kinds of random currents and eddies. It's amazing how much the quad gets pushed around. Getting used to the control surface is taking a while - it's easy to overcompensate for a swirl in the air, getting myself into more trouble and then desperately trying to recover from that before crashing. The X4 is incredibly agile, far more so than the other RC helicopters I have, and also far more stable.

Long story short, being the brave adventurer I am, I rocketed the throttle to 100 and watched my little X4 zoom up into the sky. Immediately it became apparent the wind was much stronger up there. Uh oh - tree, oh no - roof, arrgh! - tree again - each time these hazards came up I was able to "gracefully" recover and not hit anything. I always forget though to increase power when manoeuvring. The quad tends to drop a bit when you execute movements - the more extreme the movement, the more it impacts on your altitude. As the X4 soared over the roof of the house I momentarily forgot this: tried to reverse, lost altitude, tapped the roof with the front rotors, flipped and that was that.

Getting it off the roof was a real chore and the blades of the rotors were quite badly damaged. Luckily the X4 comes with spare blades - interesting they are labelled A and B. If you put them on the wrong pylon the thing won't take off. As you can see in the first TED talk above, you can cut the blades off and it will still fly. Get the wrong blades on the wrong rotors though and its not going to get off the ground.

The X4 was about $80 AUD ($20 + postage) from Hong Kong. I've already ordered more blades, new plastic protective ring (for flying indoors) and larger capacity batteries. I get about 6-7 minutes flying time and then it's a 40 minute charge on USB. This particular model has a 0.3 megapixel camera built in to it too. Camera on/off doesn't seem to knock the battery around too much, and the footage is OK. When I eventually take some footage that doesn't cause motion sickness I'll post it.

The packaging says this isn't a toy and it really isn't. You've got to really pay attention to it and fly with some care to avoid crashing and damaging it or other things. I accidentally ran it into myself and have two 3cm superficial scratches that bled!

There are quite a few videos on YouTube of this quadcopter available. Some of them are very nice. I'm looking forward to flying mine in a large open area and seeing how it goes. I've included the specs from the manufacturer Hubsan below:

Hubsan X4 H107C Quadcopter


Item No.H107C
Item Name:The Hubsan X4
barcode:6922572400030(EAN-13)
Motor (x4): Coreless Motor
Frequency: 2.4GHz
With 4 channels
Battery: 3.7V 380mAh
Flight time: around 7 minutes
Charging time:40 minutes
Latest 6-axis flight control system with adjustable gyro sensitivity
Permits super stable flight
Lightweight airframe with nice durability
4-ways flip(left,right,forward,backward)
USB charging cable allows to charge by computer.
Flying outdoor ability
Transmitter: 2.4Ghz 4 channels
Camera: 0.3 MP
Video recording module included
memory card:Micro SDHC(excluded)

Friday, 7 March 2014

Using Nagios and SNMP to monitor network devices

Usage:
check_snmp 
-H <ip_address>
-o <OID>
[-w warn_range]
[-c crit_range]
[-C community]
[-s string]
[-r regex]
[-R regexi]
[-t timeout]
[-e retries]
[-l label]
[-u units]
[-p port-number]
[-d delimiter]
[-D output-delimiter]
[-m miblist]
[-P snmp version]
[-L seclevel]
[-U secname]
[-a authproto]
[-A authpasswd]
[-x privproto]
[-X privpasswd]

Note:

the -c and -w (critical and warning ranges respectively) reflect ranges differently depending on if you want a critical to be low (under 10 for example) or high (over 90). In the former case, say the Signal Level of a microwave device you are monitoring is critical when under 10% and warning under 20% then the format of the -w and -c would be:

            -w 25: -c 10:

If on the other hand you are looking at Signal to Noise ratio where warning is 50 dB and critical is 75 dB then the command would be:

            -w :50 -c :75

If you have say a table where numbers translate to other things, again using a Microwave example:

wvSubDataRate  OBJECT-TYPE
               SYNTAX      INTEGER {
                              rf-bw-1p5-Mbps(1),
                                                          rf-bw-2p25-Mbps(2),
                                                          rf-bw-3-Mbps(3),
                                                          rf-bw-4p5-Mbps(4),
                                      rf-bw-6-Mbps(5),
                                      rf-bw-9-Mbps(6),
                                      rf-bw-12-Mbps(7),
                                                          rf-bw-13p5-Mbps(8),
                                      rf-bw-18-Mbps(9),
                                      rf-bw-24-Mbps(10),
                                                          rf-bw-27-Mbps(11),
                                      rf-bw-36-Mbps(12),
                                      rf-bw-48-Mbps(13),
                                      rf-bw-54-Mbps(14),
                                      rf-bw-72-Mbps(15),
                                      rf-bw-96-Mbps(16),
                                      rf-bw-108-Mbps(17)
                           }
               MAX-ACCESS  read-only
               STATUS      current
               DESCRIPTION
                    "The data rate of the station."
               ::= { wvSubStatusEntry 4 }            
and you'd like to have the actual data rate instead of the number then you need to tell it what MIB to use by putting the -m switch at the end e.g.

-m MWAVE-MIB and it will translate the output (typically just a number like "15 = rf-bw-72-Mbps) - giving you meaningful output.

That's it for now but more to follow as I keep working with this type of hardware.


How to fix Nagios3 external commands error

After installing nagios3 and trying to send it a command to reschedule a check or do some other external activity you may get the following error:

Error: Could not stat() command file '/var/lib/nagios3/rw/nagios.cmd'!
The external command file may be missing, Nagios may not be running, and/or Nagios may not be checking external commands.
An error occurred while attempting to commit your command for processing.
In order to fix it, do the following actions:

Check that /etc/nagios3/nagios.cfg has:

check_external_commands=1

Also check that

command_check_interval=15s is uncommented and
command_check_interval=-1 is commented like this:
command_check_interval=15s
#command_check_interval=-1
Check the path for command_file is OK. It usually looks like this:
command_file=/var/lib/nagios3/rw/nagios.cmd
Make sure that the user www-data is part of the nagios group - this is located in /etc/group

Check permissions on the command file that we looked at above:
# ls -l /var/lib/nagios3/rw/nagios.cmd
prw-rw---- 1 nagios nagios 0 Mar  7 11:56 /var/lib/nagios3/rw/nagios.cmd
If it looks like this, we're good.

The next thing to check is that the directory that nagios.cmd resides in has executable rights for the nagios group:
# ls -l /var/lib/nagios3/
total 180
-rw------- 1 nagios www-data 176049 Mar  7 11:58 retention.dat
drwx------ 2 nagios www-data   4096 Mar  7 11:56 rw
drwxr-x--- 3 nagios nagios     4096 Jun 14  2013 spool
Uh oh - rw has no group rights! Fix it with this command:

# chmod g+x /var/lib/nagios3/rw
and then
# service nagios3 restart
And the crowd goes wild!