Wednesday, March 12, 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, March 8, 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, March 7, 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!

Wednesday, February 5, 2014

How to update a single XenServer 6.2 host before adding it to a pool


You may find yourself in the position where you need to add a machine into a pool, a new host that is, and it's patching is well behind. Thankfully there is a relatively straightforward way to do this.

  • You will need to have already downloaded and extracted the required files.
  • On a computer with XenCentre installed run the following commands (assuming default install and Windows 7 / 8)
    • Open a command prompt
      • Win+r, then type cmd (or go to Start -> Run -> cmd and return)
    • cd "C:\Program Files (x86)\Citrix\XenCenter"
    • From here run: xe patch-upload -s server-ip -u root -pw secret-password file-name=c:\username\Downloads\XS62ESP1\XS62ESP1.xupdate and hit return. Make sure the items in italics is replaced with your actual details.
  • Once this finished, you'll get a long string of characters appear and that's the patch UUID. Normally when updating a pool we make note of that, but I've found another way that works just as well.
  • Download puTTY - it's an awesome terminal program and you should have it.
  • Use puTTY to connect via SSH to your xenserver and get to the console. Alternatively, do this from the server console. At any rate, type the following commands and note the two UUID's they produce:
    • # xe patch-list
      • note the UUID of the patch
    • # xe host-list
      • note the UUID of the host
    • # xe patch-apply UUID=patchUUID host-uuid=hostUUID and hit return. Once all the information stops flowing past and you're back to a # prompt type:
    • # reboot
  • if you're using puTTY, you can select the UUID's, the simply right click where you want them to be and puTTY will paste them out of the buffer. Very quick to do, rather than laboriously typing it out.
Once the machine reboots, continue to patch as applicable, and then add it to the pool.

Happy XenServering!

XenServer 6.2 - installed on a USB drive and installed on an SD Card

In this post I want to talk about recent experiences I've had with XenServer 6.2 on USB drives and SD cards. In a particular situation, I was forced initially down this path due to specific hardware and lack of appropriate drives. The upshot is that it was entirely unsuccessful and here is why:

Firstly, it's important to be aware that XenServer isn't all that happy being installed on these devices. After you install, you must boot back up on the XenServer CD and then (using ALT-F2) drop to a command line. To get XenServer to boot on USB do the following:

  • From the command line do this: 
    • # cat /proc/partitions
      • this tells you what partitions there are that XenServer can see. Typically you will see /dev/sda and it's children - /dev/sda1, /dev/sda2 etc. We want /dev/sda1
    • # mkdir /target
      • create a temporary location so we can change our root directory
    • # mount -t ext3 /dev/sda1 /target
      • mount our existing /dev/sda1 partition to /target, giving us access to the files
    • # mount proc /target/proc -t proc
      • we need a proc filesystem!
    • # mount sysfs /target/sys -t sysfs
      • and a sysfs
    • # mount --bind /dev /target/dev
      • and of course somewhere for devices to be found
    • # chroot /target
      • change to the /target install of the system (chrooting means we are running now under the actual XenServer install, not the boot cd live filesystem)
    • # cd /boot
    • # ls –al
Now we need to actually tell the kernel of our installed XenServer to add USB support to it so it'll boot. Up until this point, the system will just hang, unable to find a filesystem.

  • # mv initrd-lots.of-numbersxen.img initrd-lots.of-numbersxen.img.old
    • this backs up the initrd ing
  • # mkinitrd --with-usb initrd-lots.of-numbersxen.img lots.of-numbersxen.img
    • make sure you replace lots.of-numbers with the actual kernel version. It could look like this: 2.6.18-53.1.13.el5.xs4.1.0.254.273
  • # exit
  • # sync
  • # reboot
At this stage we are finished and the server will reboot and actually get into XenServer. After patching the pool, or indeed, the server by itself, you may need to apply the initrd update again, but with the new kernel number.

While this was cumbersome to do, particularly because I had to do it six times - 3 for initial install, 3 again after SP1 was applied, it wasn't hard to do, or particularly time consuming. I found that I had to do this for both USB drives and on the SD Card. The SD Card was significantly slower than USB. The key difference between the two was that the USB, after some magical, indeterminate time, would lose it's filesystem! XenCenter would lose connectivity to it, and the console interface was non-functional - unable to find "root"! A reboot fixed this, but these are supposed to be on all the time with minimal service loss. That was when I turned to the SD Card idea. These servers had been running an awful install of VMware 4.1 on SD Cards so I thought they would just work. Sadly, it was not to be. Once again, I'd lose connectivity to the server, but this time, I was able to get the xsconsole to respond and reboot the machine. Totally unacceptable though. I don't have time to test with this system - it's supposed to be production! At any rate, I've purchased disks and installing them. If anyone has experienced this and knows the answer - I'd love to hear it!

Saturday, January 25, 2014

ShadowCraft ShadowProtect - Employee of the Month

The last two weeks have been absolutely awful. The IOmega NAS I mentioned in a previous post had a large number of things go wrong with it all at the same time, resulting in complete failure and total data loss. This also meant a significant amount of down time for a client and ridiculous amounts of stress for me.

The good thing to come out of it was the performance of ShadowProtect. This backup solution far exceeded my expectations to the point where once the recoveries were completed we had only lost 10 minutes of work. Very little data was realistically lost, only time as we worked to recover it. The Recovery Environment was easy to use and the Hardware Independent Restore allowed me to recover virtual machine from VMware 4 ESX to VMware Player, a physical machine and also to XenServer 6.2 quite a remarkable feat really. I've had this client running in borrowed hardware for a week while we get new gear in.

The snapshot capability, ease of restore and simply replication of backup files makes ShadowProtect a real winner. Check it out!