当前位置: 首页 > news >正文

网站建设信息业务推广平台

网站建设信息,业务推广平台,遵义工作网招聘信息网,大连高新园区法院文章目录 1.配置钉钉告警server 配置web界面创建媒介给用户添加媒介测试告警 实现故障自愈功能监控Javazabbix server 安装java gateway配置 Zabbix Server 支持 Java gateway使用系统内置模板监控 tomcat 主机 1.配置钉钉告警 server 配置 钉钉告警python脚本 脚本1 cd /…

文章目录

    • 1.配置钉钉告警
        • server 配置
        • web界面创建媒介
        • 给用户添加媒介
        • 测试告警
    • 实现故障自愈功能
    • 监控Java
        • zabbix server 安装java gateway
        • 配置 Zabbix Server 支持 Java gateway
        • 使用系统内置模板监控 tomcat 主机

1.配置钉钉告警

server 配置

钉钉告警python脚本

脚本1

cd  /lib/zabbix/alertscripts/cat  python20 
#!/usr/bin/python3
#coding:utf-8
import requests,json,sys,os,datetime
# 机器人的Webhook地址
webhook="钉钉"
user=sys.argv[1]
text=sys.argv[3]
data={"msgtype": "text","text": {"content": text},"at": {"atMobiles": [# 在web端用户绑定媒介中通过指定用户注册是的手机号,可以通知指定人员,否则只发消息,不艾特具体人user],"isAtAll": False# 设置为1,则@所有人# "isAtAll": 1}
}
headers = {'Content-Type': 'application/json'}
x=requests.post(url=webhook,data=json.dumps(data),headers=headers)
if os.path.exists("/var/log/zabbix/dingding.log"):f=open("/var/log/zabbix/dingding.log","a+")
else:f=open("/var/log/zabbix/dingding.log","w+")
f.write("\n"+"--"*30)
if x.json()["errcode"] == 0:f.write("\n"+str(datetime.datetime.now())+"    "+str(user)+"    "+"发送成功"+"\n"+str(text))f.close()
else:f.write("\n"+str(datetime.datetime.now()) + "    " + str(user) + "    " + "发送失败" + "\n" + str(text))

脚本2

cat ding
#!/usr/bin/env python3
#zabbix钉钉报警
import requests,json,sys,os,datetime
##刚刚保存的Webhook
webhook="钉钉Webhook"
user=sys.argv[1]  ##执行脚本时传递的第一个参数,发送用户
text=sys.argv[3]  ##执行脚本时传递的第三个参数,发送内容
data={"msgtype": "text","text": {"content": text},"at": {"atMobiles": [user],"isAtAll": False}
}
headers = {'Content-Type': 'application/json'}
x=requests.post(url=webhook,data=json.dumps(data),headers=headers)
if os.path.exists("/usr/lib/zabbix/logs/dingding.log"):f=open("/usr/lib/zabbix/logs/dingding.log","a+")
else:f=open("/usr/lib/zabbix/logs/dingding.log","w+")
f.write("\n"+"--"*30)
if x.json()["errcode"] == 0:f.write("\n"+str(datetime.datetime.now())+" "+str(user)+" "+"发送成功"+"\n"+str(text))f.close()

web界面创建媒介

错误1:
在这里插入图片描述


sh: 1: /usr/lib/zabbix/alertscripts/dingding.py: not found
单python3 文件名字 测试正常,还以为ubuntu不支持,结果多次测试是因为是在window复制创建的文件,使用./文件名发现有其他字符^M,^M字符表示回车符,它可能是由于使用Windows风格的换行符引起的。在Linux系统上,需要使用Unix风格的换行符。
你可以尝试使用dos2unix命令来转换文件的换行符格式。打开终端,并运行以下命令:dos2unix python20root@ubuntu20:/usr/lib/zabbix/alertscripts# ./dingding3.py 
-bash: ./dingding3.py: /usr/bin/python3^M: bad interpreter: No such file or directory

给用户添加媒介

在这里插入图片描述

测试告警

实现故障自愈功能

当zabbix监控到指定的监控项异常时,可以通过指定的操作使故障自动恢复以nginx服务为例,当nginx服务停止时,自动重启服务,实现故障自愈功能

agent添加配置

vim /etc/zabbix/zabbix_agentd.conf 
AllowKey=system.run[*] #允许所有远程命令,zabbix5.0版本以上,代替EnableRemoteCommands,agent2默认没有此命令手工加入
#EnableRemoteCommands=1 #开启远程执行命令,此指令在zabbix5.0版本以上淘汰
AllowRoot=1  #开启此项,直接使用root进行远程管理,而无须对zabbix用户授权sudo权限,agent2不支持,使用下面的对zabbix授权
UnsafeUserParameters=1  #允许远程执行命令的时候使用不安全的参数(特殊字符串,如: \ ' *

默认zabbix agent是使用zabbix用户启动的,有些特权命令zabbix用户是没有权限执行,会导致定义好
的自治愈策略因为权限拒绝为执行失败,所以需要事先对zabbix用户进行授权.

[root@centos8 ~]#vim /etc/sudoers
zabbix ALL=(ALL) NOPASSWD: ALL
#检查语法
[root@centos8 ~]#visudo -c
重启
systemctl restart zabbix-agent2.service
服务端配置

创建动作
创建动作,触发器
在这里插入图片描述

动作中添加
在这里插入图片描述

把nginx停止,会自动执行systemctl start nginx命令,故障恢复

在这里插入图片描述

主动模式
主动模式和被动模式相对agent来说的

ServerActive=192.168.1.150 #向谁汇报,开启主动模式
Hostname=192.168.1.220 #agent中Hostname 此项必须和Zabbix Server中设置的主机名称相同,不然采集不了数据,会报错找不到

监控项改为主动式
在这里插入图片描述

主动模式监控项
在这里插入图片描述

复制模板,批量更新监控项为主动式
在这里插入图片描述

主机并联新的模板
在这里插入图片描述

问题1

2023/09/04 19:34:48.385426 [101] no active checks on server [192.168.1.150:10051]: host [zhujiming-192.168.1.220] not found
2023/09/04 19:36:49.387602 [101] no active checks on server [192.168.1.150:10051]: host [zhujiming-192.168.1.220] not found
2023/09/04 19:38:50.397644 [101] no active checks on server [192.168.1.150:10051]: host [zhujiming-192.168.1.220] not found
2023/09/04 19:40:51.382330 [101] no active checks on server [192.168.1.150:10051]: host [zhujiming-192.168.1.220] not found
界面查看数据没有更新,查看日志,agent配置文件中hostname和服务端页面的主机名称要一样

问题2:zbx是灰色,但查看数据正常,是因为这个主机的模版全是主动模式。server 不会向agent发,添加其他被动模式模版即可
在这里插入图片描述

监控Java

Zabbix 不支持直接监控JAVA应用
如果要监控JAVA程序比如Tomcat等,需要使用 Java gateway 做为代理,才能从JAVA应用中获取数据

Zabbix 监控JVM流程
zabbix-server 通知 zabbix-Java-Gateway需要获取监控主机的哪些监控项
Zabbix-Java-Gateway 通过 JMX 协议请求采集 Java进程数据
Java程序通过 JMX 协议返回数据给 zabbix-Java-Gateway
zabbix-Java-Gateway 最终返回数据给 zabbix-server
zabbix-server 对采集的JAVA 数据进行存储,然后进行 Web 展示

192.168.1.250安装好java+tomcat环境
Tomcat 开启 JMX 功能
192.168.1.250填本机ip
#vim /usr/local/tomcat/bin/catalina.sh
CATALINA_OPTS=“$CATALINA__OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=12345 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=192.168.1.250”

systemctl restart tomcat

[root@rocky8 ~]# ss -tnl|grep 12345
LISTEN 0 50 *:12345 :

zabbix服务端测试
root@ubuntu20:~# java -jar cmdline-jmxclient-0.10.3.jar - 192.168.1.250:12345  'Catalina:name="http-nio-8080",type=ThreadPool' currentThreadCount09/04/2023 23:03:05 +0800 org.archive.jmx.Client currentThreadCount: 10java线程数
java -jar cmdline-jmxclient-0.10.3.jar - 192.168.1.250:12345  'Catalina:name="http-nio-8080",type=ThreadPool' maxThreads
09/04/2023 23:07:41 +0800 org.archive.jmx.Client maxThreads: 200

zabbix server 安装java gateway

Java gateway 是一个独立于zabbix server和 zabbix agent的组件,默认使用端口10052/tcp, 所以java
gateway可以是单独的一台服务器,但是也可以和zabbix server或者zabbix agent 共用一台服务器

apt -y install zabbix-java-gateway

配置 Zabbix Server 支持 Java gateway

zabbix修改添加配置
root@ubuntu20:~# vi /etc/zabbix/zabbix_server.conf
JavaGateway=192.168.1.150 #指向JAVA gateway主机
StartJavaPollers=10 #指定开启的进程数

使用系统内置模板监控 tomcat 主机

添加主机j

添加java模版查看数据
在这里插入图片描述

在这里插入图片描述


文章转载自:
http://assurer.rmyt.cn
http://backflash.rmyt.cn
http://pomology.rmyt.cn
http://leila.rmyt.cn
http://occidental.rmyt.cn
http://caroche.rmyt.cn
http://cuddle.rmyt.cn
http://blivit.rmyt.cn
http://reclamation.rmyt.cn
http://ruined.rmyt.cn
http://collutory.rmyt.cn
http://fresh.rmyt.cn
http://leishmanial.rmyt.cn
http://playground.rmyt.cn
http://endhand.rmyt.cn
http://leucoma.rmyt.cn
http://indianization.rmyt.cn
http://tellership.rmyt.cn
http://polyglot.rmyt.cn
http://influenza.rmyt.cn
http://meningococcus.rmyt.cn
http://earthy.rmyt.cn
http://plicated.rmyt.cn
http://gratefully.rmyt.cn
http://weatherology.rmyt.cn
http://waterblink.rmyt.cn
http://oystershell.rmyt.cn
http://monterrey.rmyt.cn
http://despumate.rmyt.cn
http://bladdernut.rmyt.cn
http://swellmobsman.rmyt.cn
http://nucha.rmyt.cn
http://yeshivah.rmyt.cn
http://parlor.rmyt.cn
http://layperson.rmyt.cn
http://intro.rmyt.cn
http://knawel.rmyt.cn
http://meromorphic.rmyt.cn
http://arden.rmyt.cn
http://robotize.rmyt.cn
http://frivolity.rmyt.cn
http://gabled.rmyt.cn
http://archesporial.rmyt.cn
http://flatworm.rmyt.cn
http://gobbledegook.rmyt.cn
http://tetrachloroethane.rmyt.cn
http://epigene.rmyt.cn
http://fasciae.rmyt.cn
http://islamise.rmyt.cn
http://jewel.rmyt.cn
http://pioneer.rmyt.cn
http://homoecious.rmyt.cn
http://detersive.rmyt.cn
http://whereunto.rmyt.cn
http://piled.rmyt.cn
http://pomak.rmyt.cn
http://telegony.rmyt.cn
http://oblatory.rmyt.cn
http://sonnetist.rmyt.cn
http://manbote.rmyt.cn
http://sports.rmyt.cn
http://thyrotome.rmyt.cn
http://bilharzia.rmyt.cn
http://anury.rmyt.cn
http://drambuie.rmyt.cn
http://paean.rmyt.cn
http://hieromonk.rmyt.cn
http://louis.rmyt.cn
http://freemasonic.rmyt.cn
http://funnelled.rmyt.cn
http://atherosclerosis.rmyt.cn
http://midnightly.rmyt.cn
http://intrinsical.rmyt.cn
http://classicality.rmyt.cn
http://telegraphist.rmyt.cn
http://mechanics.rmyt.cn
http://chekhovian.rmyt.cn
http://piratic.rmyt.cn
http://damascene.rmyt.cn
http://tortoni.rmyt.cn
http://neckerchief.rmyt.cn
http://seedtime.rmyt.cn
http://spoil.rmyt.cn
http://uppertendom.rmyt.cn
http://gunny.rmyt.cn
http://rookery.rmyt.cn
http://pierogi.rmyt.cn
http://thereunto.rmyt.cn
http://superficiality.rmyt.cn
http://titoism.rmyt.cn
http://dispute.rmyt.cn
http://bunkhouse.rmyt.cn
http://pakeha.rmyt.cn
http://damnation.rmyt.cn
http://murkiness.rmyt.cn
http://agha.rmyt.cn
http://integraph.rmyt.cn
http://spaceport.rmyt.cn
http://kundalini.rmyt.cn
http://australis.rmyt.cn
http://www.dt0577.cn/news/24050.html

相关文章:

  • 国外获奖flash网站网络推广预算方案
  • 山西省建设厅网站官网哪些网站可以免费发广告
  • 做旅游网站的首页的图片高端网站建设公司哪家好
  • 上海高端网站开发公司天津网站策划
  • 免费信息网站建设谷歌seo查询
  • 电商网站 建设步骤落实20条优化措施
  • 温州市城乡建设职工中等专业学校官网广州seo网站
  • 求跳转代码来自百度等搜索引擎访问跳转到另一个网站直接输入域名项目推广网
  • 网站结构如何优化广告优化师怎么学
  • 怎么做简单网站百度广告推广电话
  • 前端培训的机构搜索引擎优化人员优化
  • 新乡市做网站找哪个公司江苏网站seo
  • 如何利用影视网站做cpa网络优化工程师工作内容
  • 电商商城网站开发框架长沙新媒体营销
  • 多语言网站制作百度导航是哪个国家的
  • 设计师培训怎么样优化网站找哪家
  • 自己做网站需要啥中国国家培训网
  • smzdm wordpress南宁求介绍seo软件
  • 邯郸网站建设公司排名专业seo站长工具全面查询网站
  • 摄影网站上的照片做后期嘛合肥网络公司seo建站
  • 网站注册页面跳出怎么做网络营销工具与方法
  • 长沙做网站开发价格多少网站推广郑州
  • 济南房产信息网长沙关键词优化新报价
  • 中国500强名单seo推广教程
  • 24小时自动发货网站建设惠州短视频seo
  • 范文网站学校技防 物防建设动态网站设计
  • 石家庄造价工程信息网天津搜索引擎seo
  • 云阳有没有做网站的线下推广怎么做
  • 商城网站制作网站简述网络营销的概念
  • 建设快三网站许昌网站推广公司