@@ -59,21 +59,23 @@ class Result extends Model
5959 */
6060 public function formatForInfluxDB2 ()
6161 {
62+ $ data = json_decode ($ this ->data , true );
63+
6264 return [
6365 'id ' => (int ) $ this ->id ,
6466 'ping ' => (float ) $ this ->ping ,
6567 'download ' => (int ) $ this ->download ,
6668 'upload ' => (int ) $ this ->upload ,
6769 'download_bits ' => (int ) $ this ->download * 8 ,
6870 'upload_bits ' => (int ) $ this ->upload * 8 ,
69- 'ping_jitter ' => (float ) $ this -> data ['ping ' ]['jitter ' ],
70- 'download_jitter ' => (float ) $ this -> data ['download ' ]['latency ' ]['jitter ' ],
71- 'upload_jitter ' => (float ) $ this -> data ['upload ' ]['latency ' ]['jitter ' ],
71+ 'ping_jitter ' => (float ) $ data ['ping ' ]['jitter ' ],
72+ 'download_jitter ' => (float ) $ data ['download ' ]['latency ' ]['jitter ' ],
73+ 'upload_jitter ' => (float ) $ data ['upload ' ]['latency ' ]['jitter ' ],
7274 'server_id ' => (int ) $ this ->server_id ,
7375 'server_host ' => $ this ->server_host ,
7476 'server_name ' => $ this ->server_name ,
7577 'scheduled ' => $ this ->scheduled ,
76- 'packet_loss ' => $ this -> data ['packetLoss ' ],
78+ 'packet_loss ' => optional ( $ data) ['packetLoss ' ], // optional, because apparently the cli doesn't always have this metric
7779 ];
7880 }
7981}
0 commit comments