WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Freqmon - a minimalistic approach to monitor CPU frequency  (Read 10402 times)

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Freqmon - a minimalistic approach to monitor CPU frequency
« on: March 23, 2013, 12:01:31 PM »
Freqmon is a minimalistic approach to monitor CPU frequency in the context of dynamic frequency scaling.

Depends: aterm

Bugs: This version as is only supports 1 CPU (1 core).
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11573
Re: Freqmon - a minimalistic approach to monitor CPU frequency
« Reply #1 on: March 23, 2013, 12:43:55 PM »
Hi tinypoodle
On my monitor most of the displayed terminal is off the left side of the screen. Running Xorg7.5 at 1920x1080.

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Freqmon - a minimalistic approach to monitor CPU frequency
« Reply #2 on: March 23, 2013, 12:55:49 PM »
Thanks for reporting.
Either such is unexpected with "-geometry 4x2+0+30" or I am missing something...
It was supposed to align to left screen border.
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Freqmon - a minimalistic approach to monitor CPU frequency
« Reply #3 on: March 23, 2013, 12:58:20 PM »
New version without screen positioning attached, lets users window manager handle positioning.
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11573
Re: Freqmon - a minimalistic approach to monitor CPU frequency
« Reply #4 on: March 23, 2013, 01:24:44 PM »
Hi tinypoodle
Flwm_topside positioned it right on top of wbar. I would make it something like:
Code: [Select]
-geometry 4x2+30+30just so it's visible. The end user will probably want to reposition it where they want it anyway.

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Freqmon - a minimalistic approach to monitor CPU frequency
« Reply #5 on: March 23, 2013, 04:14:14 PM »
The end user will probably want to reposition it where they want it anyway.

That is the idea, I only added geometry just before uploading it, thinking about some safe generic default, but that proves to be more complicated than I thought.

My motivation to write this was for "something which does not get in the way", after always having ended up with a default aterm sticky and top layer, just to keep track of cpufreq. I have a preference for "best value per screen estate", and 'watcher' which does an excellent job inspired me, the only thing it lacks for my needs was cpufreq. On my system I have freqmon right bottom, to have that extra newline which I didn't manage to eliminate off screen.

Attached with -geometry 4x2+30+30 as requested.
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline Paulo

  • Full Member
  • ***
  • Posts: 139
Re: Freqmon - a minimalistic approach to monitor CPU frequency
« Reply #6 on: March 24, 2013, 06:57:26 AM »
Hi tinypoodle

Quote
I have a preference for "best value per screen estate", and 'watcher' which does an excellent job....

Saving screen real estate is always a good thing however for some reason 'watch' always adds an extra line to it's output.
To save a line one could (theoretically) use this:

Code: [Select]
echo -en "\033[1;23f"
and call aterm with a geometry of 4x1

but that does not work.

If you are really keen on saving one line then why not try this:

Code: [Select]
printf '\33]2;%s\007' $MyVariableToDisplay
This will change the aterm title bar with the value in $MyVariableToDisplay
then use aterm with a geometry of 4x1.

Another advantage of using the title bar to display the required data is that the script can be minimized thus taking
no screen real estate at all and by simply glancing at the task bar will let you see it.

By the way, I also tried using a geometry of 4x0 since only the title bar is needed, but aterm goes bonkers.
One more thing that can be done is to right click on the title bar then select "shade".
This will leave only the title bar and thus saving one more line.

Hope it's of some help.


« Last Edit: March 24, 2013, 08:01:58 AM by Paulo »

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Freqmon - a minimalistic approach to monitor CPU frequency
« Reply #7 on: March 24, 2013, 11:31:24 AM »
The title output sounds like an interesting approach, though not very portable, I guess. Not sure how exactly it would be done.

I tried piping output of watch to a named pipe and then using cat or dd, but I always get the extra line, yeah well, just gonna hide it off the bottom of screen :D
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline Paulo

  • Full Member
  • ***
  • Posts: 139
Re: Freqmon - a minimalistic approach to monitor CPU frequency
« Reply #8 on: March 24, 2013, 11:45:26 AM »
Hi tinypoodle

Using the title bar will work with terminals such as aterm, xterm and rxvt.

As regards the extra line, I am convinced that it's due to 'watch' because I tried with making the script loop with a timer
instead of using 'watch' and there was no extra line.

Perhaps 'tput' is the way to go as then there are no worries about portability and just maybe it will over-ride the extra line.

Quote
DESCRIPTION
The tput utility uses the terminfo database to make the values of terminal-dependent capabilities and information available to the shell

Something like:

Code: [Select]
tput cup <row> <column>
« Last Edit: March 24, 2013, 11:59:12 AM by Paulo »

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Freqmon - a minimalistic approach to monitor CPU frequency
« Reply #9 on: March 24, 2013, 12:18:00 PM »
Yes, it's definitely watch - I ended up to nc the output (using 127.0.0.1 as address) from 1 aterm to another, exactly same result.
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11573
Re: Freqmon - a minimalistic approach to monitor CPU frequency
« Reply #10 on: March 24, 2013, 12:27:21 PM »
Hi guys
I did something similar for displaying time a while back and also struggled with getting rid of the line feed, but I did it.
Maybe there is something of use to you in my script:
http://forum.tinycorelinux.net/index.php/topic,13794.msg77140.html#msg77140

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Freqmon - a minimalistic approach to monitor CPU frequency
« Reply #11 on: March 24, 2013, 12:36:31 PM »
Thanks, but I really come to believe there is something particular to watch, which might make the newline unavoidable.
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline Paulo

  • Full Member
  • ***
  • Posts: 139
Re: Freqmon - a minimalistic approach to monitor CPU frequency
« Reply #12 on: March 24, 2013, 01:00:45 PM »
Also keep in mind that the watch that comes with TC is the BusyBox version and not the "normal" version
as found here:  http://procps.cvs.sourceforge.net/viewvc/procps/procps/watch.c?revision=1.16&view=markup

Just had a quick look at the source and straight away I see differences with options available so there could be others too
that forces the extra line.


Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Freqmon - a minimalistic approach to monitor CPU frequency
« Reply #13 on: March 24, 2013, 01:10:30 PM »
Not impossible.
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11573
Re: Freqmon - a minimalistic approach to monitor CPU frequency
« Reply #14 on: March 24, 2013, 03:08:42 PM »
Hi tinypoodle
Quote
I really come to believe there is something particular to watch, which might make the newline unavoidable.
I think you may be right. I tried stripping the newline like this:
Code: [Select]
watch -t grep M /proc/cpuinfo | tr -d '\n'and got no output. If you don't mind replacing  watch  with  sleep 2  then this works:
Code: [Select]
aterm -fade 100 -title Freqmon -fg green -bg black -ib 0 -bl +sb -cr black -geometry 4x1+30+30 -e sh -c "while true; do echo -ne '\033[1K\033[1G'; echo -ne `grep MHz /proc/cpuinfo | cut -d: -f2 | cut -d. -f1`; sleep 2; done" &