Monday, June 06, 2011

Collectd - Linux 操作系統狀態紀錄及圖示化安裝筆記

http://collectd.org/
http://wiki.debian.org/SystemMonitoring

開啟Plugin exec
<plugin exec="">
Exec user "path/to/myscript"
</plugin>
myscript 內容
#!/bin/bash
echo test message
now
在/var/log/syslog輸出如下
Jun 9 01:17:03 DBS collectd[10066]: exec plugin: Prepending `PUTVAL' to this line: Thu Jun 9 01:17:03 HKT 2011
Jun 9 01:17:13 DBS collectd[10066]: exec plugin: Prepending `PUTVAL' to this line: test message!


設定Collectd-exec示例
http://flux242.blogspot.com/2011/01/collectd-mod-exec-part-1.html

http://ubuntuforums.org/showthread.php?t=1479963

Mail list
http://dir.gmane.org/gmane.comp.monitoring.collectd

錯誤信息
collectd[4533]: mysql plugin: The `Port' config option needs exactly one string argument.
4.7版後 Port 3306
4.6版後 Port "3306"


停止apache2 Log檔記錄
因每十秒在/var/log/apache2/access.log產生一行紀錄如下
localhost - - [19/Jun/2011:07:00:13 +0800] "GET /server-status?auto HTTP/1.1" 200 477 "-" "collectd/4.8.2"
apache2 log 可據條件進行記錄,將以下加入/etc/apache2/sites-available/default設定檔中
# Mark requests from the loop-back interface
#SetEnvIf Remote_Addr "127\.0\.0\.1" dontlog #來源IP, 没使用, 免影响記錄其它本機的請求
#SetEnvIf Remote_Host "localhost" dontlog #來源主機名, 没使用
SetEnvIf User-Agent "collectd/4.8.2" dontlog #User-Agent 為Collectd, 不記錄.
#SetEnvIf Request_URI "^/server-status" dontlog #未知是否成功.
CustomLog /var/log/apache2/access.log combined env=!dontlog

!!以上需在/etc/apache2/sites-available/default中註去CustomLog /var/log/apache2/access.log combined, 否則只接受最後者設定

試過在apache2.conf加入上設定, 但會視為other virtualhost 的紀錄
而混進(包括default的log!!)/var/log/apache2/other_vhosts_access.log

CustomLog /var/log/apache2/other_vhosts_access.log vhost_combined
互相干擾, 故SetEnvIf的CustomLog不放在apache2.conf中.

1 comment:

Unknown said...

Collectd前台清單
http://collectd.org/wiki/index.php/List_of_front-ends
注: Collectd Graph Panel 不同於安裝例子中的Collectd Graph Viewer.