@@ -60,13 +60,13 @@ public function onRunJob() {
6060
6161 /* the id of the server as int */
6262 $ server_id = intval ($ conf ['server_id ' ]);
63-
63+
6464
6565 // Get record with existing data points
6666 $ type = 'sys_usage ' ;
6767 $ max_data_points = 15 ;
68- $ sql = "SELECT `data` FROM `monitor_data` WHERE `type` = ? " ;
69- $ rec = $ app ->db ->queryOneRecord ($ sql , $ type );
68+ $ sql = "SELECT `data` FROM `monitor_data` WHERE `type` = ? AND `server_id` = ? " ;
69+ $ rec = $ app ->dbmaster ->queryOneRecord ($ sql , $ type, $ server_id );
7070
7171 if (!empty ($ rec )) {
7272 $ data = unserialize ($ rec ['data ' ]);
@@ -81,7 +81,7 @@ public function onRunJob() {
8181 $ interval_seconds = 60 ;
8282 }
8383 $ data ['tstamp ' ] = time ();
84-
84+
8585 // Monitor load average in percent
8686 $ load = $ this ->get_system_load ();
8787
@@ -101,7 +101,7 @@ public function onRunJob() {
101101 }
102102
103103 $ data ['load ' ][] = $ load_percent ;
104-
104+
105105 // Trim time array size
106106 if (isset ($ data ['time ' ]) && count ($ data ['time ' ]) >= $ max_data_points ) {
107107 array_shift ($ data ['time ' ]);
@@ -172,10 +172,10 @@ public function onRunJob() {
172172 ') ' ;
173173 $ app ->dbmaster ->query ($ sql );
174174 } else {
175- $ sql = "UPDATE `monitor_data` SET `data` = ?, `created` = ? WHERE `type` = ? " ;
176- $ app ->dbmaster ->query ($ sql ,serialize ($ res ['data ' ]),time (),$ type );
175+ $ sql = "UPDATE `monitor_data` SET `data` = ?, `created` = ? WHERE `type` = ? AND `server_id` = ? " ;
176+ $ app ->dbmaster ->query ($ sql ,serialize ($ res ['data ' ]),time (),$ type, $ server_id );
177177 }
178-
178+
179179
180180 /* The new data is written, now we can delete the old one */
181181 $ this ->_tools ->delOldRecords ($ type , $ res ['server_id ' ]);
@@ -206,7 +206,7 @@ private function get_system_load() {
206206 }
207207 return $ load ;
208208 }
209-
209+
210210 /**
211211 * get_cpu_cores
212212 *
@@ -216,13 +216,13 @@ private function get_system_load() {
216216 private function get_cpu_cores () : int {
217217 return (int ) shell_exec ("nproc " );
218218 }
219-
219+
220220 /**
221221 * get_memory_info
222222 *
223223 * @return array
224224 */
225-
225+
226226 private function get_memory_info () : array {
227227 $ data = file_get_contents ("/proc/meminfo " );
228228 $ meminfo = [];
@@ -236,7 +236,7 @@ private function get_memory_info() : array {
236236 }
237237 return $ meminfo ;
238238 }
239-
239+
240240 /**
241241 * get_network_bytes
242242 *
@@ -279,4 +279,4 @@ private function getFirstExternalInterface() {
279279
280280 return null ;
281281 }
282- }
282+ }
0 commit comments