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

Longtime Red Hat Staff: Maybe Just Disable 'Secure Boot'
A refreshing take from Adam Williamson
A Dozen Observations About "UEFI 9/11" Deflections
What we are expected to see, tentatively
The World's Richest Ponzi Scheme (Faking Value Using Net Waste)
The higher they go the harder they fall
We Could Dual-Boot Back in the 1990s, Why Has This Become So Difficult?
And prone to breakage
Slopwatch: Google News is Still Promoting Many Fake Articles About "Linux", in Effect Rewarding Misinformation and Plagiarism
things continue to deteriorate
They Say That People Are Afraid of or Worried About "Hey Hi", But the Worriers Should be the Fools Who Invested in It
At the end of the day nobody should worry more than those who invested their money in this bubble
 
Links 11/09/2025: "Hey Hi" Ponzi Schemes at Oracle (Unpaid Contracts) and Cindy Cohn is Leaving the EFF
Links for the day
Gemini Links 11/09/2025: Playdate Console, Dichotomy between the Real and the Digital
Links for the day
The Microsoft AstroTurfing and Microsoft-Led Blame-Shifting Tactics Are Ahead of Us
Of course it has nothing to do with security, it's about control, i.e. them controlling everything
Celebrating Assassination is Bad Because It Legitimises Assassination of the People You Like, Too
Condoning or even celebrating political assassinations is bad optics (and taste)
Being Conditioned to Accept Unreliable Computer Systems That Fail With Black Screen of Death (BSoD)
Welcome to 2025
New Series: The Coup Against GNU/Linux Has Begun
today, this year in particular, we shall also focus on Secure Boot, which is sold based on a lie and tortures many computer user
New Paper on "BYOVD, but in firmware. Signed UEFI shells, vulnerable modules offer new paths for Secure Boot bypasses."
One might say digital "security theatre"
Links 11/09/2025: Oracle Layoffs, Drunk Pilots in Japan Airlines, US-Korea Tensions Grow
Links for the day
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Wednesday, September 10, 2025
IRC logs for Wednesday, September 10, 2025
Xubuntu Site Compromised
Let's hope it is not a security breach
Links 10/09/2025: Retaliation at Facebook and Microsoft Reveals Almost 100 Security Holes
Links for the day
Gemini Links 10/09/2025: Annihilation of Self, The Future Eaters, and Leaving Academia
Links for the day
Harassment evidence: franceinfo's Clara Lainé report on Ubisoft prosecution
Reprinted with permission from Daniel Pocock
Links 10/09/2025: Microsoft Layoffs in "RTO" Clothing and Windows TCO, GitHub TCO
Links for the day
Blaming Everything on China
TikTok works for China. GAFAM works for fascists.
People Get Tired of "Hey Hi" (AI), Unlike the Subservient Money-Obsessed Media That Gets Paid to Pretend This Bubble Still Matters
"crash will be way bigger than dot.com burst in 90s. and that was Internet, actually transformative technology, not this expensive AI toy with direct dependency on the energy input which is not scalable"
Brett Wilson LLP Accepts That the Serial Strangler From Microsoft Filed a Case That Also Implicates My Wife (Everything is Connected)
They used to pretend that there were two separate cases
10 Reasons to Disable (or Enable) UEFI Secure Boot
Tomorrow the "trusted corporation" Microsoft will see a certificate expire
Gemini Links 10/09/2025: Hospital and Large Feeds
Links for the day
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Tuesday, September 09, 2025
IRC logs for Tuesday, September 09, 2025
The Bluewashing of Red Hat is Being Completed, Many Staff Understand They'll be Made Redundant
Jim AllowHurst (Whitehurst) is meanwhile promoting Microsoft's agenda from within other companies
Throwing Away "Old" Computers (Mozilla and Other Climate Deniers)
Mozilla is not leftist
statCounter Sees GNU/Linux Exceeding 10% in Bulgaria This Month
What can Microsoft still do to stop GNU/Linux?
Dark Patterns
Microsoft saying "security" is like a Convicted Felon in the White House saying "law and order".
It's Almost Fall (Autumn)
To "Facebook prison" you are bound
Bruce Schneier About "Secure Boot"
Bruce Schneier isn't a fan of "Secure Boot"
Links 09/09/2025: Microsoft Mass Layoffs Again and "RTO" (Timed Like It Serves as a Distraction From the Mass Layoffs)
Links for the day
RMS Told Microsoft to Stop 'Secure Boot' (He Even Went There to Say That), But They Didn't Listen
Dr. Stallman (RMS) assumed that speaking to sociopaths would work
What Richard Stallman Told Me About 'Secure' Boot in 2012
"if the user doesn't control the keys, then it's a kind of shackle"
Those Who Helped Microsoft Weaponise "Secure Boot" Against GNU/Linux and BSDs Are Fleeing
Microsofters doing what they do best: they evade accountability
Simple is Better, Simplicity is Power
That is "the advantage of having commodity GNU/Linux systems," an associate notes
Much Ado About Nonsense
Microsoft Lunduke is still all dramatisation and sensationalism
Current Events in France
It needs to dump Microsoft and other GAFAM (US) giants, move to Free software
Further Media Cut-downs
media reporting about the media being cut
Links 09/09/2025: US-Korea Tensions and Meta Whistleblowers
Links for the day
Gemini Links 09/09/2025: Moon Eclipse and ROOPHLOCH Reports
Links for the day
Links 09/09/2025: “Torrents of Hate” and Political Crisis in France
Links for the day
Gemini Links 09/09/2025: "Dedigitizing" and Forgejo on FreeBSD
Links for the day
Google News (Not Just Google Search) Lets Itself by Gamed by One Slopfarm - to the Point Almost Half of "Linux" News is Bot-Produced Plagiarism (LLM Slop With Slop Images)
That says a lot about what Google thinks of quality, even in Google News
Bill Gates-Funded Media Inadvertently Refutes the Microsoft Lie That in 2025 Microsoft Had Just Two Waves of Layoffs
There were about 12 rounds of layoffs so far in 2025
Official SUSE Blog Still Uses LLM Slop (Bots) to Make Fake Articles (Marketing)
The company is all about sound bites
Companies Realise That Slop Doesn't Work as Advertised, Accordingly Dump It
"Hype dims as a country-wide survey of US corporations shows a sudden drop-off in AI use among firms with more than 250 employees."
Microsoft-Funded Lawsuits Against Critics of UEFI 'Secure Boot'
Remember that no company (or law firm) ever survives collaborations with Microsoft
From theregister.co.uk to theregister.com (US) to The Register MS (Run by Microsoft Operatives) and theregister.ai
The best way to break this racket (or cycle of hype and harm) is to break the chains of funding
Open Source Initiative (OSI) Culture of Censorship Necessitates More Speech
The OSI bans dissent or people who merely point out that the OSI is abusive
How to Reach Us Discreetly (Other Than Encrypted E-mail)
We're still managing to maintain a 100% source protection record. We soon turn 19.
LLMs Are Vastly Worse Than a Waste of Energy and the Externalities Are Huge
Worse than just higher power bills for everybody
LLMs Versus Search (Not Replacing Search But Engaging in DDoS Attacks Against Web Sites That Permit Searching)
The state of the Web isn't just bad; it's utterly terrible
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Monday, September 08, 2025
IRC logs for Monday, September 08, 2025
It's Only the Second Week of September and Already Two Waves of Layoffs at Microsoft, Slopfarms and Microsoft-Funded Sites Spin It as "AI Investments" Rather Than Commercial Failure
A very large third one expected next week
The UEFI 9/11 - Part IX - Shunning Old Computers (in 2023 the Certificate Was Updated/Overridden, Underlying Aim May Be Herding/Forcing People to Get TPM and Other 'Novel' Restrictions)
the "upgrade treadmill"