zabbix--3.0--3
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=8888
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Djava.rmi.server.hostname=192.168.58.12"

[root@linux-node2 src]# killall java
[root@linux-node2 src]# killall java
java: no process found
[root@linux-node2 src]# /usr/local/tomcat/bin/startup.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started. 看到8888端口已经起来了
[root@linux-node2 src]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 6938/zabbix_agentd
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1160/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1251/master
tcp6 0 0 :::10050 :::* LISTEN 6938/zabbix_agentd
tcp6 0 0 127.0.0.1:8005 :::* LISTEN 8522/java
tcp6 0 0 :::56614 :::* LISTEN 8522/java
tcp6 0 0 :::8009 :::* LISTEN 8522/java
tcp6 0 0 :::111 :::* LISTEN 1/systemd
tcp6 0 0 :::8080 :::* LISTEN 8522/java
tcp6 0 0 :::22 :::* LISTEN 1160/sshd
tcp6 0 0 :::8888 :::* LISTEN 8522/java
tcp6 0 0 :::57945 :::* LISTEN 8522/java
tcp6 0 0 ::1:25 :::* LISTEN 1251/master
[root@linux-node2 src]#

[root@linux-node1 ~]# zabbix_get -s 192.168.58.12 -k jmx["java.lang:type=GarbageCollector,name=Copy",CollectionCount]
ZBX_NOTSUPPORTED: Unsupported item key.
[root@linux-node1 ~]#
1、开启Nginx监控
2、编写脚本来进行数据采集
3、设置用户自定义参数
4、重启zabbix-agent
5、添加item
6、创建图形
7、创建触发器
8、创建模板
[root@linux-node2 src]# ss -ant | awk 'NR>1 {++s[$1]} END {for(k in s) print k,s[k]}'
LISTEN 14
ESTAB 4
TIME-WAIT 30
[root@linux-node2 src]#

[root@linux-node1 ~]# vim /etc/zabbix/zabbix_agentd.conf

[root@linux-node1 ~]# cd /etc/zabbix/zabbix_agentd.d/
[root@linux-node1 zabbix_agentd.d]# ls
nginx.conf userparameter_mysql.conf
[root@linux-node1 zabbix_agentd.d]# rz -E
rz waiting to receive.
[root@linux-node1 zabbix_agentd.d]# ls
nginx.conf userparameter_mysql.conf zabbix_linux_plugin.sh
[root@linux-node1 zabbix_agentd.d]# chmod +x zabbix_linux_plugin.sh
[root@linux-node1 zabbix_agentd.d]# ls
nginx.conf userparameter_mysql.conf zabbix_linux_plugin.sh
[root@linux-node1 zabbix_agentd.d]#
[root@linux-node1 ~]# vim /usr/local/nginx/conf/nginx.conf
[root@linux-node1 ~]# /usr/local/nginx/sbin/nginx -s reload
[root@linux-node1 ~]#

[root@linux-node1 ~]# /usr/local/nginx/sbin/nginx -s reload
[root@linux-node1 ~]#
[root@linux-node1 zabbix_agentd.d]# ./zabbix_linux_plugin.sh nginx_status 8080 active
1
[root@linux-node1 zabbix_agentd.d]#
[root@linux-node1 zabbix_agentd.d]# cp nginx.conf linux.conf
[root@linux-node1 zabbix_agentd.d]# vim linux.conf
[root@linux-node1 zabbix_agentd.d]# cat linux.conf
UserParameter=linux_status[*],/etc/zabbix/zabbix_agentd.d/zabbix_linux_plugin.sh "$1" "$2" "$3"
[root@linux-node1 zabbix_agentd.d]#
[root@linux-node1 zabbix_agentd.d]# systemctl restart zabbix-agent.service
[root@linux-node1 zabbix_agentd.d]#
[root@linux-node1 ~]# zabbix_get -s 192.168.58.11 -k linux_status[nginx_status,8080,active]
1
[root@linux-node1 ~]#



[root@linux-node1 zabbix_agentd.d]# pwd
/etc/zabbix/zabbix_agentd.d
[root@linux-node1 zabbix_agentd.d]# ll
total 16
-rw-r--r-- 1 root root 96 Mar 26 15:22 linux.conf
-rw-r--r-- 1 root root 117 Mar 19 20:37 nginx.conf
-rw-r--r-- 1 root root 1531 Mar 2 23:49 userparameter_mysql.conf
-rwxr-xr-x 1 root root 2776 Jun 18 2016 zabbix_linux_plugin.sh
[root@linux-node1 zabbix_agentd.d]#



邮件配置对的话,肯定能收到告警
这里还看到了一个告警,Too many processes on linux-node2
系统自带的触发器,阈值太低,修改下模板里的items里的阀值

自定义告警脚本:
1、放在 /usr/lib/zabbix/alertscripts
2、需要支持3个参数,1 收件人,2 主题, 3内容
3、执行权限
4、web界面添加
5、修改actions
curl -X POST 'http://gw.api.taobao.com/router/rest' \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'app_key=12129701' \
-d 'format=json' \
-d 'method=alibaba.aliqin.fc.sms.num.send' \
-d 'partner_id=apidoc' \
-d 'sign=DB9F439ACCF950E94514CDF0BF24DFB8' \
-d 'sign_method=hmac' \
-d 'timestamp=2017-03-26+16%3A25%3A33' \
-d 'v=2.0' \
-d 'extend=123456' \
-d 'rec_num=13000000000' \
-d 'sms_free_sign_name=%E9%98%BF%E9%87%8C%E5%A4%A7%E4%BA%8E' \
-d 'sms_param=%7B%5C%22code%5C%22%3A%5C%221234%5C%22%2C%5C%22product%5C%22%3A%5C%22alidayu%5C%22%7D' \
-d 'sms_template_code=SMS_585014' \
-d 'sms_type=normal'
[root@linux-node1 ~]# cd /usr/lib/zabbix/alertscripts
[root@linux-node1 alertscripts]# ls
[root@linux-node1 alertscripts]# vim sms.sh
[root@linux-node1 alertscripts]# chmod +x sms.sh
[root@linux-node1 alertscripts]# cat sms.sh
#!/bin/bash
ALERT_TO=$1
ALERT_TITLE=$2
ALERT_BODY=$3 echo $ALERT_TO >> /tmp/sms.log
echo $ALERT_TITLE >> /tmp/sms.log
echo $ALERT_BODY >> /tmp/sms.log
[root@linux-node1 alertscripts]#
[root@linux-node1 tmp]# tail -5 /tmp/sms.log
xxxx38@qq.com
PROBLEM: Nginx Active > 1
Original ev* (*UNKNOWN*:*UNKNOWN*): *UNKNOWN*tus[nginx_status,8080,active]): 3
[root@linux-node1 tmp]#
yum install http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm -y [root@linux-node1 ~]# yum install percona-zabbix-templates php php-mysql -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirror01.idc.hinet.net
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Package percona-zabbix-templates-1.1.7-2.noarch already installed and latest version
Package php-5.4.16-42.el7.x86_64 already installed and latest version
Package php-mysql-5.4.16-42.el7.x86_64 already installed and latest version
Nothing to do
[root@linux-node1 ~]#
相关知识点
1、php脚本用来采集数据
2、shell调用这个php
3、zabbix配置文件
4、zabbix模板文件
[root@linux-node1 ~]# rpm -ql percona-zabbix-templates
/var/lib/zabbix/percona
/var/lib/zabbix/percona/scripts
/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh
/var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php
/var/lib/zabbix/percona/templates
/var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf
/var/lib/zabbix/percona/templates/zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.7.xml
[root@linux-node1 ~]# cp /var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf /etc/zabbix/zabbix_agentd.d/
[root@linux-node1 ~]#
[root@linux-node1 ~]# cd /etc/zabbix/zabbix_agentd.d/
[root@linux-node1 zabbix_agentd.d]# ls
linux.conf userparameter_mysql.conf zabbix_linux_plugin.sh
nginx.conf userparameter_percona_mysql.conf
[root@linux-node1 zabbix_agentd.d]#
[root@linux-node1 scripts]# systemctl restart zabbix-agent.service
[root@linux-node1 scripts]#
[root@linux-node1 zabbix_agentd.d]# tail -10 userparameter_percona_mysql.conf
UserParameter=MySQL.log-writes,/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh hg
UserParameter=MySQL.Query-time-count-04,/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh op
UserParameter=MySQL.Query-time-count-05,/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh oq
UserParameter=MySQL.Query-time-count-06,/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh or
UserParameter=MySQL.Query-time-count-07,/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh os
UserParameter=MySQL.Query-time-count-08,/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh ot
UserParameter=MySQL.Query-time-count-09,/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh ou
UserParameter=MySQL.Open-files,/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh ij
UserParameter=MySQL.State-closing-tables,/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh lq
UserParameter=MySQL.running-slave,/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh running-slave
[root@linux-node1 zabbix_agentd.d]#
[root@linux-node1 zabbix_agentd.d]# cd /var/lib/zabbix/percona/scripts
[root@linux-node1 scripts]# ls
get_mysql_stats_wrapper.sh ss_get_mysql_stats.php
[root@linux-node1 scripts]#
[root@linux-node1 scripts]# cat ss_get_mysql_stats.php.cnf
<?php
$mysql_user = 'root';
$mysql_pass = '';
[root@linux-node1 scripts]#
[root@linux-node1 scripts]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 9629
Server version: 5.5.52-MariaDB MariaDB Server Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> exit
Bye
[root@linux-node1 scripts]#
[root@linux-node1 scripts]# /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh gg
0
[root@linux-node1 scripts]#
[root@linux-node1 scripts]# ll get_mysql_stats_wrapper.sh
-rwxr-xr-x 1 root root 1251 Dec 10 02:22 get_mysql_stats_wrapper.sh
[root@linux-node1 scripts]#

[root@linux-node1 scripts]# ./get_mysql_stats_wrapper.sh gm
1
[root@linux-node1 scripts]#
[root@linux-node1 scripts]# zabbix_get -s 192.168.58.11 -k MySQL.max-connections
rm: cannot remove ‘/tmp/localhost-mysql_cacti_stats.txt’: Operation not permitted
151
[root@linux-node1 scripts]#
[root@linux-node1 scripts]# ll /tmp/localhost-mysql_cacti_stats.txt
-rw-r--r-- 1 root root 1406 Mar 26 22:15 /tmp/localhost-mysql_cacti_stats.txt
[root@linux-node1 scripts]# chown zabbix.zabbix /tmp/localhost-mysql_cacti_stats.txt
[root@linux-node1 scripts]# ll /tmp/localhost-mysql_cacti_stats.txt
-rw-r--r-- 1 zabbix zabbix 1406 Mar 26 22:15 /tmp/localhost-mysql_cacti_stats.txt
[root@linux-node1 scripts]# zabbix_get -s 192.168.58.11 -k MySQL.max-connections
151
[root@linux-node1 scripts]#
[root@linux-node1 ~]# curl --head http://192.168.58.12:8080/
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/html;charset=UTF-8
Transfer-Encoding: chunked
Date: Sun, 26 Mar 2017 15:14:17 GMT [root@linux-node1 ~]#
[root@linux-node2 ~]# /usr/local/tomcat/bin/shutdown.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
[root@linux-node2 ~]# lsof -i:8080
[root@linux-node2 ~]#
[root@linux-node1 ~]# date
Mon Mar 27 08:45:34 CST 2017
[root@linux-node1 ~]# systemctl restart ntpd
[root@linux-node1 ~]# date
Mon Mar 27 08:45:46 CST 2017
[root@linux-node1 ~]# date
Mon Mar 27 08:45:47 CST 2017
[root@linux-node1 ~]# date
Mon Mar 27 08:45:48 CST 2017
[root@linux-node1 ~]# date
Wed Mar 29 23:10:17 CST 2017
[root@linux-node1 ~]#
[root@linux-node2 webapps]# mv ROOT ROOT2
[root@linux-node2 webapps]# ls
docs examples host-manager manager ROOT2
[root@linux-node2 webapps]# mv ROOT2 ROOT
[root@linux-node2 webapps]#
[root@linux-node1 ~]# tail -f /tmp/sms.log
Original ev* (*UNKNOWN*:*UNKNOWN*): *UNKNOWN*e=Runtime",Uptime]): 00:00:09
525031638@qq.com
PROBLEM: linux-node2 is not reachable
Original ev* (*UNKNOWN*:*UNKNOWN*): *UNKNOWN*e=Runtime",Uptime]): 00:00:25
525031638@qq.com
状态:OK
监控项:jmx["java.lang:type=Runtime",Uptime]):00:00:5
525031638@qq.com
状态:PROBLEM
监控项:web.test.rspcode[tomcat web monitor,tomcat index]):40
为什么使用主动模式
1、监控主机多,性能跟不上,延迟大
2、多机房,防火墙
Zabbix轻松解决。Nagios不太好解决
针对Agent来说
1、被动模式
2、主动模式,active
当监控主机超过300+,建议使用主动模式

[root@linux-node2 webapps]# systemctl restart zabbix-agent.service
[root@linux-node2 webapps]#
网页制作主动监控模式模板
add之后
这里都变成active的了
zabbix--3.0--3的更多相关文章
- zabbix 3.0 安装 ubuntu环境
zabbix 3.0 安装 标签(空格分隔): 开发 [TOC] 下载deb # wget http://repo.zabbix.com/zabbix/3.0/ubuntu/pool/main/z/z ...
- [转]Zabbix 3.0 安装笔记
Zabbix 3.0 只支持CentOS 7.0以上版本,所以先在虚拟机中安装好CentOS 7.0 x64,并设置好IP,允许虚拟机联网. 1.安装MySQL 从最新版本的linux系统开始,默认的 ...
- zabbix 3.0快速安装简介(centos 6)
zabbix快速安装 系统版本:centos 6 1.yum源配置和zabbix.msyql安装 rpm -ivh http://mirrors.aliyun.com/zabbix/zabbix/3. ...
- zabbix 3.0快速安装简介(centos 7)
zabbix快速安装 系统版本:centos 7 通过yum方法安装Zabbix3.0,安装源为阿里云 yum源配置 rpm -ivh http://mirrors.aliyun.com/zabbix ...
- Zabbix 3.0 安装笔记
Zabbix 3.0 只支持CentOS 7.0以上版本,所以先在虚拟机中安装好CentOS 7.0 x64,并设置好IP,允许虚拟机联网. 1.安装MySQL 从最新版本的linux系统开始,默认的 ...
- CentOS-6.5安装zabbix 3.0.4
关闭selinux [root@localhost /]# sed -i "s#SELINUX=enforcing#SELINUX=disabled#g" /etc/selinux ...
- Zabbix 3.0.3 SQL Injection
Zabbix version 3.0.3 suffers from a remote SQL injection vulnerability. ============================ ...
- zabbix 3.0 安装
zabbix3.0安装注意: 1.PHP要5.4版本以上 2.防火墙关闭 3.selinux关闭 注:本操作系统为centos 6.5 X86 操作步骤 一.安装PHP 添加 epel 源 # r ...
- Zabbix 3.0 从入门到精通(zabbix使用详解)
第1章 zabbix监控 1.1 为什么要监控 在需要的时刻,提前提醒我们服务器出问题了 当出问题之后,可以找到问题的根源 网站/服务器 的可用性 1.1.1 网站可用性 在软件系统的高可靠性(也 ...
- Zabbix 3.0 基础介绍 [一]
zabbix 简介 Zabbix 是一个高度集成的网络监控解决方案,可以提供企业级的开源分布式监控解决方案,由一个国外的团队持续维护更新,软件可以自由下载使用,运作团队靠提供收费的技术支持赢利 zab ...
随机推荐
- FPGA的GTP(aurora 协议)高速串行接口数据收发(转)
reference:https://blog.csdn.net/qq_40261818/article/details/83039829 PG046-Aurora 8B/10B Logicore I ...
- python23的区别-日常记录
1. xrange:python3 中取消了range函数,把python2中的xrange重新命名为range,所以在python3中直接用range就行. 2. print:python3中pri ...
- 牛客多校第五场 F take
链接:https://www.nowcoder.com/acm/contest/143/F来源:牛客网 题目描述 Kanade has n boxes , the i-th box has p[i] ...
- <Spark><Advanced Programming>
Introduction 介绍两种共享变量的方式: accumulators:聚集信息 broadcast variables:高效地分布large values 介绍对高setup costs任务的 ...
- 2019-04-03-day025-异常与日志
内容回顾 考试 6个小时 120分 (100+20) 15:00-18:00 笔试 60分 19:00-22:00 上机考试 40分 + 20分 60分及格不算附加题 简答题 读程序 简单编程 编程题 ...
- 2019-03-05-day004-列表操作
01 昨日内容回顾 bool int str 三者转换:pass int 二进制与十进制之间的转换: 二进制 -------> 十进制 0000 0100 1*2**2 str: msg = ' ...
- 安装Cygwin,,以及遇到的问题
实验需要用到Cygwin,于是去下了一个,安装过程比较顺利,参考:http://blog.csdn.net/chunleixiahe/article/details/55666792 但是发现 ma ...
- Java知识汇总——思维导图
转载:https://www.cnblogs.com/java1024/p/8757952.html Java知识点汇总,从基础到常用的API.还有常用的集合类,总结的很详细.图片是从论坛里面找到的, ...
- box-sizing布局
box-sizing 语法:box-sizing: content-box | border-box | inherit; 参考: https://www.jianshu.com/p/e2eb0d8c ...
- [转]lua元表代码分析
http://lin-style.iteye.com/blog/1012138 版本整理日期:2011/4/21 元表其实就是可以让你HOOK掉一些操作的一张表. 表的定义在ltm.h/c的文件里.对 ...