当我登录 Ubuntu 11.10 时显示的“内存使用情况”值是如何计算的?

当我登录 Ubuntu 11.10 时显示的“内存使用情况”值是如何计算的?

当我登录到我的 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 脚本来收集该值并绘制随时间变化的图表。

谢谢!

答案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 的图形 Web 前端,用于对系统进行单独监控。

相关内容