2

Using the top -b -n1 command I can get the resources utilised by my system for that instance. However, I actually need specific values out of it. I need things like, overall CPU usage, overall memory usage, and the top 5 processes using the cpu resources for that instance. Currently I am able to find:

Cpu usage: top -b -d1 -n1|grep -i 'Cpu(s)'|head -c21|cut -d '' -f3|cut -d '%' -f1

Top 5 process : ps aux | sort -nrk 3,3 | head -n 5

I am unable to work out something for the Ram usage. I am trying commands something like in the Cpu usage command, but it returns me nothing. To be frank, I am unable to cut it out properly. Some help in retrieving that is appreciated.

Extra Help: Also, on the same grounds, is it possible to get the mac address of the system. Like a command that might just return me the mac address and not 100s of lines that I need to manipulate.

Thank you for the help.

1

Total RAM Usage:

This command will return your RAM total usage as GB:

free -h |grep Mem| cut -c 20-32 | sed -e 's/^[ \t]*//'

This will return your RAM total usage as Bytes (just remove the -h):

free |grep Mem| cut -c 20-32 | sed -e 's/^[ \t]*//'

This will report the percentage of memory in use

free | grep Mem | awk '{print $3/$2 * 100.0}'

This will report the percentage of memory that's free

free | grep Mem | awk '{print $4/$2 * 100.0}'

MAC Address:

If you want to output ONLY the mac address of a specific device, you can do this (replace "wlp2s0" with the name of your network interface):

nmcli -t -f GENERAL.HWADDR device show wlp2s0 | sed 's/GENERAL.HWADDR://'
| improve this answer | |
  • 1
    That was precisely what I required! – resound Jul 31 '19 at 18:04
  • Hooray for Linux! <3 – Joshua Besneatte Jul 31 '19 at 18:06
0

For the MAC address, use this:

nmcli device show nic_name | grep GENERAL.HWADDR | cut -c41-
| improve this answer | |
  • What is the nic_name here exactly ? @ajgringo619 – resound Jul 31 '19 at 17:23
  • The name of your network device. – ajgringo619 Jul 31 '19 at 17:25
  • Thanks there! @ajgringo619 – resound Jul 31 '19 at 17:31
  • 1
    nmcli is able to output specific fields (avoiding the need for grep) ex. nmcli -t -f GENERAL.DEVICE,GENERAL.HWADDR device show – steeldriver Jul 31 '19 at 17:35
  • 1
    @JoshuaBesneatte not at all! in fact it looks like there's a newer -g (--get-values) option that might allow you to avoid the cut as well - check man nmcli – steeldriver Jul 31 '19 at 18:23
0

Conky is a light weight system monitor you setup to show information you feel is important. In my version I have many data elements you seek plus information unique to myself like no one else cares about such as today's sunrise and sunset time for tracking automatic and gradual display brightening and dimming.

Check out my Conky setup with 2 second update interval but which you can set to 60 times a second or once every 5 minutes if you prefer:

Conky 30 second clip.png

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.