funcs

package
v3.2.5+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TransferClientsLock = new(sync.RWMutex)
	TClients            *SingleConnRpcClient

	Hosts = make(map[string]string) // 存储主机IP和UUID对应关系
)
View Source
var (
	ConfigFile string
)

Functions

func DebugLog

func DebugLog(msg string, v ...interface{})

func GetExportMetric

func GetExportMetric() []byte

func GetIpList

func GetIpList() []string

func GetSourceGuidMap

func GetSourceGuidMap() map[string][]string

func HandleTransferResult

func HandleTransferResult(result map[string]PingResultObj, successCount int)

func InitSourceList

func InitSourceList()

Note: weight参数是为了在众多数据源中识别当前数据源的数据并更新,weight越小权重越高,各数据源之间的关系是并集 Note: 比如说remote的weight是3,file的weight是2,remote数据更新后不会覆盖file的数据

func InitTransfer

func InitTransfer()

func ParseConfig

func ParseConfig(cfg string) error

func SendMetrics

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

func UpdateHttpCheckExportMetric added in v1.5.0

func UpdateHttpCheckExportMetric(result []*HttpCheckObj, successCount int)

func UpdateIpList

func UpdateIpList(ips []string, sourceType int)

func UpdateLossPingExportMetric

func UpdateLossPingExportMetric(result map[string]PingResultObj)

func UpdatePingExportMetric

func UpdatePingExportMetric(result map[string]PingResultObj, successCount int)

func UpdateSourceRemoteData added in v1.7.0

func UpdateSourceRemoteData(input []*PingExportSourceObj)

func UpdateTelnetExportMetric

func UpdateTelnetExportMetric(result []*TelnetObj, successCount int)

func Uuid

func Uuid() string

Types

type GlobalConfig

type GlobalConfig struct {
	Debug            bool             `json:"debug"`
	Interval         int              `json:"interval"`
	PingEnable       bool             `json:"ping_enable"`
	TelnetEnable     bool             `json:"telnet_enable"`
	HttpCheckEnable  bool             `json:"http_check_enable"`
	HttpProxyEnable  bool             `json:"http_proxy_enable"`
	HttpProxyAddress string           `json:"http_proxy"`
	OpenFalcon       OpenFalconConfig `json:"open-falcon"`
	Prometheus       PrometheusCOnfig `json:"prometheus"`
	Source           SourceConfig     `json:"source"`
	Metrics          MetricConfig     `json:"metrics"`
	HttpCheckTimeout int              `json:"http_check_timeout"`
}

func Config

func Config() *GlobalConfig

type HttpCheckObj added in v1.5.0

type HttpCheckObj struct {
	Method     string
	Url        string
	StatusCode int
}

func GetHttpCheckList added in v1.5.0

func GetHttpCheckList() []*HttpCheckObj

type MetricConfig

type MetricConfig struct {
	Ping                  string `json:"ping"`
	PingUseTime           string `json:"ping_use_time"`
	PingCountNum          string `json:"ping_count_num"`
	PingCountSuccess      string `json:"ping_count_success"`
	PingCountFail         string `json:"ping_count_fail"`
	Telnet                string `json:"telnet"`
	TelnetCountNum        string `json:"telnet_count_num"`
	TelnetCountSuccess    string `json:"telnet_count_success"`
	TelnetCountFail       string `json:"telnet_count_fail"`
	HttpCheck             string `json:"http_check"`
	HttpCheckCountNum     string `json:"http_check_count_num"`
	HttpCheckCountSuccess string `json:"http_check_count_success"`
	HttpCheckCountFail    string `json:"http_check_count_fail"`
	PingLossPercent       string `json:"ping_loss_percent"`
}

type MetricValue

type MetricValue struct {
	Endpoint  string      `json:"endpoint"`
	Metric    string      `json:"metric"`
	Value     interface{} `json:"value"`
	Step      int64       `json:"step"`
	Type      string      `json:"counterType"`
	Tags      string      `json:"tags"`
	Timestamp int64       `json:"timestamp"`
}

func (*MetricValue) String

func (this *MetricValue) String() string

type OpenFalconConfig

type OpenFalconConfig struct {
	Enabled  bool            `json:"enabled"`
	Transfer *TransferConfig `json:"transfer"`
}

type PingExportSourceObj

type PingExportSourceObj struct {
	Ip   string `json:"ip"`
	Guid string `json:"guid"`
}

type PingResultObj added in v1.5.1

type PingResultObj struct {
	Ip          string
	UpDown      int
	UseTime     float64
	LossPercent float64
}

type PrometheusCOnfig

type PrometheusCOnfig struct {
	Enabled bool   `json:"enabled"`
	Port    string `json:"port"`
	Path    string `json:"path"`
}

type RemoteResponse added in v1.7.0

type RemoteResponse struct {
	Config []*PingExportSourceObj `json:"config"`
}

type Response

type Response struct {
	Code int      `json:"code"`
	Data []string `json:"data"`
	Msg  string   `json:"msg"`
}

type SingleConnRpcClient

type SingleConnRpcClient struct {
	sync.Mutex

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

func (*SingleConnRpcClient) Call

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

type SourceConfig

type SourceConfig struct {
	Const  SourceConstConfig  `json:"const"`
	File   SourceFileConfig   `json:"file"`
	Remote SourceRemoteConfig `json:"remote"`
	Listen SourceListenConfig `json:"listen"`
}

type SourceConstConfig

type SourceConstConfig struct {
	Enabled bool     `json:"enabled"`
	Ips     []string `json:"ips"`
	Weight  int      `json:"weight"`
}

type SourceFileConfig

type SourceFileConfig struct {
	Enabled bool   `json:"enabled"`
	Path    string `json:"path"`
	Weight  int    `json:"weight"`
}

type SourceListenConfig

type SourceListenConfig struct {
	Enabled bool   `json:"enabled"`
	Port    string `json:"port"`
	Path    string `json:"path"`
	Weight  int    `json:"weight"`
}

type SourceRemoteConfig

type SourceRemoteConfig struct {
	Enabled  bool     `json:"enabled"`
	Header   []string `json:"header"`
	GroupTag string   `json:"group_tag"`
	Url      string   `json:"url"`
	Interval int      `json:"interval"`
	Weight   int      `json:"weight"`
}

type TelnetObj

type TelnetObj struct {
	Ip      string
	Port    int
	Success bool
}

func GetTelnetList

func GetTelnetList() []*TelnetObj

type TransferConfig

type TransferConfig struct {
	Addrs    []string `json:"addrs"`
	Interval int      `json:"interval"`
	Timeout  int      `json:"timeout"`
	Sn       int      `json:"sn"`
}

type TransferResponse

type TransferResponse struct {
	Message string
	Total   int
	Invalid int
	Latency int64
}

func (*TransferResponse) String

func (this *TransferResponse) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL