Thursday, October 29, 2020

Internals of Ubiquiti ETH-SP ethernet surge protector

 A couple of photos showing the internals of Ubiquiti's Ethernet surge protector ETH-SP. 

There are eight 2RL090 90 Volt GDTs.  One between each Ethernet line and the metal grounding point.  




Friday, August 09, 2019

HTTP Time protocol

The HTTP Time Protocol (HTP) is used to synchronize a computer's time with web servers as reference time source. Very handy in situations where NTP UDP/123 is being blocked. http://www.vervest.org/htp/

Wednesday, August 15, 2018

Nagios plugin for monitoring last modified time stamps of website content

Inspired by this plugin and this discussion,  I have written a nagios plugin for monitoring the "Last-Modified" time of content on a website. The script uses curl to retrieve the header information and then warns if the content has not been updated within a specified period of time.   
I developed this plugin for checking that data & satellite plots on our aurora alert site were being refreshed at the expected intervals.
[james@orchid tmp]$ curl -s -I  http://auroraalert.otago.ac.nz/aurora/Suomi_NPP_DNBNCC_night_highresimage.png
HTTP/1.1 200 OK
Date: Tue, 14 Aug 2018 23:36:08 GMT
Server: Apache/2.4.6 (CentOS)
Last-Modified: Tue, 14 Aug 2018 05:56:06 GMT
ETag: "15cfb4-5735edda8345f"
Accept-Ranges: bytes
Content-Length: 1429428
Content-Type: image/png


 Nagios plugin shell script:
#!/usr/bin/env bash
DEFAULT_WARN_SECONDS=600
DEFAULT_CRIT_SECONDS=1200

while getopts  'hp:c:w:' option; do
    case $option in
        h) help=1;;
        p) path=$OPTARG;;
        c) crit=$OPTARG;;
        w) warn=$OPTARG;;
    esac
done
if [ -n "$help" ] || [ -z "$path" ]; then
    echo "usage: $0 -p [path (required)] -w [warning threshhold seconds] -c [critical threshold seconds]" 1>&2
    exit 3

fi
if [ -z "$warn" ]; then
    warn=$DEFAULT_WARN_SECONDS
fi
if [ -z "$crit" ]; then
    crit=$DEFAULT_CRIT_SECONDS
fi
modificationTimeStamp() {
    curl -s -I HEAD $path |
        awk '/Last-Modified/{ date=""; for(i=2;i<=NF;++i) date=(date " " $i); print date;}' |
        xargs -I{} date -d {} +"%s"
}
#seconds=$(($(date +'%s') - $(stat --format='%Y' $path)))
seconds=$(($(date +'%s') - $(modificationTimeStamp) ))
if [ $seconds -gt $crit ]; then
    echo "CRITICAL: $path was last modified $seconds seconds ago"
    exit 2
elif [ $seconds -gt $warn ]; then
    echo "WARNING: $path was last modified $seconds seconds ago"
    exit 1
else
    echo "OK: $path was last modified $seconds seconds ago"
    exit 0
fi
Add it to the command.cfg
#check last modified time on remote URL
define command{
        command_name    check_urlmtime
        command_line    $USER1$/check_urlmtime -p $ARG1$ -w $ARG2$ -c $ARG3$
        }
Example service entry
define service{
        use             generic-service         ; Inherit default values from a template
        host_name               auroraalert
        service_description     Soumi NPP satellite image
        check_command   check_urlmtime!"http://auroraalert.otago.ac.nz/aurora/Suomi_NPP_DNBNCC_night_highresimage.png"!86400!172800
        }

Friday, August 21, 2015

rsync over a non standard SSH port

Use the -e option:

rsync -avz -e "ssh -p $portNumber" user@remoteip:/path/to/files/ /local/path/

Sunday, June 14, 2015

HMC5883L magnetometer to Raspberry Pi connection notes

Some quick notes for connecting Honeywell's 3-Axis Digital Compass IC
HMC5883L to the I2C bus on a Raspbrry Pi board.

HMC5883L breakout board from SparkFun:
https://www.sparkfun.com/products/10530


Connections

GND -> GND (pin 6 on RPi I/O header)
VCC -> 3.3 V (pin 1 on RPi )
SDA -> SDA1 I2C (pin 3 on RPi)
SCL -> SCL1 I2C (pin 5 on RPi)

Configuration

Enable I2C using "raspi-config". Add user to i2c group.

pi@raspberrypi ~ $ i2cdetect 1
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-1.
I will probe address range 0x03-0x77.
Continue? [Y/n]
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- 1e --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --



Run

See below for example C code.

pi@raspberrypi ~ $ gcc magnetometer.c   -o magnetometer -lm

pi@raspberrypi ~ $ ./magnetometer
Identification: 'H43' HMC5883L sensor detected
1434246270.000000, -548, -649, 349, 67030.4 nT
1434246270.100000, -547, -650, 349, 67038.5 nT
1434246270.200000, -548, -648, 348, 66951.1 nT
1434246270.300000, -548, -650, 350, 67109.8 nT
1434246270.400000, -548, -650, 350, 67109.8 nT
1434246270.500000, -547, -650, 350, 67066.3 nT
1434246270.600000, -547, -650, 349, 67038.5 nT
1434246270.700000, -548, -650, 350, 67109.8 nT
1434246270.800000, -547, -649, 348, 66959.2 nT
1434246270.900000, -548, -650, 351, 67137.6 nT


Code

C code to read and display the magnetometer data

Tuesday, May 26, 2015

Red Hat and CentOS Linux: Use PEERNTP=no to ignore any NTP server info provided by DHCP

Any NTP server information provided by DHCP can be ignored by setting PEERNTP=no anywhere in the sourced network scripts (e.g. /etc/sysconfig/network). This is useful in situations where a specific NTP setup is required rather than a default configuration supplied via DHCP. 
https://bugzilla.redhat.com/show_bug.cgi?id=809367  

Sunday, March 08, 2015

systemd service script for soundmodem



james@arm:/lib/systemd/system$ more soundmodem.service
[Unit]
Description=Soundcard Packet Radio Modem
After=sound.target network.target multi-user.target

[Service]
Type=forking
ExecStart=/usr/sbin/soundmodem --daemonize -s

[Install]
WantedBy=multi-user.target



james@arm:/lib/systemd/system$ more /etc/debian_version
7.8
james@arm:/lib/systemd/system$ uname -a
Linux arm 3.19.0-armv7-x3 #1 SMP Wed Feb 11 21:58:07 UTC 2015 armv7l GNU/Linux
james@arm:/lib/systemd/system$

Wednesday, January 07, 2015

Baofeng BF-F8+ battery voltage display

The Baofeng BF-F8+ has a built in battery voltage display.

Baofeng BF-F8+

Press and hold the "0 SQL" key

The display will show the DC voltage of the battery. 8.1 V in this example:

Accuracy seems to be OK




Thursday, June 26, 2014

Estimating the power of a signal at different frequencies: aka spectral density estimation

This report has a good write up on using FFTs to make signal amplitude measurements: http://www.schmid-werren.ch/hanspeter/publications/2012fftnoise.pdf

Some example MATLAB code. Three signals are generated at levels of -20 dB, -40 dB & -60 dB:

clear
clf

%sampling frequency
Fs=48000;

%test frequencies
f1=11300;
f2=1510;
f3=17750;

%time
t=(0:1/Fs:1);

%generate signals
% 0.1 amplitude = -20 dB
% 0.01 = -40 dB
% 0.001 = -60 dB
y=0.1*cos(2*pi*f1*t)+0.01*cos(2*pi*f2*t)+0.001*cos(2*pi*f3*t);

%add some random background noise
noise = randn(size(y));
y=y+1e-4*noise;

%wavwrite(y,Fs,'test.wav');

N=1024;
w=blackman(N);

Y=fft(y(1:N).*w');

%scaling factors
%e.g. see
%http://www.schmid-werren.ch/hanspeter/publications/2012fftnoise.pdf
scaling = 2/(mean(w)*N);

fx=Fs/N*(0:N/2-1);
Y=Y(1:N/2);

figure(1)
plot(fx,20*log10(abs(Y) * scaling))

xlabel('Frequency/Hz')
ylabel('Amplitude/dB')
grid



Wednesday, October 16, 2013

Boot old 3.2.x kernel on beaglebone white A6b

Need to add something like this to uEnv.txt

#To boot old v3.2.x based kernel enable: (BeagleBone only)

uenvcmd=run loaduimage; run mmc_classic_boot

Friday, September 27, 2013

Power down the BeagleBone Black using the on board power button

The beaglebone black board has a power button next to the RJ45 ethernet connector. Pressing that button can get the board to cleanly shutdown.

First install acpid:

root@beagle1:/home/james# apt-get install acpid

Now test the shutdown. Press the Power button:

root@beagle1:/home/james#
Broadcast message from root@beagle1 (Fri Sep 27 01:13:49 2013):

Power button pressed
The system is going down for system halt NOW!
Connection to 192.168.1.116 closed by remote host.
Connection to 192.168.1.116 closed.

Installed system was Debian 7.1

james@beagle1:~$ more /etc/debian_version 
7.1
james@beagle1:~$ uname -a
Linux beagle1 3.8.13-bone26 #1 SMP Fri Aug 16 20:56:24 UTC 2013 armv7l GNU/Linux




Saturday, September 14, 2013

Enable UART5 on beagle bone running debian

First mount debugfs:
mount -t debugfs none /sys/kernel/debug

Enable UART5:
echo 24 > /sys/kernel/debug/omap_mux/lcd_data9
echo 4 > /sys/kernel/debug/omap_mux/lcd_data8

Hardware Pins:
P8: 37 UART5_TXD
P8: 38 UART5_RXD

Device to access:
/dev/ttyO5

References:
http://www.jerome-bernard.com/blog/2012/06/04/beaglebone-serial-ports-and-xbees/


Thursday, March 21, 2013

Debian Linux on beaglebone notes

Purchased beaglebone from digikey
http://www.digikey.co.nz/product-detail/en/BB-BONE-000/BB-BONE-000-ND/2765688

Added DVI audio cape
http://www.digikey.co.nz/product-detail/en/BB-BONE-DVID-02/BB-BONE-DVID-02-ND/3503684

Installed Debian Linux "Wheezy":
http://elinux.org/BeagleBoardDebian
http://elinux.org/BeagleBoardDebian#Debian_Wheezy_snapshot

Update system:
apt-get update; apt-get upgrade; etc

To load the modules for the audio cape:

sudo vi /etc/modules

at the end, add the lines:

snd_soc_davinci_mcasp
snd_soc_davinci
snd_soc_evm
snd_soc_tlv320aic3x

Power

With DVI audio cape attached, the device would often shutdown when powered over USB.  A separate +5 V DC 2 Amp power supply solves this problem.