WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

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

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Freqmon - a minimalistic approach to monitor CPU frequency
« Reply #15 on: March 24, 2013, 01:07:23 PM »
I tried stripping the newline like this:
Code: [Select]
watch -t grep M /proc/cpuinfo | tr -d '\n'and got no output.

OMG yes! :o
That does the job!
Well... approximately, it sort of cripples the last of the 4 digits, which doesn't occur if size is 5x1.
I had tried '\n' in many ways, e.g. with sed and awk, but never invoked tr.

EDIT:
I think I figured what is happening with last digit, there is still a cursor, even if pseudo-invisible (same color as bg).
« Last Edit: March 24, 2013, 01:19:27 PM by tinypoodle »
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 7394
Re: Freqmon - a minimalistic approach to monitor CPU frequency
« Reply #16 on: March 24, 2013, 01:24:50 PM »
Hi tinypoodle
Code: [Select]
it sort of cripples the last of the 4 digits, which doesn't occur if size is 5x1.Sorry, didn't notice that on my 863Mhz machine. This fixes it:
Code: [Select]
aterm -fade 100 -title Freqmon -fg green -bg black -ib 0 -bl +sb -geometry 4x1+30+30 -e sh -c "echo -ne '\033[?25l'; while true; do echo -ne '\033[1K\033[1G'; echo -ne `grep MHz /proc/cpuinfo | cut -d: -f2 | cut -d. -f1`; sleep 2; done" &Added:
Code: [Select]
echo -ne '\033[?25l';to hide the cursor and removed
Code: [Select]
-cr blackwhich was the black cursor obscuring the last digit.

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Freqmon - a minimalistic approach to monitor CPU frequency
« Reply #17 on: March 25, 2013, 02:06:48 AM »
Code: [Select]
aterm -fade 100 -title Freqmon -fg green -bg black -ib 0 -bl +sb -geometry 4x1+30+30 -e sh -c "echo -ne '\033[?25l'; while true; do echo -ne '\033[1K\033[1G'; echo -ne `grep MHz /proc/cpuinfo | cut -d: -f2 | cut -d. -f1`; sleep 2; done" &

This does not work for me at all, i.e. output will remain same as at the moment it is invoked.

Quote
Added:
Code: [Select]
echo -ne '\033[?25l';to hide the cursor

Wondering if and how this could be combined with 'watch', as I really have a preference for using watch for many purposes.

Either way, increasing geometry by 1 horizontally is not a biggie, I am most happy with the method of using 'tr' to remove newline which you provided  :D
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 7394
Re: Freqmon - a minimalistic approach to monitor CPU frequency
« Reply #18 on: March 25, 2013, 08:54:37 AM »
Hi tinypoodle
Quote
... output will remain same as at the moment it is invoked.
You mean the numbers never change? Even if you make the machine do some work?
Quote
Wondering if and how this could be combined with 'watch', ...
Even though it only needs to be executed once, adding it like this works:
Code: [Select]
... -e watch -t "echo -ne '\033[?25l'; grep M ...
Quote
I am most happy with the method of using 'tr' to remove newline which you provided
Could you show me how you got  tr  to work? When I tried, I got no output, like it wasn't even running:
Code: [Select]
tc@box:~$ watch -t grep M /proc/cpuinfo | tr -d '\n'
^C
tc@box:~$ watch -t grep M /proc/cpuinfo | tr -d '\n'
^C
tc@box:~$

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Freqmon - a minimalistic approach to monitor CPU frequency
« Reply #19 on: March 25, 2013, 09:43:28 AM »
You mean the numbers never change? Even if you make the machine do some work?

Exactly

Quote
Even though it only needs to be executed once, adding it like this works:
Code: [Select]
... -e watch -t "echo -ne '\033[?25l'; grep M ...

Ah, thanks, I didn't know how exactly to integrate it.

So, adding that results in:
- Without tr, 5x1 : does not work
- Without tr, 4x2 : works as desired
- With tr, 4x1 : works as desired, with a side effect of output blinking.

Quote
Could you show me how you got  tr  to work? When I tried, I got no output, like it wasn't even running:
Code: [Select]
tc@box:~$ watch -t grep M /proc/cpuinfo | tr -d '\n'
^C
tc@box:~$ watch -t grep M /proc/cpuinfo | tr -d '\n'
^C
tc@box:~$

This command works for me, showing cursor positioned imminently after output.

Attached my version including tr, see at end of line. (working as desired with 4x1, side effect of last digit getting crippled by pseudo-invisible cursor).
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 7394
Re: Freqmon - a minimalistic approach to monitor CPU frequency
« Reply #20 on: March 25, 2013, 10:05:18 AM »
Hi tinypoodle
Quote
(working as desired with 4x1, side effect of last digit getting crippled by pseudo-invisible cursor).
My machine shows the same effect, until I move the focus to another window, then the last digit is visible. If I
change it to this:
Code: [Select]
aterm -fade 100 -title Freqmon -fg green -bg black -cr black -ib 0 -bl +sb -geometry 4x1+30+30 -e watch -t "echo -ne '\033[?25l'; grep M /proc/cpuinfo|cut -d: -f2|cut -d. -f1|sed 's/^.//'|tr -d '\n'" &the last digit is always visible.
Quote
- With tr, 4x1 : works as desired, with a side effect of output blinking.
The blinking "feature" tells you it's working. ::)

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Freqmon - a minimalistic approach to monitor CPU frequency
« Reply #21 on: March 25, 2013, 11:27:54 AM »
My machine shows the same effect, until I move the focus to another window, then the last digit is visible.

Here looks crippled when unfocused and invisible when focused.

Quote
Code: [Select]
aterm -fade 100 -title Freqmon -fg green -bg black -cr black -ib 0 -bl +sb -geometry 4x1+30+30 -e watch -t "echo -ne '\033[?25l'; grep M /proc/cpuinfo|cut -d: -f2|cut -d. -f1|sed 's/^.//'|tr -d '\n'" &the last digit is always visible.

Works to perfection now, thanks a lot! :D
I can't see anything being different from what I had tried earlier... but... I later found multiple stale 'watch' PIDs running, leftovers from experiencing, so I suspect that may have been causing the excessive blinking (I didn't mean the characteristic to watch slight blinking, that's expected).
"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 #22 on: March 25, 2013, 12:55:45 PM »
Oh, and '-cr black' has now become redundant
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)