****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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。