当我登录Ubuntu 11.10时,如何计算“内存使用”值?


2

当我登录到我的Ubuntu 11.10框时,默认显示几个值。例如:

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

我想知道如何计算“内存使用”值,因此我可以编写一个shell脚本来收集它并随时间绘制它。

谢谢!

Answers:


1

当你登录motd运行所有文件 /etc/update-motd.d。您正在寻找的输出来自 50-landscape-sysinfo 这是一个符号链接 /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

这表明它来自 landscape-sysinfo。该输出只是该实用程序的STDOUT。 景观 是Canonical系统监控服务的一部分。在此处查找更多信息:

如果这还不够好,Nagious是一个更先进但免费的网络监控工具,可以监控任意数量的机器。 Cacti是RRDtool的图形网络前端,它是对系统的单独监控。


太棒了,谢谢你!我的所有盒子都在亚马逊上运行,为了简单起见,我的所有监控都通过CloudWatch进行。所以我真的只想解析并推送这些信息。 landscape-sysinfo就是我所需要的。
esilverberg
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.