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

GNU/Linux at 4% "Market Share" (Even According to Steam Survey)
Another milestone
Ahead of Mass Layoffs Microsoft Tries to Rebrand or Redefine XBox (Because the XBox is Tentatively Dead)
2026 will be the last year of XBox in all likelihood
Richard Stallman (RMS) Announces His Georgia Talk 2.5 Weeks in Advance
A lot earlier than usual
 
Gemini Links 06/01/2026: Collective Responsibility, Pico2DVI, and TV Detox
Links for the day
Microsoft Loves Freedom, Democracy... and Linux? No, Microsoft Laying Off Because "Microsoft Loves Linux" Was Failed Posturing, Its Former Staff Moves to GNU/Linux
"What are the running totals for IBM and Microsoft layoffs?"
Mozilla's Assisted Suicide, Assisted by GNOME
Firefox is meant to get better all the time, but instead it gets worse
Links 06/01/2026: Neglect of the Elderly, Abandonment of International Laws
Links for the day
Links 06/01/2026: More Reports Point to Mass Layoffs at Microsoft (Later This Month), Greenland/Denmark Cautions the Dictator Who Illegally Invaded Venezuela
Links for the day
Internet Policy/Net Reality: You Must Never Ever Rely on Google (no "S.E.O." Either)
Stack Overflow is dying
Dr. Andy Farnell on Technology That Harms People (and Lack of Regulation Which is Needed to Address This Problem)
Dr. Farnell's article is long but well worth reading
GNU/Linux Rising to 5% in Cameroon and It's Hardly the Exception
"AI" is just a smokescreen as losses pile up
Rumours: Microsoft to Lay Off 12,500-25,000 Workers Soon (Tentatively Wednesday, 15 Days From Now)
"Layoffs are coming third full week of Jan. Likely 21st but these things can move around a bit based on last minute developments."
EPO People Power - Part XXVI - European Media Has Become Part of the Problem
it is as clear as daylight that Cocainegate is real
IBM 2026 "Organizational Change/s" Means Layoffs Resume Soon, Some Claim "Forever Layoffs."
It's about "narrative control"
Microsoft Layoffs in January 2026
Get ready
Google Still Boosting Slopfarms
Slopfarms will probably all perish as soon as Google News quits sending them visitors
Links 06/01/2026: Cryptocurrency Scam Emails and Greenland's Fear of Getting 'Venezuelad'
Links for the day
Links 06/01/2026: DIY Projects and Inertial Music
Links for the day
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Monday, January 05, 2026
IRC logs for Monday, January 05, 2026
To The Register MS, ARM Means Microsoft Windows (Follow the Money)
the Free software community can campaign and run sites (like the one below), but it cannot afford to bribe so-called 'news' sites like Microsoft and its OEMs do
IBM's CEO Makes No Sense
"IBM CEO Aravind Krishna on what’s really driving tech layoffs"
Links 05/01/2026: Tensions in Korea, Ukrainians See "Double Standard" in a US Russia-Style Invasion
Links for the day
Gemini Links 05/01/2026: Farewell to CBS Reality, Being On-Call, Digital Ad Spendings
Links for the day
Remember That Nobel Prizes Are All Named After the Inventor of Explosives (Even a "Nobel Prize for Peace")
These rewards are only as valuable as the reputation they earn for themselves
Baidu and Yandex Have Overtaken Microsoft in Asia
how about all the Bing layoffs?
Googlebombing for Bill Epsteingate
Maybe the slopfarms too can help him cover up
Of Course GNU/Linux Has Reached All-Time High in Africa in 2026
Africa will, on average, gravitate towards Free software or whatever costs less
From GNU/Linux Boosting to Slop-Boosting Career
It is sad to see someone who devoted many years of his life producing GNU/Linux stories stooping down to this "AI" boot-licking
IBM Buys, Then Disposes/Sacks, the Staff (That It Paid For)
Any money gained is spent buying some more companies to add/join up their revenue, even if the debt surges and there's little integration going on (misfits absorbed)
Time for Microsoft to Rebrand to Fit the Vapourware (Ponzi Scheme)
something between Meta and Alphabet
Links 05/01/2026: Slop Ruining Children's Minds, "Complicity of the Press in US Violence"
Links for the day
Microsoft's Windows Falls Below 20% in the UK
After a lot of years of advocacy and hard work
The Real GNU Anniversary (Not Manifesto or Announcement) is Today
the development, not the manifesto
GNU/Linux Usage Said to Have Doubled in Oceania
it's hard to discount or dismiss Oceania as a bunch of "coconut islands"
There's No Such Thing as "AI Godfather", Stop Repeating This Pure Nonsense!
Infantile or corruptible media that plays along with slop or uses slop will perish
Gemini Links 05/01/2026: "Poverty and Hunger", "Entrepreneurial Family", "Abandoning Obsidian for Logseq"
Links for the day
Links 05/01/2026: A Shrinking Canadian Economy, Brigitte Bardot's Environmentalism Recalled, Unredacted Epstein Files
Links for the day
Microsoft Allegedly Uses Performance Improvement Plans (PIPs) to Hide the Massive Scale of Company-Wide Layoffs
Just like IBM; they meanwhile talk a bunch of nonsense about "AI" to distract from their commercial calamity
Battles Are Won in the Court of Public Opinion
Many "systems" rely on the mere perception or appearance of legitimacy
No, Writing Isn't in Decline, Some of the Large and Centralised Platforms Are
Slop isn't really competition, just a passing fad and pure noise
GNU/Linux Share in Mongolia More Than Doubles
they probably lack any genuine excitement for "hey hi PCs"
Whistleblowing is About Understanding Boundaries and Risks
The bottom line is, people typically find out the truth at the end
EPO People Power - Part XXV - While EPO Managers Snort Cocaine the Staff Compiles 'Insurance Files' to Expose EPO Corruption
In this increasingly authoritarian world we need more whistleblowers
"The European Patent Reform" That Represents a Gross Violation of Laws, Constitutions, and Conventions (in Order to Make the Rich Even Richer, Mostly Outside Europe)
How far and how long will EPO corruption go?
The Reputation Issue Is Not Our Fault
Trying to squash words (and people) merely diverts more attention to them
GNU/Linux Distribution "Ultimate Edition" Fixes Its Web Site (Apparently Compromised Months Ago)
they dealt with the issue before media shame and a catastrophe of trust
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Sunday, January 04, 2026
IRC logs for Sunday, January 04, 2026
Gemini Links 04/01/2026: 64-bit Addressing and 39th Chaos Communication Congress
Links for the day
Windows Was Always the Punchline
What did we count to calculate taxes?
GNU/Linux Surges to About 4% in Peru This Year
one of the poorest counties in America
This Year Our Adoption of IRC Turns 18
We have used IRC for this site since 2008
The Doors Are Closing, Windows Closing Too
Microsoft wants more vendor lock-in, but at risk that this desire will simply alienate and drive away many users
The FSF's Program Manager, Dr. Miriam Sabrina Bastian, Left in October to Lead Climate School
We are not sure why Miriam Bastian decided to leave the Free Software Foundation (FSF)
Outline of Slop, LLMs, IBM, and Things to Come
This coming week and weekend will be very productive irrespective of how much "news" gets published by other sites
Links 04/01/2026: War Without Borders, "Large Hadron Collider Being Shut Down"
Links for the day
Links 04/01/2026: US Imperialism in Greenland and Venezuela, "Climate Protesters Face Greater Risk of Crackdown Amid Rising Authoritarianism"
Links for the day
2026 Should be the Year We All Stop Saying "AI" and Call Things What They Really Are
Don't give anyone the satisfaction of this misguided belief there's any intelligence there
Ponzi Schemes Are Useful (to Corrupt CEOs)
Pathetic, corruptible so-called 'media' is bagging bribes to perpetuate the lies about "AI" (slop)
GNU/Linux at All-Time High in Algeria
In 2026 it hit a new all-time high
Online Mobbing (and Worse) Disguised as 'Free Speech'
People who say they believe in "free speech" have been trying hard to silence RMS and squash the FSF
A 'Cancer That Attaches Itself' to Bulgaria?
"Cancer" is what Microsoft called GNU/Linux
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Saturday, January 03, 2026
IRC logs for Saturday, January 03, 2026
Body-Shaming Using Fakes
a lot of the people who casually claim "defamation" are themselves defaming loads of people every day
GNU/Linux "Market Share" in Switzerland More Than Doubled Last Year, Based on statCounter
GNU/Linux continues its considerable growth
EPO People Power - Part XXIV - Today or Tomorrow You Should Write to National Representatives (Delegates) at the EPO in Your Country
Keep up the pressure!
Red Hat and IBM Layoffs, Staff Kept Quiet About it, WARN Act Skirted/WARN Notices Avoided
What a terrible company to be in
XBox Layoffs Imminent, More Appalling Sales Figures Published
Expect many layoffs in the gaming division