You are not logged in.

#1 2021-04-16 10:11:02

jet14
Member
Registered: 2021-04-16
Posts: 24

[SOLVED] Hard disk activity lights program required

Hello I have an Acer laptop and it does not have an LED indicator for hard drive activity, can someone point to a good program, i've searched everywhere and cant find one,
I have arch linux on cinnamon desktop, I want program to flash red/green icons forwhen the hard disks are being read/written.
I have found and applet but it shows a graph and no's but i would like flashing icons in panel.
can any programmers out there knock a program out since none available, i have seen them for windows but not arch linux
please somebody help thanks

Last edited by jet14 (2021-04-18 18:09:13)

Offline

#2 2021-04-16 12:46:38

Morn
Member
Registered: 2012-09-02
Posts: 886

Re: [SOLVED] Hard disk activity lights program required

Not a dock app, but this program can apparently flash your Caps Lock LED for hard drive activity: https://github.com/MeanEYE/Disk-Indicator Might be worth a try…

Offline

#3 2021-04-16 12:52:52

jet14
Member
Registered: 2021-04-16
Posts: 24

Re: [SOLVED] Hard disk activity lights program required

My silly laptop doesnt have caps lock or num lock led also, thanks for trying. Any programmers out there ?

Offline

#4 2021-04-16 14:05:45

Morn
Member
Registered: 2012-09-02
Posts: 886

Re: [SOLVED] Hard disk activity lights program required

Still not a dock app, but a Python script for the terminal I have cobbled together, based on looking at the Disk-Indicator code. You have to set your block device in the "fn=" line.

If your window manager supports setting a window to hover over everything else, it's kind of neat I think. Real manly men use terminals anyway, not dock apps! smile

import time

fn = "/sys/block/sda/stat"
ro, wo = 0, 0

while True:
	f = open(fn).read()
	f = f.split()
	r, w = f[0], f[4]
	rr, ww = "    ", "    "
	if r != ro:
		rr = "READ"
	if w != wo:
		ww = "WRITE"
	print(u"\u001b[2J")
	print(u"\u001b[31m" + rr, u"\u001b[32m" + ww)
	ro, wo = r, w
	time.sleep(.1)
	

Offline

#5 2021-04-16 14:41:31

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,768

Re: [SOLVED] Hard disk activity lights program required

jet14:  If you would like this thread to be moved, please use the report link and drop the moderators a note.  In the mean time, I am closing your other thread.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#6 2021-04-16 16:05:23

Morn
Member
Registered: 2012-09-02
Posts: 886

Re: [SOLVED] Hard disk activity lights program required

There is also this thing for KDE 4: http://crissi.linux-administrator.com/l … ex_en.html Last release was in 2010 though and who knows if this also works in Cinnamon…

Offline

#7 2021-04-16 16:06:29

jet14
Member
Registered: 2021-04-16
Posts: 24

Re: [SOLVED] Hard disk activity lights program required

Thanks Morn for that quick response, I am running it in a small terminal on top of work space. thanks, Also hopefully if an applet version to go on the bottom panel will be ideal. I have found one which just has static red/green icons and with live disk rate showing. its called Disk read and write speed and is a cinnamon applet.
I am not a programmer but was learning python a while ago and stopped. I think the applets are in GTK or gnome code, if anybody else familiar with writing programs as such could write a program to flash red/green disk or red circle icons on disk activity, thanks all

Last edited by jet14 (2021-04-16 16:08:22)

Offline

#8 2021-04-16 16:26:57

Morn
Member
Registered: 2012-09-02
Posts: 886

Re: [SOLVED] Hard disk activity lights program required

Yes, the problem is that Gnome has moved to shell extensions in Gnome 3. So the old Gnome 2 applet stuff seems to be mostly outdated. Apparently there used to be a a "gnomeapplet" module for Python, but I have no idea where to get it today.

You could try an old Gnome panel Python script, e.g. this one: https://github.com/tomviner/net-panel and see if that works under Cinnamon. If it does, maybe we could modify it to show red and green circles instead…

Offline

#9 2021-04-16 16:49:32

jet14
Member
Registered: 2021-04-16
Posts: 24

Re: [SOLVED] Hard disk activity lights program required

Hi Morn, with the net panel program i am getting error : File "/home/jet/net-panel/ping.py", line 21
    except OSError, e:
                  ^
SyntaxError: invalid syntax

maybe it was coded in python 2 or some modules not write. Maybe you could modify your program to place icons instead or next to words read/write, that will do the job.
I put # in front of that line
but now File "/home/jet/net-panel/ping.py", line 22
    print "Problem calling iwconfig at %s: %r" % (IWCONFIG_PATH, e)
          ^
SyntaxError: invalid syntax
I managed to correct that to python 3 format, so looks like it needs converting to python 3,
I only know basics of python and will not be able to decode or rewrite the code.
I think well leave it as it is. thanks for your help.

Last edited by jet14 (2021-04-16 17:13:01)

Offline

#10 2021-04-16 17:32:50

Morn
Member
Registered: 2012-09-02
Posts: 886

Re: [SOLVED] Hard disk activity lights program required

Yes, that code seems to be for Python 2, it's that old.

You can automatically convert code in a directory from Python 2 to 3 with "2to3 -w *.py". Normally that should give you a valid Python 3 program, at least for relatively simple code like this.

I will investigate this some more. I would also be interested in this panel app if it works in JWM. (My desktop PC does not have a HD light either anymore, the previous one did.) Also, I would then like a similar app with modem-style LEDs for data being uploaded/downloaded. KDE 1 had it (https://commons.wikimedia.org/wiki/File … Center.png), so that totally needs to make a comeback. wink

Offline

#11 2021-04-16 18:13:29

jet14
Member
Registered: 2021-04-16
Posts: 24

Re: [SOLVED] Hard disk activity lights program required

Hi, yes i have the internet speed up down applet from the cinnamon downloads, which show up down arrow and live data speeds, for the hard disk i have the applet which just shows a static round red/green circles and live bytes data. I did see a hard disk sensor but its under gnome-extensions and i couldnt get it going.
When i had the laptop on windows 7, i had a program that worked with flashing red/green sensors.
This new laptop is an acer about 5 years old and had win 10 on it, and it does not have any leds, so i was doing some tests recently and needed these stats to monitor the performance.
Only stuff on gnome and cinnamon type files will work on this cinnamon desktop and the kde uses its own system and wont work on cinnamon.
I will keep researching also.

Offline

#12 2021-04-17 05:48:55

jet14
Member
Registered: 2021-04-16
Posts: 24

Re: [SOLVED] Hard disk activity lights program required

While searching for more programs i did a check under different names and under HDD-LED in git-hub there are quite a few more programs and also using phrase Disk acitivity or Disk monitor brings up similar stuff, i tried quite a few but none working on my system, since some are coded in C or javascipt or other combination or designed for particular models and situations of hardware.

Offline

#13 2021-04-17 08:31:40

seth
Member
Registered: 2012-09-03
Posts: 50,924

Re: [SOLVED] Hard disk activity lights program required

Offline

#14 2021-04-17 10:00:02

jet14
Member
Registered: 2021-04-16
Posts: 24

Re: [SOLVED] Hard disk activity lights program required

HI yes i have this and using it, like i mentioned in a few chats before, it only lacks the icons dont flash but the data is shown live. its ok. really wanted the icons to flash as well!!

Offline

#15 2021-04-17 10:05:35

seth
Member
Registered: 2012-09-03
Posts: 50,924

Re: [SOLVED] Hard disk activity lights program required

They're written in javascript, won't be too hard to change the icons depending on the IO value.
But did yuo really contemplate about the idea of having some permanent flashing distraction in your sight?

Offline

#16 2021-04-17 10:38:07

Morn
Member
Registered: 2012-09-02
Posts: 886

Re: [SOLVED] Hard disk activity lights program required

seth wrote:

But did yuo really contemplate about the idea of having some permanent flashing distraction in your sight?

It's not that bad in practice, although Chromium is really non-stop with its disk writes as verified by gnome-system-monitor.

I think that's why I prefer writes to be green as in my script. Once the system is fully loaded and filesystem data has been cached, you will not see a lot of reads anyway if you have enough free memory for caching. And a blinking green light is less alarming than a red one.

But seriously, what is Chromium writing to disk every other second? What a crazy browser! smile

Offline

#17 2021-04-17 13:00:46

seth
Member
Registered: 2012-09-03
Posts: 50,924

Re: [SOLVED] Hard disk activity lights program required

https://wiki.archlinux.org/index.php/Ch … e_in_tmpfs ?
It just saves stuff all the time, eg. if I'd sigkill this instance, most or all of the text in this form would prevail.

Offline

#18 2021-04-17 13:37:47

Morn
Member
Registered: 2012-09-02
Posts: 886

Re: [SOLVED] Hard disk activity lights program required

Firefox also does this, although to a lesser extent than Chromium it seems. Even if you e.g. just load the Arch Linux homepage and do nothing there, it still writes data every few seconds. So I don't think this is about preserving user content entered into forms.

Offline

#19 2021-04-17 17:30:34

jet14
Member
Registered: 2021-04-16
Posts: 24

Re: [SOLVED] Hard disk activity lights program required

Any of you clever programmers out their able to change the code of the above post # 17 code to flash leds, or can someone write a new program to for cinnamon panel same as #17 applet. thanks.
I had a program under win 7 & win 10 and now run Arch linux on this laptop only 5 years old but they didnt put any leds on it.

Offline

#20 2021-04-17 19:29:13

Morn
Member
Registered: 2012-09-02
Posts: 886

Re: [SOLVED] Hard disk activity lights program required

I think you meant post #13? Yeah, I've looked at that, it's 2,450 lines of JavaScript! Not my idea of "easy". I am more of a Python person. But then again it was seth who claimed it would not be too hard to adapt. So please go right ahead, seth! smile

But of course even if it worked, it would only run on Cinnamon which limits its usefulness, at least to me…

Offline

#21 2021-04-17 19:48:32

koffeinfriedhof
Member
Registered: 2017-11-30
Posts: 89

Re: [SOLVED] Hard disk activity lights program required

Hi!

«Easy» would be to parse /proc/diskstats or if you want to have details /proc/[PID]/io to get the (w)chars read and written per application. See man proc for more details.

Offline

#22 2021-04-17 19:59:59

Morn
Member
Registered: 2012-09-02
Posts: 886

Re: [SOLVED] Hard disk activity lights program required

koffeinfriedhof wrote:

Hi!

«Easy» would be to parse /proc/diskstats or if you want to have details /proc/[PID]/io to get the (w)chars read and written per application. See man proc for more details.

We already have a Python script that displays the wanted information (see post #4), so getting the info is not the problem. The question is how to display that info graphically in the system tray/clock area, ideally without needing thousands of lines of JS and so it works in other WMs except Cinnamon.

Offline

#23 2021-04-17 20:52:15

seth
Member
Registered: 2012-09-03
Posts: 50,924

Re: [SOLVED] Hard disk activity lights program required

    on_gui_icon_changed: function () {
        this.gui_speed.set_reveived_icon(this.gui_read_icon_filename);
        this.gui_speed.set_sent_icon(this.gui_written_icon_filename);
    },

Probably lifted from some network indicator and also probably at least in part written by a code generator.

    update_input_output_info_values: function (info, values) {
        info.previous_sectors_read = info.sectors_read;
        info.previous_sectors_written = info.sectors_written;

        info.reads_completed = parseInt(values[this.reads_completed_index]);
        info.reads_merged = parseInt(values[this.reads_merged_index]);
        info.sectors_read = parseInt(values[this.sectors_read_index]);
        info.time_reading_ms = parseInt(values[this.time_reading_ms_index]);
        info.writes_completed = parseInt(values[this.writes_completed_index]);
        info.writes_merged = parseInt(values[this.writes_merged_index]);
        info.sectors_written = parseInt(values[this.sectors_written_index]);
        info.time_writing_ms = parseInt(values[this.time_writing_ms_index]);
        info.inputs_outputs_in_progress = parseInt(values[this.inputs_outputs_in_progress_index]);
        info.time_inputs_outputs_ms = parseInt(values[this.time_inputs_outputs_ms_index]);
        info.weighted_time_inputs_outputs_ms = parseInt(values[this.weighted_time_inputs_outputs_ms_index]);

        if(values.length >= this.discards_completed_index)
        {
            info.discards_completed = parseInt(values[this.discards_completed_index]);
            info.discards_merged = parseInt(values[this.discards_merged_index]);
            info.sectors_discarded = parseInt(values[this.sectors_discarded_index]);
            info.time_discarding = parseInt(values[this.time_discarding_index]);
        }
    },

    update_input_output_info_bytes: function (info, device_name) {
        let exists = device_name in this.disk_sector_sizes;
        if(exists) {
            let sector_size = this.disk_sector_sizes[device_name];
            info.bytes_read = info.sectors_read * sector_size;
            info.bytes_written = info.sectors_written * sector_size;
        }
    },

The interesting functions.
You'd check whether the values changed and alter the gui_*_icon_filename's accordingly (you'll need some probably gray copy of the indicator svg) and update the icons (if either value has changed) - not very elegant or efficient, but should™ get the job done.
You could also contact the author whether he's willing to support you and apply a patch. I don't use cinnamon.

Offline

#24 2021-04-18 11:22:35

Morn
Member
Registered: 2012-09-02
Posts: 886

Re: [SOLVED] Hard disk activity lights program required

OK, I have modified my Python script from post #4 to display a tray icon using GTK 3.

I have tested this in JWM, but it should also work in Cinnamon.

#!/usr/bin/env python

fn = "/sys/block/sda/stat"
UPDATE = 100	# update interval in ms
ro, wo = 0, 0
last = ""

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import GObject
from gi.repository import Gtk
tray = Gtk.StatusIcon()
tray.set_visible(True)

def update():
	global ro, wo, last

	f = open(fn).read().split()
	r, w = f[0], f[4]
	rr, ww = "0", "0"
	if r != ro:
		rr = "1"
	if w != wo:
		ww = "1"
	ro, wo = r, w
	i = f"icon{rr}{ww}.png"
	if i != last:
		tray.set_from_file(i)
		tray.set_visible(True)
		last = i
	GObject.timeout_add(UPDATE, update)

update()
Gtk.main()

Last edited by Morn (2021-04-20 08:37:31)

Offline

#25 2021-04-18 11:49:24

jet14
Member
Registered: 2021-04-16
Posts: 24

Re: [SOLVED] Hard disk activity lights program required

Hi morn excellent yes its working i get square black block and get the vertical lighst flash on, its seems to be rather brief in comparison to the other applet which displays the bytes stays on longer, i do get the following errors on running the program though it does work, thanks for your hard work!!! cheers.
/home/jet/hd-led_pygtk/icon.py:12: DeprecationWarning: Gtk.StatusIcon.set_visible is deprecated
  tray.set_visible(True)
/home/jet/hd-led_pygtk/icon.py:33: PyGIDeprecationWarning: GObject.timeout_add is deprecated; use GLib.timeout_add instead
  GObject.timeout_add(100, update)
/home/jet/hd-led_pygtk/icon.py:28: DeprecationWarning: Gtk.StatusIcon.set_from_file is deprecated
  tray.set_from_file(i)
/home/jet/hd-led_pygtk/icon.py:31: PyGIDeprecationWarning: GObject.timeout_add is deprecated; use GLib.timeout_add instead
  GObject.timeout_add(100, update)

Offline

Board footer

Powered by FluxBB