ran go fmt to fix formatting
This commit is contained in:
parent
376edf2db0
commit
964bb23924
|
@ -23,7 +23,7 @@ type Mysql struct {
|
||||||
PerfEventsStatementsTimeLimit int64 `toml:"perf_events_statemetns_time_limit"`
|
PerfEventsStatementsTimeLimit int64 `toml:"perf_events_statemetns_time_limit"`
|
||||||
TableSchemaDatabases []string `toml:"table_schema_databases"`
|
TableSchemaDatabases []string `toml:"table_schema_databases"`
|
||||||
GatherProcessList bool `toml:"gather_process_list"`
|
GatherProcessList bool `toml:"gather_process_list"`
|
||||||
GatherUserStatistics bool `toml:"gather_user_statistics"`
|
GatherUserStatistics bool `toml:"gather_user_statistics"`
|
||||||
GatherInfoSchemaAutoInc bool `toml:"gather_info_schema_auto_inc"`
|
GatherInfoSchemaAutoInc bool `toml:"gather_info_schema_auto_inc"`
|
||||||
GatherSlaveStatus bool `toml:"gather_slave_status"`
|
GatherSlaveStatus bool `toml:"gather_slave_status"`
|
||||||
GatherBinaryLogs bool `toml:"gather_binary_logs"`
|
GatherBinaryLogs bool `toml:"gather_binary_logs"`
|
||||||
|
@ -436,7 +436,7 @@ const (
|
||||||
WHERE ID != connection_id()
|
WHERE ID != connection_id()
|
||||||
GROUP BY command,state
|
GROUP BY command,state
|
||||||
ORDER BY null`
|
ORDER BY null`
|
||||||
infoSchemaUserStatisticsQuery = `
|
infoSchemaUserStatisticsQuery = `
|
||||||
SELECT *,count(*)
|
SELECT *,count(*)
|
||||||
FROM information_schema.user_statistics
|
FROM information_schema.user_statistics
|
||||||
GROUP BY user`
|
GROUP BY user`
|
||||||
|
@ -606,7 +606,7 @@ func (m *Mysql) gatherServer(serv string, acc telegraf.Accumulator) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.GatherUserStatistics {
|
if m.GatherUserStatistics {
|
||||||
err = m.GatherUserStatisticsStatuses(db, serv, acc)
|
err = m.GatherUserStatisticsStatuses(db, serv, acc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -901,7 +901,8 @@ func (m *Mysql) gatherGlobalStatuses(db *sql.DB, serv string, acc telegraf.Accum
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fields["uptime"] = i}
|
fields["uptime"] = i
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Send any remaining fields
|
// Send any remaining fields
|
||||||
if len(fields) > 0 {
|
if len(fields) > 0 {
|
||||||
|
@ -932,9 +933,9 @@ func (m *Mysql) gatherGlobalStatuses(db *sql.DB, serv string, acc telegraf.Accum
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// gather connection metrics from user_statistics for each user
|
// gather connection metrics from user_statistics for each user
|
||||||
if m.GatherUserStatistics {
|
if m.GatherUserStatistics {
|
||||||
conn_rows, err := db.Query("select user, total_connections, concurrent_connections, connected_time, busy_time, cpu_time, bytes_received, bytes_sent, binlog_bytes_written, rows_fetched, rows_updated, table_rows_read, select_commands, update_commands, other_commands, commit_transactions, rollback_transactions, denied_connections, lost_connections, access_denied, empty_queries, total_ssl_connections FROM INFORMATION_SCHEMA.USER_STATISTICS GROUP BY user")
|
conn_rows, err := db.Query("select user, total_connections, concurrent_connections, connected_time, busy_time, cpu_time, bytes_received, bytes_sent, binlog_bytes_written, rows_fetched, rows_updated, table_rows_read, select_commands, update_commands, other_commands, commit_transactions, rollback_transactions, denied_connections, lost_connections, access_denied, empty_queries, total_ssl_connections FROM INFORMATION_SCHEMA.USER_STATISTICS GROUP BY user")
|
||||||
|
|
||||||
|
@ -962,13 +963,12 @@ func (m *Mysql) gatherGlobalStatuses(db *sql.DB, serv string, acc telegraf.Accum
|
||||||
var empty_queries int64
|
var empty_queries int64
|
||||||
var total_ssl_connections int64
|
var total_ssl_connections int64
|
||||||
|
|
||||||
|
|
||||||
err = conn_rows.Scan(&user, &total_connections, &concurrent_connections,
|
err = conn_rows.Scan(&user, &total_connections, &concurrent_connections,
|
||||||
&connected_time, &busy_time, &cpu_time, &bytes_received, &bytes_sent, &binlog_bytes_written,
|
&connected_time, &busy_time, &cpu_time, &bytes_received, &bytes_sent, &binlog_bytes_written,
|
||||||
&rows_fetched, &rows_updated, &table_rows_read, &select_commands, &update_commands, &other_commands,
|
&rows_fetched, &rows_updated, &table_rows_read, &select_commands, &update_commands, &other_commands,
|
||||||
&commit_transactions, &rollback_transactions, &denied_connections, &lost_connections, &access_denied,
|
&commit_transactions, &rollback_transactions, &denied_connections, &lost_connections, &access_denied,
|
||||||
&empty_queries, &total_ssl_connections,
|
&empty_queries, &total_ssl_connections,
|
||||||
)
|
)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -1067,29 +1067,29 @@ func (m *Mysql) GatherUserStatisticsStatuses(db *sql.DB, serv string, acc telegr
|
||||||
}
|
}
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
var (
|
var (
|
||||||
user string
|
user string
|
||||||
total_connections int64
|
total_connections int64
|
||||||
concurrent_connections int64
|
concurrent_connections int64
|
||||||
connected_time int64
|
connected_time int64
|
||||||
busy_time int64
|
busy_time int64
|
||||||
cpu_time int64
|
cpu_time int64
|
||||||
bytes_received int64
|
bytes_received int64
|
||||||
bytes_sent int64
|
bytes_sent int64
|
||||||
binlog_bytes_written int64
|
binlog_bytes_written int64
|
||||||
rows_fetched int64
|
rows_fetched int64
|
||||||
rows_updated int64
|
rows_updated int64
|
||||||
table_rows_read int64
|
table_rows_read int64
|
||||||
select_commands int64
|
select_commands int64
|
||||||
update_commands int64
|
update_commands int64
|
||||||
other_commands int64
|
other_commands int64
|
||||||
commit_transactions int64
|
commit_transactions int64
|
||||||
rollback_transactions int64
|
rollback_transactions int64
|
||||||
denied_connections int64
|
denied_connections int64
|
||||||
lost_connections int64
|
lost_connections int64
|
||||||
access_denied int64
|
access_denied int64
|
||||||
empty_queries int64
|
empty_queries int64
|
||||||
total_ssl_connections int64
|
total_ssl_connections int64
|
||||||
count uint32
|
count uint32
|
||||||
)
|
)
|
||||||
|
|
||||||
var servtag string
|
var servtag string
|
||||||
|
@ -1100,46 +1100,45 @@ func (m *Mysql) GatherUserStatisticsStatuses(db *sql.DB, serv string, acc telegr
|
||||||
|
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
err = rows.Scan(&user, &total_connections, &concurrent_connections,
|
err = rows.Scan(&user, &total_connections, &concurrent_connections,
|
||||||
&connected_time, &busy_time, &cpu_time, &bytes_received, &bytes_sent, &binlog_bytes_written,
|
&connected_time, &busy_time, &cpu_time, &bytes_received, &bytes_sent, &binlog_bytes_written,
|
||||||
&rows_fetched, &rows_updated, &table_rows_read, &select_commands, &update_commands, &other_commands,
|
&rows_fetched, &rows_updated, &table_rows_read, &select_commands, &update_commands, &other_commands,
|
||||||
&commit_transactions, &rollback_transactions, &denied_connections, &lost_connections, &access_denied,
|
&commit_transactions, &rollback_transactions, &denied_connections, &lost_connections, &access_denied,
|
||||||
&empty_queries, &total_ssl_connections, &count,
|
&empty_queries, &total_ssl_connections, &count,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
tags := map[string]string{"server": servtag, "user": user}
|
tags := map[string]string{"server": servtag, "user": user}
|
||||||
fields := map[string]interface{} {
|
fields := map[string]interface{}{
|
||||||
|
|
||||||
"total_connections": total_connections,
|
"total_connections": total_connections,
|
||||||
"concurrent_connections": concurrent_connections,
|
"concurrent_connections": concurrent_connections,
|
||||||
"connected_time": connected_time,
|
"connected_time": connected_time,
|
||||||
"busy_time": busy_time,
|
"busy_time": busy_time,
|
||||||
"cpu_time": cpu_time,
|
"cpu_time": cpu_time,
|
||||||
"bytes_received": bytes_received,
|
"bytes_received": bytes_received,
|
||||||
"bytes_sent": bytes_sent,
|
"bytes_sent": bytes_sent,
|
||||||
"binlog_bytes_written": binlog_bytes_written,
|
"binlog_bytes_written": binlog_bytes_written,
|
||||||
"rows_fetched": rows_fetched,
|
"rows_fetched": rows_fetched,
|
||||||
"rows_updated": rows_updated,
|
"rows_updated": rows_updated,
|
||||||
"table_rows_read": table_rows_read,
|
"table_rows_read": table_rows_read,
|
||||||
"select_commands": select_commands,
|
"select_commands": select_commands,
|
||||||
"update_commands": update_commands,
|
"update_commands": update_commands,
|
||||||
"other_commands": other_commands,
|
"other_commands": other_commands,
|
||||||
"commit_transactions": commit_transactions,
|
"commit_transactions": commit_transactions,
|
||||||
"rollback_transactions": rollback_transactions,
|
"rollback_transactions": rollback_transactions,
|
||||||
"denied_connections": denied_connections,
|
"denied_connections": denied_connections,
|
||||||
"lost_connections": lost_connections,
|
"lost_connections": lost_connections,
|
||||||
"access_denied": access_denied,
|
"access_denied": access_denied,
|
||||||
"empty_queries": empty_queries,
|
"empty_queries": empty_queries,
|
||||||
"total_ssl_connections": total_ssl_connections,
|
"total_ssl_connections": total_ssl_connections,
|
||||||
}
|
}
|
||||||
acc.AddFields("mysql_user_stats", fields, tags)
|
acc.AddFields("mysql_user_stats", fields, tags)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// gatherPerfTableIOWaits can be used to get total count and time
|
// gatherPerfTableIOWaits can be used to get total count and time
|
||||||
// of I/O wait event for each table and process
|
// of I/O wait event for each table and process
|
||||||
func (m *Mysql) gatherPerfTableIOWaits(db *sql.DB, serv string, acc telegraf.Accumulator) error {
|
func (m *Mysql) gatherPerfTableIOWaits(db *sql.DB, serv string, acc telegraf.Accumulator) error {
|
||||||
|
|
Loading…
Reference in New Issue