Memory and SWAP usage on motd

  • hi,

    can someone help me?
    i have a motd using /etc/update-motd.d/ scripts

    shows me some system information when connect via ssh. works great on my old omv3 - some fine tunings and works on omv5 as well - but - RAM and SWAP usage allways show 0


    System Load: 3.60 IP Address:
    CPU Temp: 43°C System Temp: 42°C
    Memory usage: 0.0% of 7627M System uptime: 1 min
    Usage on /: 39% of 28G SSD Temp: 37°C
    Usage nas1 27% of 2.7T HDD Temp: 33°C
    Usage nas2 79% of 2.7T HDD Temp: 35 C
    Swap usage 0.0% of 7848M

    unless omv dashboard also didn't show the right Memory usage i didn't think about it, like "if they fix that, my will also work" now dashboard is fixed - but my script still don't show the right usage.

    here is the code for memory and swap in the motd script.

    memory_usage=`free -m | awk '/Mem:/ { total=$2 } /buffers\/cache/ { used=$3 } END { printf("%3.1f%%", used/total*100)}'`
    memory_total=$(free -m | awk '/Mem/ {print $(2)}')
    swap_usage=`free -m | awk '/Swap/ { printf("%3.1f%%", "exit !$2;$3/$2*100") }'`
    swap_total=$(free -m | awk '/Swap/ {print $(2)}')

    what to change to get it working again?

    thx ;)

  • got it

    memory_usage=`free | awk '/Mem/{printf("%.2f%"), $3/$2*100}'`
    memory_total=$(free -m | awk '/Mem/ {print $(2)}')
    swap_usage=`free | awk '/Swap/{printf("%.2f%"), $3/$2*100}'`
    swap_total=$(free -m | awk '/Swap/ {print $(2)}')

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!