Closed Eddiiie closed 4 years ago
[lazy-mode] what's the command to check CPU usage? [/lazy-mode] :)
Hi,
I found and tested a script on Octoprint / Raspberry Pi.
Taken from this URL: http://askubuntu.com/questions/450045/get-cpu-usage-in-command
It seems to work well.
Thank you for your consideration!
[https://cdn.sstatic.net/Sites/askubuntu/img/apple-touch-icon@2.png?v=c492c9229955]http://askubuntu.com/questions/450045/get-cpu-usage-in-command
server - get cpu usage in command - Ask Ubuntuhttp://askubuntu.com/questions/450045/get-cpu-usage-in-command askubuntu.com To get cpu usage, best way is to read /proc/stat file. See man 5 proc for more help. There is a useful script written by Paul Colby i found here
Text:
To get cpu usage, best way is to read /proc/stat file. See man 5 proc for more help.
There is a useful script written by Paul Colby i found herehttp://www.mail-archive.com/linuxkernelnewbies@googlegroups.com/msg01690.html
PREV_TOTAL=0 PREV_IDLE=0
while true; do
CPU=(cat /proc/stat | grep '^cpu '
) # Get the total CPU statistics.
unset CPU[0] # Discard the "cpu" prefix.
IDLE=${CPU[4]} # Get the idle CPU time.
TOTAL=0
for VALUE in "${CPU[@]:0:4}"; do let "TOTAL=$TOTAL+$VALUE" done
let "DIFF_IDLE=$IDLE-$PREV_IDLE" let "DIFF_TOTAL=$TOTAL-$PREV_TOTAL" let "DIFF_USAGE=(1000*($DIFF_TOTAL-$DIFF_IDLE)/$DIFF_TOTAL+5)/10" echo -en "\rCPU: $DIFF_USAGE% \b\b"
PREV_TOTAL="$TOTAL" PREV_IDLE="$IDLE"
sleep 1 done
save it to cpu_usage, add execute permission chmod +x cpu_usage and run:
./cpu_usage
to stop the script, hit Ctrl+c
sharehttp://askubuntu.com/a/450136improve this answerhttp://askubuntu.com/posts/450136/edit
From: Jarek Szczepanski notifications@github.com Sent: Monday, February 6, 2017 2:00 PM To: imrahil/OctoPrint-NavbarTemp Cc: Eddiiie; Author Subject: Re: [imrahil/OctoPrint-NavbarTemp] Enhancement Please - Raspi CPU % (#16)
what's the command to check CPU usage? :)
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/imrahil/OctoPrint-NavbarTemp/issues/16#issuecomment-277828010, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AKItQHOuHcPqSvtagKMYSHodpJnUWV_uks5rZ5gQgaJpZM4L3nyx.
This would be an awesome feature!
Agree.! could be great feature.
@Eddiiie @Swiftnesses @mtmello2003 what do you think if we will give you possibility to execute custom command in shell and print results on Navbar?
For sure will be the best option: let the user custom by them self.
@Cosik That would be pretty cool and include the above script as a default?
@Eddiiie I'm not sure if in first releases there will be something like "default"
@Eddiiie Hi we prepared new feature for custom commands, please read this https://github.com/imrahil/OctoPrint-NavbarTemp/pull/52
This could be done by custom command.
Hello, Love your plug in. Is there any chance you could add one more item to it and that would be the current CPU usage of the Raspi?
I often wonder what the under-lying CPU usage is.
Thank you for your consideration.