Exemple #1
0
func getRedisMetricSet(pass string) (*helper.MetricSet, error) {
	config, _ := getRedisModuleConfig(pass)
	module, mErr := helper.NewModule(config, redis.New)
	if mErr != nil {
		return nil, mErr
	}
	return helper.NewMetricSet("info", New, module)
}
func TestConnect(t *testing.T) {

	config, _ := getApacheModuleConfig()

	module, mErr := helper.NewModule(config, apache.New)
	assert.NoError(t, mErr)
	ms, msErr := helper.NewMetricSet("status", New, module)
	assert.NoError(t, msErr)

	// Setup metricset and metricseter
	err := ms.Setup()
	assert.NoError(t, err)
	err = ms.MetricSeter.Setup(ms)
	assert.NoError(t, err)

	// Check that host is correctly set
	assert.Equal(t, apache.GetApacheEnvHost(), ms.Config.Hosts[0])

	data, err := ms.MetricSeter.Fetch(ms, ms.Config.Hosts[0])
	assert.NoError(t, err)

	// Check fields
	assert.Equal(t, 13, len(data))
}
Exemple #3
0
package apache

import (
	//"github.com/elastic/beats/libbeat/logp"

	"github.com/elastic/beats/metricbeat/helper"

	"os"
)

func init() {
	Module.Register()
}

var Module = helper.NewModule("apache", Apache{})

var Config = &ApacheModuleConfig{}

type ApacheModuleConfig struct {
	Metrics map[string]interface{}
	Hosts   []string
}

type Apache struct {
	Name   string
	Config ApacheModuleConfig
}

func (r Apache) Setup() error {

	// Loads module config
Exemple #4
0
import (
	"github.com/elastic/beats/libbeat/logp"

	"github.com/elastic/beats/metricbeat/helper"

	"github.com/garyburd/redigo/redis"

	"os"
)

func init() {
	Module.Register()
}

var Module = helper.NewModule("redis", Redis{})

var Config = &RedisModuleConfig{}

type RedisModuleConfig struct {
	Metrics map[string]interface{}
	Hosts   []string
}

type Redis struct {
	Name   string
	Config RedisModuleConfig
}

func (r Redis) Setup() error {
	// Loads module config
Exemple #5
0
import (
	"github.com/elastic/beats/metricbeat/helper"

	"database/sql"
	_ "github.com/go-sql-driver/mysql"

	"os"
)

func init() {
	Module.Register()
}

// Module object
var Module = helper.NewModule("mysql", Mysql{})

type Mysql struct {
}

func (b Mysql) Setup() error {
	// TODO: Ping available servers to check if available
	return nil
}

// Connect expects a full mysql dsn
// Example: [username[:password]@][protocol[(address)]]/
func Connect(dsn string) (*sql.DB, error) {
	return sql.Open("mysql", dsn)
}
package module

import (
	"github.com/elastic/beats/metricbeat/helper"
)

func init() {
	Module.Register()
}

var Module = helper.NewModule("nagioscheck", NagiosCheckModule{})

var Config = NagiosCheckModuleConfig{}

type NagiosCheckModuleConfig struct {
	Metrics map[string]interface{}
}

type NagiosCheckModule struct {
	Name   string
	Config NagiosCheckModuleConfig
}

func (e NagiosCheckModule) Setup() {
	Module.LoadConfig(&Config)
}