Skip to content

Commit

Permalink
feat(percona) add percona metrics gathering
Browse files Browse the repository at this point in the history
  • Loading branch information
bmx0r committed May 28, 2020
1 parent c10b92f commit f2f7cfd
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 20 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).
This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins/community/blob/master/HOW_WE_CHANGELOG.md)

## [Unreleased]
### Fixed
- Align output scheme for `metrics-mysql-graphite.rb` and `metrics-mysql-processes.rb`
- Make mysql_shorthostname compliant with graphite even if 127.0.0.1 is givent as hostname
- include MR #111: Collect more innodb variables #111:
- `metrics-mysql-graphite.rb`: collect more InnoDB variables. (@boutetnico)
- include metrics gathering from `https://github.com/sensu-plugins/sensu-plugins-percona` in `metrics-mysql-graphite.rb` (there is no reason to run the gathering twice and no reasons to keep two code base)

## [3.1.1] - 2019-03-04
### Fixed
Expand Down
100 changes: 80 additions & 20 deletions bin/metrics-mysql-graphite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,32 +175,86 @@ def metrics_hash
'Handler_savepoint_rollback' => 'handlerSavepointRollback',
},
'innodb' => {
'Innodb_buffer_pool_pages_total' => 'bufferTotal_pages',
'Innodb_buffer_pool_pages_free' => 'bufferFree_pages',
'Innodb_buffer_pool_pages_dirty' => 'bufferDirty_pages',
'Innodb_buffer_pool_pages_data' => 'bufferUsed_pages',
'Innodb_page_size' => 'pageSize',
'Innodb_pages_created' => 'pagesCreated',
'Innodb_pages_read' => 'pagesRead',
'Innodb_pages_written' => 'pagesWritten',
'Innodb_row_lock_current_waits' => 'currentLockWaits',
'Innodb_row_lock_waits' => 'lockWaitTimes',
'Innodb_row_lock_time' => 'rowLockTime',
'Innodb_data_reads' => 'fileReads',
'Innodb_data_writes' => 'fileWrites',
'Innodb_data_fsyncs' => 'fileFsyncs',
'Innodb_log_writes' => 'logWrites',
'Innodb_rows_updated' => 'rowsUpdated',
'Innodb_rows_read' => 'rowsRead',
'Innodb_rows_deleted' => 'rowsDeleted',
'Innodb_rows_inserted' => 'rowsInserted',
'Innodb_buffer_pool_pages_total' => 'bufferTotal_pages',
'Innodb_buffer_pool_pages_free' => 'bufferFree_pages',
'Innodb_buffer_pool_pages_dirty' => 'bufferDirty_pages',
'Innodb_buffer_pool_pages_data' => 'bufferUsed_pages',
'Innodb_buffer_pool_pages_flushed' => 'bufferFlushed_pages',
'Innodb_buffer_pool_pages_misc' => 'bufferMisc_pages',
'Innodb_buffer_pool_bytes_data' => 'bufferUsed_bytes',
'Innodb_buffer_pool_bytes_dirty' => 'bufferDirty_bytes',
'Innodb_buffer_pool_read_ahead_rnd' => 'bufferReadAheadRnd',
'Innodb_buffer_pool_read_ahead' => 'bufferReadAhead',
'Innodb_buffer_pool_read_ahead_evicted' => 'bufferReadAheadEvicted',
'Innodb_buffer_pool_read_requests' => 'bufferReadRequests',
'Innodb_buffer_pool_reads' => 'bufferReads',
'Innodb_buffer_pool_wait_free' => 'bufferWaitFree',
'Innodb_buffer_pool_write_requests' => 'bufferWriteRequests',
'innodb_buffer_pool_size' => 'poolSize',
'Innodb_page_size' => 'pageSize',
'Innodb_pages_created' => 'pagesCreated',
'Innodb_pages_read' => 'pagesRead',
'Innodb_pages_written' => 'pagesWritten',
'Innodb_row_lock_current_waits' => 'currentLockWaits',
'Innodb_row_lock_waits' => 'lockWaitTimes',
'Innodb_row_lock_time' => 'rowLockTime',
'Innodb_data_reads' => 'fileReads',
'Innodb_data_writes' => 'fileWrites',
'Innodb_data_fsyncs' => 'fileFsyncs',
'Innodb_log_writes' => 'logWrites',
'Innodb_rows_updated' => 'rowsUpdated',
'Innodb_rows_read' => 'rowsRead',
'Innodb_rows_deleted' => 'rowsDeleted',
'Innodb_rows_inserted' => 'rowsInserted',
},
'configuration' => {
'max_connections' => 'MaxConnections',
'Max_prepared_stmt_count' => 'MaxPreparedStmtCount',
},
'cluster' => {
'wsrep_last_committed' => 'last_committed',
'wsrep_replicated' => 'replicated',
'wsrep_replicated_bytes' => 'replicated_bytes',
'wsrep_received' => 'received',
'wsrep_received_bytes' => 'received_bytes',
'wsrep_local_commits' => 'local_commits',
'wsrep_local_cert_failures' => 'local_cert_failures',
'wsrep_local_bf_aborts' => 'local_bf_aborts',
'wsrep_local_replays' => 'local_replays',
'wsrep_local_send_queue' => 'local_send_queue',
'wsrep_local_send_queue_avg' => 'local_send_queue_avg',
'wsrep_local_recv_queue' => 'local_recv_queue',
'wsrep_local_recv_queue_avg' => 'local_recv_queue_avg',
'wsrep_flow_control_paused' => 'flow_control_paused',
'wsrep_flow_control_sent' => 'flow_control_sent',
'wsrep_flow_control_recv' => 'flow_control_recv',
'wsrep_cert_deps_distance' => 'cert_deps_distance',
'wsrep_apply_oooe' => 'apply_oooe',
'wsrep_apply_oool' => 'apply_oool',
'wsrep_apply_window' => 'apply_window',
'wsrep_commit_oooe' => 'commit_oooe',
'wsrep_commit_oool' => 'commit_oool',
'wsrep_commit_window' => 'commit_window',
'wsrep_local_state' => 'local_state',
'wsrep_cert_index_size' => 'cert_index_size',
'wsrep_causal_reads' => 'causal_reads',
'wsrep_cluster_conf_id' => 'cluster_conf_id',
'wsrep_cluster_size' => 'cluster_size',
'wsrep_local_index' => 'local_index',
'wsrep_evs_repl_latency' => 'evs_repl_latency'
}
}
end

def fix_and_output_evs_repl_latency_data(row, mysql_shorthostname, category)
# see https://github.com/codership/galera/issues/67 for documentation on field mappings
data = row['Value'].split('/')
output "#{config[:scheme]}.#{mysql_shorthostname}.#{category}.wsrep_evs_repl_latency_min", data[0]
output "#{config[:scheme]}.#{mysql_shorthostname}.#{category}.wsrep_evs_repl_latency_avg", data[1]
output "#{config[:scheme]}.#{mysql_shorthostname}.#{category}.wsrep_evs_repl_latency_max", data[2]
output "#{config[:scheme]}.#{mysql_shorthostname}.#{category}.wsrep_evs_repl_latency_stddev", data[3]
output "#{config[:scheme]}.#{mysql_shorthostname}.#{category}.wsrep_evs_repl_latency_samplesize", data[4]
end

def run
# props to https://github.com/coredump/hoardd/blob/master/scripts-available/mysql.coffee
Expand Down Expand Up @@ -228,9 +282,15 @@ def run
end

results.each_hash do |row|
# special handling for wsrep_evs_repl_latency as this contains forward slash delimited data
fix_and_output_evs_repl_latency_data(row) if row['Variable_name'] == 'wsrep_evs_repl_latency'
metrics.each do |category, var_mapping|
if var_mapping.key?(row['Variable_name'])
output "#{config[:scheme]}.#{mysql_shorthostname}.#{category}.#{var_mapping[row['Variable_name']]}", row['Value']
if row['Variable_name'] == 'wsrep_evs_repl_latency'
fix_and_output_evs_repl_latency_data(row, mysql_shorthostname, category)
else
output "#{config[:scheme]}.#{mysql_shorthostname}.#{category}.#{var_mapping[row['Variable_name']]}", row['Value']
end
end
end
end
Expand Down

0 comments on commit f2f7cfd

Please sign in to comment.