forked from open-falcon/falcon-plus
/
g.go
52 lines (46 loc) · 1.51 KB
/
g.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 g
import (
"log"
"runtime"
)
// TODO
// change graph.store cache struct(key: md5->uuid)
// flush when query happens seems unreasonable
// shrink packages
// CHANGE LOGS
// 0.4.8 fix filename bug emporarily, fix dirty-index-cache bug of query,
// add filter for debug
// 0.4.9 mv db back to g, add rpc.last
// 0.5.0 rm trace, add history&last api
// 0.5.1 add http interface v2, using form args
// 0.5.2 add last_raw
// 0.5.3 fix bug of last&last_raw
// 0.5.4 fix bug of Query.merge
// 0.5.5 use commom(rm model), fix sync disk
// 0.5.7 set xff to 0 from 0.5, in order to support irregular step counter
// 0.5.8 clean GraphItems/historyCache Cache at regular intervals
// 0.5.9 add flush style(flush by number of every counter's monitoring data)
const (
VERSION = "0.5.9"
GAUGE = "GAUGE"
DERIVE = "DERIVE"
COUNTER = "COUNTER"
DEFAULT_STEP = 60 //s
MIN_STEP = 30 //s
CLEAN_CACHE = 86400 //s the step that clean GraphItems/historyCache Cache
CACHE_DELAY = 1800 //s
CACHE_TIME = 1800000 //ms
FLUSH_DISK_STEP = 1000 //ms
FLUSH_MIN_COUNT = 6 // flush counter to disk when its number of monitoring data greater than FLUSH_MIN_COUNT
FLUSH_MAX_WAIT = 86400 //s flush counter to disk if it not be flushed within FLUSH_MAX_WAIT seconds
)
const (
GRAPH_F_MISS uint32 = 1 << iota
GRAPH_F_ERR
GRAPH_F_SENDING
GRAPH_F_FETCHING
)
func init() {
runtime.GOMAXPROCS(runtime.NumCPU())
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
}