Surströmming

Last Updated or created 2022-04-30

Surströmming as it should be eaten.

As the tin is pressurised, open the surströmming in a basin of water. Wash it, gut it, and wrap it in buttered tunnbröd, a type of sweetened flat bread, with sour cream, potatoes and onion. Accompany with beer.

Didn’t have tunnbröd, used another flat bread.

I liked it enough to have two portions, would eat again.

Oak island

Last Updated or created 2024-02-21

I was about 16 when i first read about Oak Island, it was the first book posted below (it’s from 1979 and i still got it, it already was a few years old before i got it.). It was mysterious and about a place that still existed and i never forgot about it in all those years.

I even wanted to build a model to understand how it could have worked, with the drain system and the ‘boobystraps’.

In 2014 a series started on History Canada about trying to solve this mystery.
I still watch it whenever a new episode is posted.

A few years back i’ve been playing with Unity and Unreal. I’m really a beginner, but it would be nice if some community effort was made to get a Oak Island in a game engine where you can explore some of the things they found.

Another book i got some years later.

My own home build computer

Last Updated or created 2022-05-12

Part 1 of my 680x computer.

Running a little program to read dipswitches and displaying them using leds.

0000 CE 8020 ; LDX #$8020 
0003 6A 01   ; DEC 1,X
0005 86 04   ; LDA A A
0007 A7 02   ; STA A 2,X
0009 A7 03   ; STA A 3,X
000B A6 00   ; LDA A 0,X
000D A7 01   ; STA A 1,X
000F 20 FA   ; BRA

Design of sound chip intergration

C64 Tape found

Last Updated or created 2023-01-25

Tape i found yesterday

I found a cassette tape yesterday. I was really curious .. dont remember making this.

Connected a tape drive to my C64 and tried to get the damn thing to read the tape.

Commodore tape drive

Got stuck on READY’s with no programs. Being a little rusty into using C64 i tried:

  • L+shiftO
  • shift break
  • LOAD”$”,8
  • LOAD”$”,8,1
  • LOAD”*”,8

Maybe there was a turbo loader used?
Maybe my tape unit wasn’t aligned?

Tried multiple tape units, couldnt find a Tape Head Alignment Program like:

So i used another method to see if data was recoverable.

Using UberCassette or AudioTap

Above are two examples with uses recorded wave files and calculations to generate the original written bits!

Recorded the tape to mono wav file using a generic linux recording application.

ubercassette taperecording.wav mytape.tap 

Started to build a Drawbridge

Last Updated or created 2022-04-26

For my amiga i started to build a floppy disk reader/writer using a arduino.
I found a superb project by rob smith.
It uses only a arduino pro and a FTDI USB to serial breakout board, to raw read and write disks.
I wanted to convert my own created amiga disks to PC image to use in a emulator like vice.

http://amiga.robsmithdev.co.uk/instructions/promini

I’m not going to copy his website, with all instructions. Only my personal experiences.

Starting with … don’t use a IDE cable, and start soldering .. it is a diskdrive cable .. connector doesn’t fit! ..

Getting components and flashing arduino … no brainer

How many vlan’s are enough?

Last Updated or created 2022-04-26

Many years ago i started segmenting my network using vlans.

In 2022 i started to reconfigure my lab and using a lot more Mikrotik switches.
So how many … is to many, because i always overdo stuff.

Well .. is 9 to many for home environments?

  • default vlan – did’t bother to configure
  • old DMZ .. to be migrated
  • DMZ – my servers live here
  • Wifi personal workstations – Mobiles and laptops .. macaddress limited
  • IOT – only arduino’s, raspberries and other hardware live here
  • Personal workstations – UTP connected workstations with less networking limitations
  • LAB – My lab environment, Ovirt virtualisation for fun and manage access to servers in dmz
  • Storage – my SFP enabled all-flash storage
  • Management – really tight restricted access to management interfaces (switches/routers/storage/ILO)

Hard to manage? All those vlan’s? .. Sure, but i learn a lot!
(Not really .. when you got the basics down, more of the same.
Hardest part? .. not cutting-off connections/switchports you are using!)

Working Amiga 500

Last Updated or created 2022-04-30

Got a working amiga again. \o/ woot
Needed to replace Paula chip, cleaning and some TLC.

Modulator
Chip donor

Scart cable i’ve got is one without the resistors, so my monitor isn’t detecting the signal.
Using a A520 modulator works. At least RF, don’t know why RCA/composite video isn’t working.

Even a memory expansion and second drive (5.24 inch) are working.

One of the first disks i tested

To do:

  • Fix something to get disk images from and to my pc.
  • (My old catweasel card only fits in a ISA slot which i don’t have any more)
  • I was wrong .. i’ve got a IV Catweasel .. PCI it is
  • Fix scart
  • Fix my Action Replay, which i soldered into a non working state apparently .. 🙂
  • Get a better mouse!
Catweasel IV

Disks to convert:

  • Personal text files from ages ago
  • My first seka demo
  • My oscillator drawing program
  • Other assembly source files

Got another one running today also:

Gluster and Rhev scripts

Last Updated or created 2023-02-02

List Ovirt/RHV VM’s

( curl -s -u admin@internal:secretpassword -k https://ovirt-engine.lab/ovirt-engine/api/vms/ | grep "^        <name>" | cut -f2 -d\> | cut -f1 -d \< | while read;  do
echo "$REPLY"
done ) > list
echo "NOT IN BACKUP"
cat list | while read ; do ls vmbackup/$REPLY.ova 2>/dev/null >/dev/null || echo $REPLY ;done
echo ""
ls vmbackup/*ova | while read ; do
host=$( echo $REPLY | cut -f2 -d/ | cut -f1 -d.)
age=$(stat -c %y $REPLY  | cut -f1 -d" ")
echo "$age $host"
done

Backup: (UPDATE)
While i made my own backup script for Ovirt, i found this ansible based one.
https://github.com/silverorange/ovirt_ansible_backup

Backup Ovirt Engine using ansible

Usage : ansible-playbook -i ovirt-engine.lab, playbook.yml -u root (-k)

## Playbook
---
- hosts: all
  vars:
    ovirt_backup_mode: 'backup'
    ovirt_backup_archive: '/tmp/engine-backup.gzip'
    ovirt_backup_log_file: '/tmp/engine-backup.log'
    ovirt_backup_scope: 'all'
    ansible_python_interpreter: /usr/bin/python3
  roles:
      - ovirt-engine-backup

## roles/ovirt-engine-backup/tasks/main.yml
---
- name: run engine-backup
  shell: 'engine-backup --mode={{ ovirt_backup_mode }} --file={{ ovirt_backup_archive }} --log={{ ovirt_backup_log_file }} --scope={{ ovirt_backup_scope }}'
  tags:
    - skip_ansible_lint
  register: ovirt_backup_status

- name: download engine backup file
  fetch:
    src: "{{ ovirt_backup_archive }}"
    dest: "{{ ovirt_backup_archive }}"
  when: ovirt_backup_status is succeeded

- name: download log file
  fetch:
    src: "{{ ovirt_log_file }}"
    dest: "{{ ovirt_log_file }}"
  when: ovirt_backup_status is failed

Gluster overview

#!/bin/bash
ansible -i inventory all  -m shell -a "/sbin/gluster v info" --become  -K > output
cat output  | grep "^Volume Name"  | sort | cut -c14- | sort | uniq
cat output  | egrep "^Volume Name|^Brick|^Type"   | grep -v Bricks

Gluster to grafana using influx

#!/bin/bash
export PATH=$PATH:/sbin
(
# Get short shotname
host=$(echo $HOSTNAME | cut -f1 -d.)

echo "-- vg info --"
# Get vg info - pool nog doen
vgs --units k | egrep "brick|data0" | while read brickinfo ; do
name=$(echo $brickinfo | awk '{ print $1}'  )
size=$(echo $brickinfo | awk '{ print $6}' | cut -f1 -d.)
free=$(echo $brickinfo | awk '{ print $7}' | cut -f1 -d. | sed s/k//g)
usage=$(echo $(( $size - $free )))
curl -i -XPOST 'http://grafanaserver:8086/write?db=gluster' --data-binary "$host-$name size=$size,free=$free,usage=$usage"
done
echo "-- vg info done --"
echo "-- lv info --"
# Get lv info - these are mountpoints (not bricks)
#lvs --units k | egrep "brick|data0" | grep -v pool | while read volinfo ; do
df  | egrep "brick|data0" | while read volinfo ; do
name=$(echo $volinfo | awk '{ print $1}' | rev | cut -f1 -d/ | rev  )
size=$(df | grep -v svg |grep "$name" | awk '{ print $2}')
usage=$(df | grep -v svg |grep "$name" | awk '{ print $3}')
free=$(df | grep -v svg |grep "$name" | awk '{ print $4}')
curl -i -XPOST 'http://grafanaserver:8086/write?db=gluster' --data-binary "$host-$name size=$size,free=$free,usage=$usage"
done

echo "-- lv info done --"

# Get gluster volumes without gluster command, due to issues running multiple instances
# One volume on one mountpoint ? Then df == volume metrics
: > /tmp/vollist
find /var/lib/glusterd/| grep $HOSTNAME | grep vol$ | while read brickpath ; do
grep brick-path $brickpath | awk '{print $3 }' >> /tmp/vollist
done
mount | egrep "brick|data0" | awk '{print $3 }' | while read mountpoint ; do
count=$(grep $mountpoint /tmp/vollist | wc -l)
if [ $count -lt 2 ] ; then
echo "lv = brick .. df info"
#brick=$(echo $mountpoint)
#volume=$(echo $mountpoint |rev | cut -f1 -d/ | rev)
#size=$(df $mountpoint | grep -v Filesystem | awk '{ print $2 }')
#free=$(df $mountpoint | grep -v Filesystem | awk '{ print $4 }')
#usage=$(df $mountpoint | grep -v Filesystem | awk '{ print $5 }' | sed s/%//g )


dfinfo=$(df $mountpoint | grep -v ^Filesystem)
name=$(echo $dfinfo | awk '{print $1}' | rev | cut -f1 -d/ | rev)
size=$(echo $dfinfo | awk '{print $2}')
usage=$(echo $dfinfo | awk '{print $3}')
free=$(echo $dfinfo | awk '{print $4}')
perc=$(echo $dfinfo | awk '{print $5}' | sed s/%//g)
curl -i -XPOST 'http://grafanaserver:8086/write?db=gluster' --data-binary "$host-$name size=$size,free=$free,usage=$usage"
#curl -i -XPOST 'http://grafanaserver:8086/write?db=gluster' --data-binary "$host-$brick-$volume size=$size,free=$free,usage=$usage"
else
echo "du script draaien voor $mountpoint"
fi

done

echo "-- data% --"
lvs --units k -a -oname,vg_name,size,vgfree,data_percent,pool_lv | grep -v \\[ | egrep  "brick|data" | grep -v sysdata | grep -v "^  thin" | while read ; do
vg=$(echo $REPLY | awk '{print $2}')
name=$(echo $REPLY | awk '{print $6"-"$1}')
size=$(echo $REPLY | awk '{ print $3 }' | cut -f1 -d.)
free=$(echo $REPLY | awk '{ print $4 }' | cut -f1 -d. | sed s/k//g)
dataperc=$(echo $REPLY | awk '{ print $5 }' | cut -f1 -d. )
if [ "w$dataperc" == "w" ] ; then dataperc=0 ;fi
curl -i -XPOST 'http://grafanaserver:8086/write?db=gluster' --data-binary "$host-$name-$vg size=$size,free=$free,dataperc=$dataperc"
done


) 2> /dev/null >/dev/null

Running Ovirt and want a overview of glustermounts in VMs?

run makeinventory.sh (this creats an list of linux hosts which are UP in RHV/Ovirt)

#!/bin/bash
#ik haal een lijst op van virtual machines die aanstaan en linux draaien
#set -x
mkdir -p tmp
rm -f tmp/linuxup
read -p "Username: " x2
read -s -p "Password: " x1
echo " "
curl -s -X GET -H "Accept: application/xml"  --insecure -u $x2@radlan:$x1 https://ovirtserver/ovirt-engine/api/vms | grep "vm href=" | cut -c37-72 > tmp/vms
cat tmp/vms | while read vm ; do
echo -n "."
curl -s -X GET -H "Accept: application/xml"  --insecure -u $x2@radlan:$x1 https://ovirtserver/ovirt-engine/api/vms/$vm > tmp/$vm
done
echo " "
: > tmp/linuxup
find tmp -type f -mtime 0 | egrep -v "vms$|linuxup" | while read ; do

name=$(cat $REPLY | grep -i "^    <name>"| cut -f2 -d\> | cut -f1 -d \<)
os=$(cat $REPLY | egrep "^        <family>" | egrep -v "svw|SVNT|debian|ubuntu|server|spice|vnc|windows_|native" | cut -f2 -d\> | cut -f1 -d \<)
up=$(cat $REPLY |  grep -A1 start_time | tail -1| cut -f2 -d\> | cut -f1 -d \<)


echo $name,$os,$up | grep -v ",," | grep ",up" >> tmp/linuxup

cat tmp/linuxup
echo ""
echo "staat in tmp/linuxup"

done
echo "[all]" > inventory
cat tmp/linuxup | grep "."| grep -i linux | cut -f1 -d, >> inventory

Run get.sh
* ansible on all hosts (inventory) and fetches gluster mounts
* reorders this info
* generates a dot file (graphviz)
* running dot fot a svg/png output for every gluster host

#!/bin/bash
echo "draai eerst makeinventory.sh voor een nieuwe host lijst"
read d
echo "Kijk ook of ansible alle servers kan bereiken"
read d
ansible -i inventory all -m shell -a cat /etc/mtab | grep gluster | while read; do source=$(echo $REPLY | cut -f1 -d" ");dest=$(echo $REPLY | cut -f2 -d" ") ; echo " " ;echo "$source $HOSTNAME:$dest" ;done > gluster
cat gluster  | grep ^s | grep : > gluster.grep

cat gluster.grep  | cut -f1 -d: | sort | uniq | while read gluster ; do

cat header > $gluster.dot
cat gluster.grep | grep $gluster | cut -f1 -d" "| sort | uniq | while read ; do echo "    \"$REPLY\";" ;done >> $gluster.dot
cat middel >> $gluster.dot
cat gluster.grep | grep $gluster| sed s/^/\"/ | sed s/\ /\"\ \-\>\ \"/ | sed s/$/\"\;/ >> $gluster.dot
cat footer >> $gluster.dot
dot $gluster.dot -Tsvg >$gluster.svg
dot -Gsize=9,15\! -Gdpi=100  $gluster.dot -Tpng >$gluster.png
done

A php select page to few them

<form method="post">
<select name="volume">
    <?PHP
    foreach (glob("*.svg") as $filename) {
        echo "<option value=" . $filename .">" . $filename . "</option>";
    }
    ?>
    </select>
 <input type="submit" value="Submit">
</form>
<?PHP
    if (isset($_POST['volume'])){
            $image=$_POST['volume'];
            echo "<img src=\"$image\">";
    }
?>



example below:

Get a list of RHV snapshots and descriptions

#!/bin/bash
: > outlist
read -p  "Username: " user
read -s -p "Password: " pass

curl -X GET -H "Accept: application/xml" -u $user@internal:$pass -k  https://ovirt-engine:443/ovirt-engine/api/vms   | egrep "<name>|snapshots" | grep -v "           " | sed '$!N;s/\n/ /' > templist
cat templist  | cut -f2,3 -d\> | cut -f1,3 -d\< | sed 's/<link href=\"/ /g' | cut -f1 -d\" > templist2
cat templist2 | while read ; do
host=$(echo $REPLY | awk '{ print $1 }')
link=$(echo $REPLY | awk '{ print $2 }')
echo $host >> outlist
curl -X GET -H "Accept: application/xml" -u $user@radlan:$pass -k  https://ovirt-engine:443/$link | egrep "description|date" | grep -v '            <'  >> outlist ; echo "----" >> outlist
done
cat outlist | awk '/Active VM/ {getline; next} { print }' > /tmp/outlist
grep -B3 date /tmp/outlist  |sed -e 's/<[^>]*>//g' > /tmp/snapshots
cat /tmp/snapshots | awk '/----/ {printf "\n%s\n",$0;next} {printf "%s ",$0}' | sed 's/ --*//g' | grep -v '\-\-\-\-' | grep "  " > snapshots

Output:
svr04.lab         Backup              2019-06-28T07:55:28.909+02:00
svr05.lab         upgrade             2019-06-18T14:18:49.745+02:00
svr33.lab         pre_ansible         2019-06-18T14:04:43.569+02:00

Somewhere i've got a snapshot age warn script.
This information was posted in Mattermost when sending the "/snapshots" command

Ansible Playbook to add virtual nics

---
- name: adnic
  hosts: localhost
  gather_facts: false
  become: no


  vars_prompt:
    - name: "username"
      prompt: "IPA username"
      private: no
    - name: "password"
      prompt: "IPA password"
      private: yes
    - name: "server"
      prompt: "server"
      private: no
    - name: "interface"
      prompt: "interface"
      private: no
      default: 'eth1'
    - name: "nicprofile"
      prompt: "dmz or other"
      private: no
      default: 'dmz'

  tasks:
  - name: Obtain SSO token with using username/password credentials
    ovirt_auth:
      url: https://ovirt-engine.lab/ovirt-engine/api
      username: "{{ username }}@internal"
      insecure: yes
      password: "{{ password }}"
    
  - ovirt_nics:
      auth: "{{ ovirt_auth }}"
      vm: "{{ server }}"
      state: "present"
      name: "{{ interface }}"
      network: "{{ nicprofile }}"
      profile: "{{ nicprofile }}"

Ansible playbook to create snapshots

- name: makesnap
  hosts: localhost
  gather_facts: false

  vars_prompt:
    - name: "username"
      prompt: "IPA username"
      private: no
    - name: "password"
      prompt: "IPA password"
      private: yes
    - name: "hostname"
      prompt: "hostname"
      private: no
    - name: "snapshotname"
      prompt: "snapshotname"
      private: no

  tasks:
  - name: Make snapshot
    ovirt_snapshots:
      auth:
        username: "{{ username }}@internal"
        password: "{{ password }}"
        insecure: True
        url: https://ovirt-engine.lab/ovirt-engine/api
      description: "{{ snapshotname }}"
      use_memory: true
      state: present
      timeout: 600
      vm_name: "{{ hostname }}"

Scripts on my domoticz instance

Last Updated or created 2022-04-13

Script NO1:
Below is a script which checks all sensors and switches available on my domoticz instance, and gives me information about last updates.
For example when a device is out of reach or battery empty.

Usage:

Outputs to console, or you can use it in check_mk monitoring.
(For the latter, create a script

vi /usr/lib/check_mk_agent/local/checkfrontdoor
chmod +x /usr/lib/check_mk_agent/local/checkfrontdoor
put in the script 
#!/bin/bash
cd /path/to/script/
./belowscript "Frontdoor" 300 checkmk

Code:

#!/bin/bash
#set -x
# after running once check stateseconds for names
if [ $# -eq 0 ]; then
echo "$(basename $0) - without options .. getting states"
echo "use $(basename $0) "Sensorname" seconds" for check
echo "Getting all states"
: > stateseconds
curl -s -i -H "Accept: application/json" "http://127.0.0.1:8080/json.htm?type=devices&filter=all&used=true&order=Name" | egrep "Name|Last" | grep -v HardwareName |grep -vi levelnames> states
sed -i 'N;s/\n/,/' states
now=$(date +%s)
cat states  | awk '{ print $3" "$4$7$8$9$10$11$12 }' | sed s/,,/,/g |rev | cut -c2- | rev | while read ; do
name="$(echo $REPLY | cut -f2 -d, )"
dater="$(echo $REPLY | cut -f1 -d, | sed s/\"//g)"
#echo $dater
seen=$(date -d "$dater" +%s)
#echo $seen
echo "$name $(( $now - $seen))" >> stateseconds
echo -n "."
done
fi
echo ""
if [[ ! -z "$1" && ! -z $2 ]]; then
checkold=$(cat stateseconds | grep "$1\"" | head -1 | awk '{ print $2 }')
total=$(( checkold - $2 ))
if [ -z $3 ] ; then
if [ $checkold -gt $2 ] ; then echo "$name lastseen longer than $2 seconds ago ($total sec)" ; exit 1 ;fi
else
if [ $checkold -gt $2 ] ; then echo "2 \"$1\" - Sensor older than $2 seconds" ; exit 1
else
echo "0 \"$1\" - Sensor age ok" ; exit 0
fi
fi
fi

Above to your Mqtt broker?

#!/bin/bash
# change 300 ( age below 5 minutes )
# and $2>=900 ( age above 15 minutes )
./agecheck.sh # Updates statefile
cat stateseconds | tr -d '"-/:"_' | sort -n -k2 | awk '$2<=300' | while read; do
sensorname=$(echo $REPLY | awk '{ print $1 }' )
age=$(echo $REPLY | awk '{ print $2 }' )
mosquitto_pub -h 10.1.0.17 -t sensorsage/$sensorname -m "$age"
done

Script NO:2
This is a mqtt speech script with caching sounds, speech generated for me by google

MQTT Part

#!/usr/bin/python
import paho.mqtt.client as mqttClient
import time
import os
import subprocess
import shlex
Connected = False

def on_connect(client, userdata, flags, rc):
    if rc == 0:
        print("Connected to broker")
        global Connected
        Connected =True
    else:
        print("Connection failed")

def on_message(client, userdata, message):
    print "Message received: " + message.topic + " : " + message.payload
    fileName = "/home/pi/domoticz/scripts/speech" + " \"" + message.payload + "\""
    print fileName
    args = shlex.split(fileName)
    time.sleep(1)
    p = subprocess.Popen(args)


broker_address = "mqttbroker"
port = 1883
user = "myuser"
password = "mysecretpass"
client = mqttClient.Client("speechcmd")
client.username_pw_set(user, password=password)
client.on_connect = on_connect
client.on_message = on_message

client.connect(broker_address, port=port)
client.loop_start()

while Connected != True:
    time.sleep(0.1)

client.subscribe('speech/cmd')

try:
    while True:
        time.sleep(1)

except KeyboardInterrupt:
    print "exiting"
    client.disconnect()
    client.loop_stop()

Speech part (uses mpg123 to play sound though speaker)

#!/bin/bash
#set -x

INPUT=$*
input2=$(echo $INPUT | base64)
echo "$input2 = $INPUT" >> /home/pi/cache/files-text-relation
if [ -f /home/pi/cache/$input2.mp3 ] ; then
mpg123 -q /home/pi/cache/$input2.mp3 1>/dev/null 2>/dev/null
else
echo not cached
STRINGNUM=0

ary=($INPUT)
for key in "${!ary[@]}"
  do
    SHORTTMP[$STRINGNUM]="${SHORTTMP[$STRINGNUM]} ${ary[$key]}"
    LENGTH=$(echo ${#SHORTTMP[$STRINGNUM]})
    #echo "word:$key, ${ary[$key]}"
    #echo "adding to: $STRINGNUM"
    if [[ "$LENGTH" -lt "100" ]]; then
      #echo starting new line
      SHORT[$STRINGNUM]=${SHORTTMP[$STRINGNUM]}
    else
      STRINGNUM=$(($STRINGNUM+1))
      SHORTTMP[$STRINGNUM]="${ary[$key]}"
      SHORT[$STRINGNUM]="${ary[$key]}"
    fi
done

for key in "${!SHORT[@]}"
  do
    #echo "line: $key is: ${SHORT[$key]}"

    echo "Playing line: $(($key+1)) of $(($STRINGNUM+1))"
    NEXTURL=$(echo ${SHORT[$key]} | xxd -plain | tr -d '\n' | sed 's/\(..\)/%\1/g')
echo $NEXTURL
    mpg123 -w $input2 -q "http://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&q=$NEXTURL&tl=En-us"
    ffmpeg -i $input2 -codec:a libmp3lame -qscale:a 2 /home/pi/cache/$input2.mp3
mpg123 /home/pi/cache/$input2.mp3
done
fi

set msg.payload to “Doorbell”
and Mqtt topic to “speech/cmd”

To be continued !