_91160_monitor

package
v0.0.0-...-07ef6c8 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2023 License: Artistic-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MonitorTitle = "短信提交数监控"
)

Variables

This section is empty.

Functions

func ChangeColor

func ChangeColor(input string) interface{}

func ChangeColorFloat64

func ChangeColorFloat64(input float64, threshold float64) interface{}

func ChangeColorInt64

func ChangeColorInt64(input int64) interface{}

func LineSplit

func LineSplit(line string) (int64, int64, string, int64, error)

返回毫秒时间戳int64 , Hour int64, spid string,计费条数 int64,错误

func LineSplitDynamic

func LineSplitDynamic(line string, minutesAggr int64) (int64, int64, string, int64, error)

返回毫秒时间戳int64 ,period int64, spid string,计费条数 int64,错误

func PeriodHumanRead

func PeriodHumanRead(period int64, aggregationMinute int64) string

Types

type ChangeData

type ChangeData struct {
	SpId              string
	LastPeriodCount   int64
	OnePeriodAgoCount int64
	OneWeekAgoCount   int64

	ChangeRateToOneWeekAgo   float64
	ChangeRateToOnePeriodAgo float64
}

type CountCompare

type CountCompare struct {
	OlderCount int64 `json:"older_count"`
	NewerCount int64 `json:"newer_count"`
}

type MailData

type MailData struct {
	//var lastPeriodString,onePeriodAgoString,oneWeekAgoString string
	Subject            string
	LastPeriodString   string
	OnePeriodAgoString string
	OneWeekAgoString   string
	Threshold          float64
	TData              map[string]*ChangeData
}

type MonitorManage

type MonitorManage interface {
	//设置内存中数据保留的天数
	SetReserveDays(dayCount int64)
	//设置比较的周期 比如一个小时维度进行比较
	SetAggregationMinute(aggregationMinute int64)
	//处理从其他的消息源传来的日志
	HandleLine(line string) error
	//设置变化阈值
	SetChangeThreshold(newThreshold float64)
	//设置收件人
	SetReceiver(receiver []string)
	//
	SetSpids(in []string)
	//设置最后的日志时间戳(13位带毫秒),可以根据这个判断最后的日志时间
	SetLastTimestamp(ltime int64)
	//根据日期 序列化成json写入到文件,日期是 timestamp/87600
	Save()
	//根据日期 把json文件内容读取 反序列化成结构体
	Load()
	//删除内存中的过期数据
	RemoveOutdate() error
	//
	Compare()
	//发送报警邮件
	SendMail(title, content string) error
}

type MonitorManager

type MonitorManager struct {
	*sync.Mutex
	ReserveDays       int64   `json:"reserve_days"`
	AggregationMinute int64   `json:"aggregation_minute"`
	ChangeThreshold   float64 `json:"change_threshold"`
	LastTimestamp     int64   `json:"last_timestamp"`
	//SaveFilePath string `json:"save_file_path"`
	//数据内嵌map 第一个int64是 小时 timestamp/3600 小时的int64表示
	//第二个map[string]int64 string代表spid,第二个int64表示提交数
	DataMap    map[int64]map[string]*StatisticsCount `json:"data_map"`
	SmtpConfig *SmtpConfig                           `json:"smtp_config"`
	SpIdMap    map[string]bool                       `json:"sp_id_map"`
}

func NewOrLoadMonitorManager

func NewOrLoadMonitorManager(reserveDays int64, aggregationMinute int64, spids string) *MonitorManager

func (*MonitorManager) Compare

func (mm *MonitorManager) Compare()

func (*MonitorManager) HandleLine

func (mm *MonitorManager) HandleLine(line string) error

func (*MonitorManager) Load

func (mm *MonitorManager) Load()

func (*MonitorManager) RemoveOutdate

func (mm *MonitorManager) RemoveOutdate() error

动态范围 如半小时或者一小时聚合 需要改的

func (*MonitorManager) Save

func (mm *MonitorManager) Save()

func (*MonitorManager) SendMail

func (mm *MonitorManager) SendMail(subject, body string) error

func (*MonitorManager) SetAggregationMinute

func (mm *MonitorManager) SetAggregationMinute(aggregationMinute int64)

func (*MonitorManager) SetChangeThreshold

func (mm *MonitorManager) SetChangeThreshold(newThreshold float64)

func (*MonitorManager) SetLastTimestamp

func (mm *MonitorManager) SetLastTimestamp(ltime int64)

func (*MonitorManager) SetReceiver

func (mm *MonitorManager) SetReceiver(receiver []string)

func (*MonitorManager) SetReserveDays

func (mm *MonitorManager) SetReserveDays(dayCount int64)

func (*MonitorManager) SetSpids

func (mm *MonitorManager) SetSpids(in []string)

type SmtpConfig

type SmtpConfig struct {
	SmtpHost  string   `json:"smtp_host"` //smtp.qq.com
	SmtpPort  int      `json:"smtp_port"` //= 465
	Username  string   `json:"username"`  //= '316957076'
	Password  string   `json:"password"`  //= 'apwyxjaxlymncbah'
	Sender    string   `json:"sender"`    //= '316957076@qq.com'
	Receivers []string `json:"receivers"` //.join(['429882405@qq.com','505727532@qq.com'])
}

type StatisticsCount

type StatisticsCount struct {
	SubmitCount   int64 `json:"submit_count"`
	LastTimestamp int64 `json:"last_timestamp"`
}

Jump to

Keyboard shortcuts

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