Enormous /tmp/asitop_powermetrics* files
martinalderson opened this issue · 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
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.
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?
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).
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.
You could also just use subprocess to capture what it's printing to stdout.
Thanks, I didn't know about fifo
Can the /tmp/asitop_powermetrics* file be automatically deleted after KeyboardInterrupt? I think this would be useful.