@@ -75,8 +75,19 @@ private void ProcessPlayerInfo()
7575 PrometheusMgr . PlayerOnlineGague . RemoveLabelled ( item ) ;
7676 }
7777 }
78+
79+ curLabels = PrometheusMgr . PlayerCountGague . GetAllLabelValues ( ) ;
80+ if ( curLabels != null )
81+ {
82+ foreach ( var item in curLabels )
83+ {
84+ PrometheusMgr . PlayerCountGague . RemoveLabelled ( item ) ;
85+ }
86+ }
7887 }
7988
89+ PrometheusMgr . PlayerCountGague . WithLabels ( new string [ ] { configItem . IPAddress , configItem . Port . ToString ( ) , $ "{ configItem . IPAddress } :{ configItem . Port } ", serverName } ) . Set ( playerInfo . Players . Count ) ;
90+
8091 foreach ( var player in playerInfo . Players )
8192 {
8293 if ( ! String . IsNullOrWhiteSpace ( player . PlayerName ) )
@@ -108,7 +119,10 @@ private void ProcessPlayerInfo()
108119 }
109120 }
110121 }
111- catch ( Exception ) { }
122+ catch ( Exception )
123+ {
124+ PrometheusMgr . PlayerCountGague . WithLabels ( new string [ ] { configItem . IPAddress , configItem . Port . ToString ( ) , $ "{ configItem . IPAddress } :{ configItem . Port } ", serverName } ) . Set ( 0 ) ;
125+ }
112126 }
113127
114128 private void ProcessServerInfo ( )
@@ -132,28 +146,28 @@ private void ProcessServerInfo()
132146 }
133147 }
134148
135- curLabels = PrometheusMgr . PlayerCountGague . GetAllLabelValues ( ) ;
136- if ( curLabels != null )
137- {
138- foreach ( var item in curLabels )
139- {
140- PrometheusMgr . PlayerCountGague . RemoveLabelled ( item ) ;
141- }
142- }
149+ // curLabels = PrometheusMgr.PlayerCountGague.GetAllLabelValues();
150+ // if (curLabels != null)
151+ // {
152+ // foreach (var item in curLabels)
153+ // {
154+ // PrometheusMgr.PlayerCountGague.RemoveLabelled(item);
155+ // }
156+ // }
143157 }
144158 serverName = serverInfo . Name ;
145159
146160 // Update the "IsUp" gague setting to "true"
147161 PrometheusMgr . IsUpGague . WithLabels ( new string [ ] { configItem . IPAddress , configItem . Port . ToString ( ) , $ "{ configItem . IPAddress } :{ configItem . Port } ", serverName } ) . Set ( 1 ) ;
148- PrometheusMgr . PlayerCountGague . WithLabels ( new string [ ] { configItem . IPAddress , configItem . Port . ToString ( ) , $ "{ configItem . IPAddress } :{ configItem . Port } ", serverName } ) . Set ( serverInfo . Players ) ;
162+ // PrometheusMgr.PlayerCountGague.WithLabels(new string[] { configItem.IPAddress, configItem.Port.ToString(), $"{configItem.IPAddress}:{configItem.Port}", serverName }).Set(serverInfo.Players);
149163 }
150164 catch ( Exception )
151165 {
152166 var curName = serverName ?? String . Empty ;
153167
154168 // Update the "IsUp" gague setting to "false"
155169 PrometheusMgr . IsUpGague . WithLabels ( new string [ ] { configItem . IPAddress , configItem . Port . ToString ( ) , $ "{ configItem . IPAddress } :{ configItem . Port } ", curName } ) . Set ( 0 ) ;
156- PrometheusMgr . PlayerCountGague . WithLabels ( new string [ ] { configItem . IPAddress , configItem . Port . ToString ( ) , $ "{ configItem . IPAddress } :{ configItem . Port } ", serverName } ) . Set ( 0 ) ;
170+ // PrometheusMgr.PlayerCountGague.WithLabels(new string[] { configItem.IPAddress, configItem.Port.ToString(), $"{configItem.IPAddress}:{configItem.Port}", serverName }).Set(0);
157171 }
158172 }
159173 }
0 commit comments