Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I login to my Ubuntu 11.10 box, several values are displayed by default. For example:

Welcome to Ubuntu 11.10 (GNU/Linux 3.0.0-17-virtual x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Thu Apr  5 20:35:07 UTC 2012

  System load:  0.01              Processes:           56
  Usage of /:   15.5% of 7.87GB   Users logged in:     0
  Memory usage: 26%               IP address for eth0: XX.XXX.XX.XXX
  Swap usage:   0%

  Graph this data and manage this system at https://landscape.canonical.com/
Get cloud support with Ubuntu Advantage Cloud Guest
  http://www.ubuntu.com/business/services/cloud

I would like to know how the "Memory usage" value is calculated, so I can write a shell script to collect this and graph it over time.

Thanks!

share|improve this question
up vote 1 down vote accepted

When you login motd runs all of the files in /etc/update-motd.d. The output you're looking for comes from 50-landscape-sysinfo which is a symlink to /usr/share/landscape/landscape-sysinfo.wrapper.

This is just a short script though:

#!/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

Which indicates it comes from landscape-sysinfo. That output is just STDOUT for that utility. Landscape is all part of a Canonical system monitoring service. Find more information here:

If this isn't good enough Nagious is a more advanced but free networking monitoring tool that can monitor any number of machines. Cacti is a graphing web-frontend to RRDtool which is individual monitoring for a system.

share|improve this answer
    
Awesome, thank you! All my boxes run on Amazon and for the sake of simplicity, I have all my monitoring going through CloudWatch. So I really just want to parse and push this info into that. landscape-sysinfo is what I needed. – esilverberg Apr 5 '12 at 21:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .