Skip to content

Commit 33953c5

Browse files
author
Till Brehm
committed
Merge branch '6834-multiserver-metrics-fixes' into 'develop'
Fixed metrics for nodes in a multiserver setup Closes #6834 See merge request ispconfig/ispconfig3!1990
2 parents 594fe0d + c2eb39a commit 33953c5

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

install/lib/installer_base.lib.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ public function grant_master_database_rights($verbose = false) {
775775
$this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
776776
}
777777

778-
$query = "GRANT SELECT, INSERT , DELETE ON ?? TO ?@?";
778+
$query = "GRANT SELECT, INSERT, UPDATE, DELETE ON ?? TO ?@?";
779779
if ($verbose){
780780
echo $query ."\n";
781781
}

server/lib/classes/cron.d/100-monitor_sys_usage.inc.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)