File Activity Plugin - How can I figure out what keeps spinning up my disks?


dlandon

Recommended Posts

3 hours ago, tuxbass said:

Note data share doesn't show any modifications as of late. The activity above is expected to be under the backup share alone.

Any idea as to why above activity is listed also for /mnt/user/data share?

No, but looking into it.

Link to comment

Looking at source, isn't the problematic bit caused by
 

$share_dev = basename($share)."/";
$files = shell_exec("cat /var/log/file.activity.log 2>/dev/null | grep ".escapeshellarg($share_dev)."

i.e. we take basename of a share (resulting in "data" in my case) and then grep it through activity log; as the backup share node has "/data/" in event file path, those events get erroneously included?

 

On an unrelated note - in this particular case there's no real need to escapeshellarg - can use grep's --fixed-strings option instead. Also, that is a great example of useless use of cat, why not directly grep the file?

Edited by tuxbass
Link to comment
4 hours ago, tuxbass said:

i.e. we take basename of a share (resulting in "data" in my case) and then grep it through activity log; as the backup share node has "/data/" in event file path, those events get erroneously included?

I have a fix for this.  I just haven't released it yet.

 

4 hours ago, tuxbass said:

On an unrelated note - in this particular case there's no real need to escapeshellarg - can use grep's --fixed-strings option instead. Also, that is a great example of useless use of cat, why not directly grep the file?

Different styles.  If you think you can do a better job, you are free to fork this project and do it yourself.

Link to comment
6 hours ago, tuxbass said:

On an unrelated note - in this particular case there's no real need to escapeshellarg - can use grep's --fixed-strings option instead. Also, that is a great example of useless use of cat, why not directly grep the file?

Just as a clarificaton.  When AI is asked about which approach is better, the response is:

"It depends on the size of the file /var/log/file.activity.log and the frequency of the script execution.

 

If the file is relatively small and the script is not executed frequently, directly grepping the file would likely be more efficient and result in lower disk I/O. This is because reading the file directly with grep avoids the overhead of piping the output of cat into grep.

 

However, if the file is large or the script is executed frequently, it may be more efficient to use a combination of cat and grep as you have done, especially if you're only interested in specific lines matching a pattern. This can help avoid repeatedly scanning the entire file with grep, potentially reducing overall disk I/O."

 

The line of code in question is executed for every disk device and the log can get large (it is limited to 20,000 lines though), so based on the AI response, it appears the " useless use of cat" may not be useless after all.

 

Maybe before criticizing the code, you need to understand it better?

Link to comment
17 minutes ago, dlandon said:

Just as a clarificaton.  When AI is asked about which approach is better, the response is:

"It depends on the size of the file /var/log/file.activity.log and the frequency of the script execution.

 

If the file is relatively small and the script is not executed frequently, directly grepping the file would likely be more efficient and result in lower disk I/O. This is because reading the file directly with grep avoids the overhead of piping the output of cat into grep.

 

However, if the file is large or the script is executed frequently, it may be more efficient to use a combination of cat and grep as you have done, especially if you're only interested in specific lines matching a pattern. This can help avoid repeatedly scanning the entire file with grep, potentially reducing overall disk I/O."

 

The line of code in question is executed for every disk device and the log can get large (it is limited to 20,000 lines though), so based on the AI response, it appears the " useless use of cat" may not be useless afterall.

 

Maybe before criticizing the code, you need to understand it better.

 

Truly thought I might be helpful here tracking down the possible cause of the problem affecting me, and just mentioned the UUOC and a different grep option - I personally don't know everything and oftentimes learn from others in similar manner. Didn't realize I'm doing something awful here.

 

In my professional developer career I haven't reached the place where I ask "AI" (whatever that means) how to solve problems, I'll try to improve, sorry.

 

Also wasn't aware this thread is essentially /r/Conservative where people get hurt over literally nothing, am sorry again.

 

And it's really cool to slide into people's DMs and vaguely threaten them with reporting their horrible posts like mine. Just wanted to reiterate it's completely OK and I invite everyone to report such content.

Link to comment

Do you have:

  • ZFS master plugin installed? swap to lazy load.
  • Other monitoring containers like netdata etc? try unticking priveled mode when you edit the container settings.
  • Bazarr doing subtitle searches on all media?
  • Disk Location plugin? check the smart health check settings.
Edited by dopeytree
  • Upvote 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.