Nagios监控数据库的方法
创始人
2024-07-24 02:10:41
0

  Nagios监控数据库的方法:

  check_mysql_health监控数据库

  1、check_mysql_health安装

  在监控服务器上安装

  1.   # cd /usr/local/src/tarbag  
  2.  
  3.   # wget http://labs.consol.de/wp-content/uploads/2010/03/check_mysql_health-2.1.1.tar.gz  
  4.  
  5.   # tar zxvf check_mysql_health-2.1.1.tar.gz -C ../software/  
  6.  
  7.   # ./configure \  
  8.  
  9.   –prefix=/usr/local/nagios/ \  
  10.  
  11.   –with-nagios-user=nagios \  
  12.  
  13.   –with-nagios-group=nagios \  
  14.  
  15.   –with-perl=/usr/bin/perl \  
  16.  
  17.   –with-statefiles-dir=/usr/local/nagios/var/tmp \  
  18.  
  19.   –with-perl perl\ 程序运行路径  
  20.  
  21.   –with-statefiles-dir 状态信息文件路径  
  22.  
  23.   # make  
  24.  
  25.   # make install  
  26.  

  2、check_mysql_health选项

  1.   Options:  
  2.  
  3.   –hostname  
  4.  
  5.   the database server’s hostname  
  6.  
  7.   –port  
  8.  
  9.   the database’s port. (default: 3306)  
  10.  
  11.   –socket  
  12.  
  13.   the database’s unix socket.  
  14.  
  15.   –username  
  16.  
  17.   the mysql db user  
  18.  
  19.   –password  
  20.  
  21.   the mysql db user’s password  
  22.  
  23.   –database  
  24.  
  25.   the database’s name. (default: information_schema)  
  26.  
  27.   –warning  
  28.  
  29.   the warning range  
  30.  
  31.   –critical  
  32.  
  33.   the critical range  
  34.  
  35.   –mode  
  36.  
  37.   the mode of the plugin. select one of the following keywords:  
  38.  
  39.   connection-time 连接到服务器上的时间  
  40.  
  41.   uptime 服务器运行的时间  
  42.  
  43.   threads-connected 当前连接到数据库的连接数  
  44.  
  45.   threadcache-hitrate 线程缓存命中率  
  46.  
  47.   slave-lag slave落后master多少时间  
  48.  
  49.   slave-io-running slave复制是否正常  
  50.  
  51.   slave-sql-running slave复制是否正常  
  52.  
  53.   qcache-hitrate 查询缓存命中率  
  54.  
  55.   qcache-lowmem-prunes (Query cache entries pruned because of low memory)  
  56.  
  57.   keycache-hitrate (MyISAM key cache hitrate)  
  58.  
  59.   bufferpool-hitrate (InnoDB buffer pool hitrate)  
  60.  
  61.   bufferpool-wait-free (InnoDB buffer pool waits for clean page available)  
  62.  
  63.   log-waits (InnoDB log waits because of a too small log buffer)  
  64.  
  65.   tablecache-hitrate 表缓存命中率  
  66.  
  67.   table-lock-contention 表锁率  
  68.  
  69.   index-usage 索引使用情况  
  70.  
  71.   tmp-disk-tables (Percent of temp tables created on disk)  
  72.  
  73.   slow-queries 慢查询  
  74.  
  75.   long-running-procs 长时间运行的进程  
  76.  
  77.   cluster-ndbd-running ndb节点运行状况  
  78.  
  79.   sql 返回一个数字的任何SQL语句  
  80.  

  3、check_mysql_health监控配置

  监控服务器:10.59.97.42

  MySQL数据授权:

  在要监控的MySQL数据库服务器上

  1.   mysql> grant usage on *.* to honyho@10.59.97.42 identified by “honyho@8123“;  
  2.  
  3.   mysql> flush privileges;  
  4.  

  在监控服务器上

  1》查看当前连接到数据库的连接数

  1.   #./check_mysql_health –hostname 10.59.97.57 –username honyho –password honyho@8123 –mode threads-connected  
  2.  
  3.   OK – 3 client connection threads | threads_connected=3;10;20  
  4.  
  5.   threads_connected=3;10;20  
  6.  

  3表示连接数

  10 表示warning阀值(默认)

  20 表示critical阀值(默认)

#p#

  Nagios相关配置

  1》配置commands.cfg文件

  1.   define command{  
  2.  
  3.   command_name check_mysql_health  
  4.  
  5.   command_line $USER1$/check_mysql_health –hostname $ARG1$ –username $ARG2$ –password $ARG3$ –warning $ARG4$ –critical $ARG5$ –mode $ARG6$  
  6.  
  7.   }  
  8.  

  2》配置121_207_231_17.cfg文件

  1.   define service{  
  2.  
  3.   use local-service  
  4.  
  5.   host_name 121.207.231.17  
  6.  
  7.   service_description threads-connected  
  8.  
  9.   check_command check_mysql_health!10.59.97.57!honyho!honyho@8123!1000!1500!threads-connected  
  10.  
  11.   }  
  12.  

  ———————————————————–

#p#

  nagios-mysql-plugins插件监控数据库

  一、安装此插件

  1.   #wget 北北没有给地址  
  2.  
  3.   #tar zxvf nagios-mysql-plugins-0.3.tar.gz -C ../software/  
  4.  
  5.   #cd nagios-mysql-plugins-0.3  
  6.  
  7.   #chmod +x *mysql*  
  8.  

  二、插件内容

  check_db_mysql.pl 检测mysql是否运行

  check_errorlog_mysql.pl 检测mysql数据库错误日志

  check_repl_mysql_cnt_slave_hosts.pl 统计连接到从主机数

  check_repl_mysql_heartbeat.pl 检测心跳 (安装完默认名字是check_repl_mysql_hearbeat.pl)

  check_repl_mysql_io_thread.pl 检测IO线程

  check_repl_mysql_read_exec_pos.pl

  check_repl_mysql_readonly.pl 检测从是否设置为只读

  check_repl_mysql_seconds_behind_master.pl检测从多少时间与主同步

  check_repl_mysql_sql_thread.pl 检测SQL线程

  perf_mysql.pl 收集性能数据

  1.   perf_mysql.pl -m  
  2.  
  3.   connections,  
  4.  
  5.   thread_cache,  
  6.  
  7.   network_traffic,  
  8.  
  9.   queries,query_cache,  
  10.  
  11.   myisam_key_buffer,  
  12.  
  13.   table_cache,  
  14.  
  15.   temporary_tables,  
  16.  
  17.   tables,  
  18.  
  19.   slow_queries,  
  20.  
  21.   bin_log,uptime,  
  22.  
  23.   innodb_buffer_pool,  
  24.  
  25.   innodb_buffer_pool_io,  
  26.  
  27.   innodb_io,innodb_data,  
  28.  
  29.   innodb_logfile,  
  30.  
  31.   innodb_row_locking,  
  32.  
  33.   innodb_queries  

【编辑推荐】

Nagios飞信Linux系统免费短信报警配置

20分钟内在Ubuntu上实现Nagios的主机监控

Nagios监控oracle

相关内容

热门资讯

如何允许远程连接到MySQL数... [[277004]]【51CTO.com快译】默认情况下,MySQL服务器仅侦听来自localhos...
如何利用交换机和端口设置来管理... 在网络管理中,总是有些人让管理员头疼。下面我们就将介绍一下一个网管员利用交换机以及端口设置等来进行D...
施耐德电气数据中心整体解决方案... 近日,全球能效管理专家施耐德电气正式启动大型体验活动“能效中国行——2012卡车巡展”,作为该活动的...
Windows恶意软件20年“... 在Windows的早期年代,病毒游走于系统之间,偶尔删除文件(但被删除的文件几乎都是可恢复的),并弹...
20个非常棒的扁平设计免费资源 Apple设备的平面图标PSD免费平板UI 平板UI套件24平图标Freen平板UI套件PSD径向平...
德国电信门户网站可实时显示全球... 德国电信周三推出一个门户网站,直观地实时提供其安装在全球各地的传感器网络检测到的网络攻击状况。该网站...
为啥国人偏爱 Mybatis,... 关于 SQL 和 ORM 的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行...
《非诚勿扰》红人闫凤娇被曝厕所... 【51CTO.com 综合消息360安全专家提醒说,“闫凤娇”、“非诚勿扰”已经被黑客盯上成为了“木...