RRD: сбор статистики по использованию памяти
Материал из Linux Wiki
Версия от 16:33, 3 декабря 2008; Rain (обсуждение | вклад) (Новая: <source lang=bash> #!/bin/bash dbfile="$1" if [ -z "${1}" ]; then echo -e " \e[32mUsage: \e[31m$0 \e[33mRRDBFILE \e[32mExample: \e[31m$0 \e[33m/home/$USER/myups.rrd \e[0m" exit 2...)
#!/bin/bash
dbfile="$1"
if [ -z "${1}" ]; then
echo -e "
\e[32mUsage: \e[31m$0 \e[33mRRDBFILE
\e[32mExample: \e[31m$0 \e[33m/home/$USER/myups.rrd
\e[0m"
exit 2
fi
if [ ! -e "${dbfile}" ]; then
echo -e "\e[31mError: Database \e[33m\"${dbfile}\" \e[31mnot exist\e[0m"
exit 1
fi
if [ ! -r /proc/meminfo ]; then
echo -e "\e[31mError: \e[35m/proc/meminfo:\e[31mcan't get info\e[0m"
exit 3
fi
rrdtool update "${dbfile}" $(awk '
/^MemTotal:/{all=$2}
/^MemFree:/{free=$2}
/^Buffers:/{buf=$2}
/^Cached:/{cache=$2}
END {print systime()":"all":"buf":"cache":"all-free-buf-cache":"free}
' /proc/meminfo)