当前位置: 首页>>代码示例>>Golang>>正文


Golang logging.GetLogger函数代码示例

本文整理汇总了Golang中github.com/mackerelio/mackerel-agent/logging.GetLogger函数的典型用法代码示例。如果您正苦于以下问题:Golang GetLogger函数的具体用法?Golang GetLogger怎么用?Golang GetLogger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GetLogger函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: CollectFilesystemValues

	"github.com/mackerelio/mackerel-agent/logging"
)

// FilesystemInfo XXX
type FilesystemInfo struct {
	PercentUsed string
	KbUsed      float64
	KbSize      float64
	KbAvailable float64
	Mount       string
	Label       string
	VolumeName  string
	FsType      string
}

var windowsLogger = logging.GetLogger("windows")

// CollectFilesystemValues XXX
func CollectFilesystemValues() (map[string]FilesystemInfo, error) {
	filesystems := make(map[string]FilesystemInfo)

	drivebuf := make([]byte, 256)

	r, _, err := GetLogicalDriveStrings.Call(
		uintptr(len(drivebuf)),
		uintptr(unsafe.Pointer(&drivebuf[0])))
	if r == 0 {
		return nil, err
	}

	drives := []string{}
开发者ID:y-kuno,项目名称:mackerel-agent,代码行数:31,代码来源:filesystem.go

示例2:

package mpunicorn

import (
	"flag"
	"fmt"
	"io/ioutil"

	"os"

	"strings"

	mp "github.com/mackerelio/go-mackerel-plugin-helper"
	"github.com/mackerelio/mackerel-agent/logging"
)

var logger = logging.GetLogger("metrics.plugin.unicorn")

var graphdef = map[string]mp.Graphs{
	"unicorn.memory": {
		Label: "Unicorn Memory",
		Unit:  "bytes",
		Metrics: []mp.Metrics{
			{Name: "memory_workers", Label: "Workers", Diff: false, Stacked: true},
			{Name: "memory_master", Label: "Master", Diff: false, Stacked: true},
			{Name: "memory_workeravg", Label: "Worker Average", Diff: false, Stacked: false},
		},
	},
	"unicorn.workers": {
		Label: "Unicorn Workers",
		Unit:  "integer",
		Metrics: []mp.Metrics{
开发者ID:supercaracal,项目名称:mackerel-agent-plugins,代码行数:31,代码来源:unicorn.go

示例3: NewFilesystemGenerator

	"github.com/mackerelio/mackerel-agent/logging"
	"github.com/mackerelio/mackerel-agent/metrics"
	"github.com/mackerelio/mackerel-agent/util/windows"
)

// FilesystemGenerator XXX
type FilesystemGenerator struct {
}

// NewFilesystemGenerator XXX
func NewFilesystemGenerator() (*FilesystemGenerator, error) {
	return &FilesystemGenerator{}, nil
}

var logger = logging.GetLogger("metrics.filesystem")

// Generate XXX
func (g *FilesystemGenerator) Generate() (metrics.Values, error) {
	filesystems, err := windows.CollectFilesystemValues()
	if err != nil {
		return nil, err
	}

	ret := make(map[string]float64)
	for name, values := range filesystems {
		if matches := regexp.MustCompile(`^(.*):`).FindStringSubmatch(name); matches != nil {
			device := regexp.MustCompile(`[^A-Za-z0-9_-]`).ReplaceAllString(matches[1], "_")

			ret["filesystem."+device+".size"] = values.KbSize * 1024
			ret["filesystem."+device+".used"] = values.KbUsed * 1024
开发者ID:y-kuno,项目名称:mackerel-agent,代码行数:30,代码来源:filesystem.go

示例4: generateValues

package agent

import (
	"sync"

	"github.com/mackerelio/mackerel-agent/logging"
	"github.com/mackerelio/mackerel-agent/metrics"
)

var logger = logging.GetLogger("agent")

func generateValues(generators []metrics.Generator) chan metrics.Values {
	processed := make(chan metrics.Values)
	finish := make(chan bool)
	result := make(chan metrics.Values)

	go func() {
		allValues := metrics.Values(make(map[string]float64))
		for {
			select {
			case values := <-processed:
				allValues.Merge(values)
			case <-finish:
				result <- allValues
				return
			}
		}
	}()

	go func() {
		var wg sync.WaitGroup
开发者ID:lucasgalton,项目名称:sycub-agent,代码行数:31,代码来源:generator.go

示例5:

package main

import (
	"encoding/json"
	"errors"
	"flag"
	"fmt"
	"net/http"
	"os"

	mp "github.com/mackerelio/go-mackerel-plugin"
	"github.com/mackerelio/mackerel-agent/logging"
)

var logger = logging.GetLogger("metrics.plugin.elasticsearch")

var graphdef = map[string](mp.Graphs){
	"elasticsearch.http": mp.Graphs{
		Label: "Elasticsearch HTTP",
		Unit:  "integer",
		Metrics: [](mp.Metrics){
			mp.Metrics{Name: "http_opened", Label: "Opened", Diff: true},
		},
	},
	"elasticsearch.indices": mp.Graphs{
		Label: "Elasticsearch Indices",
		Unit:  "integer",
		Metrics: [](mp.Metrics){
			mp.Metrics{Name: "total_indexing_index", Label: "Indexing-Index", Diff: true, Stacked: true},
			mp.Metrics{Name: "total_indexing_delete", Label: "Indexing-Delete", Diff: true, Stacked: true},
			mp.Metrics{Name: "total_get", Label: "Get", Diff: true, Stacked: true},
开发者ID:tnmt,项目名称:mackerel-agent-plugins,代码行数:31,代码来源:elasticsearch.go

示例6: Key

// KernelGenerator Generates specs about the kernel.
// Keys below are expected.
// - name:    the operating system name ("Linux")
// - release: the operating system release ("2.6.32-5-686")
// - version: the operating system version ("#1 SMP Sun Sep 23 09:49:36 UTC 2012")
// - machine: the machine hardware name ("i686")
// - os:      the operating system name ("GNU/Linux")
type KernelGenerator struct {
}

// Key XXX
func (g *KernelGenerator) Key() string {
	return "kernel"
}

var kernelLogger = logging.GetLogger("spec.kernel")

// Generate XXX
func (g *KernelGenerator) Generate() (interface{}, error) {
	unameArgs := map[string][]string{
		"release": []string{"-r"},
		"version": []string{"-v"},
		"machine": []string{"-m"},
		"os":      []string{"-s"},
	}

	results := make(map[string]string, len(unameArgs)+1)

	for field, args := range unameArgs {
		out, err := exec.Command("/usr/bin/uname", args...).Output()
		if err != nil {
开发者ID:lucasgalton,项目名称:sycub-agent,代码行数:31,代码来源:kernel.go

示例7: Generate

	"github.com/mackerelio/mackerel-agent/metrics"
)

/*
collect load average

`loadavg5`: load average per 5 minutes retrieved from /proc/loadavg

graph: `loadavg5`
*/

// Loadavg5Generator XXX
type Loadavg5Generator struct {
}

var loadavg5Logger = logging.GetLogger("metrics.loadavg5")

// Generate XXX
func (g *Loadavg5Generator) Generate() (metrics.Values, error) {
	contentbytes, err := ioutil.ReadFile("/proc/loadavg")
	if err != nil {
		loadavg5Logger.Errorf("Failed (skip these metrics): %s", err)
		return nil, err
	}
	content := string(contentbytes)
	cols := strings.Split(content, " ")

	f, err := strconv.ParseFloat(cols[1], 64)
	if err != nil {
		loadavg5Logger.Errorf("Failed to parse loadavg5 metrics (skip these metrics): %s", err)
		return nil, err
开发者ID:y-kuno,项目名称:mackerel-agent,代码行数:31,代码来源:loadavg5.go

示例8: FetchMetrics

package main

import (
	"flag"
	"fmt"
	"os"
	"regexp"

	mp "github.com/mackerelio/go-mackerel-plugin-helper"
	"github.com/mackerelio/mackerel-agent/logging"
)

var logger = logging.GetLogger("metrics.plugin.proc-fd")

// ProcfdPlugin for fetching metrics
type ProcfdPlugin struct {
	Process           string
	NormalizedProcess string
	MetricName        string
}

// FetchMetrics fetch the metrics
func (p ProcfdPlugin) FetchMetrics() (map[string]interface{}, error) {
	fds, err := openFd.getNumOpenFileDesc()
	if err != nil {
		return nil, err
	}

	stat := make(map[string]interface{})

	// Compute maximum open file descriptor
开发者ID:netmarkjp,项目名称:mackerel-agent-plugins,代码行数:31,代码来源:proc_fd.go

示例9:

package mppostgres

import (
	"flag"
	"fmt"
	"os"

	"github.com/jmoiron/sqlx"
	// PostgreSQL Driver
	_ "github.com/lib/pq"
	mp "github.com/mackerelio/go-mackerel-plugin-helper"
	"github.com/mackerelio/mackerel-agent/logging"
)

var logger = logging.GetLogger("metrics.plugin.postgres")

var graphdef = map[string]mp.Graphs{
	"postgres.connections": {
		Label: "Postgres Connections",
		Unit:  "integer",
		Metrics: []mp.Metrics{
			{Name: "active", Label: "Active", Diff: false, Stacked: true},
			{Name: "waiting", Label: "Waiting", Diff: false, Stacked: true},
		},
	},
	"postgres.commits": {
		Label: "Postgres Commits",
		Unit:  "integer",
		Metrics: []mp.Metrics{
			{Name: "xact_commit", Label: "Xact Commit", Diff: true, Stacked: false},
			{Name: "xact_rollback", Label: "Xact Rollback", Diff: true, Stacked: false},
开发者ID:supercaracal,项目名称:mackerel-agent-plugins,代码行数:31,代码来源:postgres.go

示例10:

package mpjmxjolokia

import (
	"encoding/json"
	"flag"
	"fmt"
	"net/http"

	mp "github.com/mackerelio/go-mackerel-plugin-helper"
	"github.com/mackerelio/mackerel-agent/logging"
)

var logger = logging.GetLogger("metrics.plugin.jmx-jolokia")

// JmxJolokiaPlugin mackerel plugin for Jolokia
type JmxJolokiaPlugin struct {
	Target   string
	Tempfile string
}

// JmxJolokiaResponse response for Jolokia
type JmxJolokiaResponse struct {
	Status    uint32
	Timestamp uint32
	Request   map[string]interface{}
	Value     map[string]interface{}
	Error     string
}

var graphdef = map[string]mp.Graphs{
	"jmx.jolokia.memory.heap_memory_usage": {
开发者ID:supercaracal,项目名称:mackerel-agent-plugins,代码行数:31,代码来源:jmx-jolokia.go

示例11:

package main

import (
	"os"
	"os/exec"
	"regexp"
	"runtime"
	"strconv"
	"strings"

	mp "github.com/mackerelio/go-mackerel-plugin-helper"
	"github.com/mackerelio/mackerel-agent/logging"
)

var logger = logging.GetLogger("metrics.plugin.inode")

// InodePlugin plugin
type InodePlugin struct{}

var dfHeaderPattern = regexp.MustCompile(
	`^Filesystem\s+`,
)

var dfColumnsPattern = regexp.MustCompile(
	`^(.+?)\s+(?:(?:\d+)\s+(?:\d+)\s+(?:\d+)\s+(?:\d+%)\s+|(?:\d+)\s+)?(\d+)\s+(\d+)\s+(\d+%)\s+(.+)$`,
)

var devicePattern = regexp.MustCompile(
	`^/dev/(.*)$`,
)
开发者ID:y-kuno,项目名称:mackerel-agent-plugins,代码行数:30,代码来源:inode.go

示例12: Key

// CloudGenerator definition
type CloudGenerator struct {
	CloudMetaGenerator
}

// CloudMetaGenerator interface of metadata generator for each cloud platform
type CloudMetaGenerator interface {
	Generate() (interface{}, error)
}

// Key is a root key for the generator.
func (g *CloudGenerator) Key() string {
	return "cloud"
}

var cloudLogger = logging.GetLogger("spec.cloud")

var ec2BaseURL, gceMetaURL, digitalOceanBaseURL *url.URL

func init() {
	ec2BaseURL, _ = url.Parse("http://169.254.169.254/latest/meta-data")
	gceMetaURL, _ = url.Parse("http://metadata.google.internal/computeMetadata/v1/?recursive=true")
	digitalOceanBaseURL, _ = url.Parse("http://169.254.169.254/metadata/v1") // has not been yet used
}

var timeout = 100 * time.Millisecond

// SuggestCloudGenerator returns suitable CloudGenerator
func SuggestCloudGenerator() *CloudGenerator {
	if isEC2() {
		return &CloudGenerator{&EC2Generator{ec2BaseURL}}
开发者ID:naoto43,项目名称:mackerel-agent,代码行数:31,代码来源:cloud.go

示例13:

package checks

import (
	"fmt"
	"time"

	"github.com/mackerelio/mackerel-agent/config"
	"github.com/mackerelio/mackerel-agent/logging"
	"github.com/mackerelio/mackerel-agent/util"
)

var logger = logging.GetLogger("checks")

// Status is a status that is produced by periodical checking.
// It is currently compatible with Nagios.
type Status string

// Current possible statuses, which is taken from command's exit code.
// the mapping is given as exitCodeToStatus.
const (
	StatusUndefined Status = ""
	StatusOK        Status = "OK"
	StatusWarning   Status = "WARNING"
	StatusCritical  Status = "CRITICAL"
	StatusUnknown   Status = "UNKNOWN"
)

var exitCodeToStatus = map[int]Status{
	0: StatusOK,
	1: StatusWarning,
	2: StatusCritical,
开发者ID:naoto43,项目名称:mackerel-agent,代码行数:31,代码来源:checker.go

示例14: NewDiskGenerator

	"time"
	"unsafe"

	"github.com/mackerelio/mackerel-agent/logging"
	"github.com/mackerelio/mackerel-agent/metrics"
	"github.com/mackerelio/mackerel-agent/util/windows"
)

// DiskGenerator XXX
type DiskGenerator struct {
	Interval time.Duration
	query    syscall.Handle
	counters []*windows.CounterInfo
}

var diskLogger = logging.GetLogger("metrics.disk")

// NewDiskGenerator XXX
func NewDiskGenerator(interval time.Duration) (*DiskGenerator, error) {
	g := &DiskGenerator{interval, 0, nil}

	var err error
	g.query, err = windows.CreateQuery()
	if err != nil {
		diskLogger.Criticalf(err.Error())
		return nil, err
	}

	drivebuf := make([]byte, 256)
	r, _, err := windows.GetLogicalDriveStrings.Call(
		uintptr(len(drivebuf)),
开发者ID:lucasgalton,项目名称:sycub-agent,代码行数:31,代码来源:disk.go

示例15: getApibase

package config

import (
	"fmt"
	"io/ioutil"
	"os"
	"path/filepath"
	"regexp"
	"strings"
	"time"

	"github.com/BurntSushi/toml"
	"github.com/mackerelio/mackerel-agent/logging"
)

var configLogger = logging.GetLogger("config")

// `apibase` and `agentName` are set from build flags
var apibase string

func getApibase() string {
	if apibase != "" {
		return apibase
	}
	return "https://mackerel.io"
}

var agentName string

func getAgentName() string {
	if agentName != "" {
开发者ID:y-kuno,项目名称:mackerel-agent,代码行数:31,代码来源:config.go


注:本文中的github.com/mackerelio/mackerel-agent/logging.GetLogger函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。