Bonum Certa Men Certa

Using a Single-Board Computer to Monitor IPFS

IPFS lights-based monitoring on self-hosted SBC
IPFS lights-based monitoring on self-hosted SBC (blue is for status, green and red for upstream and downstream payloads)



Summary: IPFS is light and simple enough to run from one's home, even on a low-voltage machine, and the code below can be used as a baseline for monitoring IPFS activity 24/7




#!/usr/bin/python3
# 2019-04-22
# 2020-11-07



from blinkt import set_pixel, show from random import randint,random,shuffle,randrange from time import sleep import argparse import signal

def solid(r,g,b,s): while True: for pixel in range(8): set_pixel(pixel, r, g, b) show() sleep(0.1)

def random_lights3(): while True: for pixel in range(8): r = randint(0, 255) g = randint(0, 255) b = randint(0, 255) set_pixel(pixel, r, g, b) show() sleep(0.1)

def random_lights2(): while True: p=range(8) p=sorted(p, key=lambda x: random()) for pixel in p: r = randrange(0, 255, 16) g = randrange(0, 255, 16) b = randrange(0, 255, 16) set_pixel(pixel, r, g, b) show() sleep(0.1)

def random_lights1(): while True: p=range(8) p=sorted(p, key=lambda x: random()) for pixel in p: r = randrange(0, 255, 8) g = randrange(0, 255, 8) b = randrange(0, 255, 8) set_pixel(pixel, r, g, b) show() sleep(0.1)

def spacer(r,g,b,seconds): while True: for pixel in range(8): set_pixel(pixel, r, g, b) next = (pixel+1)%8 set_pixel(next, 0, 0, 0) show() sleep(seconds)

def reversed_spacer(r,g,b,seconds): while True: for pixel in reversed(range(8)): set_pixel(pixel, r, g, b) prev = (pixel-1)%8 set_pixel(prev, 0, 0, 0) show() sleep(seconds)

def cylon(r,g,b,seconds): while True: for pixel in reversed(range(8)): set_pixel(pixel, r, g, b) prev = (pixel-1)%8 if prev < pixel: set_pixel(prev, 0, 0, 0) show() sleep(seconds) for pixel in range(8): set_pixel(pixel, r, g, b) next = (pixel+1)%8 if next > pixel: set_pixel(next, 0, 0, 0) show() sleep(seconds)

def pulsed_bar(r,g,b,seconds): steps=8 while True: for fade in reversed(range(steps)): r2=r*(fade+1)/steps g2=g*(fade+1)/steps b2=b*(fade+1)/steps # print (fade) for pixel in range(8): set_pixel(pixel, r2, g2, b2)

show() sleep(seconds) for fade in range(int(steps/1)): r2=r*(fade+1)/steps g2=g*(fade+1)/steps b2=b*(fade+1)/steps for pixel in range(8): set_pixel(pixel, r2, g2, b2)

show() sleep(seconds*0.5)

def ipfs(r,g,b,seconds): steps=4 # how many stages in gradient brightness=0.5 # how bright the lights will get bluebright=100 # the brightness of the blue light in the middle (0-255), albeit overriden by input dim=1 # increase to dim down the lights run = 0 # running count for periodic file access while True: # run always (until interruption) run=run+1 # first, open from files the required values, which change over time if (int(run) % 50 == 1): with open(r'~/RateIn', 'r') as f: # open from file the IN value # print(r) lines = f.read().splitlines() r=int(lines[-1]) # read the value # r=int(map(int, f.readline().split())) # prototype, for multiples (stale)

with open(r'~/RateOut', 'r') as f: # open from file OUT value # print(g) # show values, debugging lines = f.read().splitlines() g=int(lines[-1])

with open(r'~/Swarm', 'r') as f: # open from file Swarm value # print(g) # show values, debugging lines = f.read().splitlines() bluebright=int(lines[-1])/2 # print(bluebright)

for fade in reversed(range(steps)): # fade in effect # print(g2) # show values again, debugging # print(r2) r2=r*(fade+1)/steps/dim g2=g*(fade+1)/steps/dim b2=b*(fade+1)/steps/dim

# print(g2) # show values again, debugging # print(r2)

# print (fade) for pixel in range(3): # first 3 LED lights set_pixel(pixel, r2/20, (g2*brightness)+(pixel*1), b2/20)

for pixel in range(5,8): # the other/last 3 lights set_pixel(pixel, (r2*brightness)+(pixel*1), g2/20, b2/20) if (bluebright==0): set_pixel(3, 255, 255, 255) set_pixel(4, 255, 255, 255) else: set_pixel(3, 0, 0, 0) set_pixel(4, 0, 0, bluebright)

show() sleep(seconds/r*r+0.1) for fade in range(int(steps/1)): # fade out effect r2=r*(fade+1)/steps/dim g2=g*(fade+1)/steps/dim b2=b*(fade+1)/steps/dim

for pixel in range(3): set_pixel(pixel, r2/20, (g2*brightness)+(pixel*1), b2/20)

for pixel in range(5,8): set_pixel(pixel, (r2*brightness)+(pixel*1), g2/20, b2/20) set_pixel(3, 0, 0, bluebright) set_pixel(4, 0, 0, 0) show() sleep(seconds/g*g+0.1)

def flashed_bar(r,g,b,seconds): while True: for half in range(4): set_pixel(half,r,g,b) for half in range(4,8): set_pixel(half,0,0,0) show() sleep(seconds) for half in range(4,8): set_pixel(half,r,g,b) for half in range(4): set_pixel(half,0,0,0) show() sleep(seconds)

def handler(signum, frame): print("\nSignal handler called with signal", signum) exit(0)

signal.signal(signal.SIGTERM, handler) signal.signal(signal.SIGINT, handler)

# read run-time options

parser = argparse.ArgumentParser(description="Drive 'blinkt' 8-pixel display.") parser.add_argument("pattern", help="name of light pattern: \ random[1-3], spacer, reversed_spacer, cylon, pulsed_bar, flashed_bar") parser.add_argument("r", metavar="r", type=int, help="red channel, 0-255") parser.add_argument("g", metavar="g", type=int, help="green channel, 0-255") parser.add_argument("b", metavar="b", type=int, help="blue channel, 0-255") parser.add_argument("timing", metavar="s", type=float, \ help="rate of binking in seconds") options = parser.parse_args()

pattern = options.pattern.lower() r = options.r g = options.g b = options.b s = options.timing

if pattern == "solid": solid(r,b,g,s) elif pattern == "random3": random_lights3() elif pattern == "random2": random_lights2() elif pattern == "random1" or pattern == "random": random_lights1() elif pattern == "spacer": spacer(r,g,b,s) elif pattern == "reversed_spacer": reversed_spacer(r,g,b,s) elif pattern == "cylon": cylon(r,g,b,s) elif pattern == "pulsed_bar": pulsed_bar(r,g,b,s) elif pattern == "ipfs": ipfs(r,g,b,s) elif pattern == "flashed_bar": flashed_bar(r,g,b,s) else: print("Unknown pattern") exit(1)

exit(0)





Example runtime: run-blinkt-ipfs.py ipfs 0 0 0 0.00

Based on or derived from baseline blinkt scripts; requires the hardware and accompanying libraries being installed on the system.

For the code to run properly in the above form, given that it takes input from files, the IPFS values need to be periodically written to disk/card, e.g. for every minute of the day:

* * * * * ipfs stats bw | grep RateIn | cut -d ' ' -f 2 | cut -d '.' -f 1 >> ~/RateIn * * * * * ipfs stats bw | grep RateOut | cut -d ' ' -f 2 | cut -d '.' -f 1 >> ~/RateOut * * * * * ipfs swarm peers | wc -l >> ~/Swarm

These lists of numbers can, in turn, also produce status reports to be shown in IRC channels. When our git repository becomes public it'll be included (AGPLv3).

Recent Techrights' Posts

Banning Things Versus Teaching People the Reason/s to Shun/Boycott Those Things
Prohibition has its limits
European Patent Office (EPO) Crisis: Huge EPO Strikes, Profound Corruption, and Cocaine Use by Managers Tolerated
These strikes won't be ending any time soon
 
SLAPP Censorship - Part 100 Out of 200: Interlude and Outline of the First Half, 3+ Months That Got Us Death Threats Connected to Brett Wilson LLP (and Cyber Attacks That Are Difficult to Attribute)
This week we plan to have a good time
Links 07/06/2026: NASA's Mars Maven Declared Dead, Telegram Founder Pavel Durov Bemoans Russia's Crackdown
Links for the day
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Saturday, June 06, 2026
IRC logs for Saturday, June 06, 2026
Gemini Links 07/06/2026: How to Train Your Dragon (2010) and "Six Days of Play"
Links for the day
Links 06/06/2026: 'Epstein Problem' in Board of Directors of Microsoft, Surveillance Giant Google Under Legal Threats for Online Misuses
Links for the day
Software Freedom Takes a Lot More Than Coding
some of the roles in the Free software community that don't receive (m)any grateful words
Ubuntu is Losing to Other GNU/Linux Distros
"Linux Mint"
Old Articles Explaining That Patents - Especially Software Patents - Are Bad for Innovation
We've omitted more than 50% of the articles we had gathered as candidates for inclusion
Why GNU and FSF Will Choose AV1 Over AV2 (It's More Widely Supported)
for the foreseeable future they'll stick with AV1
Mass Layoffs (RAs) and PIPs (Excuses to Sack) at IBM: Insiders Tell No Relation to Actual Performance
If many thousands are impacted by this, then certainly it is newsworthy
Links 06/06/2026: LinkedIn Infested With Spies, Ethernet WiFi Router On Pi Pico 2W
Links for the day
25 Years With PalmOS
That my Palm PDA still works in 2026 (not in mint condition but close to that) says a lot about the "build quality" of gadgets 20+ years ago
Why We Dumped Online Shopping (Groceries)
subsidies kept the "online" stuff artificially cheap
Microsoft Fell to All-Time Low in Monaco Last Month
So says statCounter anyway
Lawsuits That Don't Work
Not as expected anyway
SLAPP Censorship - Part 99 Out of 200: Graveley and Garrett Seem to Have Crashed Brett Wilson LLP (Worse Than Taking Russian Oligarchs as SLAPP Clients)
a state of disarray
Microsoft Has Spent Months Preparing Lists of People to Cull in Massive Wave of Layoffs (Allegedly Start of July)
There is some consensus that we're weeks away from mega-layoffs at Microsoft
Gemini Links 06/06/2026: "Competing" With LLMs and "Automation of Any Kind"
Links for the day
Links 06/06/2026: 'Linux' Foundation Openwashing Slop on Microsoft's Payroll, Ukraine Wants Permanent Ceasefire With Russia
Links for the day
50% of the 'Gains' Made by "Quantum" Hype Already Evaporated
"It was all hype about quantum nonsense. Heading back to reality now. Expect sub-$220 after earnings release next month."
Heap of Trash Online, Not Just the Fault of LLM Slop But Enabled by Slop
Google News has just promoted a pair of prolific slopfarms
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Friday, June 05, 2026
IRC logs for Friday, June 05, 2026
Links 05/06/2026: Lawyers in Trouble for Citing Cases That Don't Exist (Slop Too Bad to Justify Costs; Even It It Did Work, It Would Still be Far Too Expensive)
Links for the day
Gemini Links 05/06/2026: Bears in the Streets, WWII Revisionism, and Westworld
Links for the day
IBM is "Making an Exit". Only the Executives Will Get Rich.
failure disguised as success
Microsoft's LinkedIn Called "Dying Platform" by One Who Worked There
The co-founder of LinkedIn has just stepped down too
GAFAM (Google, Amazon, Facebook, Apple, Microsoft) Layoffs Are Due to Surging Debt, or About 120 Billion Dollars Borrowed in One Year Alone
It's well above 150 billion dollars if one adds Oracle
2026 is the Year of Blockchains, Says IBM's CEO a Decade Ago?
"falling upwards"
After One Jeffrey Epstein Associate 'Leaves' Microsoft's Board Another Jeffrey Epstein Associate Steps Down, Workers Concerned About the Mass Layoffs
How many more loans can Microsoft receive? Those loans are becoming increasingly risky.
IBM Exploits Overambitious, Hungry Young Men to Help the "Great Quantum Hype Campaign" (Pumping the Stock Based on Deliberate Misinformation or Outright Disinformation)
The boot-licking campaign is live...
What Will Likely Happen When the Slop Bubble Pops (and When It'll be Widely Accepted That It Popped)
all the "most successful" slop companies are so deep in debt
The Register MS is Part of the Problem, It's Publishing "AI" SPAM Because it's Paid by Chinese Military-Connected Firms
Given that The Register MS is run by a Microsofter (since last summer), destruction seems inevitable
Most Coders Used to be Women, Not Men (and Men Who Dropped Out of College Now Plunder Everything They Can)
"Ethics For Hackers"
IBM's CEO Does Not Use GNU/Linux, So Why Did He Suggest Buying Red Hat Only to Lay Off Its Workers, Market Slop Instead of Linux, and Sack UNIX Professionals?
Shortly after IBM had bought Red Hat and there were mass layoffs we pointed out that Red Hat's CEO was not using GNU/Linux
If You're Not Focusing on Software Freedom, All You'll Get is Slopware and Buzzwords
If you're not focusing on attaining Software Freedom (and remember "Linux" is just a brand), then you're losing sight of the goals that actually matter
Red Hat/IBM: Microsoft is Our Partner of the Year
Red Hat is a really bad gravy
Gemini Links 05/06/2026: Enshittification of Institutes for Project Management, Codebases Contaminated With Slop, Personal Stories
Links for the day
Communicating With Freedom - Part II - Quibble Breathing New Life Into LibreJS
Notice how work on one thing led to thousands of lines of code added to a mostly dormant (but nevertheless important) project
Slop Has no ROI, an Economy Built on False Assumptions of Slop is Doomed
we're all going to suffer from this Ponzi scheme
Links 05/06/2026: More GAFAM Layoffs, Google Faces Regulatory Crackdown in UK Over Plagiarism in "AI" Clothing
Links for the day
Rumour That Layoffs at Microsoft Will Kick Off on July 1st, 2026 (Impacting 10,000 or More Workers)
this is what the rumour mill or the word through the grapevine is
Mission:Libre, Which Teaches Young People Free Software Ideals, Needs Financial Backing
plea for assistance with Mission:Libre
The Slop Ponzi Scheme is a Problem and Threat to All of Us (Even Those Who Don't Invest in or Use Slop at All)
This problem is systemic, not contained
"Blind Justice" Examines the Solicitors Regulation Authority (SRA) Turning a Blind Eye to Abuse by British Solicitors
We have some jaw-dropping examples of how the SRA does not do actual regulation - to the point where its staff does not actual work and does not look into any evidence at all!
7 Days From Now the FSF's Founder Gives a Talk in Bern, the FSF Has Just Advertised This
Meanwhile the FSF (or GNU) processes and uploads many recent talks by RMS
European Patent Office (EPO) Series: Down But Not Out – Costa's Comeback
he managed to secure a top-level EU position in June 2024
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Thursday, June 04, 2026
IRC logs for Thursday, June 04, 2026