@@ -183,14 +183,16 @@ class GrafanaHandler {
183183 * @param {* } server
184184 */
185185 handleStatistics ( statistics , server ) {
186- if ( ! statistics || typeof statistics !== "string" ) return
186+ if ( ! statistics || typeof statistics !== "string" ) return ;
187187 const json = JSON . parse ( statistics . split ( "\n" ) [ 0 ] ) ;
188188 const otherStats = json [ Object . keys ( json ) [ 0 ] ] . other ;
189-
190- playercountGauge . set (
191- { server : server . name } ,
192- Array . isArray ( otherStats . online_players ) ? otherStats . online_players . length : 0
193- )
189+
190+ playercountGauge . set (
191+ { server : server . name } ,
192+ Array . isArray ( otherStats . online_players )
193+ ? otherStats . online_players . length
194+ : 0
195+ ) ;
194196 Object . keys ( otherStats . mods ) . forEach ( ( modname ) =>
195197 modGauge . set (
196198 {
@@ -248,53 +250,53 @@ class GrafanaHandler {
248250
249251 if ( production ) {
250252 Object . keys ( production . item_input ) . forEach ( ( key ) =>
251- itemProductionInput . set (
252- { server : server . name , force : forcename , name : key } ,
253- production . item_input [ key ] . count
254- )
255- ) ;
256- Object . keys ( production . item_output ) . forEach ( ( key ) =>
257- itemProductionOutput . set (
258- { server : server . name , force : forcename , name : key } ,
259- production . item_output [ key ] . count
260- )
261- ) ;
262- Object . keys ( production . fluid_input ) . forEach ( ( key ) =>
263- fluidProductionInput . set (
264- { server : server . name , force : forcename , name : key } ,
265- production . fluid_input [ key ] . count
266- )
267- ) ;
268- Object . keys ( production . fluid_output ) . forEach ( ( key ) =>
269- fluidProductionOutput . set (
270- { server : server . name , force : forcename , name : key } ,
271- production . fluid_output [ key ] . count
272- )
273- ) ;
274- Object . keys ( production . kill_input ) . forEach ( ( key ) =>
275- killProductionInput . set (
276- { server : server . name , force : forcename , name : key } ,
277- production . kill_input [ key ] . count
278- )
279- ) ;
280- Object . keys ( production . kill_output ) . forEach ( ( key ) =>
281- killProductionOutput . set (
282- { server : server . name , force : forcename , name : key } ,
283- production . kill_output [ key ] . count
284- )
285- ) ;
286- Object . keys ( production . build_input ) . forEach ( ( key ) =>
287- buildProductionInput . set (
288- { server : server . name , force : forcename , name : key } ,
289- production . build_input [ key ] . count
290- )
291- ) ;
292- Object . keys ( production . build_output ) . forEach ( ( key ) =>
293- buildProductionOutput . set (
294- { server : server . name , force : forcename , name : key } ,
295- production . build_output [ key ] . count
296- )
297- ) ;
253+ itemProductionInput . set (
254+ { server : server . name , force : forcename , name : key } ,
255+ production . item_input [ key ] . count
256+ )
257+ ) ;
258+ Object . keys ( production . item_output ) . forEach ( ( key ) =>
259+ itemProductionOutput . set (
260+ { server : server . name , force : forcename , name : key } ,
261+ production . item_output [ key ] . count
262+ )
263+ ) ;
264+ Object . keys ( production . fluid_input ) . forEach ( ( key ) =>
265+ fluidProductionInput . set (
266+ { server : server . name , force : forcename , name : key } ,
267+ production . fluid_input [ key ] . count
268+ )
269+ ) ;
270+ Object . keys ( production . fluid_output ) . forEach ( ( key ) =>
271+ fluidProductionOutput . set (
272+ { server : server . name , force : forcename , name : key } ,
273+ production . fluid_output [ key ] . count
274+ )
275+ ) ;
276+ Object . keys ( production . kill_input ) . forEach ( ( key ) =>
277+ killProductionInput . set (
278+ { server : server . name , force : forcename , name : key } ,
279+ production . kill_input [ key ] . count
280+ )
281+ ) ;
282+ Object . keys ( production . kill_output ) . forEach ( ( key ) =>
283+ killProductionOutput . set (
284+ { server : server . name , force : forcename , name : key } ,
285+ production . kill_output [ key ] . count
286+ )
287+ ) ;
288+ Object . keys ( production . build_input ) . forEach ( ( key ) =>
289+ buildProductionInput . set (
290+ { server : server . name , force : forcename , name : key } ,
291+ production . build_input [ key ] . count
292+ )
293+ ) ;
294+ Object . keys ( production . build_output ) . forEach ( ( key ) =>
295+ buildProductionOutput . set (
296+ { server : server . name , force : forcename , name : key } ,
297+ production . build_output [ key ] . count
298+ )
299+ ) ;
298300 }
299301
300302 if ( robots ) {
@@ -360,7 +362,7 @@ class GrafanaHandler {
360362 "/collectdata rcon" ,
361363 server . discordid
362364 ) ;
363- this . handleStatistics ( data . resp , server ) ;
365+ if ( data ) this . handleStatistics ( data . resp , server ) ;
364366 } ) ;
365367 }
366368 destroy ( ) {
0 commit comments