Draw histograms on Pimoroni's Unicorn HAT with colorful approach to temporal resolution
Silicorn takes in values from 0 to 100 from stdin and draws on the HAT.
It will remember the last 128 values, average them and change color according to a built-in heatmap (heatmap.c)
.
HAT-o-graming modest CPU utilization from a Catalyst switch:
This is what silicorn expects as input:
pi@raspberrypi $ while :; do shuf -i 1-100 -n1 ; sleep 0.6 ; done
46
83
0
14
One value per line, terminated by \n
(end-of-line).
Float is good too, so:
12.023
0
0.12
100.0
will all get you some LED action.
0
(zero) is represented one pixel high. Otherwise you wouldn't know the difference between silicorn not running anymore or your input just feeding in zeros. That being said, silicorn doesn't break.
Alright alright, if you fuzz it really hard it will probably shit rainbows from all I/Os. Try it.
Edit hat.c
:
#define BRIGHTNESS 6 /* 0-255 */`
Edit debug.h
:
#define DEBUG 1
git clone https://github.com/snobu/silicorn
cd silicorn
sudo make
sudo `while :; do shuf -i 1-100 -n1 ; sleep 0.6 ; done | ./silicorn`
pollsnmp.sh:
#!/usr/bin/env bash
SILICORN=/tmp/silicorn/silicorn
SNMP_COMMUNITY=public
SLEEP_BETWEEN_POLLS=5 #seconds
while :
do
snmpwalk -Oqv -v2c -c $SNMP_COMMUNITY $1 .1.3.6.1.4.1.9.2.1.56
sleep $SLEEP_BETWEEN_POLLS
done | $SILICORN
pi@raspberrypi $ chmod +x pollsnmp.sh
pi@raspberrypi $ sudo ./pollsnmp.sh 10.1.1.1
10.1.1.1 = Cisco box
.1.3.6.1.4.1.9.2.1.56 = SNMP MIB for CPU utilization over the last five seconds
How to Collect CPU Utilization on Cisco IOS Devices Using SNMP
pi@raspberrypi $ wget -qO- "http://finance.yahoo.com/d/quotes.csv?s=MSFT&f=snl1"
"MSFT","Microsoft Corporation",42.905
pi@raspberrypi $ wget -qO- "http://finance.yahoo.com/d/quotes.csv?s=MSFT&f=snl1" | awk -F, '{print $3}'
42.905
nasdaq.sh:
#!/usr/bin/env bash
while :
do
wget -qO- "http://finance.yahoo.com/d/quotes.csv?s=MSFT&f=snl1" |
awk -F, '{print $3}'
sleep 60
done | ./silicorn
pi@raspberrypi $ chmod +x nasdaq.sh
pi@raspberrypi $ sudo ./nasdaq.sh