g

package
Version: v0.0.0-...-4fdcf46 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 29, 2021 License: Apache-2.0, Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VERSION          = "6.1.0"
	COLLECT_INTERVAL = time.Second
	URL_CHECK_HEALTH = "url.check.health"
	NET_PORT_LISTEN  = "net.port.listen"
	DU_BS            = "du.bs"
	PROC_NUM         = "proc.num"
	UPTIME           = "sys.uptime"
)

changelog: 3.1.3: code refactor 3.1.4: bugfix ignore configuration 5.0.0: 支持通过配置控制是否开启/run接口;收集udp流量数据;du某个目录的大小 5.1.0: 同步插件的时候不再使用checksum机制 5.1.1: 修复往多个transfer发送数据的时候crash的问题 5.1.2: ignore mount point when blocks=0 6.0.0: agent自升级,新增一些监控项 6.0.1: agent collect level 6.0.2: 添加单核监控开关默认不打开,单核监控tag变更为core=core0x ,添加mem.available.percent 6.0.3: 增加sys.uptime 6.0.4: 修复cpu.iowait>100的bug 6.0.5: 添加进程采集监控,间隔30s 6.0.6: 调整内置的采集func间隔 disk io相关和tcp 10s-->30s,agent_version 整数代表当前版本,去掉动态监控方法 6.0.7: ntp 支持chronyc ,服务监控rpc call 间隔调整为一分钟 6.0.8: 修改监控项抓取时间间隔, 10s只保留cpu,解决断点问题 6.0.9: 修复dfa dfb块设备采集,修复不同版本ss-s的bug 6.1.0: 修复机器上主机名被改case,使ip转化为nxx-xx-xx的形式

Variables

View Source
var (
	ConfigFile string

	ServiceChangeSigns = make(map[string]chan int)
)
View Source
var (
	TransferClientsLock *sync.RWMutex                   = new(sync.RWMutex)
	TransferClients     map[string]*SingleConnRpcClient = map[string]*SingleConnRpcClient{}
)

定义transfer的rpcClient对应Map, transferClients读写锁

View Source
var (
	Root           string
	LocalIp        string
	UpgradeChannel chan *model.AgentUpgradeArgs
	HbsClient      *SingleConnRpcClient

	InUpgrading bool
)

Functions

func AgentSelfUpgrade

func AgentSelfUpgrade()

func BackUpFile

func BackUpFile(old string) (err error)

func CheckFileExist

func CheckFileExist(filename string) bool

func CheckMd5

func CheckMd5(fp, argMd5 string) (same bool)

func CheckPathAndMkdir

func CheckPathAndMkdir(path string) error

func CopyFile

func CopyFile(dstName, srcName string)

func DuPaths

func DuPaths() []string

func ExeShellCommand

func ExeShellCommand(cmdStr string) (string, error)

func ExeSysCommand

func ExeSysCommand(cmdStr string) string

func GetCurrPluginVersion

func GetCurrPluginVersion() string

func GetDynamicMonitoringConfig

func GetDynamicMonitoringConfig() map[string]int

func Hostname

func Hostname() (string, error)

func IP

func IP() string

func InitLocalIp

func InitLocalIp()

func InitLog

func InitLog(level string) (err error)

func InitRootDir

func InitRootDir()

func InitRpcClients

func InitRpcClients()

func InitUpgradeChannel

func InitUpgradeChannel()

func IntArrayToStringArr

func IntArrayToStringArr(intArr []int) []string

func IntSliceEqualBCE

func IntSliceEqualBCE(a, b []int) bool

common funcs

func IsTrustable

func IsTrustable(remoteAddr string) bool

func ParseConfig

func ParseConfig(cfg string)

func ReportPorts

func ReportPorts() []int64

func ReportProcs

func ReportProcs() map[string]map[int]string

func ReportUrls

func ReportUrls() map[string]string

func SendMetrics

func SendMetrics(metrics []*model.MetricValue, resp *model.TransferResponse)

发送数据到随机的transfer

func SendToTransfer

func SendToTransfer(metrics []*model.MetricValue)

func SetDuPaths

func SetDuPaths(paths []string)

func SetDynamicMonitoringConfig

func SetDynamicMonitoringConfig(cfg map[string]int)

func SetReportPorts

func SetReportPorts(ports []int64)

func SetReportProcs

func SetReportProcs(procs map[string]map[int]string)

func SetReportUrls

func SetReportUrls(urls map[string]string)

func SetTrustableIps

func SetTrustableIps(ipStr string)

func ShellCmdTimeout

func ShellCmdTimeout(timeout int, cmd string, args ...string) (stdout, stderr string, e error)

运行Shell命令,设定超时时间(秒)

func StrSliceEqualBCE

func StrSliceEqualBCE(a, b []string) bool

func TrustableIps

func TrustableIps() []string

Types

type CollectorConfig

type CollectorConfig struct {
	IfacePrefix []string `json:"ifacePrefix"`
	MountPoint  []string `json:"mountPoint"`
}

type GlobalConfig

type GlobalConfig struct {
	Debug                     bool                       `json:"debug"`
	Hostname                  string                     `json:"hostname"`
	IP                        string                     `json:"ip"`
	Plugin                    *PluginConfig              `json:"plugin"`
	Heartbeat                 *HeartbeatConfig           `json:"heartbeat"`
	Transfer                  *TransferConfig            `json:"transfer"`
	Http                      *HttpConfig                `json:"http"`
	Collector                 *CollectorConfig           `json:"collector"`
	DefaultTags               map[string]string          `json:"default_tags"`
	IgnoreMetrics             map[string]bool            `json:"ignore"`
	MetricLevelIntervalConfig *MetricLevelIntervalConfig `json:"metric_level_interval"`
	AppBaseDir                string                     `json:"app_base_dir"`
	SelfUpgrade               bool                       `json:"self_upgrade"`
	CpuPerCoreCollect         bool                       `json:"cpu_per_core_collect"`
}

func Config

func Config() *GlobalConfig

type HeartbeatConfig

type HeartbeatConfig struct {
	Enabled  bool   `json:"enabled"`
	Addr     string `json:"addr"`
	Interval int    `json:"interval"`
	Timeout  int    `json:"timeout"`
}

type HttpConfig

type HttpConfig struct {
	Enabled  bool   `json:"enabled"`
	Listen   string `json:"listen"`
	Backdoor bool   `json:"backdoor"`
}

type MetricLevelIntervalConfig

type MetricLevelIntervalConfig struct {
	Level1 int `json:"level_1"`
	Level2 int `json:"level_2"`
	Level3 int `json:"level_3"`
	Level4 int `json:"level_4"`
}

type PluginConfig

type PluginConfig struct {
	Enabled bool   `json:"enabled"`
	Dir     string `json:"dir"`
	Git     string `json:"git"`
	LogDir  string `json:"logs"`
}

type Service

type Service struct {
	Name string
	Pids []int
}

type SingleConnRpcClient

type SingleConnRpcClient struct {
	sync.Mutex

	RpcServer string
	Timeout   time.Duration
	// contains filtered or unexported fields
}

简单封装rpc.Cilent

func (*SingleConnRpcClient) Call

func (this *SingleConnRpcClient) Call(method string, args interface{}, reply interface{}) error

rpc client调用hbs函数

type TransferConfig

type TransferConfig struct {
	Enabled  bool     `json:"enabled"`
	Addrs    []string `json:"addrs"`
	Interval int      `json:"interval"`
	Timeout  int      `json:"timeout"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL