Skip to content

snobu/silicorn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

silicorn

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).

Pics or it didn't happen

HAT-o-graming modest CPU utilization from a Catalyst switch:
lowcpu

CPU is too damn high!
highcpu

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.

Adjust brightness (optional)

Edit hat.c:

#define BRIGHTNESS      6 /* 0-255 */`

Enable DEBUG output (optional)

Edit debug.h:

#define DEBUG 1

Build

git clone https://github.com/snobu/silicorn
cd silicorn
sudo make

Test Run

sudo `while :; do shuf -i 1-100 -n1 ; sleep 0.6 ; done | ./silicorn`

Alright, what do i do with this thing?

Read CPU utilization over SNMP and plot every 5 seconds

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

Plot NASDAQ real time price for MSFT

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

About

Draw histograms on Pimoroni's Unicorn HAT with colorful approach to temporal resolution

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published