コード例 #1
0
ファイル: agent.go プロジェクト: ChrisSmith/gorelic
//Run initialize Agent instance and start harvest go routine
func (agent *StandardAgent) Run() error {
	if agent.NewrelicLicense == "" {
		return errors.New("please, pass a valid newrelic license key")
	}

	agent.plugin = newrelic_platform_go.NewNewrelicPlugin(agent.AgentVersion, agent.NewrelicLicense, agent.NewrelicPollInterval)
	component := newrelic_platform_go.NewPluginComponent(agent.NewrelicName, agent.AgentGUID)
	agent.plugin.AddComponent(component)

	addRuntimeMericsToComponent(component)

	if agent.CollectGcStat {
		addGCMericsToComponent(component, agent.GCPollInterval)
		agent.debug(fmt.Sprintf("Init GC metrics collection. Poll interval %d seconds.", agent.GCPollInterval))
	}
	if agent.CollectMemoryStat {
		addMemoryMericsToComponent(component, agent.MemoryAllocatorPollInterval)
		agent.debug(fmt.Sprintf("Init memory allocator metrics collection. Poll interval %d seconds.", agent.MemoryAllocatorPollInterval))
	}

	if agent.CollectHTTPStat {
		agent.initTimer()
		addHTTPMericsToComponent(component, agent.HTTPTimer)
		agent.debug(fmt.Sprintf("Init HTTP metrics collection."))
	}

	agent.plugin.Verbose = agent.Verbose
	go agent.plugin.Run()
	return nil
}
コード例 #2
0
ファイル: agent.go プロジェクト: gistia/slackbot
//Run initialize Agent instance and start harvest go routine
func (agent *Agent) Run() error {
	if agent.NewrelicLicense == "" {
		return errors.New("please, pass a valid newrelic license key")
	}

	agent.plugin = newrelic_platform_go.NewNewrelicPlugin(agent.AgentVersion, agent.NewrelicLicense, agent.NewrelicPollInterval)
	agent.plugin.Client = agent.Client

	var component newrelic_platform_go.IComponent
	component = newrelic_platform_go.NewPluginComponent(agent.NewrelicName, agent.AgentGUID)

	// Add default metrics and tracer.
	addRuntimeMericsToComponent(component)
	agent.Tracer = newTracer(component)

	// Check agent flags and add relevant metrics.
	if agent.CollectGcStat {
		addGCMericsToComponent(component, agent.GCPollInterval)
		agent.debug(fmt.Sprintf("Init GC metrics collection. Poll interval %d seconds.", agent.GCPollInterval))
	}

	if agent.CollectMemoryStat {
		addMemoryMericsToComponent(component, agent.MemoryAllocatorPollInterval)
		agent.debug(fmt.Sprintf("Init memory allocator metrics collection. Poll interval %d seconds.", agent.MemoryAllocatorPollInterval))
	}

	if agent.CollectHTTPStat {
		agent.initTimer()
		addHTTPMericsToComponent(component, agent.HTTPTimer)
		agent.debug(fmt.Sprintf("Init HTTP metrics collection."))
	}

	for _, metric := range agent.CustomMetrics {
		component.AddMetrica(metric)
		agent.debug(fmt.Sprintf("Init %s metric collection.", metric.GetName()))
	}

	if agent.CollectHTTPStatuses {
		agent.initStatusCounters()
		component = &resettableComponent{component, agent.HTTPStatusCounters}
		addHTTPStatusMetricsToComponent(component, agent.HTTPStatusCounters)
		agent.debug(fmt.Sprintf("Init HTTP status metrics collection."))
	}

	// Init newrelic reporting plugin.
	agent.plugin = newrelic_platform_go.NewNewrelicPlugin(agent.AgentVersion, agent.NewrelicLicense, agent.NewrelicPollInterval)
	agent.plugin.Verbose = agent.Verbose

	// Add our metrics component to the plugin.
	agent.plugin.AddComponent(component)

	// Start reporting!
	go agent.plugin.Run()
	return nil
}
コード例 #3
0
ファイル: component.go プロジェクト: maciejmrowiec/pgmonitor
func InitTupleSummaryComponent(db *sql.DB, hostname string, verbose bool) platform.IComponent {

	component := platform.NewPluginComponent(hostname, "com.github.maciejmrowiec.pgmonitor", verbose)

	component.AddMetrica(NewTableAverageSummaryMetric(db, "tuple/summary/percent/active", TupleActivePercent, "%"))
	component.AddMetrica(NewTableAverageSummaryMetric(db, "tuple/summary/percent/dead", TupleDeadPercent, "%"))
	component.AddMetrica(NewTableAverageSummaryMetric(db, "tuple/summary/percent/free", TupleFreePercent, "%"))

	return component

}
コード例 #4
0
func InitSingleSamplesComponent(hostname string, verbose bool) platform.IComponent {

	component := platform.NewPluginComponent(hostname, "com.github.maciejmrowiec.cfclientmonitor", verbose)

	component.AddMetrica(NewCommandMetric("disksize/cfengine", MakeSizeCommand("/var/cfengine"), "B", SizeCommandToFloat))

	component.AddMetrica(NewCommandMetric("cpu/loadaverage/1m", "cat /proc/loadavg | awk '{print$1}'", "", BytesToFloat))
	component.AddMetrica(NewCommandMetric("cpu/loadaverage/5m", "cat /proc/loadavg | awk '{print$2}'", "", BytesToFloat))
	component.AddMetrica(NewCommandMetric("cpu/loadaverage/15m", "cat /proc/loadavg | awk '{print$3}'", "", BytesToFloat))

	component.AddMetrica(NewCommandMetric("cpu/tasks/active", "cat /proc/loadavg | awk '{print$4}' | awk -F '/' '{print $1}'", "units", BytesToFloat))
	component.AddMetrica(NewCommandMetric("cpu/tasks/total", "cat /proc/loadavg | awk '{print$4}' | awk -F '/' '{print $2}'", "units", BytesToFloat))

	return component

}
コード例 #5
0
func main() {
	plugin := newrelic_platform_go.NewNewrelicPlugin("0.0.1", "7bceac019c7dcafae1ef95be3e3a3ff8866de246", 60)
	component := newrelic_platform_go.NewPluginComponent("Wave component", "com.exmaple.plugin.gowave")
	plugin.AddComponent(component)

	m := &WaveMetrica{
		sawtoothMax:     10,
		sawtoothCounter: 5,
	}
	component.AddMetrica(m)

	m1 := &SquareWaveMetrica{
		squarewaveMax:     4,
		squarewaveCounter: 1,
	}
	component.AddMetrica(m1)

	plugin.Verbose = true
	plugin.Run()
}
コード例 #6
0
ファイル: stats.go プロジェクト: hfeeki/signaling_go
// TODO: drop appname
func InitNewrelicAgent(license string, appname string, verbose bool, obs Observable) error {

	if license == "" {
		return fmt.Errorf("Please specify NewRelic license")
	}

	plugin := newrelic_platform_go.NewNewrelicPlugin(CurrentAgentVersion, license, PollInterval)
	component := newrelic_platform_go.NewPluginComponent(DefaultAgentName, DefaultAgentGuid)
	plugin.AddComponent(component)

	m := &MembersMetrica{obs}

	component.AddMetrica(m)

	f := &FailuresMetrica{obs}

	component.AddMetrica(f)

	plugin.Verbose = verbose
	go plugin.Run()
	return nil
}
コード例 #7
0
ファイル: agent.go プロジェクト: rounds/newrelic_tigertonic
// Run initialize Agent instance and start harvest go routine
func (agent *Agent) Run() error {

	if agent.NewrelicLicense == "" {
		return errors.New("Cannot start NewRelic agent, pass a valid license key")
	}

	agent.plugin = newrelic_platform_go.NewNewrelicPlugin(agent.AgentVersion, agent.NewrelicLicense, agent.NewrelicPollInterval)
	component := newrelic_platform_go.NewPluginComponent(agent.NewrelicName, agent.AgentGUID)
	agent.plugin.AddComponent(component)
	registry := metrics.DefaultRegistry
	registry.Each(func(name string, i interface{}) {
		switch metric := i.(type) {
		case metrics.Timer:
			addTimerMericsToComponent(component, metric, name)
		case metrics.Counter:
			addCounterMericsToComponent(component, metric, name)
		}
	})

	agent.plugin.Verbose = agent.Verbose
	go agent.plugin.Run()
	return nil
}