监控MySQL服务及httpd服务
Server=127.0.0.1,192.168.200.11
ServerActive=192.168.200.11
Hostname=server.zabbix.com
LogFile=/usr/local/zabbix/logs/zabbix_agentd.log
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/*.conf
UserParameter=mysql.version,mysql -v
UserParameter=mysql.status[*],/usr/local/zabbix/etc/chk_mysql.sh $1
UserParameter=mysql.ping,mysqladmin -uroot -p123123 -P3306 -h192.168.200.11 ping | grep -c alive
#!/bin/bash
#FileName: check_mysql.sh
# Revision: 1.0
# Date: 2015/06/09
# Author: DengYun
# Email: dengyun@ttlsa.com
# Website: www.ttlsa.com
# Description:
# Notes: ~
# -------------------------------------------------------------------------------
# Copyright: 2015 (c) DengYun
# License: GPL
MYSQL_USER='root'
MYSQL_PWD='123123'
MYSQL_HOST='192.168.200.11'
MYSQL_PORT='3306'
if [ $# -ne "1" ];then
echo "arg error!"
fi
case $1 in
Uptime)
result=`${MYSQL_CONN} status|cut -f2 -d":"|cut -f1 -d"T"`
echo $result
;;
Com_update)
result=`${MYSQL_CONN} extended-status |grep -w "Com_update"|cut -d"|" -f3`
echo $result
;;
Slow_queries)
result=`${MYSQL_CONN} status |cut -f5 -d":"|cut -f1 -d"O"`
echo $result
result=`${MYSQL_CONN} extended-status |grep -w "Com_select"|cut -d"|" -f3`
echo $result
;;
Com_rollback)
result=`${MYSQL_CONN} extended-status |grep -w "Com_rollback"|cut -d"|" -f3`
echo $result
;;
Questions)
result=`${MYSQL_CONN} status|cut -f4 -d":"|cut -f1 -d"S"`
echo $result
;;
Com_insert)
result=`${MYSQL_CONN} extended-status |grep -w "Com_insert"|cut -d"|" -f3`
echo $result
;;
Com_delete)
result=`${MYSQL_CONN} extended-status |grep -w "Com_delete"|cut -d"|" -f3`
echo $result
;;
Com_commit)
result=`${MYSQL_CONN} extended-status |grep -w "Com_commit"|cut -d"|" -f3`
echo $result
;;
Bytes_sent)
result=`${MYSQL_CONN} extended-status |grep -w "Bytes_sent" |cut -d"|" -f3`
echo $result
;;
Bytes_received)
result=`${MYSQL_CONN} extended-status |grep -w "Bytes_received" |cut-d"|" -f3`
echo $result
;;
Com_begin)
result=`${MYSQL_CONN} extended-status |grep -w "Com_begin"|cut -d"|"-f3`
echo $result
;;
echo "Usage:$0(Uptime|Com_update|Slow_queries|Com_select|Com_rollback|Questions|Com_
insert|Com_delete|Com_commit|Bytes_sent|Bytes_received|Com_begin)"
;;
esac
[root@server etc]# cd
[root@server ~]# mysql -uroot -p123123
Query OK, 0 rows affected (0.00 sec)
1


二:监控httpd服务
PidFile=/tmp/zabbix_agentd.pid
Server=127.0.0.1,192.168.200.11
ServerActive=192.168.200.11
stname=server.zabbix.com
LogFile=/usr/local/zabbix/logs/zabbix_agentd.log
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/*.conf
UserParameter=mysql.version,mysql -v
UserParameter=mysql.status[*],/usr/local/zabbix/etc/chk_mysql.sh $1
UserParameter=mysql.ping,mysqladmin -uroot -p123123 -P3306 -h192.168.200.11 ping | grep -c a
live
#!/bin/bash
#检查httpd服务是否正常运行,正常输出1不正常输出2
if [ $? -eq 0 ];then
echo "1"
else
echo "0"
fi
~
[root@server etc]# killall -9 zabbix_agentd
[root@server etc]# zabbix_agentd
[root@server etc]# /usr/local/zabbix/bin/zabbix_get -s 192.168.200.11 -k httpd.status
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
1
[root@server etc]# which netstat
/usr/bin/netstat
[root@server etc]# chmod u+s /usr/bin/netstat
[root@server etc]# /usr/local/zabbix/bin/zabbix_get -s 192.168.200.11 -k httpd.status
1
添加图形
创建触发器
三:磁盘监控
PidFile=/tmp/zabbix_agentd.pid
Server=127.0.0.1,192.168.200.11
ServerActive=192.168.200.11
Hostname=server.zabbix.com
LogFile=/usr/local/zabbix/logs/zabbix_agentd.log
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/*.conf
UserParameter=mysql.version,mysql -v
UserParameter=mysql.status[*],/usr/local/zabbix/etc/chk_mysql.sh $1
UserParameter=mysql.ping,mysqladmin -uroot -p123123 -P3306 -h192.168.200.11 ping | grep -c alive
UserParameter=sdb1.used,df -hT| awk -F'[ %]' 'NR==7{ print $(NF-2)}' #引入命令
[root@server ~]# zabbix_agentd
[root@server ~]# /usr/local/zabbix/bin/zabbix_get -s 192.168.200.11 -k sda1.used
17
监控MySQL服务及httpd服务的更多相关文章
- 在Mac上开启自带的Apache,httpd服务
下面演示的是Mac自带的httpd服务 启动httpd服务 AppledeMacBook-Pro:python2_zh apple$ sudo apachectl start AppledeMacBo ...
- cacti系列(一)之cacti的安装及配置监控mysql服务
简介 Cacti是通过 snmpget来获取数据,使用 RRDtool绘画图形,而且你完全可以不需要了解RRDtool复杂的参数.它提供了非常强大的数据和用户管理功能,可以指定每一个用户能查看树状结构 ...
- shell脚本监控MySQL服务是否正常
监控MySQL服务是否正常,通常的思路为:检查3306端口是否启动,ps查看mysqld进程是否启动,命令行登录mysql执行语句返回结果,php或jsp程序检测(需要开发人员开发程序)等等: 方法1 ...
- centos httpd服务做yum本地源,以及安装Mysql
step0 首先centos的iso文件是有两张的,dvd1和dvd2,dvd2是额外的软件,常有的一些软件都在dvd1里面,而且repodata配置文件也在dvd1里面,如果直接把dvd2当做镜像文 ...
- zabbix-server端监控MySQL服务
Zabbix 监控MySQL数据库 为server.zabbix,com 添加服务模块 创建MySQL服务图形 Server.zabbix.com 服务器操作 [root@server ~]# cd ...
- shell脚本监控httpd服务80端口状态
监控httpd服务端口状态,根据端口判断服务器是否启动,如果没有启动则脚本自动拉起服务,如果服务正在运行则退出脚本程序:如果换成别的服务端口也可以,但是脚本程序需要做调整. #!/bin/bash # ...
- shell习题第26题:监控mysql服务
[题目要求] 假设mysql密码是123456. 写脚本监控mysql服务是否正常,比如是否可以执行show processlist,并检测一下当前的mysql服务是主还是从.如果是从,请判断他的主从 ...
- 案例六:shell脚本监控httpd服务80端口状态
这里是举例监控httpd服务端口状态,根据端口判断服务器是否启动,如果没有启动则脚本自动拉起服务,如果服务正在运行则退出脚本程序:如果换成别的服务端口也可以,但是脚本程序需要做调整. #!/bin/b ...
- 【Prometheus+Grafana系列】监控MySQL服务
前言 前面的一篇文章已经介绍了 docker-compose 搭建 Prometheus + Grafana 服务.当时实现了监控服务器指标数据,是通过 node_exporter.Prometheu ...
随机推荐
- 监控实战Prometheus+Grafana
这期的分享是监控实战,其实不想写这篇的,因为网上相关的文章也挺多的,但是出于光说不练都是假把式,而且也想告诉你:当帅气的普罗米修斯(Prometheus)遇到高颜值的格拉法纳(Grafana)究竟会擦 ...
- 1049 Counting Ones (30分)
The task is simple: given any positive integer N, you are supposed to count the total number of 1's ...
- 这个案例写出来,还怕跟面试官扯不明白 OAuth2 登录流程?
昨天和小伙伴们介绍了 OAuth2 的基本概念,在讲解 Spring Cloud Security OAuth2 之前,我还是先来通过实际代码来和小伙伴们把 OAuth2 中的各个授权模式走一遍,今天 ...
- 尝试用tornado部署django
import os from tornado.options import options, define from tornado import httpserver from tornado.io ...
- linux美化网址
参考博文地址 https://blog.csdn.net/qq_42527676/article/details/91356154 https://www.opendesktop.org/ Dash ...
- 统计分析_集中趋势and离散程度
1.数组的集中趋势-如何定义数组的中心 1.1 常用几下几个指标来描述一个数组的集中趋势 均值-算术平均数 . 中位数-将数组升序或降序排列后,位于中间的数. 众数-数组中出现最多的数. 1.2 指标 ...
- Array(数组)对象-->slice() 方法
1.定义和用法 slice()方法可提取字符串的某个部分,并以新的字符串返回被提取的部分. 语法: array.slice(start, end) 参数:start 开始元素的下标,截取内容包含该元素 ...
- Oracle--pl/sql编程-分支语句(判断、循环)
if语句 oracle: elsif java: else if if (条件) then pl/sql或sql语句 [elsif (条件) then ] ...可以有多个elsif [el ...
- CH5701 开车旅行(倍增dp+set)
传送门 解题思路: 一道比较有趣的题,解题工作主要分为两块: ①找出k(k=0表示小A先走,k=1表示小B先走,下面同理)从点i出发下一个到达的点to[k][i]; 一开始偷懒用了vector(偷懒一 ...
- alg-链表中有环
typedef struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(nullptr) {} }ListN ...