由 top指令得到 mysql的 CPU百分值

top -b -u mysql -n1 | grep mysqld | awk '{print $9}'

free指令取得記憶體容使用量

#!/bin/bash

memtotal=`free -m | grep "Mem:" | awk '{print $2}'`
memused=`free -m | grep "Mem:" | awk '{print $3}'`
memfree=`free -m | grep "Mem:" | awk '{print $4}'`

echo $memused
echo $memfree
echo $memtotal

   vi mrtg-mem.cfg

WorkDir: /var/www/mrtg/mem

Target[10.1.1.254_mem]: `/etc/mrtg/mrtg-mem.sh`
RouterUptime[10.1.1.254_mem]: cross@10.1.1.254
MaxBytes[10.1.1.254_mem]: 512
Directory[10.1.1.254_mem]: 254mem
WithPeak[10.1.1.254_mem]: wmy
Options[10.1.1.254_mem]: growright, nopercent, gauge
YLegend[10.1.1.254_mem]: amount
ShortLegend[10.1.1.254_mem]: mb
Legend1[10.1.1.254_mem]: amount of used memory
Legend2[10.1.1.254_mem]: amount of free memory
Legend3[10.1.1.254_mem]: amount of total memory
Legend4[10.1.1.254_mem]: amount of ? memory
LegendI[10.1.1.254_mem]:  Used:
LegendO[10.1.1.254_mem]:  Free:
Title[10.1.1.254_mem]: amount of free and used memory
PageTop[10.1.1.254_mem]: <H1>amount of free and used memory[10.1.1.254] – free</H1>

netstat指令取得 httpd人數
   Quote:
http://linux.vbird.org/linux_security/old/04mrtg.php#online

   vi mrtg-http.sh

#!/bin/bash
# 程式主要在計算有多少人以 WWW 的方式連線進主機
# 1. 計算連線的數目
echo `netstat -a | grep www|awk '{print $5}'|sort | wc -l|awk '{print$1 – 1}'`
# 底下在說明整個的列出(檢查用)
# netstat -a | grep www|awk '{print $5}'|sort| uniq
# 2. 計算連線人數:
echo `netstat -a | grep www|awk '{print $5}'|cut -d":" -f1|sort| uniq |wc -l | awk '{print $1 – 1}'`
# netstat -a | grep www|awk '{print $5}'|cut -d":" -f1|sort| uniq
# 3. 輸出時間
UPtime=`/usr/bin/uptime | awk '{print $3 " " $4 " " $5}'`
echo $UPtime
echo 10.10.1.100
Related posts 相關文章
使用 Grafana 與 Prometheus 監控主機
More...
nagios 使用 pnp4nagios 畫 rrdtool 圖,像 MRTG 圖表
More...
我們一步一步的被監控著,IPHONE 5S的指紋是否會被 NSA 用去
More...
RRDTOOL 的 RRD 檔一些小心得,關於存的筆數
More...

作者

留言

撰寫回覆或留言

發佈留言必須填寫的電子郵件地址不會公開。