How to find the current CPU usage in Ubuntu – not the average

There are several ways to find the current CPU usage in Ubuntu. If you’re looking for real time statistics, simply use the “top” command. You can change the update rate using the -d argument to change it to a number of seconds between updates. The issue arises however if you’re trying to have a program get the current CPU usage. If you run top with the -n 1 argument to make it stop updating and just return the...

Read More

Swap monitoring and auto fix script

So a little while ago I mentioned that you could combine the swap monitoring script and the script that trys to put the swap back into working memory into a script that would just take care of it. I found that my machines were going into swap for trivial reasons, so I just set up a cron to run every 15 minutes that checks for swap, and if it finds any it just throws it back into working memory. Script below: #!/bin/bash swap=$(top -bi -n 1 |...

Read More