Example #1
0
// Fetch fetches status messages from a mysql host.
func (m *MetricSet) Fetch() (event common.MapStr, err error) {
	if m.db == nil {
		var err error
		m.db, err = mysql.NewDB(m.dsn)
		if err != nil {
			return nil, errors.Wrap(err, "mysql-status fetch failed")
		}
	}

	status, err := m.loadStatus(m.db)
	if err != nil {
		return nil, err
	}

	return eventMapping(status), nil
}
Example #2
0
// Fetch fetches status messages from a mysql host.
func (m *MetricSet) Fetch() (common.MapStr, error) {
	if m.db == nil {
		var err error
		m.db, err = mysql.NewDB(m.HostData().URI)
		if err != nil {
			return nil, errors.Wrap(err, "mysql-status fetch failed")
		}
	}

	status, err := m.loadStatus(m.db)
	if err != nil {
		return nil, err
	}

	event := eventMapping(status)

	if m.Module().Config().Raw {
		event["raw"] = rawEventMapping(status)
	}
	return event, nil
}