Workaround for Nagios check_disk failure in RHEL / CentOS 6.2

After updating from EL 6.1 to 6.2, the Nagios “check_disk” plugin suddenly stopped working with “Permission denied” errors. This problem is related to the SElinux policy (you *are* running with SElinux enabled, aren’t you?).

By default, these AVC denials are not logged in /var/log/audit/audit.log which makes this problem harder to spot (if you want, you can enable all audit-messages by running semodule -DB).

There are at least two relevant entries in Bugzilla:

  • Bug 771245 – nagios-plugins-disk fails when checking /boot on RHEL6.2 boxes
  • Bug 768055 – SELinux silent denials of Nagios NRPE check of /boot

Fortunately, there is a simple workaround while we wait for an updated selinux-policy package. As root, do the following:

chcon -t nagios_unconfined_plugin_exec_t /usr/lib64/nagios/plugins/check_disk

Or, for 32-bit systems:

chcon -t nagios_unconfined_plugin_exec_t /usr/lib/nagios/plugins/check_disk

No need to restart anything; just wait until Nagios re-checks the service and the problem should be gone. Enjoy!

Controlling the Foscam FI8919W IP Camera

Foscam FI8918W IP Camera, whiteThe Foscam FI8919W Pan-Tilt camera supports a number of preset locations, or Presets.

The onboard web interface does not seem to offer a way to configure these presets – but there is another way!

I have written a couple of small shell scripts (for Linux or Mac OS X) that allow you to set a preset, move to a preset and even take a snapshot right from the command line.

The first script stores the current camera position into the specified preset.

You need to open a web browser or camera app (my favorite: Live Cams Pro on iPad/iPhone) and set the camera position.

Then, run this script, specifying the preset number (for example, “foscam_set 0” to set the first preset):

#!/bin/bash
# Store current camera position in specified preset (0..16)

# Commandline handling
#
preset=$1
if [ -z $preset ];
then
    echo "Syntax: $0 <preset>, where preset is a number (0..16)"
    exit 1
fi

# Address (or address:port number) where to reach the camera
# Username / password to access camera functions
#
CAMERA=192.168.1.2
USERNAME=theUsername
PASSWORD=thePassword

# Presets are set using URL with command (30 + preset*2), and recalled using URL with command (31 + preset*2)
#
command=$((30 + 2*$preset))
echo "Storing current camera position in preset ${preset} (command = ${command})"
wget -O - http://${CAMERA}/decoder_control.cgi?command=${command}\&user=${USERNAME}\&pwd=${PASSWORD}

Next, a script to move the camera to a specified preset (for example, “foscam_go 3“:

#!/bin/bash
# Move camera to specified preset (0..16)

# Commandline handling
#
preset=$1
if [ -z $preset ];
then
    echo "Syntax: $0 <preset>, where preset is a number (0..16)"
    exit 1
fi

# Address (or address:port number) where to reach the camera
# Username / password to access camera functions
#
CAMERA=192.168.1.2
USERNAME=theUsername
PASSWORD=thePassword

# Presets are set using URL with command (30 + preset*2), and recalled using URL with command (31 + preset*2)
#
command=$((31 + 2*$preset))
echo "Moving camera to preset ${preset} (command = ${command})"
wget -O - http://${CAMERA}/decoder_control.cgi?command=${command}\&user=${USERNAME}\&pwd=${PASSWORD}

Finally, a demo script that moves the camera to a preset, takes a snapshot and stores it locally (based on a post by 1994MGoBlue):

#!/bin/bash
# Take snapshots of certain preset camera locations

# Address (or address:port number) where to reach the camera
# Username / password to access camera functions
#
CAMERA=192.168.1.2
USERNAME=theUsername
PASSWORD=thePassword

# The camera should normally be in this position
DEFAULT_PRESET=3

# Seconds to sleep after issuing a camera move command, allow it to reach new position.
# You may have to change this value to your needs
DELAY=10

# Presets are set using URL with command (30 + preset*2), and recalled using URL with command (31 + preset*2)
#
for preset in 0 1 2 3 4;
do
    command=$((31 + 2*$preset))
    echo "Taking snapshot in preset ${preset} (command = ${command})"

    # Move camera, delay, take snapshot (stored in /tmp/)
    wget -O - http://${CAMERA}/decoder_control.cgi?command=${command}\&user=${USERNAME}\&pwd=${PASSWORD}
    sleep ${DELAY}
    wget -O /tmp/preset-${preset}.jpg http://${CAMERA}/snapshot.cgi?user=${USERNAME}\&pwd=${PASSWORD}
done

# Done, send camera back to default position
command=$((31 + 2*$DEFAULT_PRESET))
wget -O - http://${CAMERA}/decoder_control.cgi?command=${command}\&user=${USERNAME}\&pwd=${PASSWORD}

Enjoy!

Assembling the JeeLabs OOK433 Plug, part 1

JeeLabs OOK433 PlugI got some KAKU (Klik Aan Klik Uit) switches to control lighting etc. These can be remote controlled using a JeeNode with the OOK433 Plug.

This plug contains a separate receiver and transmitter board. After consulting the schematic, it appears that the receiver is hooked up to the AIO pin, while the transmitter is connected to the DIO pin. This information is needed when reconfiguring the software for the actual Port socket you plugged the OOK433 into.

There are two solder jumpers that need to be made (marked in the picture on the right):

  • The upper one selects supply voltage. According to current documentation, the rightmost two pads need to be bridged, selecting +3V.
  • The lower solder jumper should always be bridged (except if a resistor R1 is to be installed)

Note that the Receiver and Transmitter modules have “+5V’ and “+12V” markings on them – apparently, they also work at this much lower voltage.

JeeLabs OOK433 Plug with HeaderAfter making these two solder jumpers, continue assembly. I soldered a 6-pin header (not included with the kit)  to the Port connector so I can plug it straight into a JeeNode.

The trick here is to apply some solder to one pad and one pin first. Then, hold the header in place while re-heating the solder on that pad. The remaining pads can now be soldered properly. The picture shows the solder jumpers I made, as well as the preparations for soldering the 6-pin header in place.

Make sure you get shiny solder joints that are properly heated (lead-free solder tends to shine a bit less than the 60/40 I use).

Next up: the transmitter module. Note that when soldering, you usually work from “lowest” to “highest” component. This makes life easier. Simply insert the transmitter module into the 3 holes and solder it. Note that the module has an antenna connector (marked “ANT”) for adding a straight-wire antenna, approx. 17cm in length. This corresponds to 1/4 wavelength at 433MHz.

OOK433 Plug with Transmitter moduleFinally, the receiver module. Insert it into the 4 holes and solder it. This module also has an antenna connector, you may want to add a 17cm straight-wire antenna here as well.

The end result is in the picture below. Now for the moment of truth: trying to make it work with a JeeNode and a software sketch.

This is where my trouble began. I used various sketches with my new KAKU remote, to no avail:

I searched the blog and forums using Google (“site:jeelabs.net OOK433”) and found several people struggling to make the OOK433 Plug work. Several issues appear to be at play here:

  1. Confusion regarding the correct supply voltage; it seems that +3V is not enough.
    This means that you would need to bridge the leftmost two pads on the upper solder jumper, instead of the rightmost two pads.
  2. Confusion regarding port numbers / Arduino pin numbers.
    The KlikAanKlikUit_A_type sketch is the only one that seems to clearly document where the Plug is expected to be for the sketch to work.
  3. Confusion regarding the antennas being “optional” or not.
    I have no antennas connected at the moment, but I’m using the remote at close range so it should not be a problem.
  4. Confusion regarding the different KAKU protocols out there.
    I think I have the most recent protocol, with house code (A-D on my remote). The old protocol apparently does not have that.

All in all, quite a few variables ;-)

I decided to go ahead with the ookScope2.ino sketch – that appears to be a fairly recent sketch; hopefully that code works as expected. First hurdle: determining which port to plug the OOK433 Plug into…

The code contains this line:

#define OOK_PIN   2   // this is the input pin with the signal to be analyzed

This might refer to AVR pin PD2, Arduino pin “Digital 2” but that would mean it’s connected to the RFM12B INT line! Not very likely… I tried the code, and apart from the [ookScope] identifier, nothing happened. So, where does that OOK433 Plug need to go for the sketch to work?

OK, back to the schematic I talked about at the start of this post. The OOK433 receiver module appears to be connected to the AIO pin. If I want to use the plug in Port 3, I need to find the proper value for AIO3. That would be Analog 2 / Digital 16 (hey, ‘2’ looks familiar but it didn’t work).

I then tried seting OOK_PIN to 16 (Digital 16), plugged the OOK433 into Port 3 and behold! The sketch starts, and emits binary garbage on the serial output! This is promising!

Next up: install the JeeRev / JeeMon software on my Mac according to instructions. Unfortunately, that didn’t result in a nice bar graph display – the bars remain at zero, even though I pressed the remote buttons. Perhaps the ookScope2.ino sketch doesn’t work with this version of the JeeMon software? What’s next? Debugging the JeeMon installation? Nah…

Anyway, my head hurts after reading through the various forum and blog posts – once I get this working I’ll post “part 2” of this adventure ;-)

JeeLabs OOK433 Plug, completely assembled

P.S.: I think we as a community should work on improving the “Out of Box Experience” for the JeeLabs hardware. Detailed assembly instructions, a simple test sketch with clear instructions on setting up the test bed – life would be so much easier ;-) If possible, add a low-level hardware diagnostics mode in that test sketch to help isolate the cause of any hardware-related problems. For example, try communicating over the SPI / I2C bus. If that doesn’t work, you might have to inspect your soldering. And most importantly: find a way to reduce @JCW’s workload – it would not be realistic to expect him to do all the work on documentation / test sketches etc.

Still massively enjoying the JeeLabs learning experience, one (steep) step at a time ;-)

Onwards!

Assembling the JeeLabs LCD Plug

Assembled the JeeLabs LCD PlugToday I received my new items from JeeLabs – an LCD Plug and a set of stacking headers.

After soldering the control board to the LCD display,I tried compiling the lcd_demo.ino demo sketch. No luck – it seems that the code no longer compiled with Arduino 1.0.

I added the include-file that was missing:

#include <PortsLCD.h>

and suddenly… nothing happened.

JeeLabs LCD Plug 2 annotatedI verified the connections – everything looked good. Oh well – “if all else fails, read the manual”. There were no detailed assembly instructions for this kit, so I had to search through various posts to help debug the issue.

Turns out that you have to set two solder jumpers (Logic to 3v3, Backlight to 3v3) as well as short out a current limiting resistor (which is not actually present on the board). Click the annotated image on the left for a (blurry) close-up.

This still did not seem to solve the problem – the backlight worked, but still no text on the display. After adjusting the contrast level with the trimpot (near the read arrow in the image), the display finally sprang to life. I had to rotate it completely counter-clockwise.

The test assembly looks like this – battery holder on top, JeeNode in the middle, LCD Plug at the bottom of the image. The LCD Plug is connected to Port 1 on the JeeNode.

LCD Plug test assembly, running off a battery