forked from open-falcon/falcon-plus
/
sender_cron.go
52 lines (45 loc) · 1.05 KB
/
sender_cron.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package sender
import (
"github.com/open-falcon/falcon-plus/modules/transfer/proc"
"github.com/toolkits/container/list"
"log"
"strings"
"time"
)
const (
DefaultProcCronPeriod = time.Duration(5) * time.Second //ProcCron的周期,默认1s
DefaultLogCronPeriod = time.Duration(3600) * time.Second //LogCron的周期,默认300s
)
// send_cron程序入口
func startSenderCron() {
go startProcCron()
go startLogCron()
}
func startProcCron() {
for {
time.Sleep(DefaultProcCronPeriod)
refreshSendingCacheSize()
}
}
func startLogCron() {
for {
time.Sleep(DefaultLogCronPeriod)
logConnPoolsProc()
}
}
func refreshSendingCacheSize() {
proc.JudgeQueuesCnt.SetCnt(calcSendCacheSize(JudgeQueues))
proc.GraphQueuesCnt.SetCnt(calcSendCacheSize(GraphQueues))
}
func calcSendCacheSize(mapList map[string]*list.SafeListLimited) int64 {
var cnt int64 = 0
for _, list := range mapList {
if list != nil {
cnt += int64(list.Len())
}
}
return cnt
}
func logConnPoolsProc() {
log.Printf("connPools proc: \n%v", strings.Join(GraphConnPools.Proc(), "\n"))
}