Saturday, February 26, 2022

Debian 11 on Gigabyte B660M D3H DDR4 board

 I recently setup a Debian 11.2 system on a Gigabyte B660M D3H DDR4. During installation I noticed the onboard networking didn't function.

james@debian11:~$ lspci |grep Ethernet
04:00.0 Ethernet controller: Intel Corporation Ethernet Controller I225-V (rev 03)


With the default 5.10 kernel the module 'igc' for this controller fails with the following error:

root@debian11:/var/log# grep igc messages 
Feb 25 09:44:13 debian11 kernel: [    4.353002] igc: probe of 0000:03:00.0 failed with error -2

The solution for me was to install kernel 5.15 from backports:

root@debian11:/var/log# uname -a
Linux debian11 5.15.0-0.bpo.3-amd64 #1 SMP Debian 5.15.15-2~bpo11+1 (2022-02-03) x86_64 GNU/Linux

root@debian11:/var/log# dmesg |grep igc
[    3.825490] igc 0000:04:00.0: PTM enabled, 4ns granularity
[    3.871312] igc 0000:04:00.0 (unnamed net_device) (uninitialized): PHC added
[    3.930345] igc 0000:04:00.0: 4.000 Gb/s available PCIe bandwidth (5.0 GT/s PCIe x1 link)
[    3.930348] igc 0000:04:00.0 eth0: MAC: d8:5e:d3:91:15:95
[    3.931844] igc 0000:04:00.0 enp4s0: renamed from eth0
[   10.465411] igc 0000:04:00.0 enp4s0: NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX/TX

You'll temporarily need an alternative network controller to install and update the system. I used a USB adapter that I have on hand for such problems. 



Tuesday, August 24, 2021

Plotting an image in MATLAB and maintaining the original size

This worked for me:

 https://stackoverflow.com/questions/1848176/how-do-i-save-a-plotted-image-and-maintain-the-original-image-size-in-matlab


I = imread('peppers.png');      %# Load a sample image
imshow(I);                      %# Display it
[r,c,d] = size(I);              %# Get the image size
set(gca,'Units','normalized','Position',[0 0 1 1]);  %# Modify axes size
set(gcf,'Units','pixels','Position',[200 200 c r]);  %# Modify figure size
hold on;
plot(100,100,'r*');             %# Plot something over the image
f = getframe(gcf);              %# Capture the current window
imwrite(f.cdata,'image2.jpg');  %# Save the frame data

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
        }