Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shortcut for live plot of memory usage? #167

Open
gamesbook opened this issue Jan 21, 2024 · 7 comments
Open

Shortcut for live plot of memory usage? #167

gamesbook opened this issue Jan 21, 2024 · 7 comments

Comments

@gamesbook
Copy link

The existing command in the doc is:

sar -r 1 | perl -lane 'BEGIN{$|=1} print "@F[5]"' | ttyplot -s 100 -t "memory used %" -u "%"

But I found on my system (Mint 21.2) I had to use:

sar -r 1 | perl -lane 'BEGIN{$|=1} print "@F[4]"' | ttyplot -s 100 -t "memory used %" -u "%"

Perhaps its obvious to others, but for me as a newbie, I figured I needed to run:

sar -r 1

And then count to the colored column in which %memused appeared.

@tenox7
Copy link
Owner

tenox7 commented Jan 23, 2024

thank you, I will update the doc; in general however the examples are not meant to be exhaustive or even fully correct on all systems, just a general samples of how the app can be used

@hartwork
Copy link
Collaborator

@tenox7 unless I'm overlooking something, it would be worth labelling examples that should not be run verbatim, because many of them do work well with copy-pasting and it doesn't seem unreasonable to then expect that approach to work well with other examples also. So if some examples are more like templates that need adjustment, let's make sure that's impossible to not notice before first running the command.
I theory we could also turn most of these samples into files named like ttyplot-ram-usage or so on and maintain them and enrich them with checks for command availability and such, but we may get flooded with pull requests then, I don't know 😄

@tenox7
Copy link
Owner

tenox7 commented Jan 28, 2024

I like the idea of have scripts with concrete metrics. We could write shell scripts that not only check command availability but also resolve OS differences between Linux/BSD/MacOS, etc. I have a bunch of scripts myself that I wanted to add but they are little beyond what I want in examples. I'm ok with getting flood of pull requests for these. What I'm unclear is how to actually distribute them. Should it go to the package? if so where should they land? Maybe have one shell script that takes argument of a metric?

In respect of examples in the readme I have a feeling that there already is too many of them, and definitely too many are using awk. I want to convert more to sed/perl, maybe python? Also there is too much sar, I think for memory usage I would like to use free perhaps? These are supposed to be just examples and not exhaustive.

@hartwork
Copy link
Collaborator

I like the idea of have scripts with concrete metrics. We could write shell scripts that not only check command availability but also resolve OS differences between Linux/BSD/MacOS, etc. I have a bunch of scripts myself that I wanted to add but they are little beyond what I want in examples.

@tenox7 I see!

I'm ok with getting flood of pull requests for these.

A flood of pull requests will need quick response times to not end up in frustration.

What I'm unclear is how to actually distribute them. Should it go to the package?

Probably yes, they would become part of the API then though meaning that usage of a script cannot just change in breaking ways without a major version bump or frustrate users.

if so where should they land?

For candidates:

  • /usr/bin if scripts are named ttyplot-<something>
  • (/usr/sbin if only root should use them. Probably not.)
  • /usr/lib/ttyplot/bin/ if we want to stay out of ${PATH} with lib or /usr/lib/ overridable by distros
  • /usr/libexec/ttyplot/ if we want to stay out of ${PATH}

Needs checking against FHS, was only brainstorming so far.

Maybe have one shell script that takes argument of a metric?

I'm not sure that will give good maintainability. I'd prefer a bunch of independent scripts where each can be fixed without breaking the rest of them.

In respect of examples in the readme I have a feeling that there already is too many of them, and definitely too many are using awk.

Too many seems like a concern of discoverability and/or cognitive overload. Good organization would be an alternative to dropping existing useful bits.

I want to convert more to sed/perl, maybe python?

How would sed be better than awk?
Keeping Perl out of this would be my main concern, I'd be good with any of sed, awk, Python 3 and the more readable, the better (if still reasonably portable).

Also there is too much sar, I think for memory usage I would like to use free perhaps?

Maybe, I don't have sar installed and I need to know or research that I need package "sysstat" installed for it. Not a showstopper to me personally though.

These are supposed to be just examples and not exhaustive.

Understood, yes.

@edgar-bonet
Copy link
Collaborator

@hartwork suggested:

For candidates: • /usr/bin [...]

Rather /usr/local/{bin,lib,man...}. This is where non-distro stuff is typically installed. And it should be easy to override by distro packagers, who would move that to /usr/{bin,lib,man...}.

@hartwork
Copy link
Collaborator

@edgar-bonet $(PREFIX)/bin, you're right 👍

@Manamama
Copy link

Manamama commented Apr 9, 2024

Quick confirmation that in default Termux also only this makes sense:
sar -r 1 | perl -lane 'BEGIN{$|=1} print "@F[4]"' | ttyplot -s 100 -t "memory used %" -u "%"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants