• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang logging.GetLogger函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: prepareHost

	"math"
	"os"
	"time"

	"github.com/Songmu/retry"
	"github.com/mackerelio/mackerel-agent/agent"
	"github.com/mackerelio/mackerel-agent/checks"
	"github.com/mackerelio/mackerel-agent/config"
	"github.com/mackerelio/mackerel-agent/logging"
	"github.com/mackerelio/mackerel-agent/mackerel"
	"github.com/mackerelio/mackerel-agent/metrics"
	"github.com/mackerelio/mackerel-agent/spec"
	"github.com/mackerelio/mackerel-agent/util"
)

var logger = logging.GetLogger("command")
var metricsInterval = 60 * time.Second

var retryNum uint = 20
var retryInterval = 3 * time.Second

// prepareHost collects specs of the host and sends them to Mackerel server.
// A unique host-id is returned by the server if one is not specified.
func prepareHost(conf *config.Config, api *mackerel.API) (*mackerel.Host, error) {
	// XXX this configuration should be moved to under spec/linux
	os.Setenv("PATH", "/sbin:/usr/sbin:/bin:/usr/bin:"+os.Getenv("PATH"))
	os.Setenv("LANG", "C") // prevent changing outputs of some command, e.g. ifconfig.

	doRetry := func(f func() error) {
		retry.Retry(retryNum, retryInterval, f)
	}
开发者ID:y-kuno,项目名称:mackerel-agent,代码行数:31,代码来源:command.go


示例17: Generate

import (
	"fmt"
	"os/exec"
	"strconv"
	"strings"

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

// CPUUsageGenerator XXX
type CPUUsageGenerator struct {
}

var cpuUsageLogger = logging.GetLogger("metrics.cpuUsage")

var iostatFieldToMetricName = []string{"user", "nice", "system", "interrupt", "idle"}

// Generate returns current CPU usage of the host.
// Keys below are expected:
// - cpu.user.percentage
// - cpu.system.percentage
// - cpu.idle.percentage
func (g *CPUUsageGenerator) Generate() (metrics.Values, error) {

	// $ iostat -n0 -c2 -d -C
	//            cpu
	// us ni sy in id
	//  3 21  4  1 71
	//  0  0  4  0 96
开发者ID:lucasgalton,项目名称:sycub-agent,代码行数:30,代码来源:cpuusage.go


示例18: Key

	"unsafe"

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

// MemoryGenerator collects the host's memory specs.
type MemoryGenerator struct {
}

// Key XXX
func (g *MemoryGenerator) Key() string {
	return "memory"
}

var memoryLogger = logging.GetLogger("spec.memory")

// Generate XXX
func (g *MemoryGenerator) Generate() (interface{}, error) {
	result := make(map[string]interface{})

	var memoryStatusEx windows.MEMORY_STATUS_EX
	memoryStatusEx.Length = uint32(unsafe.Sizeof(memoryStatusEx))
	r, _, err := windows.GlobalMemoryStatusEx.Call(uintptr(unsafe.Pointer(&memoryStatusEx)))
	if r == 0 {
		return nil, err
	}

	result["total"] = fmt.Sprintf("%dkb", memoryStatusEx.TotalPhys/1024)
	result["free"] = fmt.Sprintf("%dkb", memoryStatusEx.AvailPhys/1024)
开发者ID:lucasgalton,项目名称:sycub-agent,代码行数:30,代码来源:memory.go


示例19: FetchMetrics

import (
	"crypto/md5"
	"flag"
	"fmt"
	"os"
	"regexp"
	"strconv"
	"strings"
	"time"

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

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

type RedisPlugin struct {
	Host     string
	Port     string
	Socket   string
	Prefix   string
	Timeout  int
	Tempfile string
}

func (m RedisPlugin) FetchMetrics() (map[string]float64, error) {
	network := "tcp"
	target := fmt.Sprintf("%s:%s", m.Host, m.Port)
	if m.Socket != "" {
		target = m.Socket
开发者ID:atsaki,项目名称:mackerel-agent-plugins,代码行数:31,代码来源:redis.go


示例20: init

var dfHeaderPattern = regexp.MustCompile(
	// 1024-blocks or 1k-blocks
	`^Filesystem\s+(?:1024|1[Kk])-block`,
)

// DfColumnSpec XXX
type DfColumnSpec struct {
	Name  string
	IsInt bool // type of collected data  true: int64, false: string
}

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

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

var dfOpt []string

func init() {
	switch runtime.GOOS {
	case "darwin":
		dfOpt = []string{"-Pkl"}
	case "freebsd":
		dfOpt = []string{"-Pkt", "noprocfs,devfs,fdescfs,nfs,cd9660"}
	case "netbsd":
		dfOpt = []string{"-Pkl"}
	default:
		dfOpt = []string{"-P"}
	}
}
开发者ID:y-kuno,项目名称:mackerel-agent,代码行数:31,代码来源:filesystem.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang metrics.Values函数代码示例发布时间:2022-05-23
下一篇:
Golang go-mackerel-plugin-helper.NewMackerelPlugin函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap