Re: [new/wip] sysutils/apmtop

2024-01-11 Thread Benjamin Stürz

Hi,

thanks for the contributions.
I have attached a new version of the port.

On 1/11/24 11:14, Omar Polo wrote:

Hello,

Well, the port actually looks good, even if a manpage (or at least
installing the README) would be useful :)

apmtop(1) now has a man page.
It's still quite bare bones, but so is apmtop itself.


I tried it on my desktop and I can say it seems to mostly work.  It
report the cpu temperature as -1 C which I assume means 'not available'.
There is actually one sensor on this machine that reports a temperature,
but since it doesn't contain the "cpu" string in its name it gets
skipped.

% sysctl -a | grep degC
hw.sensors.ksmn0.temp0=25.25 degC (Tctl)

It looks like ksmn(4) is actually a CPU temperature sensor.
But why isn't it called 'hw.sensors.cpu0.temp0' then?


it also reports the power as 0, but I guess it's just a metric not
available on my handware.

(BAT is obviously 0 for me too, but it's a desktop)


[...]
Nice utility! Don't know if I'll use it since I like to squeeze such
things into my status bar, but maybe I can learn from it. One annoyance:
xterm flashes on every update as the TUI is redrawn, which is
distracting when I'm trying to look at something else.


I agree, it's a nice little utility :)

Thanks, I'll continue improving it,
once I'm done studying for my exams :)


I got a bit annoyed by the screen flashes at each update and gave it a
try at improving it, see diff below.

Thanks, I wasn't able to solve it on my own.
But I did solve the wrong-temperature-bug.
It was a simple conversion mistake.



I too put these things into my status bar,
but I wanted to have a nice graph,
to make optimizing battery life a little easier.


Index: apmtop.c
--- apmtop.c.orig
+++ apmtop.c
@@ -259,7 +259,7 @@ draw_graph (struct graph *g, const char *fmt, int min,
w -= 2;
h -= 3;
  
-	wclear (g->win);

+   werase (g->win);
  
  	for (int i = 0; i < entries; ++i) {

int v = g->log[i];
@@ -287,7 +287,7 @@ draw_graph (struct graph *g, const char *fmt, int min,
  static void
  draw (struct display *dpy)
  {
-   clear ();
+   erase ();
  
  	draw_graph (&dpy->g[G_CPUUSAGE],	"CPU: %d%%",	0, 100);

draw_graph (&dpy->g[G_CPUTEMP],  "CPU: %d C",  0, 100);
@@ -302,12 +302,10 @@ draw (struct display *dpy)
  
  	printw (" %c delay=%d", dpy->running ? 'R' : 'S', dpy->delay);
  
-	refresh ();

+   wnoutrefresh (stdscr);
for (int i = 0; i < NGRAPH; ++i)
wnoutrefresh (dpy->g[i].win);
doupdate ();
-   move (0, 0);
-
  }
  
  static void


apmtop-0.3.1.tgz
Description: Binary data


Re: [new/wip] sysutils/apmtop

2024-01-11 Thread James Cook

I tried it on my desktop and I can say it seems to mostly work.  It
report the cpu temperature as -1 C which I assume means 'not available'.
There is actually one sensor on this machine that reports a temperature,
but since it doesn't contain the "cpu" string in its name it gets
skipped.

% sysctl -a | grep degC
hw.sensors.ksmn0.temp0=25.25 degC (Tctl)


Oh, I didn't know about hw.sensors.

I see

hw.sensors.cpu0.temp0=38.00 degC
hw.sensors.pchtemp0.temp0=37.00 degC

but apmtop is showing "CPU: 31 C".

--
James



Re: [new/wip] sysutils/apmtop

2024-01-11 Thread Omar Polo
Hello,

On 2024/01/06 03:42:44 +0100, Benjamin Stürz  wrote:
> On 1/5/24 19:33, James Cook wrote:
> > On Thu, Jan 04, 2024 at 10:24:18PM +0100, Benjamin Stürz wrote:
> >> Hi ports@,
> >>
> >> this is my next little project, after sysutils/lsblk.
> >>
> >> apmtop is a simple utility for measuring power consumption
> >> and statistics related to it, in a little TUI interface.
> >> There is still some work to do, but I wanted to see
> >> if anyone would be interested in using/testing this project.
> >>
> >> Obviously, this is not (yet) commit-ready, so:
> >> Comments and Suggestions are _very_ welcome!
> >>
> >> WWW: https://got.stuerz.xyz/?action=summary&path=apmtop.git
> >>
> >> PS:
> >> The keybindings are in the README.md, until I write a man page.
> >>
> >> Happy new year,
> >> Benjamin Stürz

Well, the port actually looks good, even if a manpage (or at least
installing the README) would be useful :)

I tried it on my desktop and I can say it seems to mostly work.  It
report the cpu temperature as -1 C which I assume means 'not available'.
There is actually one sensor on this machine that reports a temperature,
but since it doesn't contain the "cpu" string in its name it gets
skipped.

% sysctl -a | grep degC
hw.sensors.ksmn0.temp0=25.25 degC (Tctl)

it also reports the power as 0, but I guess it's just a metric not
available on my handware.

(BAT is obviously 0 for me too, but it's a desktop)

> > [...]
> > Nice utility! Don't know if I'll use it since I like to squeeze such 
> > things into my status bar, but maybe I can learn from it. One annoyance: 
> > xterm flashes on every update as the TUI is redrawn, which is 
> > distracting when I'm trying to look at something else.

I agree, it's a nice little utility :)

I got a bit annoyed by the screen flashes at each update and gave it a
try at improving it, see diff below.

> I too put these things into my status bar,
> but I wanted to have a nice graph,
> to make optimizing battery life a little easier.

Index: apmtop.c
--- apmtop.c.orig
+++ apmtop.c
@@ -259,7 +259,7 @@ draw_graph (struct graph *g, const char *fmt, int min,
w -= 2;
h -= 3;
 
-   wclear (g->win);
+   werase (g->win);
 
for (int i = 0; i < entries; ++i) {
int v = g->log[i];
@@ -287,7 +287,7 @@ draw_graph (struct graph *g, const char *fmt, int min,
 static void
 draw (struct display *dpy)
 {
-   clear ();
+   erase ();
 
draw_graph (&dpy->g[G_CPUUSAGE],"CPU: %d%%",0, 100);
draw_graph (&dpy->g[G_CPUTEMP], "CPU: %d C",0, 100);
@@ -302,12 +302,10 @@ draw (struct display *dpy)
 
printw (" %c delay=%d", dpy->running ? 'R' : 'S', dpy->delay);
 
-   refresh ();
+   wnoutrefresh (stdscr);
for (int i = 0; i < NGRAPH; ++i)
wnoutrefresh (dpy->g[i].win);
doupdate ();
-   move (0, 0);
-
 }
 
 static void



Re: [new/wip] sysutils/apmtop

2024-01-10 Thread James Cook

Thanks, I tried it out on my laptop.

Thanks for trying.


The BAT and PWR displays always show 0% and 0mW respectively as far 
as I can tell. Note "apm -l" can show my batter percentage so I 
guess that at least should be possible to get right. dmesg below in 
case it's useful.

Now it's fixed.
I forgot to unveil("/dev/apm", "r").
See attached port.


Now BAT works (matches apm -l). Power still shows 0mW 
(min: 0/max: 0) but I don't even know if my laptop can report power 
consumption.



CPU percentage is lower than what "top -1" shows. E.g. with
"++$x while 1" running in a perl repl, top -1 shows 19% user but 
your tool shows about 10%. I don't know which is more accurate, so 
this isn't necessarily a complaint.

Try with a different delay, maybe the same one as top uses.
Use `apmtop -d DELAY` with DELAY being measured in tenths of seconds.
e.g. `apmtop -d 10` refreshes every second.


Comparing "apmtop -d 10" with "top -1s1" it's still a bit different, 
but I don't have any evidence top's estimate is better.


I'm running "find /" in an xterm to use the CPU a bit.

Two side-by-side "top -1s1" instances agree within a couple percentage 
points. "apmtop -d 10" shows a different number, e.g. 21% when top 
shows 32%. Usually lower but sometimes higher.


CPU frequency looks plausible. Temperature is at least changing 
(went from 32 C to 33 C); not sure if it's accurate.

I'll look into that.


I'm not saying 32C sounds wrong, just that I don't have 
a way to verify it :)


--
James



Re: [new/wip] sysutils/apmtop

2024-01-05 Thread Benjamin Stürz

On 1/5/24 19:33, James Cook wrote:

On Thu, Jan 04, 2024 at 10:24:18PM +0100, Benjamin Stürz wrote:

Hi ports@,

this is my next little project, after sysutils/lsblk.

apmtop is a simple utility for measuring power consumption
and statistics related to it, in a little TUI interface.
There is still some work to do, but I wanted to see
if anyone would be interested in using/testing this project.

Obviously, this is not (yet) commit-ready, so:
Comments and Suggestions are _very_ welcome!

WWW: https://got.stuerz.xyz/?action=summary&path=apmtop.git

PS:
The keybindings are in the README.md, until I write a man page.

Happy new year,
Benjamin Stürz


Thanks, I tried it out on my laptop.

Thanks for trying.


The BAT and PWR displays always show 0% and 0mW respectively as far as I 
can tell. Note "apm -l" can show my batter percentage so I guess that at 
least should be possible to get right. dmesg below in case it's useful.

Now it's fixed.
I forgot to unveil("/dev/apm", "r").
See attached port.


CPU percentage is lower than what "top -1" shows. E.g. with
"++$x while 1" running in a perl repl, top -1 shows 19% user but your 
tool shows about 10%. I don't know which is more accurate, so this isn't 
necessarily a complaint.

Try with a different delay, maybe the same one as top uses.
Use `apmtop -d DELAY` with DELAY being measured in tenths of seconds.
e.g. `apmtop -d 10` refreshes every second.


CPU frequency looks plausible. Temperature is at least changing (went 
from 32 C to 33 C); not sure if it's accurate.

I'll look into that.


Nice utility! Don't know if I'll use it since I like to squeeze such 
things into my status bar, but maybe I can learn from it. One annoyance: 
xterm flashes on every update as the TUI is redrawn, which is 
distracting when I'm trying to look at something else.

I too put these things into my status bar,
but I wanted to have a nice graph,
to make optimizing battery life a little easier.

apmtop-0.2.tgz
Description: Binary data


Re: [new/wip] sysutils/apmtop

2024-01-05 Thread James Cook

On Thu, Jan 04, 2024 at 10:24:18PM +0100, Benjamin Stürz wrote:

Hi ports@,

this is my next little project, after sysutils/lsblk.

apmtop is a simple utility for measuring power consumption
and statistics related to it, in a little TUI interface.
There is still some work to do, but I wanted to see
if anyone would be interested in using/testing this project.

Obviously, this is not (yet) commit-ready, so:
Comments and Suggestions are _very_ welcome!

WWW: https://got.stuerz.xyz/?action=summary&path=apmtop.git

PS:
The keybindings are in the README.md, until I write a man page.

Happy new year,
Benjamin Stürz


Thanks, I tried it out on my laptop.

The BAT and PWR displays always show 0% and 0mW respectively as far 
as I can tell. Note "apm -l" can show my batter percentage so I 
guess that at least should be possible to get right. dmesg below 
in case it's useful.


CPU percentage is lower than what "top -1" shows. E.g. with
"++$x while 1" running in a perl repl, top -1 shows 19% user but 
your tool shows about 10%. I don't know which is more accurate, so 
this isn't necessarily a complaint.


CPU frequency looks plausible. Temperature is at least changing 
(went from 32 C to 33 C); not sure if it's accurate.


Nice utility! Don't know if I'll use it since I like to squeeze 
such things into my status bar, but maybe I can learn from it. One 
annoyance: xterm flashes on every update as the TUI is redrawn, 
which is distracting when I'm trying to look at something else.


--
James


OpenBSD 7.4-current (GENERIC.MP) #1578: Thu Dec 28 00:15:55 MST 2023
dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 16837365760 (16057MB)
avail mem = 16307105792 (15551MB)
random: good seed from bootblocks
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 3.2 @ 0x5e6c6000 (94 entries)
bios0: vendor Dell Inc. version "1.7.0" date 10/22/2020
bios0: Dell Inc. XPS 13 7390
efi0 at bios0: UEFI 2.7
efi0: Dell rev 0x1
acpi0 at bios0: ACPI 6.1
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP SSDT SSDT HPET APIC MCFG SSDT SSDT NHLT SSDT SSDT TPM2 
LPIT SSDT DBGP DBG2 BOOT SSDT DMAR SSDT BGRT FPDT
acpi0: wakeup devices XHC_(S0) XDCI(S4) HDAS(S4) RP01(S4) PXSX(S4) RP02(S4) 
PXSX(S4) RP03(S4) PXSX(S4) RP04(S4) PXSX(S4) RP05(S4) PXSX(S4) RP06(S4) 
PXSX(S4) RP07(S4) [...]
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpihpet0 at acpi0: 2399 Hz
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM) i7-10710U CPU @ 1.10GHz, 2893.26 MHz, 06-a6-00, patch 
00f8
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,TSC_ADJUST,SGX,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,SRBDS_CTRL,MD_CLEAR,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,IBRS_ALL,SKIP_L1DFL,MDS_NO,MISC_PKG_CT,ENERGY_FILT,FB_CLEAR,RRSBA,GDS_CTRL,XSAVEOPT,XSAVEC,XGETBV1,XSAVES
cpu0: 32KB 64b/line 8-way D-cache, 32KB 64b/line 8-way I-cache, 256KB 64b/line 
4-way L2 cache, 12MB 64b/line 16-way L3 cache
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 10 var ranges, 88 fixed ranges
cpu0: apic clock running at 24MHz
cpu0: mwait min=64, max=64, C-substates=0.2.1.2.4.1.1.1, IBE
cpu1 at mainbus0: apid 2 (application processor)
cpu1: Intel(R) Core(TM) i7-10710U CPU @ 1.10GHz, 2893.26 MHz, 06-a6-00, patch 
00f8
cpu1: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,TSC_ADJUST,SGX,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,SRBDS_CTRL,MD_CLEAR,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,IBRS_ALL,SKIP_L1DFL,MDS_NO,MISC_PKG_CT,ENERGY_FILT,FB_CLEAR,RRSBA,GDS_CTRL,XSAVEOPT,XSAVEC,XGETBV1,XSAVES
cpu1: 32KB 64b/line 8-way D-cache, 32KB 64b/line 8-way I-cache, 256KB 64b/line 
4-way L2 cache, 12MB 64b/line 16-way L3 cache
cpu1: smt 0, core 1, package 0
cpu2 at mainbus0: apid 4 (application processor)
cpu2: Intel(R) Core(TM) i7-10710U CPU @ 1.10GHz, 2893.26 MHz, 06-a6-00, patch 
00f8
cpu2: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,TSC_ADJUST,SGX,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,SRBDS_CTRL,MD_CLEAR,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT

[new/wip] sysutils/apmtop

2024-01-04 Thread Benjamin Stürz

Hi ports@,

this is my next little project, after sysutils/lsblk.

apmtop is a simple utility for measuring power consumption
and statistics related to it, in a little TUI interface.
There is still some work to do, but I wanted to see
if anyone would be interested in using/testing this project.

Obviously, this is not (yet) commit-ready, so:
Comments and Suggestions are _very_ welcome!

WWW: https://got.stuerz.xyz/?action=summary&path=apmtop.git

PS:
The keybindings are in the README.md, until I write a man page.

Happy new year,
Benjamin Stürz

apmtop.tgz
Description: Binary data