码迷,mamicode.com
首页 > 其他好文 > 详细

zabbix监控脚本

时间:2019-01-21 11:21:25      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:handler   rev   next   zabbix监控   sqli   list   result   $1   begin   

#!/bin/bash
MySQlBin=/usr/bin/mysql
MySQLAdminBin=/usr/bin/mysqladmin
Host=192.168.50.202
User=zabbix
Password=123456

if [[ $# == 1 ]];then
case $1 in
Uptime)
result=$MySQLAdminBin -u$User -p$Password -h$Host status 2>/dev/null |cut -f2 -d":"|cut -f1 -d"T"
echo $result
;;
Com_update)
result=$MySQLAdminBin -u$User -p$Password -h$Host extended-status 2>/dev/null |grep -w "Com_update"|cut -d"|" -f3
echo $result
;;
Slow_queries)
result=$MySQLAdminBin -u$User -p$Password -h$Host status 2>/dev/null |cut -f5 -d":"|cut -f1 -d"O"
echo $result
;;
Com_select)
result=$MySQLAdminBin -u$User -p$Password -h$Host extended-status 2>/dev/null |grep -w "Com_select"|cut -d"|" -f3
echo $result
;;
Com_rollback)
result=$MySQLAdminBin -u$User -p$Password -h$Host extended-status 2>/dev/null |grep -w "Com_rollback"|cut -d"|" -f3
echo $result
;;
Questions)
result=$MySQLAdminBin -u$User -p$Password -h$Host status 2>/dev/null |cut -f4 -d":"|cut -f1 -d"S"
echo $result
;;
Com_insert)
result=$MySQLAdminBin -u$User -p$Password -h$Host extended-status 2>/dev/null |grep -w "Com_insert"|cut -d"|" -f3
echo $result
;;
Com_delete)
result=$MySQLAdminBin -u$User -p$Password -h$Host extended-status 2>/dev/null |grep -w "Com_delete"|cut -d"|" -f3
echo $result
;;
Com_commit)
result=$MySQLAdminBin -u$User -p$Password -h$Host extended-status 2>/dev/null |grep -w "Com_commit"|cut -d"|" -f3
echo $result
;;
Bytes_sent)
result=$MySQLAdminBin -u$User -p$Password -h$Host extended-status 2>/dev/null |grep -w "Bytes_sent" |cut -d"|" -f3
echo $result
;;
Bytes_received)
result=$MySQLAdminBin -u$User -p$Password -h$Host extended-status 2>/dev/null |grep -w "Bytes_received" |cut -d"|" -f3
echo $result
;;
Com_begin)
result=$MySQLAdminBin -u$User -p$Password -h$Host extended-status 2>/dev/null |grep -w "Com_begin"|cut -d"|" -f3
echo $result
;;
*)
echo -e "\033[33mUsage: ./getmysqlinfo {Ping|Threads|Questions|Slowqueries|Qps|Slave_IO_State|Slave_SQL_State|Key_buffer_size|Key_reads|Key_read_requests|Key_cache_miss_rate|Key_blocks_used|Key_blocks_unused|Key_blocks_used_rate|Innodb_buffer_pool_size|Innodb_log_file_size|Innodb_log_buffer_size|Table_open_cache|Open_tables|Opened_tables|Open_tables_rate|Table_open_cache_used_rate|Thread_cache_size|Threads_cached|Threads_connected|Threads_created|Threads_running|Qcache_free_blocks|Qcache_free_memory|Qcache_hits|Qcache_inserts|Qcache_lowmem_prunes|Qcache_not_cached|Qcache_queries_in_cache|Qcache_total_blocks|Qcache_fragment_rate|Qcache_used_rate|Qcache_hits_rate|Query_cache_limit|Query_cache_min_res_unit|Query_cache_size|Sort_merge_passes|Sort_range|Sort_rows|Sort_scan|Handler_read_first|Handler_read_key|Handler_read_next|Handler_read_prev|Handler_read_rnd|Handler_read_rnd_next|Com_select|Com_insert|Com_insert_select|Com_update|Com_replace|Com_replace_select|Table_scan_rate|Open_files|Open_files_limit|Open_files_rate|Created_tmp_disk_tables|Created_tmp_tables|Created_tmp_disk_tables_rate|Max_connections|Max_used_connections|Processlist|Max_connections_used_rate|Table_locks_immediate|Table_locks_waited|Engine_select|Connection_occupancy_rate} \033[0m"
;;
esac
fi

zabbix监控脚本

标签:handler   rev   next   zabbix监控   sqli   list   result   $1   begin   

原文地址:http://blog.51cto.com/12131824/2344356

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!