asitop icon indicating copy to clipboard operation
asitop copied to clipboard

Enormous /tmp/asitop_powermetrics* files

Open martinalderson opened this issue 2 years ago • 7 comments

It's filled my hard drive up with files like this:

-rw-r--r-- 1 root wheel 43G 14 Dec 16:01 asitop_powermetrics1637685873 -rw-r--r-- 1 root wheel 37G 14 Dec 16:01 asitop_powermetrics1637936130

martinalderson avatar Dec 14 '21 16:12 martinalderson

The current version should not have this issue. An older version had a issue where sometimes the log files from powermetrics are not cleared. Can you confirm you are using the current version? If so, I’ll look into it again.

tlkh avatar Dec 15 '21 02:12 tlkh

Why are you writing to regular files anyhow? Can't you make a pipe or fifo so it's just in RAM until the script reads it?

floam avatar Jan 22 '22 00:01 floam

I welcome any suggestions on that. Currently, it is because there are 2 only options I am aware of:

  • Call powermetrics once, and read the output. This causes a performance overhead, and slows down other tasks.
  • Start a powermetrics subprocess and tell it to write to a temporary file, and then read the temporary file.

The temp file should be cleared every time asitop quits or starts. This issue arises when you run asitop for very extended periods of time (or powermetrics as a process fails to stop for some reason).

tlkh avatar Jan 22 '22 05:01 tlkh

Start a powermetrics subprocess and tell it to write to a temporary file, and then read the temporary file

You can do effectively this, but if that file is a fifo you will not be torturing disks.

If you are not familiar, this should make it all make sense:

In a terminal run

mkfifo magic
sudo powermetrics -o magic

in another terminal run tail -f magic

You'll see the output, but the data is gone as soon as it is read. It was never actually on disk. It's like piping the output of a command to another command, but through a special file name.

floam avatar Jan 22 '22 05:01 floam

You could also just use subprocess to capture what it's printing to stdout.

floam avatar Jan 22 '22 05:01 floam

Thanks, I didn't know about fifo

tlkh avatar Jan 22 '22 11:01 tlkh

Can the /tmp/asitop_powermetrics* file be automatically deleted after KeyboardInterrupt? I think this would be useful.

TimYao18 avatar Nov 03 '23 06:11 TimYao18