| | |
| | | $app->dbmaster->query($sql); |
| | | |
| | | /* The new data is written, now we can delete the old one */ |
| | | $this->_delOldRecords($type, 4); |
| | | $this->_delOldRecords($type, $res['server_id']); |
| | | } |
| | | |
| | | private function _monitorServer() { |
| | |
| | | $app->dbmaster->query($sql); |
| | | |
| | | /* The new data is written, now we can delete the old one */ |
| | | $this->_delOldRecords($type, 4); |
| | | $this->_delOldRecords($type, $res['server_id']); |
| | | } |
| | | |
| | | private function _monitorOsVer() { |
| | |
| | | $app->dbmaster->query($sql); |
| | | |
| | | /* The new data is written, now we can delete the old one */ |
| | | $this->_delOldRecords($type, 4); |
| | | $this->_delOldRecords($type, $res['server_id']); |
| | | } |
| | | |
| | | private function _monitorIspcVer() { |
| | |
| | | $app->dbmaster->query($sql); |
| | | |
| | | /* The new data is written, now we can delete the old one */ |
| | | $this->_delOldRecords($type, 4); |
| | | $this->_delOldRecords($type, $res['server_id']); |
| | | } |
| | | |
| | | private function _monitorDiskUsage() { |
| | |
| | | $app->dbmaster->query($sql); |
| | | |
| | | /* The new data is written, now we can delete the old one */ |
| | | $this->_delOldRecords($type, 4); |
| | | $this->_delOldRecords($type, $res['server_id']); |
| | | } |
| | | |
| | | private function _monitorMemUsage() { |
| | |
| | | $app->dbmaster->query($sql); |
| | | |
| | | /* The new data is written, now we can delete the old one */ |
| | | $this->_delOldRecords($type, 4); |
| | | $this->_delOldRecords($type, $res['server_id']); |
| | | } |
| | | |
| | | private function _monitorCpu() { |
| | |
| | | $app->dbmaster->query($sql); |
| | | |
| | | /* The new data is written, now we can delete the old one */ |
| | | $this->_delOldRecords($type, 4); |
| | | $this->_delOldRecords($type, $res['server_id']); |
| | | } |
| | | |
| | | private function _monitorServices() { |
| | |
| | | $app->dbmaster->query($sql); |
| | | |
| | | /* The new data is written, now we can delete the old one */ |
| | | $this->_delOldRecords($type, 4); |
| | | $this->_delOldRecords($type, $res['server_id']); |
| | | } |
| | | |
| | | private function _monitorOpenVzHost() { |
| | |
| | | $app->dbmaster->query($sql); |
| | | |
| | | /* The new data is written, now we can delete the old one */ |
| | | $this->_delOldRecords($type, 4); |
| | | $this->_delOldRecords($type, $res['server_id']); |
| | | } |
| | | |
| | | private function _monitorOpenVzUserBeancounter() { |
| | |
| | | $app->dbmaster->query($sql); |
| | | |
| | | /* The new data is written, now we can delete the old one */ |
| | | $this->_delOldRecords($type, 4); |
| | | $this->_delOldRecords($type, $res['server_id']); |
| | | } |
| | | |
| | | private function _monitorSystemUpdate() { |
| | |
| | | $app->dbmaster->query($sql); |
| | | |
| | | /* The new data is written, now we can delete the old one */ |
| | | $this->_delOldRecords($type, 4); |
| | | $this->_delOldRecords($type, $res['server_id']); |
| | | } |
| | | |
| | | private function _monitorMailQueue() { |
| | |
| | | $app->dbmaster->query($sql); |
| | | |
| | | /* The new data is written, now we can delete the old one */ |
| | | $this->_delOldRecords($type, 4); |
| | | $this->_delOldRecords($type, $res['server_id']); |
| | | } |
| | | |
| | | private function _monitorRaid() { |
| | |
| | | $app->dbmaster->query($sql); |
| | | |
| | | /* The new data is written, now we can delete the old one */ |
| | | $this->_delOldRecords($type, 4); |
| | | $this->_delOldRecords($type, $res['server_id']); |
| | | } |
| | | |
| | | private function _monitorRkHunter() { |
| | |
| | | $app->dbmaster->query($sql); |
| | | |
| | | /* The new data is written, now we can delete the old one */ |
| | | $this->_delOldRecords($type, 4); |
| | | $this->_delOldRecords($type, $res['server_id']); |
| | | } |
| | | |
| | | private function _monitorFail2ban() { |
| | |
| | | $app->dbmaster->query($sql); |
| | | |
| | | /* The new data is written, now we can delete the old one */ |
| | | $this->_delOldRecords($type, 4); |
| | | $this->_delOldRecords($type, $res['server_id']); |
| | | } |
| | | |
| | | private function _monitorSysLog() { |
| | |
| | | $app->dbmaster->query($sql); |
| | | |
| | | /* The new data is written, now we can delete the old one */ |
| | | $this->_delOldRecords($type, 4); |
| | | $this->_delOldRecords($type, $res['server_id']); |
| | | } |
| | | |
| | | private function _monitorMailLog() { |
| | |
| | | $app->dbmaster->query($sql); |
| | | |
| | | /* The new data is written, now we can delete the old one */ |
| | | $this->_delOldRecords($type, 4); |
| | | $this->_delOldRecords($type, $res['server_id']); |
| | | } |
| | | |
| | | private function _monitorMailWarnLog() { |
| | |
| | | $app->dbmaster->query($sql); |
| | | |
| | | /* The new data is written, now we can delete the old one */ |
| | | $this->_delOldRecords($type, 4); |
| | | $this->_delOldRecords($type, $res['server_id']); |
| | | } |
| | | |
| | | private function _monitorMailErrLog() { |
| | |
| | | $app->dbmaster->query($sql); |
| | | |
| | | /* The new data is written, now we can delete the old one */ |
| | | $this->_delOldRecords($type, 4); |
| | | $this->_delOldRecords($type, $res['server_id']); |
| | | } |
| | | |
| | | private function _monitorMessagesLog() { |
| | |
| | | $app->dbmaster->query($sql); |
| | | |
| | | /* The new data is written, now we can delete the old one */ |
| | | $this->_delOldRecords($type, 4); |
| | | $this->_delOldRecords($type, $res['server_id']); |
| | | } |
| | | |
| | | private function _monitorISPCCronLog() { |
| | |
| | | $app->dbmaster->query($sql); |
| | | |
| | | /* The new data is written, now we can delete the old one */ |
| | | $this->_delOldRecords($type, 4); |
| | | $this->_delOldRecords($type, $res['server_id']); |
| | | } |
| | | |
| | | private function _monitorFreshClamLog() { |
| | |
| | | $app->dbmaster->query($sql); |
| | | |
| | | /* The new data is written, now we can delete the old one */ |
| | | $this->_delOldRecords($type, 4); |
| | | $this->_delOldRecords($type, $res['server_id']); |
| | | } |
| | | |
| | | private function _monitorClamAvLog() { |
| | |
| | | $app->dbmaster->query($sql); |
| | | |
| | | /* The new data is written, now we can delete the old one */ |
| | | $this->_delOldRecords($type, 4); |
| | | $this->_delOldRecords($type, $res['server_id']); |
| | | } |
| | | |
| | | private function _monitorIspConfigLog() { |
| | |
| | | $app->dbmaster->query($sql); |
| | | |
| | | /* The new data is written, now we can delete the old one */ |
| | | $this->_delOldRecords($type, 4); |
| | | $this->_delOldRecords($type, $res['server_id']); |
| | | } |
| | | |
| | | /* |
| | | Deletes Records older than n. |
| | | /** |
| | | * Deletes Records older than 4 minutes. |
| | | * The monitor writes new data every 5 minutes or longer (4 hour, 1 day). |
| | | * So if i delete all Date older than 4 minutes i can be sure, that all old data |
| | | * are deleted... |
| | | */ |
| | | |
| | | private function _delOldRecords($type, $min, $hour=0, $days=0) { |
| | | private function _delOldRecords($type, $serverId) { |
| | | global $app; |
| | | |
| | | $now = time(); |
| | | $old = $now - ($min * 60) - ($hour * 60 * 60) - ($days * 24 * 60 * 60); |
| | | $old = $now - (4 * 60); // 4 minutes |
| | | /* |
| | | * ATTENTION if i do NOT pay attention of the server id, i delete all data (of the type) |
| | | * of ALL servers. This means, if i have a multiserver-environment and a server has a |
| | | * time not synced with the others (for example, all server has 11:00 and ONE server has |
| | | * 10:45) then the actual data of this server (with the time-stamp 10:45) get lost |
| | | * even though it is the NEWEST data of this server. To avoid this i HAVE to include |
| | | * the server-id! |
| | | */ |
| | | $sql = 'DELETE FROM monitor_data ' . |
| | | 'WHERE ' . |
| | | 'type =' . "'" . $app->dbmaster->quote($type) . "' " . |
| | | 'AND ' . |
| | | 'created < ' . $old; |
| | | ' created < ' . $old . ' ' . |
| | | 'AND ' . |
| | | ' server_id = ' . $serverId; |
| | | $app->dbmaster->query($sql); |
| | | } |
| | | |