@@ -18,37 +18,37 @@ type Monitoring struct {
1818 Lc * LocalConfig
1919
2020 // Structure with amount of metrics from client.
21- got source
21+ serverStat serverStat
2222
2323 // Statistic per carbon receiver
24- stat map [string ]* stat
24+ clientStat map [string ]* clientStat
25+ }
26+
27+ // The source of metric daemon got.
28+ type serverStat struct {
29+ // Amount of metrics from directory.
30+ dir int
2531
2632 // Amount of invalid metrics.
2733 invalid int
28- }
2934
30- // The source of metric daemon got.
31- type source struct {
3235 // Amount of metrics from network.
3336 net int
37+ }
3438
35- // Amount of metrics from directory.
36- dir int
39+ // The statistic of metrics per backend
40+ type clientStat struct {
41+ // Amount of dropped metrics.
42+ dropped int
3743
3844 // Amount of metrics from retry file.
39- retry int
40- }
45+ fromRetry int
4146
42- // The statistic of metrics per backend
43- type stat struct {
4447 // Amount of saved metrics.
4548 saved int
4649
4750 // Amount of sent metrics.
4851 sent int
49-
50- // Amount of dropped metrics.
51- dropped int
5252}
5353
5454var statLock sync.Mutex
@@ -61,18 +61,18 @@ func (m *Monitoring) generateOwnMonitoring() {
6161 statLock .Lock ()
6262
6363 monitorSlice := []string {
64- fmt .Sprintf ("%s.got.net %v %v" , path , m .got .net , now ),
65- fmt .Sprintf ("%s.got.dir %v %v" , path , m .got .dir , now ),
66- fmt .Sprintf ("%s.got.retry %v %v" , path , m .got .retry , now ),
67- fmt .Sprintf ("%s.invalid %v %v" , path , m .invalid , now ),
64+ fmt .Sprintf ("%s.got.net %v %v" , path , m .serverStat .net , now ),
65+ fmt .Sprintf ("%s.got.dir %v %v" , path , m .serverStat .dir , now ),
66+ fmt .Sprintf ("%s.invalid %v %v" , path , m .serverStat .invalid , now ),
6867 }
6968
7069 for _ , carbonAddrTCP := range m .Lc .carbonAddrsTCP {
7170 backend := carbonAddrTCP .String ()
7271 backendString := strings .Replace (backend , "." , "_" , - 1 )
73- monitorSlice = append (monitorSlice , fmt .Sprintf ("%s.%s.saved %v %v" , path , backendString , m .stat [backend ].saved , now ))
74- monitorSlice = append (monitorSlice , fmt .Sprintf ("%s.%s.sent %v %v" , path , backendString , m .stat [backend ].sent , now ))
75- monitorSlice = append (monitorSlice , fmt .Sprintf ("%s.%s.dropped %v %v" , path , backendString , m .stat [backend ].dropped , now ))
72+ monitorSlice = append (monitorSlice , fmt .Sprintf ("%s.%s.dropped %v %v" , path , backendString , m .clientStat [backend ].dropped , now ))
73+ monitorSlice = append (monitorSlice , fmt .Sprintf ("%s.%s.from_retry %v %v" , path , backendString , m .clientStat [backend ].fromRetry , now ))
74+ monitorSlice = append (monitorSlice , fmt .Sprintf ("%s.%s.saved %v %v" , path , backendString , m .clientStat [backend ].saved , now ))
75+ monitorSlice = append (monitorSlice , fmt .Sprintf ("%s.%s.sent %v %v" , path , backendString , m .clientStat [backend ].sent , now ))
7676 }
7777
7878 statLock .Unlock ()
@@ -84,7 +84,7 @@ func (m *Monitoring) generateOwnMonitoring() {
8484 m .Lc .lg .Printf ("Too many metrics in the MON queue! This is very bad" )
8585 for _ , carbonAddrTCP := range m .Lc .carbonAddrsTCP {
8686 backend := carbonAddrTCP .String ()
87- m .Increase (& m .stat [backend ].dropped , 1 )
87+ m .Increase (& m .clientStat [backend ].dropped , 1 )
8888 }
8989 }
9090 }
@@ -94,12 +94,12 @@ func (m *Monitoring) generateOwnMonitoring() {
9494func (m * Monitoring ) clean () {
9595 for _ , carbonAddrTCP := range m .Lc .carbonAddrsTCP {
9696 backend := carbonAddrTCP .String ()
97- m .stat [backend ].saved = 0
98- m .stat [backend ].sent = 0
99- m .stat [backend ].dropped = 0
97+ m .clientStat [backend ].dropped = 0
98+ m .clientStat [backend ].fromRetry = 0
99+ m .clientStat [backend ].saved = 0
100+ m .clientStat [backend ].sent = 0
100101 }
101- m .invalid = 0
102- m .got = source {0 , 0 , 0 }
102+ m .serverStat = serverStat {0 , 0 , 0 }
103103}
104104
105105// Increase metric value in the thread safe way
@@ -113,10 +113,11 @@ func (m *Monitoring) Increase(metric *int, value int) {
113113// Should be run in separate goroutine.
114114func (m * Monitoring ) Run () {
115115 statLock .Lock ()
116- m .stat = make (map [string ]* stat )
116+ m .clientStat = make (map [string ]* clientStat )
117117 for _ , carbonAddrTCP := range m .Lc .carbonAddrsTCP {
118118 backend := carbonAddrTCP .String ()
119- m .stat [backend ] = & stat {
119+ m .clientStat [backend ] = & clientStat {
120+ 0 ,
120121 0 ,
121122 0 ,
122123 0 ,
@@ -128,8 +129,8 @@ func (m *Monitoring) Run() {
128129 statLock .Lock ()
129130 for _ , carbonAddrTCP := range m .Lc .carbonAddrsTCP {
130131 backend := carbonAddrTCP .String ()
131- if m .stat [backend ].dropped != 0 {
132- m .Lc .lg .Printf ("Too many metrics in the main buffer of %s server. Had to drop incommings: %d" , backend , m .stat [backend ].dropped )
132+ if m .clientStat [backend ].dropped != 0 {
133+ m .Lc .lg .Printf ("Too many metrics in the main buffer of %s server. Had to drop incommings: %d" , backend , m .clientStat [backend ].dropped )
133134 }
134135 }
135136 m .clean ()
0 commit comments