cacti 重圖形,有數據歷史,需用到數據庫支持,支持web配置,默認不支持告警,可以加插件;
nagios重狀態和結果,沒有數據歷史,不成圖像,不支持web配置,可以自己開發腳本定製個性化監控,支持多種插件;
zabbix有數據歷史,可成圖像,支持web配置,可以自動發現;
第一部分:監控軟件Cacti搭建
一、環境準備
1、安裝epel擴展源
關閉selinux
臨時關閉 setenforce 0
vim /etc/selinux/config
SELINUX=disbabled
1 |
|
2、搭建lamp環境
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
3、安裝cacti監控主機
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|
4、通過瀏覽器訪問
如果訪問不了,請檢查主機的iptables和selinux
http://IP/cacti/
點兩下“next” 和一次”Finish“ 即可
輸入admin admin 登錄,重新設置新的密碼
5 查看默認主機
執行poller.php, 生成圖形, 加入計劃任務
/usr/bin/php /usr/share/cacti/poller.php添加cron任務
cront -e 增加:
*/5 * * * * /usr/bin/php /usr/share/cacti/poller.php
6 添加需要被監控的主機
接下來我們添加被監控的主機
在被監控的主機上安裝
[root@rsa ~]
# yum install -y net-snmp lm_sensors
[root@rsa ~]
# vim /etc/snmp/snmpd.conf
#syslocation Unknown (edit /etc/snmp/snmpd.conf)
syslocation 192.168.1.118
#group context sec.model sec.level prefix read write notif
access notConfigGroup
""
any noauth exact all none none
view all included .1 80
[root@rsa ~]
# /etc/init.d/snmpd start
修改syslocation以及syscontact, 其中syslocation 可以寫本機ip,syscontact寫管理員郵箱
view systemview included .1.3.6.1.2.1.1
修改爲:
view systemview included .1.3.6.1.2.1(如果不改,可能找不到網卡)
7 啓動 snmp
/etc/init.d/snmpd start
8 管理cacti後臺
點console , 再點Device, 在右上角點”Add“
Description 寫本機ip或你自定義一個名字
Hostname 寫本機ip
Host Template 選ucd/net SNMP Host
SNMP Version 選Version 2
點右下角的create
點右上角的”Create Graphs for this Host“
Graph Types: 選擇SNMP - Interface Statistics
Graph Types: 再選擇 Graph Template Based
在下面的框中,選擇你要監控的項目,比如ucd/net - Load Average
在右側小方塊中打對勾,然後點右下角的create
9 添加實時監控後臺
選中”Default Tree“
點右上角的Add
Tree Item Type 選擇 ”Host“
Host 選擇我們剛剛增加的那個機器ip
點右下角的create
10 點左上角的Graphs
在左側可以看到
Defaut Tree下面已經增加了我們剛剛添加的主機,圖形一開始不會那麼快出來,要等一小會纔可以。
參考文章:http://www.it165.net/admin/html/201310/1956.html
Cacti安裝高效輪詢器spine(轉)
Cacti默認輪詢器cmd.php執行效率有點低,spine爲C語言編寫的組件,性能要好許多。
編譯安裝spine需以下軟件支持:
1 net-snmp-devel
2 mysql
3 mysql-devel
4 openssl-devel
5 gcc
安裝spine要和Cacti的版本相匹配,本文以最新版cacti0.8.8a安裝爲例。
1 cd /usr/local/src/
2 wget
http://www.cacti.net/downloads/spine/cacti-spine-0.8.8a.tar.gz
3 tar -zxvf cacti-spine-0.8.8a.tar.gz
4 cd cacti-spine-0.8.8a
編譯:
5 ./configure
6 make && make instatll
配置spine:
1 cd /usr/local/spine/etc/
2 mv spine.conf.dist
/etc/spine.conf
3 vi spine.conf
填寫數據庫信息,即Cacti數據庫。
DB_Host localhost
DB_Database cacti
DB_User root
DB_Pass cacti
DB_Port 3306
設置spine路徑,Console——Settings——Paths
cacti設置spine路徑
/usr/local/spine/bin/spine
更改cacti輪詢器爲spine,Console——Settings——Poller
cacti更改輪詢器爲spine
運行:
#/usr/local/spine/bin/spine
SPINE: Using spine config file [/etc/spine.conf]
SPINE: Version 0.8.7g starting
SPINE: Time: 0.2410 s, Threads: 5, Hosts: 2
說明:spine默認配置文件需要放在/etc纔會生效,否則報如下錯誤:
SPINE: Poller[0] FATAL: Unable to read configuration file! (Spine
init)