From 3c937983ef3befb6a3205dd4ff4178ce65c1fe0e Mon Sep 17 00:00:00 2001 From: Kamil Porembinski Date: Mon, 2 May 2016 09:29:00 +0200 Subject: [PATCH] Missing scripts --- bin/apc-check.php | 1 - bin/arduino.py | 16 + bin/blacklist.sh | 68 + bin/check-update.sh | 7 + bin/hdd_discovery.sh | 6 - bin/mysql_discover_tables.sh | 19 + bin/mysql_print_table_size.sh | 29 + bin/pgsql_find_db.sh | 12 + bin/ss_get_mysql_stats.php | 750 +++++---- bin/swap_enabled.sh | 7 + sudoers.d/zabbix | 6 + templates/Template App MySQL.xml | 2501 +++++++++++++----------------- 12 files changed, 1643 insertions(+), 1779 deletions(-) create mode 100644 bin/arduino.py create mode 100644 bin/blacklist.sh create mode 100644 bin/check-update.sh create mode 100644 bin/mysql_discover_tables.sh create mode 100644 bin/mysql_print_table_size.sh create mode 100644 bin/pgsql_find_db.sh create mode 100644 bin/swap_enabled.sh diff --git a/bin/apc-check.php b/bin/apc-check.php index f3c79bb..748db37 100644 --- a/bin/apc-check.php +++ b/bin/apc-check.php @@ -1,7 +1,6 @@ ([a-z]+\.){1,7}[a-z]+" | sed -r "s|||g;/$Exclude/d") + + +# --------------------------------------------------------------------- + +HostToIP() +{ + if ( echo "$host" | egrep -q "[a-zA-Z]" ); then + IP=$(host "$host" | awk '/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/ {print$NF}') + else + IP="$host" + fi +} + +Reverse() +{ + echo $1 | awk -F. '{print$4"."$3"."$2"."$1}' +} + +Check() +{ + result=$(dig +short $rIP.$BL) + if [ -n "$result" ]; then + echo -e "$host LISTED $BL (answer = $result)" + else + echo -e "$host OK $BL" + fi +} + +if [ -n "$1" ]; then + hosts=$@ +fi + +if [ -z "$hosts" ]; then + hosts=$(netstat -tn | awk '$4 ~ /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/ && $4 !~ /127.0.0/ {gsub(/:[0-9]+/,"",$4);} END{print$4}') +fi + +for host in $hosts; do + HostToIP + rIP=$(Reverse $IP) + # Checking $IP against BLs from $WPurl" + for BL in $WPlst; do + Check + done + # Checking $IP against BLs from a local list" + for BL in $LocalList; do + Check + done +done \ No newline at end of file diff --git a/bin/check-update.sh b/bin/check-update.sh new file mode 100644 index 0000000..5c992d2 --- /dev/null +++ b/bin/check-update.sh @@ -0,0 +1,7 @@ +#!/bin/bash +day=$(date +%e) +if ((day <= 7)) ; then + result=`/usr/bin/yum -q check-update | grep -v "^$"` + echo -n "$result" > /tmp/yum-update-pending + chown zabbix.zabbix /tmp/yum-update-pending +fi diff --git a/bin/hdd_discovery.sh b/bin/hdd_discovery.sh index c78951e..edc9f70 100644 --- a/bin/hdd_discovery.sh +++ b/bin/hdd_discovery.sh @@ -1,10 +1,4 @@ #!/bin/bash -# Script for HDD discovery -# -# Created by: -# Michał Macioszek, Taras Baran, Michal Gębora, Marcin Wilk, Maks Bednarek, Anna Fałek, Mikołaj Szczuraszek - - disks=`ls -l /dev/sd* | awk '{print $NF}' | sed 's/[0-9]//g' | uniq` echo -n "{\"data\":[" diff --git a/bin/mysql_discover_tables.sh b/bin/mysql_discover_tables.sh new file mode 100644 index 0000000..4140b6e --- /dev/null +++ b/bin/mysql_discover_tables.sh @@ -0,0 +1,19 @@ +#!bin/bash + +comma=1 +echo -n "{\"data\":[" + +for i in $(sudo /bin/find /var/lib/mysql -type f -printf %p+%s= | tr "=" "\n" | grep -v "\/mysql\/mysql\/" | grep "\.ibd" | cut -d "+" -f 1 | sed 's/@002d/\-/g' | cut -d "/" -f 5- | sed 's/.ibd//g' ); do + + dbname=$(echo $i | cut -d '/' -f 1) + tblname=$(echo $i | cut -d '/' -f 2) + + if [ $comma -eq 0 ]; then + echo -n "," + fi + comma=0 + echo -n "{\"{#DBNAME}\":\"$dbname\",\"{#TABLENAME}\":\"$tblname\"}" + +done + +echo -n "]}" diff --git a/bin/mysql_print_table_size.sh b/bin/mysql_print_table_size.sh new file mode 100644 index 0000000..50a7803 --- /dev/null +++ b/bin/mysql_print_table_size.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +cachefile='/tmp/mysqldbsize.log' +random=$RANDOM + +if [ ! -e $cachefile ]; then + touch -d "2 hours ago" $cachefile +fi + +if [ $# -ne 2 ]; then + echo "Usage: $0 dbname tablename" + exit 1 +fi + +cachefileage=$(($(date +%s) - $(stat -c %Y $cachefile))) +process_running=$(ps aux | grep 'find /var/lib/mysql' | grep -v "grep" | wc -l) + +if [ "$cachefileage" -gt 60 ] && [ "$process_running" -eq 0 ]; then + + sudo /bin/find /var/lib/mysql -type f -printf %p+%s= | tr "=" "\n" | grep -v "\/mysql\/mysql\/" | grep "\.ibd" | sed 's/@002d/\-/g' > $cachefile.$random + + if [ $? -eq 0 ]; then + mv $cachefile.$random $cachefile + chown zabbix.zabbix $cachefile + fi +fi + +grep "/$1/" $cachefile | grep "/$2\.ibd" | cut -d "+" -f 2 + diff --git a/bin/pgsql_find_db.sh b/bin/pgsql_find_db.sh new file mode 100644 index 0000000..c31cbc8 --- /dev/null +++ b/bin/pgsql_find_db.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# If you want to monitor "foo" and "bar" databases, you set the GETDB as +# GETDB="select datname from pg_database where datname in ('foo','bar');" +# CREATE USER zabbix WITH PASSWORD 'asfrtgrg432f'; +# GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO zabbix; + +GETDB="select datname from pg_database where datistemplate = 'f';" + +for dbname in $(psql -U zabbix -d postgres -t -c "${GETDB}"); do + dblist="$dblist,"'{"{#DBNAME}":"'$dbname'"}' +done +echo '{"data":['${dblist#,}' ]}' \ No newline at end of file diff --git a/bin/ss_get_mysql_stats.php b/bin/ss_get_mysql_stats.php index 27d101a..86c7dfe 100644 --- a/bin/ss_get_mysql_stats.php +++ b/bin/ss_get_mysql_stats.php @@ -1,24 +1,11 @@ true, # Do you want to check InnoDB statistics? 'master' => true, # Do you want to check binary logging? 'slave' => true, # Do you want to check slave status? 'procs' => true, # Do you want to check SHOW PROCESSLIST? - 'get_qrt' => true, # Get query response times from Percona Server? + 'get_qrt' => true, # Get query response times from Percona Server or MariaDB? ); $use_ss = FALSE; # Whether to use the script server or not @@ -63,13 +58,18 @@ $debug_log = FALSE; # If $debug_log is a filename, it'll be used. # ============================================================================ # You should not need to change anything below this line. # ============================================================================ -$version = "1.1.8"; +$version = '1.1.5'; # ============================================================================ -# Include settings from an external config file (issue 39). +# Include settings from an external config file. # ============================================================================ -if ( file_exists(__FILE__ . '.cnf' ) ) { +if ( file_exists('/etc/cacti/' . basename(__FILE__) . '.cnf' ) ) { + require('/etc/cacti/' . basename(__FILE__) . '.cnf'); + debug('Found configuration file /etc/cacti/' . basename(__FILE__) . '.cnf'); +} +elseif ( file_exists(__FILE__ . '.cnf' ) ) { require(__FILE__ . '.cnf'); + debug('Found configuration file ' . __FILE__ . '.cnf'); } # Make this a happy little script even when there are errors. @@ -104,6 +104,18 @@ if ( $use_ss ) { } } +# ============================================================================ +# Set the default timezone either to the configured, system timezone, or the +# default set above in the script. +# ============================================================================ +if ( function_exists("date_default_timezone_set") + && function_exists("date_default_timezone_get") ) { + $tz = ($timezone ? $timezone : @date_default_timezone_get()); + if ( $tz ) { + @date_default_timezone_set($tz); + } +} + # ============================================================================ # Make sure we can also be called as a script. # ============================================================================ @@ -156,8 +168,12 @@ if ( !function_exists('array_change_key_case') ) { # Validate that the command-line options are here and correct # ============================================================================ function validate_options($options) { - debug($options); - $opts = array('host', 'items', 'user', 'pass', 'heartbeat', 'nocache', 'port'); + $opts = array('host', 'items', 'user', 'pass', 'nocache', 'port', 'server-id'); + # Show help + if ( array_key_exists('help', $options) ) { + usage(''); + } + # Required command-line options foreach ( array('host', 'items') as $option ) { if ( !isset($options[$option]) || !$options[$option] ) { @@ -175,21 +191,20 @@ function validate_options($options) { # Print out a brief usage summary # ============================================================================ function usage($message) { - global $mysql_user, $mysql_pass, $mysql_port, $heartbeat; + global $mysql_user, $mysql_pass, $mysql_port; $usage = << --items [OPTION] - --host Hostname to connect to; use host:port syntax to specify a port - Use :/path/to/socket if you want to connect via a UNIX socket + --host MySQL host --items Comma-separated list of the items whose data you want - --user MySQL username; defaults to $mysql_user if not given - --pass MySQL password; defaults to $mysql_pass if not given - --heartbeat MySQL heartbeat table; defaults to '$heartbeat' (see mk-heartbeat) + --user MySQL username + --pass MySQL password + --port MySQL port + --server-id Server id to associate with a heartbeat if heartbeat usage is enabled --nocache Do not cache results in a file - --port MySQL port; defaults to $mysql_port if not given - --mysql_ssl Add the MYSQL_CLIENT_SSL flag to mysql_connect() call + --help Show usage EOF; die($usage); @@ -200,39 +215,23 @@ EOF; # return them as an array ( arg => value ) # ============================================================================ function parse_cmdline( $args ) { - $result = array(); - $cur_arg = ''; - foreach ($args as $val) { - if ( strpos($val, '--') === 0 ) { - if ( strpos($val, '--no') === 0 ) { - # It's an option without an argument, but it's a --nosomething so - # it's OK. - $result[substr($val, 2)] = 1; - $cur_arg = ''; + $options = array(); + while (list($tmp, $p) = each($args)) { + if (strpos($p, '--') === 0) { + $param = substr($p, 2); + $value = null; + $nextparam = current($args); + if ($nextparam !== false && strpos($nextparam, '--') !==0) { + list($tmp, $value) = each($args); } - elseif ( $cur_arg ) { # Maybe the last --arg was an option with no arg - if ( $cur_arg == '--user' || $cur_arg == '--pass' || $cur_arg == '--port' ) { - # Special case because Cacti will pass these without an arg - $cur_arg = ''; - } - else { - die("No arg: $cur_arg\n"); - } - } - else { - $cur_arg = $val; - } - } - else { - $result[substr($cur_arg, 2)] = $val; - $cur_arg = ''; + $options[$param] = $value; } } - if ( $cur_arg && ($cur_arg != '--user' && $cur_arg != '--pass' && $cur_arg != '--port') ) { - die("No arg: $cur_arg\n"); + if ( array_key_exists('host', $options) ) { + $options['host'] = substr($options['host'], 0, 4) == 'tcp:' ? substr($options['host'], 4) : $options['host']; } - debug($result); - return $result; + debug($options); + return $options; } # ============================================================================ @@ -240,43 +239,24 @@ function parse_cmdline( $args ) { # top of this file. # ============================================================================ function ss_get_mysql_stats( $options ) { - # Process connection options and connect to MySQL. - global $debug, $mysql_user, $mysql_pass, $heartbeat, $cache_dir, $poll_time, - $chk_options, $mysql_port, $mysql_ssl; + # Process connection options. + global $debug, $mysql_user, $mysql_pass, $cache_dir, $poll_time, $chk_options, + $mysql_port, $mysql_ssl, $mysql_ssl_key, $mysql_ssl_cert, $mysql_ssl_ca, + $heartbeat, $heartbeat_table, $heartbeat_server_id, $heartbeat_utc; - # Connect to MySQL. $user = isset($options['user']) ? $options['user'] : $mysql_user; $pass = isset($options['pass']) ? $options['pass'] : $mysql_pass; + $host = $options['host']; $port = isset($options['port']) ? $options['port'] : $mysql_port; - $heartbeat = isset($options['heartbeat']) ? $options['heartbeat'] : $heartbeat; - # If there is a port, or if it's a non-standard port, we add ":$port" to the - # hostname. - $host_str = $options['host'] - . (isset($options['port']) || $port != 3306 ? ":$port" : ''); - debug(array('connecting to', $host_str, $user, $pass)); - if ( !extension_loaded('mysql') ) { - debug("The MySQL extension is not loaded"); - die("The MySQL extension is not loaded"); - } - if ( $mysql_ssl || (isset($options['mysql_ssl']) && $options['mysql_ssl']) ) { - $conn = mysql_connect($host_str, $user, $pass, true, MYSQL_CLIENT_SSL); - } - else { - $conn = mysql_connect($host_str, $user, $pass); - } - if ( !$conn ) { - die("MySQL: " . mysql_error()); - } + $heartbeat_server_id = isset($options['server-id']) ? $options['server-id'] : $heartbeat_server_id; - $sanitized_host - = str_replace(array(":", "/"), array("", "_"), $options['host']); - $cache_file = "$cache_dir/$sanitized_host-mysql_cacti_stats.txt" - . (isset($options['port']) || $port != 3306 ? ":$port" : ''); + $sanitized_host = str_replace(array(":", "/"), array("", "_"), $host); + $cache_file = "$cache_dir/$sanitized_host-mysql_cacti_stats.txt" . ($port != 3306 ? ":$port" : ''); debug("Cache file is $cache_file"); # First, check the cache. $fp = null; - if ( !isset($options['nocache']) ) { + if ( $cache_dir && !array_key_exists('nocache', $options) ) { if ( $fp = fopen($cache_file, 'a+') ) { $locked = flock($fp, 1); # LOCK_SH if ( $locked ) { @@ -308,14 +288,36 @@ function ss_get_mysql_stats( $options ) { } } else { - debug("Couldn't lock the cache file, ignoring it."); $fp = null; + debug("Couldn't lock the cache file, ignoring it"); } } + else { + $fp = null; + debug("Couldn't open the cache file"); + } } else { - $fp = null; - debug("Couldn't open the cache file"); + debug("Caching is disabled."); + } + + # Connect to MySQL. + debug(array('Connecting to', $host, $port, $user, $pass)); + if ( !extension_loaded('mysqli') ) { + debug("PHP MySQLi extension is not loaded"); + die("PHP MySQLi extension is not loaded"); + } + if ( $mysql_ssl ) { + $conn = mysqli_init(); + mysqli_ssl_set($conn, $mysql_ssl_key, $mysql_ssl_cert, $mysql_ssl_ca, NULL, NULL); + mysqli_real_connect($conn, $host, $user, $pass, NULL, $port); + } + else { + $conn = mysqli_connect($host, $user, $pass, NULL, $port); + } + if ( mysqli_connect_errno() ) { + debug("MySQL connection failed: " . mysqli_connect_error()); + die("ERROR: " . mysqli_connect_error()); } # Set up variables. @@ -334,22 +336,22 @@ function ss_get_mysql_stats( $options ) { 'innodb_sem_wait_time_ms' => 0, # Values for the 'state' column from SHOW PROCESSLIST (converted to # lowercase, with spaces replaced by underscores) - 'State_closing_tables' => null, - 'State_copying_to_tmp_table' => null, - 'State_end' => null, - 'State_freeing_items' => null, - 'State_init' => null, - 'State_locked' => null, - 'State_login' => null, - 'State_preparing' => null, - 'State_reading_from_net' => null, - 'State_sending_data' => null, - 'State_sorting_result' => null, - 'State_statistics' => null, - 'State_updating' => null, - 'State_writing_to_net' => null, - 'State_none' => null, - 'State_other' => null, # Everything not listed above + 'State_closing_tables' => 0, + 'State_copying_to_tmp_table' => 0, + 'State_end' => 0, + 'State_freeing_items' => 0, + 'State_init' => 0, + 'State_locked' => 0, + 'State_login' => 0, + 'State_preparing' => 0, + 'State_reading_from_net' => 0, + 'State_sending_data' => 0, + 'State_sorting_result' => 0, + 'State_statistics' => 0, + 'State_updating' => 0, + 'State_writing_to_net' => 0, + 'State_none' => 0, + 'State_other' => 0, # Everything not listed above ); # Get SHOW STATUS and convert the name-value array into a simple @@ -367,7 +369,14 @@ function ss_get_mysql_stats( $options ) { # Get SHOW SLAVE STATUS, and add it to the $status array. if ( $chk_options['slave'] ) { - $result = run_query("SHOW SLAVE STATUS", $conn); + # Leverage lock-free SHOW SLAVE STATUS if available + $result = run_query("SHOW SLAVE STATUS NONBLOCKING", $conn); + if ( !$result ) { + $result = run_query("SHOW SLAVE STATUS NOLOCK", $conn); + if ( !$result ) { + $result = run_query("SHOW SLAVE STATUS", $conn); + } + } $slave_status_rows_gotten = 0; foreach ( $result as $row ) { $slave_status_rows_gotten++; @@ -379,9 +388,16 @@ function ss_get_mysql_stats( $options ) { # Check replication heartbeat, if present. if ( $heartbeat ) { + if ( $heartbeat_utc ) { + $now_func = 'UNIX_TIMESTAMP(UTC_TIMESTAMP)'; + } + else { + $now_func = 'UNIX_TIMESTAMP()'; + } $result2 = run_query( - "SELECT GREATEST(0, UNIX_TIMESTAMP() - UNIX_TIMESTAMP(ts) - 1)" - . " AS delay FROM $heartbeat WHERE id = 1", $conn); + "SELECT MAX($now_func - ROUND(UNIX_TIMESTAMP(ts)))" + . " AS delay FROM $heartbeat_table" + . " WHERE $heartbeat_server_id = 0 OR server_id = $heartbeat_server_id", $conn); $slave_delay_rows_gotten = 0; foreach ( $result2 as $row2 ) { $slave_delay_rows_gotten++; @@ -391,7 +407,7 @@ function ss_get_mysql_stats( $options ) { $status['slave_lag'] = $row2['delay']; } else { - debug("Couldn't get slave lag from $heartbeat"); + debug("Couldn't get slave lag from $heartbeat_table"); } } if ( $slave_delay_rows_gotten == 0 ) { @@ -443,6 +459,10 @@ function ss_get_mysql_stats( $options ) { if ( $state == '' ) { $state = 'none'; } + # MySQL 5.5 replaces the 'Locked' state with a variety of "Waiting for + # X lock" types of statuses. Wrap these all back into "Locked" because + # we don't really care about the type of locking it is. + $state = preg_replace('/^(Table lock|Waiting for .*lock)$/', 'Locked', $state); $state = str_replace(' ', '_', strtolower($state)); if ( array_key_exists("State_$state", $status) ) { increment($status, "State_$state", 1); @@ -453,35 +473,59 @@ function ss_get_mysql_stats( $options ) { } } + # Get SHOW ENGINES to be able to determine whether InnoDB is present. + $engines = array(); + $result = run_query("SHOW ENGINES", $conn); + foreach ( $result as $row ) { + $engines[$row[0]] = $row[1]; + } + # Get SHOW INNODB STATUS and extract the desired metrics from it, then add # those to the array too. if ( $chk_options['innodb'] - && array_key_exists('have_innodb', $status) - && $status['have_innodb'] == 'YES' + && array_key_exists('InnoDB', $engines) + && $engines['InnoDB'] == 'YES' + || $engines['InnoDB'] == 'DEFAULT' ) { $result = run_query("SHOW /*!50000 ENGINE*/ INNODB STATUS", $conn); $istatus_text = $result[0]['Status']; $istatus_vals = get_innodb_array($istatus_text); - # Get response time histogram from Percona Server if enabled. + # Get response time histogram from Percona Server or MariaDB if enabled. if ( $chk_options['get_qrt'] - && isset($status['have_response_time_distribution']) - && ($status['have_response_time_distribution'] == 'YES')) + && (( isset($status['have_response_time_distribution']) + && $status['have_response_time_distribution'] == 'YES') + || (isset($status['query_response_time_stats']) + && $status['query_response_time_stats'] == 'ON')) ) { debug('Getting query time histogram'); $i = 0; $result = run_query( - "SELECT `count`, total * 1000000 AS total " + "SELECT `count`, ROUND(total * 1000000) AS total " . "FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME " . "WHERE `time` <> 'TOO LONG'", $conn); foreach ( $result as $row ) { + if ( $i > 13 ) { + # It's possible that the number of rows returned isn't 14. + # Don't add extra status counters. + break; + } $count_key = sprintf("Query_time_count_%02d", $i); $total_key = sprintf("Query_time_total_%02d", $i); $status[$count_key] = $row['count']; $status[$total_key] = $row['total']; $i++; } + # It's also possible that the number of rows returned is too few. + # Don't leave any status counters unassigned; it will break graphs. + while ( $i <= 13 ) { + $count_key = sprintf("Query_time_count_%02d", $i); + $total_key = sprintf("Query_time_total_%02d", $i); + $status[$count_key] = 0; + $status[$total_key] = 0; + $i++; + } } else { debug('Not getting time histogram because it is not enabled'); @@ -506,6 +550,8 @@ function ss_get_mysql_stats( $options ) { 'Innodb_rows_inserted' => 'rows_inserted', 'Innodb_rows_read' => 'rows_read', 'Innodb_rows_updated' => 'rows_updated', + 'Innodb_buffer_pool_reads' => 'pool_reads', + 'Innodb_buffer_pool_read_requests' => 'pool_read_requests', ); # If the SHOW STATUS value exists, override... @@ -548,204 +594,221 @@ function ss_get_mysql_stats( $options ) { } # Define the variables to output. I use shortened variable names so maybe - # it'll all fit in 1024 bytes for Cactid and Spine's benefit. This list must - # come right after the word MAGIC_VARS_DEFINITIONS. The Perl script parses - # it and uses it as a Perl variable. + # it'll all fit in 1024 bytes for Cactid and Spine's benefit. Strings must + # have some non-hex characters (non a-f0-9) to avoid a Cacti bug. This list + # must come right after the word MAGIC_VARS_DEFINITIONS. The Perl script + # parses it and uses it as a Perl variable. $keys = array( - 'Key_read_requests' => 'a0', - 'Key_reads' => 'a1', - 'Key_write_requests' => 'a2', - 'Key_writes' => 'a3', - 'history_list' => 'a4', - 'innodb_transactions' => 'a5', - 'read_views' => 'a6', - 'current_transactions' => 'a7', - 'locked_transactions' => 'a8', - 'active_transactions' => 'a9', - 'pool_size' => 'aa', - 'free_pages' => 'ab', - 'database_pages' => 'ac', - 'modified_pages' => 'ad', - 'pages_read' => 'ae', - 'pages_created' => 'af', - 'pages_written' => 'ag', - 'file_fsyncs' => 'ah', - 'file_reads' => 'ai', - 'file_writes' => 'aj', - 'log_writes' => 'ak', - 'pending_aio_log_ios' => 'al', - 'pending_aio_sync_ios' => 'am', - 'pending_buf_pool_flushes' => 'an', - 'pending_chkp_writes' => 'ao', - 'pending_ibuf_aio_reads' => 'ap', - 'pending_log_flushes' => 'aq', - 'pending_log_writes' => 'ar', - 'pending_normal_aio_reads' => 'as', - 'pending_normal_aio_writes' => 'at', - 'ibuf_inserts' => 'au', - 'ibuf_merged' => 'av', - 'ibuf_merges' => 'aw', - 'spin_waits' => 'ax', - 'spin_rounds' => 'ay', - 'os_waits' => 'az', - 'rows_inserted' => 'b0', - 'rows_updated' => 'b1', - 'rows_deleted' => 'b2', - 'rows_read' => 'b3', - 'Table_locks_waited' => 'b4', - 'Table_locks_immediate' => 'b5', - 'Slow_queries' => 'b6', - 'Open_files' => 'b7', - 'Open_tables' => 'b8', - 'Opened_tables' => 'b9', - 'innodb_open_files' => 'ba', - 'open_files_limit' => 'bb', - 'table_cache' => 'bc', - 'Aborted_clients' => 'bd', - 'Aborted_connects' => 'be', - 'Max_used_connections' => 'bf', - 'Slow_launch_threads' => 'bg', - 'Threads_cached' => 'bh', - 'Threads_connected' => 'bi', - 'Threads_created' => 'bj', - 'Threads_running' => 'bk', - 'max_connections' => 'bl', - 'thread_cache_size' => 'bm', - 'Connections' => 'bn', - 'slave_running' => 'bo', - 'slave_stopped' => 'bp', - 'Slave_retried_transactions' => 'bq', - 'slave_lag' => 'br', - 'Slave_open_temp_tables' => 'bs', - 'Qcache_free_blocks' => 'bt', - 'Qcache_free_memory' => 'bu', - 'Qcache_hits' => 'bv', - 'Qcache_inserts' => 'bw', - 'Qcache_lowmem_prunes' => 'bx', - 'Qcache_not_cached' => 'by', - 'Qcache_queries_in_cache' => 'bz', - 'Qcache_total_blocks' => 'c0', - 'query_cache_size' => 'c1', - 'Questions' => 'c2', - 'Com_update' => 'c3', - 'Com_insert' => 'c4', - 'Com_select' => 'c5', - 'Com_delete' => 'c6', - 'Com_replace' => 'c7', - 'Com_load' => 'c8', - 'Com_update_multi' => 'c9', - 'Com_insert_select' => 'ca', - 'Com_delete_multi' => 'cb', - 'Com_replace_select' => 'cc', - 'Select_full_join' => 'cd', - 'Select_full_range_join' => 'ce', - 'Select_range' => 'cf', - 'Select_range_check' => 'cg', - 'Select_scan' => 'ch', - 'Sort_merge_passes' => 'ci', - 'Sort_range' => 'cj', - 'Sort_rows' => 'ck', - 'Sort_scan' => 'cl', - 'Created_tmp_tables' => 'cm', - 'Created_tmp_disk_tables' => 'cn', - 'Created_tmp_files' => 'co', - 'Bytes_sent' => 'cp', - 'Bytes_received' => 'cq', - 'innodb_log_buffer_size' => 'cr', - 'unflushed_log' => 'cs', - 'log_bytes_flushed' => 'ct', - 'log_bytes_written' => 'cu', - 'relay_log_space' => 'cv', - 'binlog_cache_size' => 'cw', - 'Binlog_cache_disk_use' => 'cx', - 'Binlog_cache_use' => 'cy', - 'binary_log_space' => 'cz', - 'innodb_locked_tables' => 'd0', - 'innodb_lock_structs' => 'd1', - 'State_closing_tables' => 'd2', - 'State_copying_to_tmp_table' => 'd3', - 'State_end' => 'd4', - 'State_freeing_items' => 'd5', - 'State_init' => 'd6', - 'State_locked' => 'd7', - 'State_login' => 'd8', - 'State_preparing' => 'd9', - 'State_reading_from_net' => 'da', - 'State_sending_data' => 'db', - 'State_sorting_result' => 'dc', - 'State_statistics' => 'dd', - 'State_updating' => 'de', - 'State_writing_to_net' => 'df', - 'State_none' => 'dg', - 'State_other' => 'dh', - 'Handler_commit' => 'di', - 'Handler_delete' => 'dj', - 'Handler_discover' => 'dk', - 'Handler_prepare' => 'dl', - 'Handler_read_first' => 'dm', - 'Handler_read_key' => 'dn', - 'Handler_read_next' => 'do', - 'Handler_read_prev' => 'dp', - 'Handler_read_rnd' => 'dq', - 'Handler_read_rnd_next' => 'dr', - 'Handler_rollback' => 'ds', - 'Handler_savepoint' => 'dt', - 'Handler_savepoint_rollback' => 'du', - 'Handler_update' => 'dv', - 'Handler_write' => 'dw', - # Some InnoDB stats added later... - 'innodb_tables_in_use' => 'dx', - 'innodb_lock_wait_secs' => 'dy', - 'hash_index_cells_total' => 'dz', - 'hash_index_cells_used' => 'e0', - 'total_mem_alloc' => 'e1', - 'additional_pool_alloc' => 'e2', - 'uncheckpointed_bytes' => 'e3', - 'ibuf_used_cells' => 'e4', - 'ibuf_free_cells' => 'e5', - 'ibuf_cell_count' => 'e6', - 'adaptive_hash_memory' => 'e7', - 'page_hash_memory' => 'e8', - 'dictionary_cache_memory' => 'e9', - 'file_system_memory' => 'ea', - 'lock_system_memory' => 'eb', - 'recovery_system_memory' => 'ec', - 'thread_hash_memory' => 'ed', - 'innodb_sem_waits' => 'ee', - 'innodb_sem_wait_time_ms' => 'ef', - 'Key_buf_bytes_unflushed' => 'eg', - 'Key_buf_bytes_used' => 'eh', - 'key_buffer_size' => 'ei', - 'Innodb_row_lock_time' => 'ej', - 'Innodb_row_lock_waits' => 'ek', - 'Query_time_count_00' => 'el', - 'Query_time_count_01' => 'em', - 'Query_time_count_02' => 'en', - 'Query_time_count_03' => 'eo', - 'Query_time_count_04' => 'ep', - 'Query_time_count_05' => 'eq', - 'Query_time_count_06' => 'er', - 'Query_time_count_07' => 'es', - 'Query_time_count_08' => 'et', - 'Query_time_count_09' => 'eu', - 'Query_time_count_10' => 'ev', - 'Query_time_count_11' => 'ew', - 'Query_time_count_12' => 'ex', - 'Query_time_count_13' => 'ey', - 'Query_time_total_00' => 'ez', - 'Query_time_total_01' => 'fa', - 'Query_time_total_02' => 'fb', - 'Query_time_total_03' => 'fc', - 'Query_time_total_04' => 'fd', - 'Query_time_total_05' => 'fe', - 'Query_time_total_06' => 'ff', - 'Query_time_total_07' => 'fg', - 'Query_time_total_08' => 'fh', - 'Query_time_total_09' => 'fi', - 'Query_time_total_10' => 'fj', - 'Query_time_total_11' => 'fk', - 'Query_time_total_12' => 'fl', - 'Query_time_total_13' => 'fm', + 'Key_read_requests' => 'gg', + 'Key_reads' => 'gh', + 'Key_write_requests' => 'gi', + 'Key_writes' => 'gj', + 'history_list' => 'gk', + 'innodb_transactions' => 'gl', + 'read_views' => 'gm', + 'current_transactions' => 'gn', + 'locked_transactions' => 'go', + 'active_transactions' => 'gp', + 'pool_size' => 'gq', + 'free_pages' => 'gr', + 'database_pages' => 'gs', + 'modified_pages' => 'gt', + 'pages_read' => 'gu', + 'pages_created' => 'gv', + 'pages_written' => 'gw', + 'file_fsyncs' => 'gx', + 'file_reads' => 'gy', + 'file_writes' => 'gz', + 'log_writes' => 'hg', + 'pending_aio_log_ios' => 'hh', + 'pending_aio_sync_ios' => 'hi', + 'pending_buf_pool_flushes' => 'hj', + 'pending_chkp_writes' => 'hk', + 'pending_ibuf_aio_reads' => 'hl', + 'pending_log_flushes' => 'hm', + 'pending_log_writes' => 'hn', + 'pending_normal_aio_reads' => 'ho', + 'pending_normal_aio_writes' => 'hp', + 'ibuf_inserts' => 'hq', + 'ibuf_merged' => 'hr', + 'ibuf_merges' => 'hs', + 'spin_waits' => 'ht', + 'spin_rounds' => 'hu', + 'os_waits' => 'hv', + 'rows_inserted' => 'hw', + 'rows_updated' => 'hx', + 'rows_deleted' => 'hy', + 'rows_read' => 'hz', + 'Table_locks_waited' => 'ig', + 'Table_locks_immediate' => 'ih', + 'Slow_queries' => 'ii', + 'Open_files' => 'ij', + 'Open_tables' => 'ik', + 'Opened_tables' => 'il', + 'innodb_open_files' => 'im', + 'open_files_limit' => 'in', + 'table_cache' => 'io', + 'Aborted_clients' => 'ip', + 'Aborted_connects' => 'iq', + 'Max_used_connections' => 'ir', + 'Slow_launch_threads' => 'is', + 'Threads_cached' => 'it', + 'Threads_connected' => 'iu', + 'Threads_created' => 'iv', + 'Threads_running' => 'iw', + 'max_connections' => 'ix', + 'thread_cache_size' => 'iy', + 'Connections' => 'iz', + 'slave_running' => 'jg', + 'slave_stopped' => 'jh', + 'Slave_retried_transactions' => 'ji', + 'slave_lag' => 'jj', + 'Slave_open_temp_tables' => 'jk', + 'Qcache_free_blocks' => 'jl', + 'Qcache_free_memory' => 'jm', + 'Qcache_hits' => 'jn', + 'Qcache_inserts' => 'jo', + 'Qcache_lowmem_prunes' => 'jp', + 'Qcache_not_cached' => 'jq', + 'Qcache_queries_in_cache' => 'jr', + 'Qcache_total_blocks' => 'js', + 'query_cache_size' => 'jt', + 'Questions' => 'ju', + 'Com_update' => 'jv', + 'Com_insert' => 'jw', + 'Com_select' => 'jx', + 'Com_delete' => 'jy', + 'Com_replace' => 'jz', + 'Com_load' => 'kg', + 'Com_update_multi' => 'kh', + 'Com_insert_select' => 'ki', + 'Com_delete_multi' => 'kj', + 'Com_replace_select' => 'kk', + 'Select_full_join' => 'kl', + 'Select_full_range_join' => 'km', + 'Select_range' => 'kn', + 'Select_range_check' => 'ko', + 'Select_scan' => 'kp', + 'Sort_merge_passes' => 'kq', + 'Sort_range' => 'kr', + 'Sort_rows' => 'ks', + 'Sort_scan' => 'kt', + 'Created_tmp_tables' => 'ku', + 'Created_tmp_disk_tables' => 'kv', + 'Created_tmp_files' => 'kw', + 'Bytes_sent' => 'kx', + 'Bytes_received' => 'ky', + 'innodb_log_buffer_size' => 'kz', + 'unflushed_log' => 'lg', + 'log_bytes_flushed' => 'lh', + 'log_bytes_written' => 'li', + 'relay_log_space' => 'lj', + 'binlog_cache_size' => 'lk', + 'Binlog_cache_disk_use' => 'll', + 'Binlog_cache_use' => 'lm', + 'binary_log_space' => 'ln', + 'innodb_locked_tables' => 'lo', + 'innodb_lock_structs' => 'lp', + 'State_closing_tables' => 'lq', + 'State_copying_to_tmp_table' => 'lr', + 'State_end' => 'ls', + 'State_freeing_items' => 'lt', + 'State_init' => 'lu', + 'State_locked' => 'lv', + 'State_login' => 'lw', + 'State_preparing' => 'lx', + 'State_reading_from_net' => 'ly', + 'State_sending_data' => 'lz', + 'State_sorting_result' => 'mg', + 'State_statistics' => 'mh', + 'State_updating' => 'mi', + 'State_writing_to_net' => 'mj', + 'State_none' => 'mk', + 'State_other' => 'ml', + 'Handler_commit' => 'mm', + 'Handler_delete' => 'mn', + 'Handler_discover' => 'mo', + 'Handler_prepare' => 'mp', + 'Handler_read_first' => 'mq', + 'Handler_read_key' => 'mr', + 'Handler_read_next' => 'ms', + 'Handler_read_prev' => 'mt', + 'Handler_read_rnd' => 'mu', + 'Handler_read_rnd_next' => 'mv', + 'Handler_rollback' => 'mw', + 'Handler_savepoint' => 'mx', + 'Handler_savepoint_rollback' => 'my', + 'Handler_update' => 'mz', + 'Handler_write' => 'ng', + 'innodb_tables_in_use' => 'nh', + 'innodb_lock_wait_secs' => 'ni', + 'hash_index_cells_total' => 'nj', + 'hash_index_cells_used' => 'nk', + 'total_mem_alloc' => 'nl', + 'additional_pool_alloc' => 'nm', + 'uncheckpointed_bytes' => 'nn', + 'ibuf_used_cells' => 'no', + 'ibuf_free_cells' => 'np', + 'ibuf_cell_count' => 'nq', + 'adaptive_hash_memory' => 'nr', + 'page_hash_memory' => 'ns', + 'dictionary_cache_memory' => 'nt', + 'file_system_memory' => 'nu', + 'lock_system_memory' => 'nv', + 'recovery_system_memory' => 'nw', + 'thread_hash_memory' => 'nx', + 'innodb_sem_waits' => 'ny', + 'innodb_sem_wait_time_ms' => 'nz', + 'Key_buf_bytes_unflushed' => 'og', + 'Key_buf_bytes_used' => 'oh', + 'key_buffer_size' => 'oi', + 'Innodb_row_lock_time' => 'oj', + 'Innodb_row_lock_waits' => 'ok', + 'Query_time_count_00' => 'ol', + 'Query_time_count_01' => 'om', + 'Query_time_count_02' => 'on', + 'Query_time_count_03' => 'oo', + 'Query_time_count_04' => 'op', + 'Query_time_count_05' => 'oq', + 'Query_time_count_06' => 'or', + 'Query_time_count_07' => 'os', + 'Query_time_count_08' => 'ot', + 'Query_time_count_09' => 'ou', + 'Query_time_count_10' => 'ov', + 'Query_time_count_11' => 'ow', + 'Query_time_count_12' => 'ox', + 'Query_time_count_13' => 'oy', + 'Query_time_total_00' => 'oz', + 'Query_time_total_01' => 'pg', + 'Query_time_total_02' => 'ph', + 'Query_time_total_03' => 'pi', + 'Query_time_total_04' => 'pj', + 'Query_time_total_05' => 'pk', + 'Query_time_total_06' => 'pl', + 'Query_time_total_07' => 'pm', + 'Query_time_total_08' => 'pn', + 'Query_time_total_09' => 'po', + 'Query_time_total_10' => 'pp', + 'Query_time_total_11' => 'pq', + 'Query_time_total_12' => 'pr', + 'Query_time_total_13' => 'ps', + 'wsrep_replicated_bytes' => 'pt', + 'wsrep_received_bytes' => 'pu', + 'wsrep_replicated' => 'pv', + 'wsrep_received' => 'pw', + 'wsrep_local_cert_failures' => 'px', + 'wsrep_local_bf_aborts' => 'py', + 'wsrep_local_send_queue' => 'pz', + 'wsrep_local_recv_queue' => 'qg', + 'wsrep_cluster_size' => 'qh', + 'wsrep_cert_deps_distance' => 'qi', + 'wsrep_apply_window' => 'qj', + 'wsrep_commit_window' => 'qk', + 'wsrep_flow_control_paused' => 'ql', + 'wsrep_flow_control_sent' => 'qm', + 'wsrep_flow_control_recv' => 'qn', + 'pool_reads' => 'qo', + 'pool_read_requests' => 'qp', ); # Return the output. @@ -846,13 +909,26 @@ function get_innodb_array($text) { $results['spin_rounds'][] = to_int($row[5]); $results['os_waits'][] = to_int($row[8]); } - elseif (strpos($line, 'RW-shared spins') === 0 ) { + elseif (strpos($line, 'RW-shared spins') === 0 + && strpos($line, ';') > 0 ) { # RW-shared spins 3859028, OS waits 2100750; RW-excl spins 4641946, OS waits 1530310 $results['spin_waits'][] = to_int($row[2]); $results['spin_waits'][] = to_int($row[8]); $results['os_waits'][] = to_int($row[5]); $results['os_waits'][] = to_int($row[11]); } + elseif (strpos($line, 'RW-shared spins') === 0 && strpos($line, '; RW-excl spins') === FALSE) { + # Post 5.5.17 SHOW ENGINE INNODB STATUS syntax + # RW-shared spins 604733, rounds 8107431, OS waits 241268 + $results['spin_waits'][] = to_int($row[2]); + $results['os_waits'][] = to_int($row[7]); + } + elseif (strpos($line, 'RW-excl spins') === 0) { + # Post 5.5.17 SHOW ENGINE INNODB STATUS syntax + # RW-excl spins 604733, rounds 8107431, OS waits 241268 + $results['spin_waits'][] = to_int($row[2]); + $results['os_waits'][] = to_int($row[7]); + } elseif (strpos($line, 'seconds the semaphore:') > 0) { # --Thread 907205 has waited at handler/ha_innodb.cc line 7156 for 1.00 seconds the semaphore: increment($results, 'innodb_sem_waits', 1); @@ -866,7 +942,8 @@ function get_innodb_array($text) { # transactions # Trx id counter 0 1170664159 # Trx id counter 861B144C - $results['innodb_transactions'] = make_bigint($row[3], $row[4]); + $results['innodb_transactions'] = make_bigint( + $row[3], (isset($row[4]) ? $row[4] : null)); $txn_seen = TRUE; } elseif ( strpos($line, 'Purge done for trx') === 0 ) { @@ -952,6 +1029,16 @@ function get_innodb_array($text) { $results['ibuf_used_cells'] = to_int($row[2]); $results['ibuf_free_cells'] = to_int($row[6]); $results['ibuf_cell_count'] = to_int($row[9]); + if (strpos($line, 'merges')) { + $results['ibuf_merges'] = to_int($row[10]); + } + } + elseif (strpos($line, ', delete mark ') > 0 && strpos($prev_line, 'merged operations:') === 0 ) { + # Output of show engine innodb status has changed in 5.5 + # merged operations: + # insert 593983, delete mark 387006, delete 73092 + $results['ibuf_inserts'] = to_int($row[1]); + $results['ibuf_merged'] = to_int($row[1]) + to_int($row[4]) + to_int($row[6]); } elseif (strpos($line, ' merged recs, ') > 0 ) { # 19817685 inserts, 19817684 merged recs, 3552620 merges @@ -1007,8 +1094,9 @@ function get_innodb_array($text) { } # BUFFER POOL AND MEMORY - elseif (strpos($line, "Total memory allocated") === 0 ) { + elseif (strpos($line, "Total memory allocated") === 0 && strpos($line, "in additional pool allocated") > 0 ) { # Total memory allocated 29642194944; in additional pool allocated 0 + # Total memory allocated by read views 96 $results['total_mem_alloc'] = to_int($row[3]); $results['additional_pool_alloc'] = to_int($row[8]); } @@ -1088,6 +1176,7 @@ function get_innodb_array($text) { $results['queries_inside'] = to_int($row[0]); $results['queries_queued'] = to_int($row[4]); } + $prev_line = $line; } foreach ( array('spin_waits', 'spin_rounds', 'os_waits') as $key ) { @@ -1144,23 +1233,29 @@ function to_int ( $str ) { } # ============================================================================ -# Wrap mysql_query in error-handling, and instead of returning the result, +# Wrap mysqli_query in error-handling, and instead of returning the result, # return an array of arrays in the result. # ============================================================================ function run_query($sql, $conn) { global $debug; debug($sql); - $result = @mysql_query($sql, $conn); - if ( $debug ) { - $error = @mysql_error($conn); + $result = @mysqli_query($conn, $sql); + if ( $debug && strpos($sql, 'SHOW SLAVE STATUS ') === false ) { + $error = @mysqli_error($conn); if ( $error ) { debug(array($sql, $error)); die("SQLERR $error in $sql"); } } $array = array(); - while ( $row = @mysql_fetch_array($result) ) { - $array[] = $row; + $count = @mysqli_num_rows($result); + if ( $count > 10000 ) { + debug('Abnormal number of rows returned: ' . $count); + } + else { + while ( $row = @mysqli_fetch_array($result) ) { + $array[] = $row; + } } debug(array($sql, $array)); return $array; @@ -1268,7 +1363,7 @@ function debug($val) { if ( !count($calls) ) { $calls[] = "at $file:$line"; } - fwrite($fp, date('Y-m-d h:i:s') . ' ' . implode(' <- ', $calls)); + fwrite($fp, date('Y-m-d H:i:s') . ' ' . implode(' <- ', $calls)); fwrite($fp, "\n" . var_export($val, TRUE) . "\n"); fclose($fp); } @@ -1278,4 +1373,3 @@ function debug($val) { } } -?> diff --git a/bin/swap_enabled.sh b/bin/swap_enabled.sh new file mode 100644 index 0000000..8f20e8a --- /dev/null +++ b/bin/swap_enabled.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +swap=$(free -m | grep -i swap | awk '{ print $2 }') + +if [ "$swap" != "0" ]; then + echo '{"data":[{"{#TOTAL}":"total", "{#FREE}":"free", "{#PFREE}":"pfree", "{#PUSED}":"pused" } ]}' +fi diff --git a/sudoers.d/zabbix b/sudoers.d/zabbix index d131954..3cd5aff 100644 --- a/sudoers.d/zabbix +++ b/sudoers.d/zabbix @@ -9,4 +9,10 @@ zabbix ALL=(ALL) NOPASSWD: /opt/dell/srvadmin/bin/omreport zabbix ALL=(ALL) NOPASSWD: /usr/bin/bcu zabbix ALL=(ALL) NOPASSWD: /sbin/powermt zabbix ALL=(ALL) NOPASSWD: /bin/find /var/spool/postfix/ -type f +zabbix ALL=(ALL) NOPASSWD: /usr/sbin/httpd -v +zabbix ALL=(ALL) NOPASSWD: /usr/sbin/dmidecode +zabbix ALL=(ALL) NOPASSWD: /usr/bin/stat +zabbix ALL=(ALL) NOPASSWD: /usr/bin/md5sum +zabbix ALL=(ALL) NOPASSWD: /bin/find /var/lib/mysql/ -type f -printf %p+%s= +zabbix ALL=(ALL) NOPASSWD: /etc/zabbix/bin/haproxy.sh Defaults:zabbix !requiretty diff --git a/templates/Template App MySQL.xml b/templates/Template App MySQL.xml index c5a082a..8cd3d4e 100644 --- a/templates/Template App MySQL.xml +++ b/templates/Template App MySQL.xml @@ -1,7 +1,7 @@ - 2.0 - 2015-08-12T06:50:17Z + 3.0 + 2016-05-02T07:25:49Z Templates @@ -24,8 +24,54 @@ Database Fileystem + + MySQL Tables + + + MySQL is enabled in autostart + 0 + + 0 + + chkconfig[mysql] + 3600 + 7 + 30 + 0 + 3 + + + 0 + + + 0 + 0 + + 0 + + 1 + + + + 3 + 0 + + + + + + + 0 + + + Database + + + + + Aborted clients 0 @@ -327,49 +373,6 @@ - - Binlog cache size - 0 - - 0 - - mysql.setting.binlog_cache_size - 3600 - 30 - 365 - 0 - 0 - - - 0 - - - 0 - 0 - - 0 - - 0 - - - - 0 - 0 - - - - - - - 0 - - - Database - - - - - Binlog cache use 0 @@ -499,49 +502,6 @@ - - Checksum of $1 - 0 - - 0 - - vfs.file.cksum[/etc/my.cnf] - 600 - 7 - 30 - 0 - 3 - - - 0 - - - 0 - 0 - - 0 - - 1 - - - - 0 - 0 - - - - - - - 0 - - - Database - - - - - Com delete 0 @@ -972,6 +932,49 @@ + + MySQL Connections + 0 + + 0 + + mysql.connection + 30 + 30 + 365 + 0 + 3 + + + 0 + + + 0 + 0 + + 0 + + 1 + + + + 0 + 0 + + + + + + + 0 + + + Database + + + + + Connections 0 @@ -1273,45 +1276,6 @@ - - File exists: $1 - 0 - - 0 - - vfs.file.exists[/etc/my.cnf] - 600 - 7 - 30 - 0 - 3 - - - 0 - - - 0 - 0 - - 0 - - 1 - - - - 0 - 0 - - - - - - - 0 - - - - File fsyncs 0 @@ -1484,178 +1448,6 @@ - - Free disk space on $1 - 0 - - 0 - - vfs.fs.size[/var/lib/mysql,free] - 30 - 30 - 365 - 0 - 3 - - B - 0 - - - 0 - 0 - - 0 - - 1 - - - - 0 - 0 - - - - - - - 0 - - - Database Fileystem - - - - - - - Free disk space on $1 in % - 0 - - 0 - - vfs.fs.size[/var/lib/mysql,pfree] - 30 - 30 - 365 - 0 - 0 - - % - 0 - - - 0 - 0 - - 0 - - 1 - - - - 0 - 0 - - - - - - - 0 - - - Database Fileystem - - - - - - - Free number of inodes on $1 - 0 - - 0 - - vfs.fs.inode[/var/lib/mysql,free] - 60 - 30 - 365 - 0 - 3 - - - 0 - - - 0 - 0 - - 0 - - 1 - - - - 0 - 0 - - - - - - - 0 - - - Database Fileystem - - - - - - - Free number of inodes on $1 in % - 0 - - 0 - - vfs.fs.inode[/var/lib/mysql,pfree] - 60 - 30 - 365 - 0 - 0 - - % - 0 - - - 0 - 0 - - 0 - - 1 - - - - 0 - 0 - - - - - - - 0 - - - Database Fileystem - - - - - Free pages 0 @@ -3204,6 +2996,264 @@ + + MyISAM Key buf bytes unflushed + 0 + + 0 + + mysql.Key_buf_bytes_unflushed + 120 + 30 + 365 + 0 + 0 + + B + 0 + + + 0 + 0 + + 0 + + 0 + + + + 0 + 0 + + + + + + + 0 + + + Database + + + + + + + MyISAM Key buf bytes used + 0 + + 0 + + mysql.Key_buf_bytes_used + 120 + 30 + 365 + 0 + 0 + + B + 0 + + + 0 + 0 + + 0 + + 0 + + + + 0 + 0 + + + + + + + 0 + + + Database + + + + + + + MyISAM Key reads + 0 + + 0 + + mysql.Key_reads + 120 + 30 + 365 + 0 + 0 + + + 2 + + + 0 + 0 + + 0 + + 0 + + + + 0 + 0 + + + + + + + 0 + + + Database + + + + + + + MyISAM Key read requests + 0 + + 0 + + mysql.Key_read_requests + 120 + 30 + 365 + 0 + 0 + + + 2 + + + 0 + 0 + + 0 + + 0 + + + + 0 + 0 + + + + + + + 0 + + + Database + + + + + + + MyISAM Key writes + 0 + + 0 + + mysql.Key_writes + 120 + 30 + 365 + 0 + 0 + + + 2 + + + 0 + 0 + + 0 + + 0 + + + + 0 + 0 + + + + + + + 0 + + + Database + + + + + + + MyISAM Key write requests + 0 + + 0 + + mysql.Key_write_requests + 120 + 30 + 365 + 0 + 0 + + + 2 + + + 0 + 0 + + 0 + + 0 + + + + 0 + 0 + + + + + + + 0 + + + Database + + + + + Locked transactions 0 @@ -3419,49 +3469,6 @@ - - Max connections - 0 - - 0 - - mysql.setting.max_connections - 3600 - 30 - 365 - 0 - 0 - - - 0 - - - 0 - 0 - - 0 - - 0 - - - - 0 - 0 - - - - - - - 0 - - - Database - - - - - Max used connections 0 @@ -3548,651 +3555,6 @@ - - MyISAM Key buf bytes unflushed - 0 - - 0 - - mysql.Key_buf_bytes_unflushed - 120 - 30 - 365 - 0 - 0 - - B - 0 - - - 0 - 0 - - 0 - - 0 - - - - 0 - 0 - - - - - - - 0 - - - Database - - - - - - - MyISAM Key buf bytes used - 0 - - 0 - - mysql.Key_buf_bytes_used - 120 - 30 - 365 - 0 - 0 - - B - 0 - - - 0 - 0 - - 0 - - 0 - - - - 0 - 0 - - - - - - - 0 - - - Database - - - - - - - MyISAM key buffer size - 0 - - 0 - - mysql.setting.key_buffer_size - 3600 - 30 - 365 - 0 - 0 - - B - 0 - - - 0 - 0 - - 0 - - 0 - - - - 0 - 0 - - - - - - - 0 - - - Database - - - - - - - MyISAM Key read requests - 0 - - 0 - - mysql.Key_read_requests - 120 - 30 - 365 - 0 - 0 - - - 2 - - - 0 - 0 - - 0 - - 0 - - - - 0 - 0 - - - - - - - 0 - - - Database - - - - - - - MyISAM Key reads - 0 - - 0 - - mysql.Key_reads - 120 - 30 - 365 - 0 - 0 - - - 2 - - - 0 - 0 - - 0 - - 0 - - - - 0 - 0 - - - - - - - 0 - - - Database - - - - - - - MyISAM Key write requests - 0 - - 0 - - mysql.Key_write_requests - 120 - 30 - 365 - 0 - 0 - - - 2 - - - 0 - 0 - - 0 - - 0 - - - - 0 - 0 - - - - - - - 0 - - - Database - - - - - - - MyISAM Key writes - 0 - - 0 - - mysql.Key_writes - 120 - 30 - 365 - 0 - 0 - - - 2 - - - 0 - 0 - - 0 - - 0 - - - - 0 - 0 - - - - - - - 0 - - - Database - - - - - - - MySQL Connections - 0 - - 0 - - mysql.connection - 30 - 30 - 365 - 0 - 3 - - - 0 - - - 0 - 0 - - 0 - - 1 - - - - 0 - 0 - - - - - - - 0 - - - Database - - - - - - - MySQL is enabled in autostart - 0 - - 0 - - chkconfig[mysql] - 3600 - 7 - 30 - 0 - 3 - - - 0 - - - 0 - 0 - - 0 - - 1 - - - - 3 - 0 - - - - - - - 0 - - - Database - - - - - - - MySQL ping - 0 - - 0 - - mysql.ping - 30 - 30 - 365 - 0 - 3 - localhost - - 0 - - - 0 - 0 - - 0 - - 0 - - - - 0 - 0 - - - - - - - 0 - - - Database - - - - - - - MySQL QPS - 0 - - 0 - - mysql.qps - 30 - 30 - 365 - 0 - 0 - localhost - - 0 - - - 0 - 0 - - 0 - - 0 - - - - 0 - 0 - - - - - - - 0 - - - Database - - - - - - - MySQL Server Version - 0 - - 0 - - mysql.version - 3600 - 7 - 365 - 0 - 1 - - - 0 - - - 0 - 0 - - 0 - - 1 - - - - 0 - 0 - - - - - - - 0 - - - Database - - - - - - - MySQL Slow Queries - 0 - - 0 - - mysql.slowqueries - 30 - 30 - 365 - 0 - 3 - localhost - - 0 - - - 0 - 0 - - 0 - - 0 - - - - 0 - 0 - - - - - - - 0 - - - Database - - - - - - - MySQL Threads - 0 - - 0 - - mysql.threads - 30 - 30 - 365 - 0 - 3 - localhost - - 0 - - - 0 - 0 - - 0 - - 0 - - - - 0 - 0 - - - - - - - 0 - - - Database - - - - - - - Number of running processes mysqld - 0 - - 0 - - proc.num[mysqld] - 60 - 30 - 365 - 0 - 3 - - - 0 - - - 0 - 0 - - 0 - - 0 - - - - 0 - 0 - - - - - - - 0 - - - Database - - - - - Opened tables 0 @@ -4279,49 +3641,6 @@ - - Open files limit - 0 - - 0 - - mysql.setting.open_files_limit - 3600 - 30 - 365 - 0 - 0 - - - 0 - - - 0 - 0 - - 0 - - 0 - - - - 0 - 0 - - - - - - - 0 - - - Database - - - - - Open tables 0 @@ -4408,49 +3727,6 @@ - - Page hash memory - 0 - - 0 - - mysql.page_hash_memory - 120 - 30 - 365 - 0 - 0 - - B - 0 - - - 0 - 0 - - 0 - - 0 - - - - 0 - 0 - - - - - - - 0 - - - Database - - - - - Pages created 0 @@ -4580,6 +3856,49 @@ + + Page hash memory + 0 + + 0 + + mysql.page_hash_memory + 120 + 30 + 365 + 0 + 0 + + B + 0 + + + 0 + 0 + + 0 + + 0 + + + + 0 + 0 + + + + + + + 0 + + + Database + + + + + Pending AIO log ios 0 @@ -4968,19 +4287,19 @@ - Pool size + MySQL ping 0 0 - mysql.setting.pool_size - 3600 + mysql.ping + 30 30 365 0 - 0 - - B + 3 + localhost + 0 @@ -5355,19 +4674,19 @@ - Query cache size + MySQL QPS 0 0 - mysql.setting.query_cache_size - 3600 + mysql.qps + 30 30 365 0 0 - - B + localhost + 0 @@ -5956,6 +5275,350 @@ + + Binlog cache size + 0 + + 0 + + mysql.setting.binlog_cache_size + 3600 + 30 + 365 + 0 + 0 + + + 0 + + + 0 + 0 + + 0 + + 0 + + + + 0 + 0 + + + + + + + 0 + + + Database + + + + + + + MyISAM key buffer size + 0 + + 0 + + mysql.setting.key_buffer_size + 3600 + 30 + 365 + 0 + 0 + + B + 0 + + + 0 + 0 + + 0 + + 0 + + + + 0 + 0 + + + + + + + 0 + + + Database + + + + + + + Max connections + 0 + + 0 + + mysql.setting.max_connections + 3600 + 30 + 365 + 0 + 0 + + + 0 + + + 0 + 0 + + 0 + + 0 + + + + 0 + 0 + + + + + + + 0 + + + Database + + + + + + + Open files limit + 0 + + 0 + + mysql.setting.open_files_limit + 3600 + 30 + 365 + 0 + 0 + + + 0 + + + 0 + 0 + + 0 + + 0 + + + + 0 + 0 + + + + + + + 0 + + + Database + + + + + + + Pool size + 0 + + 0 + + mysql.setting.pool_size + 3600 + 30 + 365 + 0 + 0 + + B + 0 + + + 0 + 0 + + 0 + + 0 + + + + 0 + 0 + + + + + + + 0 + + + Database + + + + + + + Query cache size + 0 + + 0 + + mysql.setting.query_cache_size + 3600 + 30 + 365 + 0 + 0 + + B + 0 + + + 0 + 0 + + 0 + + 0 + + + + 0 + 0 + + + + + + + 0 + + + Database + + + + + + + Table cache + 0 + + 0 + + mysql.setting.table_cache + 3600 + 30 + 365 + 0 + 0 + + + 0 + + + 0 + 0 + + 0 + + 0 + + + + 0 + 0 + + + + + + + 0 + + + Database + + + + + + + Thread cache size + 0 + + 0 + + mysql.setting.thread_cache_size + 3600 + 30 + 365 + 0 + 0 + + + 0 + + + 0 + 0 + + 0 + + 0 + + + + 0 + 0 + + + + + + + 0 + + + Database + + + + + Slave lag 0 @@ -6171,6 +5834,49 @@ + + MySQL Slow Queries + 0 + + 0 + + mysql.slowqueries + 30 + 30 + 365 + 0 + 3 + localhost + + 0 + + + 0 + 0 + + 0 + + 0 + + + + 0 + 0 + + + + + + + 0 + + + Database + + + + + Slow launch threads 0 @@ -7203,49 +6909,6 @@ - - Table cache - 0 - - 0 - - mysql.setting.table_cache - 3600 - 30 - 365 - 0 - 0 - - - 0 - - - 0 - 0 - - 0 - - 0 - - - - 0 - 0 - - - - - - - 0 - - - Database - - - - - Table locks immediate 0 @@ -7333,18 +6996,18 @@ - Thread cache size + MySQL Threads 0 0 - mysql.setting.thread_cache_size - 3600 + mysql.threads + 30 30 365 0 - 0 - + 3 + localhost 0 @@ -7375,49 +7038,6 @@ - - Thread hash memory - 0 - - 0 - - mysql.thread_hash_memory - 120 - 30 - 365 - 0 - 0 - - B - 0 - - - 0 - 0 - - 0 - - 0 - - - - 0 - 0 - - - - - - - 0 - - - Database - - - - - Threads cached 0 @@ -7591,17 +7211,17 @@ - Total disk space on $1 + Thread hash memory 0 0 - vfs.fs.size[/var/lib/mysql,total] - 30 + mysql.thread_hash_memory + 120 30 365 0 - 3 + 0 B 0 @@ -7612,7 +7232,7 @@ 0 - 1 + 0 @@ -7627,7 +7247,7 @@ 0 - Database Fileystem + Database @@ -7676,49 +7296,6 @@ - - Total number of inodes on $1 - 0 - - 0 - - vfs.fs.inode[/var/lib/mysql,total] - 60 - 30 - 365 - 0 - 3 - - - 0 - - - 0 - 0 - - 0 - - 1 - - - - 0 - 0 - - - - - - - 0 - - - Database Fileystem - - - - - Uncheckpointed bytes 0 @@ -7806,19 +7383,62 @@ - Used disk space on $1 + MySQL Server Version 0 0 - vfs.fs.size[/var/lib/mysql,used] - 30 + mysql.version + 3600 + 7 + 0 + 0 + 1 + + + 0 + + + 0 + 0 + + 0 + + 1 + + + + 0 + 0 + + + + + + + 0 + + + Database + + + + + + + Number of running processes mysqld + 0 + + 0 + + proc.num[mysqld] + 60 30 365 0 3 - B + 0 @@ -7827,7 +7447,7 @@ 0 - 1 + 0 @@ -7842,65 +7462,22 @@ 0 - Database Fileystem + Database - Used disk space on $1 in % + Checksum of $1 0 0 - vfs.fs.size[/var/lib/mysql,pused] - 30 - 30 - 365 - 0 - 0 - - % - 0 - - - 0 - 0 - - 0 - - 1 - - - - 0 - 0 - - - - - - - 0 - - - Database Fileystem - - - - - - - Used number of inodes on $1 - 0 - - 0 - - vfs.fs.inode[/var/lib/mysql,used] - 60 - 30 - 365 + vfs.file.cksum[/etc/my.cnf] + 600 + 7 + 30 0 3 @@ -7928,26 +7505,26 @@ 0 - Database Fileystem + Database - Used number of inodes on $1 in % + File exists: $1 0 0 - vfs.fs.inode[/var/lib/mysql,pused] - 60 - 30 - 365 + vfs.file.exists[/etc/my.cnf] + 600 + 7 + 30 0 - 0 + 3 - % + 0 @@ -7969,16 +7546,146 @@ 0 - - - Database Fileystem - - + - + + + MySQL tables + 0 + + + mysql.discovertablesize + 3600 + 0 + + + + 0 + 0 + + 0 + + + + + 0 + + + + + + + 0 + + + + {#TABLENAME} + @excludeMySQLTables + 8 + A + + + + 0 + + + + MySQL table {#DBNAME}.{#TABLENAME} physical size + 0 + + 0 + + mysql.table_physical_size[{#DBNAME},{#TABLENAME}] + 900 + 30 + 365 + 0 + 3 + + + 0 + + + 0 + 0 + + 0 + + 1 + + + + 0 + 0 + + + + + + MySQL table size reported by filesystem + 0 + + + MySQL Tables + + + + + + + + MySQL table {#DBNAME}.{#TABLENAME} virtual size + 0 + + 0 + + mysql.table_virtual_size[{#DBNAME},{#TABLENAME}] + 900 + 30 + 365 + 0 + 3 + + + 0 + + + 0 + 0 + + 0 + + 1 + + + + 0 + 0 + + + + + + MySQL table size reported by MySQL database + 0 + + + MySQL Tables + + + + + + + + + + + + @@ -8253,86 +7960,6 @@ 0 - - {Template App MySQL:vfs.fs.size[/var/lib/mysql,pfree].last(0)}<1 - Low free (<1%) disk space, volume /san/mysql-fs - - 0 - 5 - - 0 - - - - {Template App MySQL:vfs.fs.inode[/var/lib/mysql,pfree].last(0)}<1 - Low free (<1%) inodes, volume /san/mysql-fs - - 0 - 5 - - 0 - - - - {Template App MySQL:vfs.fs.size[/var/lib/mysql,pfree].last(0)}<5 - Low free (<5%) disk space, volume /san/mysql-fs - - 0 - 4 - - 0 - - - - {Template App MySQL:vfs.fs.inode[/var/lib/mysql,pfree].last(0)}<5 - Low free (<5%) inodes, volume /san/mysql-fs - - 0 - 4 - - 0 - - - - {Template App MySQL:vfs.fs.size[/var/lib/mysql,pfree].last(0)}<10 - Low free (<10%) disk space, volume /san/mysql-fs - - 0 - 3 - - 0 - - - - {Template App MySQL:vfs.fs.inode[/var/lib/mysql,pfree].last(0)}<10 - Low free (<10%) inodes, volume /san/mysql-fs - - 0 - 3 - - 0 - - - - {Template App MySQL:vfs.fs.size[/var/lib/mysql,pfree].last(0)}<20 - Low free (<20%) disk space, volume /san/mysql-fs - - 0 - 2 - - 0 - - - - {Template App MySQL:vfs.fs.inode[/var/lib/mysql,pfree].last(0)}<20 - Low free (<20%) inodes, volume /san/mysql-fs - - 0 - 2 - - 0 - - {Template App MySQL:mysql.Threads_connected.last(0)}>300 More than 300 threads @@ -8413,6 +8040,16 @@ 0 + + {Template App MySQL:mysql.Table_locks_waited.delta(300)}>20 + Server is waiting on table locks + + 0 + 2 + + 0 + + ({TRIGGER.VALUE}=0 and {Template App MySQL:mysql.State_copying_to_tmp_table.count(900,1,"ge")}>10) or ({TRIGGER.VALUE}=1 and {Template App MySQL:mysql.State_copying_to_tmp_table.count(900,1,"ge")}>0) Thread in state Copying_to_tmp_table for more than 15 min @@ -8423,6 +8060,26 @@ 0 + + {Template App MySQL:proc.num[mysqld].last(0)}>1 + Too many instances of mysqld (current: {ITEM.LASTVALUE}) + + 0 + 4 + + 0 + + + + {Template App MySQL:proc.num[mysqld].last(0)}>1 + Too many instances of mysql running (current: {ITEM.LASTVALUE}) + + 0 + 4 + + 0 + + @@ -8669,50 +8326,6 @@ - - [MySQL] Database Filesystem Usage - 900 - 200 - 0.0000 - 100.0000 - 0 - 0 - 1 - 1 - 0 - 0.0000 - 0.0000 - 0 - 0 - 0 - 0 - - - 1 - 1 - 00C800 - 0 - 2 - 0 - - Template App MySQL - vfs.fs.size[/var/lib/mysql,pfree] - - - - 0 - 1 - C80000 - 0 - 2 - 0 - - Template App MySQL - vfs.fs.size[/var/lib/mysql,pused] - - - - [MySQL] Files and Tables 800 @@ -8735,7 +8348,7 @@ 0 0 DE0056 - 1 + 0 2 0 @@ -8747,7 +8360,7 @@ 1 0 4A6959 - 1 + 0 2 0 @@ -8759,7 +8372,7 @@ 2 0 1D1159 - 1 + 0 2 0 @@ -8771,7 +8384,7 @@ 3 1 D09887 - 1 + 0 2 0 @@ -8931,7 +8544,7 @@ 0 1 C0C0C0 - 1 + 0 2 0 @@ -8943,7 +8556,7 @@ 1 0 FF0000 - 1 + 0 2 0 @@ -9275,7 +8888,7 @@ 0 0 4444FF - 1 + 0 2 0 @@ -9287,7 +8900,7 @@ 1 0 FFF200 - 1 + 0 2 0 @@ -9299,7 +8912,7 @@ 2 0 FF7D00 - 1 + 0 2 0 @@ -9311,7 +8924,7 @@ 3 0 8F9286 - 1 + 0 2 0 @@ -9323,7 +8936,7 @@ 4 0 00A348 - 1 + 0 2 0 @@ -9335,7 +8948,7 @@ 5 0 6DC8FE - 1 + 0 2 0 @@ -9347,7 +8960,7 @@ 6 0 B90054 - 1 + 0 2 0 @@ -9359,7 +8972,7 @@ 7 0 FF0000 - 1 + 0 2 0 @@ -9371,7 +8984,7 @@ 8 0 55009D - 1 + 0 2 0 @@ -9827,7 +9440,7 @@ 0 1 AFECED - 1 + 0 2 0 @@ -9839,7 +9452,7 @@ 1 5 EA8F00 - 1 + 0 2 0 @@ -9851,7 +9464,7 @@ 2 5 35962B - 1 + 0 2 0 @@ -9863,7 +9476,7 @@ 3 5 DA4725 - 1 + 0 2 0 @@ -10319,7 +9932,7 @@ 0 1 4B2744 - 1 + 0 2 0 @@ -10331,7 +9944,7 @@ 1 1 E4C576 - 1 + 0 2 0 @@ -10755,7 +10368,7 @@ 0 5 13343B - 1 + 0 2 0 @@ -10767,7 +10380,7 @@ 1 5 AA3B27 - 1 + 0 2 0 @@ -10779,7 +10392,7 @@ 2 5 EDAA41 - 1 + 0 2 0 @@ -10791,7 +10404,7 @@ 3 1 3D1500 - 1 + 0 2 0 @@ -10803,7 +10416,7 @@ 4 5 686240 - 1 + 0 2 0 @@ -11039,7 +10652,7 @@ 0 2 DE0056 - 1 + 0 2 0 @@ -11051,7 +10664,7 @@ 1 1 D8ACE0 - 1 + 0 2 0