Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm a n00b when it comes to bash scripting, so I was hoping someone could help me out.

I have a server running 11.04, and my message of the day includes how much memory is currently used:

System information as of Tue Sep 24 10:58:28 MDT 2013

  System load:  0.0                Processes:           90
  Usage of /:   16.6% of 19.68GB   Users logged in:     0
  Memory usage: 49%                IP address for eth0: XX.XX.XX.XX
  Swap usage:   12%                IP address for eth1: XX.XX.XX.XX

I spun up another server running 13.04, and that message isn't there. So it looked into how to add it, and found on my 11.04 server under /etc/update-motd.d there is a link to a script at /usr/share/landscape/landscape-sysinfo.wrapper:

#!/bin/sh
cores=$(grep -c ^processor /proc/cpuinfo 2>/dev/null)
[ "$cores" -eq "0" ] && cores=1
threshold="${cores:-1}.0"
if [ $(echo "`cut -f1 -d ' ' /proc/loadavg` < $threshold" | bc) -eq 1 ]; then
    echo
    echo -n "  System information as of "
    /bin/date
    echo
    /usr/bin/landscape-sysinfo
else
    echo
    echo " System information disabled due to load higher than $threshold"
fi

I added this script to my 13.04 server, but the script must be running into an error somewhere because it shows the "else" message, "System information disabled due to load higher than 1.0". Both servers have the same specs, other than the version of Ubuntu they're running. How can I edit this script on my 13.04 system to get it to show current memory usage?

UPDATE:

It looks like 13.04 doesn't have landscape. I ran dpkg -l | grep landscape and no results. 11.04 has it running. So I guess the question is, how can I show memory usage without landscape?

share|improve this question
add comment

2 Answers

I have no idea why your dpkg command didn't return the landscape-common package because it does exist in Raring and owns the /usr/bin/landscape-sysinfo file.

Install it with this command:

sudo apt-get install landscape-common
share|improve this answer
add comment

If you want to display your memory usage in a landscape like way:

free -k | {
    read ; read TITLE TOTAL USED REST
    echo "Memory usage: $(( 100 * $USED / $TOTAL ))%"

    #you also want swap displayed ?  No problem

    read ; read TITLE TOTAL USED REST
    echo "Swap usage:   $(( 100 * $USED / $TOTAL ))%"

}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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