您好,登錄后才能下訂單哦!
****zabbix****
Zabbix
server(agent): 172.25.264.165
proxy(代理機): 172.25.254.161
agent: 172.25.254.164
一.安裝zabbix所需軟件包
(1) yum install
zabbix-server-2.4.5-1.el6.x86_64.rpm
zabbix-server-mysql-2.4.5-1.el6.x86_64.rpm
zabbix-web-2.4.5-1.el6.noarch.rpm
zabbix-web-mysql-2.4.5-1.el6.noarch.rpm
zabbix-2.4.5-1.el6.x86_64.rpm
fping-2.4b2-16.el6.x86_64.rpm
php-bcmath-5.3.3-26.el6.x86_64.rpm
php-mbstring-5.3.3-26.el6.x86_64.rpm
iksemel-1.4-2.el6.x86_64.rpm -y
(2)agent,被監控端所需軟件包
yum install
zabbix-2.4.5-1.el6.x86_64.rpm
zabbix-agent-2.4.5-1.el6.x86_64.rpm
(3)配置mysql數據庫
/etc/init.d/mysqld start
mysql
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'hxl123';
mysql> quit;
cd /usr/share/doc/zabbix-server-mysql-2.4.5/create
mysql -uzabbix -phxl123 zabbix < schema.sql
stop here if you are creating database for Zabbix proxy ##
mysql -uzabbix -phxl123 zabbix < p_w_picpaths.sql
mysql -uzabbix -phxl123 zabbix < data.sql
(4)配置zabbix server
vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=hxl123
(5)配置php(實則就是配置了一個timezone)
vim /etc/httpd/conf.d/zabbix.conf
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value date.timezone Asia/Shanghai
(6)訪問,直接在瀏覽器輸入http:/172.25.254.165/zabbix
二.添加agent主機
(1)agent,被監控端所需軟件包
yum install(rpm安裝)
zabbix-2.4.5-1.el6.x86_64.rpm
zabbix-agent-2.4.5-1.el6.x86_64.rpm
(2)配置
vim /etc/zabbix/zabbix_agentd.conf
Server=172.25.254.165
ServerActive=172.25.254.165
Hostname=server4.example.com [主機名需要有解析,這是自己的]
啟動 zabbix agent
service zabbix-agent start
(3)1.在zabbix server 上添加自動發現功能
點擊 Configuration -> Actions -> Create action 按下圖所示設置:
添加名稱和檢索ip的范圍
2. 自定義Configuration of actions,選擇Event source 為 Auto registration,Create action
Conditions 選項卡保持默認即可。
Operations 選項卡添加如下:
Add host:自動注冊主機添加到 hosts 列表
Add to host groups:自動注冊主機加入 linux servers 組(組名可以自定義)
Link to templates:自動注冊主機應用模板 Template OS linux
3.Configuration -> Hosts 點擊側邊的all 則可以查看所有主機
三.Agent主機設置為主動推送監控信息
(1)更改配置文件/etc/zabbix/zabbix_agentd.conf
#server=172.25.254.165[注釋掉]
StartAgents=0[改為0]
ServerActive=172.25.254.165[保留]
(2)克隆items,重新生成Zabbix agent(active)類型(以Template OS Linux 為例子)
1.在 Configuration of templates 下找到 Template OS Linux,選中 fullclone,并重新命名為Template OS Linux active
2.進入Template OS Linux active 將里面的items都設置成active類型(有的設置不完全的項目,要追其源項,以同樣的方式fullclone,然后重新鏈入Template OS Linux active中,這樣所有的都為active類型了)
3.再將Template OS Linux active 模板添入agent主機模板中即可(先刪除原先的鏈接)
圖示:
四.添加代理機proxy(代理主機:172.25.254.161 server1.example.com)
(1)下載軟件包
fping-2.4b2-16.el6.x86_64.rpm zabbix-2.4.5-1.el6.x86_64.rpm
zabbix-proxy-2.4.5-1.el6.x86_64.rpm zabbix-proxy-mysql-2.4.5-1.el6.x86_64.rpm
mysql-server
(2)配置數據庫
/etc/init.d/mysqld start
mysql
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'hxl123';
mysql> quit;
cd /usr/share/doc/zabbix-server-mysql-2.4.5/create
mysql -uzabbix -phxl123 zabbix < schema.sql
(3)配置文件
vim /etc/zabbix/zabbix_proxy.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=hxl123
/etc/init.d/zabbix-proxy start
vim /etc/zabbix/zabbix_agent.conf
ServerActive=172.25.254.161
Hostname=server4.example.com
五.擴展mysql數據庫信息,加載percona-zabbix-templates-1.1.6-1.noarch.rpm
(1)下載安裝文件(yum,rpm)
(2)cd /var/lib/zabbix/percona/templates
vim /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php.cnf
<?php
$mysql_user = 'zabbix';
$mysql_pass = 'hxl123';
vim /var/lib/zabbix/.my.cnf
[client]
user = zabbix
password = hxl123
cd /tmp/
chown zabbix.zabbix localhost-mysql_cacti_stats.txt
(3)scp /var/lib/zabbix/percona/templates/zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.6.xml發送到物理機上,有便與在瀏覽器上添加
六.云告警
(1).安裝
tar zxf alert-agent-4.1.3.1-linux-x64.tar.gz
cp -R alert-agent /usr/lib/zabbix/alertscripts/
cd /usr/lib/zabbix/alertscripts/
chown -R zabbix.zabbix alert-agent/
cp alert-agent/plugin/zabbix-plugin/110monitor /usr/lib/zabbix/alertscripts
chown +x /usr/lib/zabbix/alertscripts/110monitor
(2).程序界面配置
1.Administration
Media types
Create media type
2.Administration
users
zabbix administration user1
user1 < Admin < media < add
[這里的key,就是你在云告警上注冊的,人家給你的那個key]
3.Configuration
Action
最右角的 Event source 選擇 Triggers 選擇 Create action
[這兩個Action的內容,其實zabbix官網是有教程步驟的,你可以去找找就不用自己手動填寫了http://wiki.110monitor.com/integration/zabbix-manual.html]
(3)測試
systcl -w net.ipv4.icmp_echo_ignore_all = 1 禁ping
systcl -w net.ipv4.icmp_echo_ignore_all = 0 啟ping
server 主機執行 ./110monitor 1b5c86fa-7157-da2c-ef66-eed359b6f4b3 trigger “alarmName:helloworld”
顯示 success 即表示成功,一會變會根據你在云告警平臺設置的策略而向你推送消息。
七.JXM(tomcat監控)
Agent主機:
(1)tar zxf apache-tomcat-7.0.37.tar.gz
yum install -y jdk-8u121-linux-x64.rpm
(2)vim apache-tomcat-7.0.37/bin/catalina.sh
...
CATALINA_OPTS="-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.port=8888
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.rmi.server.hostname=172.25.254.164"
...
(3)./startup.sh
netstat -antlpe
Server主機:
(1)zabbix-java-gateway-2.4.5-1.el6.x86_64.rpm
配置文件保持默認則可
(2) /etc/init.d/zabbix-java-gateway start
netstat -antlpe(見上圖)
(3) vim /etc/zabbix/zabbix_server.conf
JavaGateway=172.0.0.1[java-gateway 與zabbix-server 在同一主機上]
JavaGatewayPort=10052
StartJavaPoller=5[server和proxy中的開啟數目要小于等于gateway中的]
/etc/init.d/zabbix-server restart
(4)因為本機先前做了proxy,所以proxy主機上的配置文件也要更改
JavaGateway=172.25.254.165
JavaGateway=10052
Start.JavaPollers=5
/etc/init.d/zabbix-proxy restart
圖示:
注意:這里只將StartAgents=0
其他項修改已經在proxy板塊修改完成,
vim /etc/zabbix/zabbix_agent.conf
ServerActive=172.25.254.161
Hostname=server1.example.com
切記,要添加JMX端口和server name
這是一些自己練習的筆記
curl -s http://172.25.254.164/status | grep Active | awk '{print $NF}'
Cobber + ipmi + pxe
pxe ——> system ——> zabbix-agent
Execl ——> redis ——> python ——> zabbix-api
mysql ——> salt ——> api ——> 0.1 nginx 0.2 haproxy ...
1.[root@server3 ~]# curl -s -X POST -H 'Content-Type:application/json' -d '
{
"jsonrpc": "2.0",
"method": "user.login",
"params": {
"user": "Admin",
"password": "westos"
},
"id": 1,
"auth": null
> }' http://172.25.0.3/zabbix/api_jsonrpc.php | python -m json.tool
{
"id": 1,
"jsonrpc": "2.0",
"result": "b478818c41288fbf9a38ee0c0e1491d3"
}
2.[root@server3 ~]# curl -s -X POST -H 'Content-Type:application/json' -d '
{
"jsonrpc": "2.0",
"method": "host.get",
"params": {
"output": ["host"]
},
"auth": "b478818c41288fbf9a38ee0c0e1491d3",
"id": 1
}' http://172.25.0.3/zabbix/api_jsonrpc.php | python -m json.tool
3.[root@server3 ~]# curl -s -X POST -H 'Content-Type:application/json' -d '
{
"jsonrpc": "2.0",
"method": "host.delete",
"params": [
"10113"
],
"auth": "b478818c41288fbf9a38ee0c0e1491d3",
"id": 1
}' http://172.25.0.3/zabbix/api_jsonrpc.php | python -m json.tool
4.[root@server3 ~]# curl -s -X POST -H 'Content-Type:application/json' -d '
{
"jsonrpc": "2.0",
"method": "host.create",
"params": {
"host": "Linux server",
"interfaces": [
{
"type": 1,
"main": 1,
"useip": 1,
"ip": "172.25.0.4",
"dns": "",
"port": "10050"
}
],
"groups": [
{
"groupid": "2"
}
],
"templates": [
{
"templateid": "10001"
}
]
},
"auth": "b478818c41288fbf9a38ee0c0e1491d3",
"id": 1
}' http://172.25.0.3/zabbix/api_jsonrpc.php | python -m json.tool
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"hostids": [
"10115"
]
}
}
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。