server1:服务端–>172.25.25.11
server7: 172.25.25.7
nginx监控
server7
[root@server7 ~]# rpm -ivh nginx-1.8.0-1.el6.ngx.x86_64.rpm
[root@server7 ~]# cd /etc/nginx/conf.d/
[root@server7 conf.d]# vim default.conf
13 location /status {
14 stub_status on;
15 access_log off;
16 allow 127.0.0.1;
17 deny all;
18 }
[root@server7 conf.d]# nginx -t
[root@server7 conf.d]# nginx
default.conf内容:
[root@server7 conf.d]# curl -s http://127.0.0.1/status | grep Active |awk '{print $NF}'
1
[root@server7 conf.d]# cd /etc/zabbix/zabbix_agentd.d/
[root@server7 zabbix_agentd.d]# ls
userparameter_mysql.conf
[root@server7 zabbix_agentd.d]# cp userparameter_mysql.conf userparameter_nginx.conf
[root@server7 zabbix_agentd.d]# vim userparameter_nginx.conf
UserParameter=nginx.active,curl -s http://127.0.0.1/status | grep Active| awk '{print $NF}'
UserParameter=nginx.accepts,curl -s http://127.0.0.1/status | awk NR==3 | awk '{print $1}'
UserParameter=nginx.handled,curl -s http://127.0.0.1/status | awk NR==3 | awk '{print $2}'
UserParameter=nginx.requests,curl -s http://127.0.0.1/status | awk NR==3 | awk '{print $3}'
[root@server7 zabbix_agentd.d]# /etc/init.d/zabbix-agent restart
userparameter_nginx.conf文件内容:
server1
关闭火墙,打开服务
[root@server1 ~]# systemctl start httpd
[root@server1 ~]# systemctl enable httpd
[root@server1 ~]# systemctl start mariadb
[root@server1 ~]# systemctl start zabbix-server
[root@server1 ~]# systemctl start zabbix-agent
# 单引号里内容的为server7的userparameter_nginx.conf文件里的键值
[root@server1 ~]# zabbix_get -s 172.25.25.7 -p 10050 -k 'nginx.active'
1
[root@server1 ~]# zabbix_get -s 172.25.25.7 -p 10050 -k 'nginx.accepts'
22
[root@server1 ~]# zabbix_get -s 172.25.25.7 -p 10050 -k 'nginx.handled'
23
[root@server1 ~]# zabbix_get -s 172.25.25.7 -p 10050 -k 'nginx.requests'
28
浏览器访问172.25.25.11/zabbix
选择刚创建的项目
其他三个项目也和第一个一样,但是不用再创建图形,直接把他们都添加到第一次创建的图形里去,结果如下,点击更新
查看:
2.数据库导入
server1的配置
[root@server1 ~]# rpm -ivh percona-zabbix-templates-1.1.8-1.noarch.rpm
[root@server1 ~]# cd /var/lib/zabbix/
[root@server1 zabbix]# ls
percona
[root@server1 scripts]# cd /var/lib/zabbix/percona/templates/
[root@server1 templates]# cp userparameter_percona_mysql.conf /etc/zabbix/zabbix_agentd.d/
[root@server1 templates]# cd /etc/zabbix/zabbix_agentd.d/
[root@server1 zabbix_agentd.d]# cat userparameter_percona_mysql.conf
[root@server1 zabbix_agentd.d]# systemctl restart zabbix-agent
[root@server1 zabbix_agentd.d]# cd -
/var/lib/zabbix/percona/templates
[root@server1 templates]# ls
userparameter_percona_mysql.conf
zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.8.xml
[root@server1 templates]# cd /var/lib/zabbix/percona/scripts/
[root@server1 scripts]# ls
get_mysql_stats_wrapper.sh ss_get_mysql_stats.php
[root@server1 scripts]# vim ss_get_mysql_stats.php.cnf
[root@server1 scripts]# mysql -p #测试是否可以登录进去
[root@server1 scripts]# /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh gg
4
[root@server1 scripts]# cd /tmp/
[root@server1 tmp]# ls
[root@server1 tmp]# rm -fr localhost-mysql_cacti_stats.txt
[root@server1 tmp]# cd /etc/zabbix/zabbix_agentd.d/
[root@server1 zabbix_agentd.d]# zabbix_get -s 127.0.0.1 -p 10050 -k 'MySQL.Threads-connected' #'MySQL.Threads-connected'是userparameter_percona_mysql.conf文件里的
24
浏览器:
导入后的mysql监控项会增加到一百多个
3.java
server7的配置
[root@server7 ~]# rpm -ivh jdk-8u121-linux-x64.rpm
[root@server7 ~]# tar zxf apache-tomcat-7.0.90.tar.gz -C /usr/local/
[root@server7 ~]# cd /usr/local/
[root@server7 local]# ln -s apache-tomcat-7.0.90/ tomcat
[root@server7 local]# cd tomcat/bin/
[root@server7 bin]# vim catalina.sh
CATALINA_OPTS='-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=8888
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false'
[root@server7 bin]# ./startup.sh
catalina.sh文件内容:
server1的配置
[root@server1 ~]# yum install zabbix-java-gateway-3.4.6-1.el7.x86_64.rpm -y
[root@server1 ~]# cd /etc/zabbix/
[root@server1 zabbix]# ls
web zabbix_agentd.d zabbix_java_gateway_logback.xml
zabbix_agentd.conf zabbix_java_gateway.conf zabbix_server.conf
[root@server1 zabbix]# systemctl start zabbix-java-gateway
[root@server1 zabbix]# vim zabbix_server.conf
JavaGateway=172.25.25.11
JavaGatewayPort=10052
StartJavaPollers=5
[root@server1 zabbix]# systemctl restart zabbix-java-gateway
zabbix_server.conf文件内容:
浏览器操作:
4.110云告警
注册一个帐号
物理主机添加防火墙策略
[root@foundation25 iso]# iptables -t nat -I POSTROUTING -s 172.25.25.0/24 -j MASQUERADE
server1的配置
[root@server1 zabbix]# route add default gw 172.25.25.250 #网关
[root@server1 zabbix]# route -n
[root@server1 zabbix]# vim /etc/resolv.conf #DNS
nameserver 114.114.114.114
[root@server1 zabbix]# ping baidu.com
安装oneitsm-zabbix-release
[root@server1 ~]# tar zxf oneitsm_zabbix_release-1.2.0.tar.gz
[root@server1 ~]# mv oneitsm /usr/lib/zabbix/alertscripts/ #移到脚本目录下
[root@server1 ~]# cd /usr/lib/zabbix/alertscripts/
[root@server1 alertscripts]# cd oneitsm/
[root@server1 oneitsm]# cd bin/
[root@server1 bin]# ./install.sh f009e018-e8cd-ca93-5267-49df0ecf7615
./log.sh: line 6: /usr/lib/zabbix/alertscripts/oneitsm/bin/oneitsm.conf: No such file or directory
start to create config file...
Zabbix管理地址: http://172.25.25.11/zabbix
Zabbix管理员账号: Admin
Zabbix管理员密码:
添加zabbix应用,得到key,记得添加通知策略~
server7的配置
关闭服务
[root@server7 bin]# /etc/init.d/zabbix-agent stop
浏览器:
查看告警,认领
开启服务
server7
[root@server7 bin]# /etc/init.d/zabbix-agent start
等待五分钟左右
IPMI
智能平台管理接口 (IPMI) 是一种开放标准的硬件管理接口规格,定义了嵌入式管理子系统进行通信的特定方法。IPMI 信息通过基板管理控制器 (BMC)(位于 IPMI 规格的硬件组件上)进行交流。使用低级硬件智能管理而不使用操作系统进行管理,具有两个主要优点: 首先,此配置允许进行带外服务器管理;其次,操作系统不必负担传输系统状态数据的任务
原本需要客户端取服务端去取数据,现在由server端主动发给客户端
浏览器图形界面操作:
在所有模版中:
全部选中,批量更新
监控项:改为主动式
添加一个新主机
server6配置
[root@server6 ~]# rpm -ivh zabbix-agent-3.4.6-1.el6.x86_64.rpm
[root@server6 ~]# /etc/init.d/zabbix-agent start
[root@server6 ~]# vim /etc/zabbix/zabbix_agentd.conf
server=172.25.25.11
hostname=server6
[root@server6 ~]# /etc/init.d/zabbix-agent restart
[root@server6 ~]# netstat -antlp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 910/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1328/master
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 1454/zabbix_agentd
tcp 0 0 172.25.25.6:50072 172.25.25.11:10051 FIN_WAIT2 -
tcp 0 0 172.25.25.6:22 172.25.25.250:34888 ESTABLISHED 1382/sshd
tcp 0 0 :::22 :::* LISTEN 910/sshd
tcp 0 0 ::1:25 :::* LISTEN 1328/master
tcp 0 0 :::10050 :::* LISTEN 1454/zabbix_agentd
tcp 0 0 :::3306 :::* LISTEN 1188/mysqld
[root@server6 ~]# /etc/init.d/zabbix-agent restart
Shutting down Zabbix agent: [ OK ]
Starting Zabbix agent: [ OK ]
/etc/zabbix/zabbix_agentd.conf文件内容:
浏览器访问:
结果显示server6添加进去则成功
proxy实现agent代理
server6
[root@server6 ~]# yum install -y zabbix-proxy-mysql-3.4.6-1.el6.x86_64.rpm fping-2.4b2-16.el6.x86_64.rpm
[root@server6 ~]# /etc/init.d/zabbix-agent stop
[root@server6 ~]# yum install mariadb-server -y
[root@server6 ~]# vim /etc/zabbix/zabbix_proxy.conf
server=172.25.25.11
hostname=server6
DBUser=zabbix
DBPassword=Redhat+123
DBSocket=/usr/local/mysql/mysql.sock
[root@server6 ~]# mysql -p
mysql> create database zabbix_proxy character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix_proxy.* to zabbix@localhost identified by'Redhat+123';
[root@server6 ~]# cd /usr/share/doc/zabbix-proxy-mysql-3.4.6/
[root@server6 zabbix-proxy-mysql-3.4.6]# zcat schema.sql.gz | mysql -u zabbix -p zabbix_proxy
# 导入数据库
[root@server6 zabbix-proxy-mysql-3.4.6]# /etc/init.d/mysqld restart
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
[root@server6 zabbix-proxy-mysql-3.4.6]# /etc/init.d/zabbix-proxy restart
/etc/zabbix/zabbix_proxy.conf
server7的配置
[root@server7 ~]# vim /etc/zabbix/zabbix_agentd.conf
Server=172.25.25.6
ServerActive=172.25.25.6
root@server7 ~]# /etc/init.d/zabbix-agent restart
hutting down Zabbix agent: [ OK ]
tarting Zabbix agent: [ OK ]
/etc/zabbix/zabbix_agentd.conf 文件内容:
浏览器里图形页面配置:
结果: