load('monitor_tools'); $this->_tools = new monitor_tools(); /* end global section for monitor cronjobs */ /* the id of the server as int */ $server_id = intval($conf['server_id']); /** The type of the data */ $type = 'iptables_rules'; /* This monitoring is only available if fail2ban is installed */ system('which iptables', $retval); // Debian, Ubuntu, Fedora if ($retval === 0) { /* Get the data of the log */ $data['output'] = '

iptables -S (ipv4)

'.shell_exec('iptables -S 2>/dev/null'); /* * At this moment, there is no state (maybe later) */ $state = 'no_state'; } else { $state = 'no_state'; $data = ''; } /* This monitoring is only available if fail2ban is installed */ system('which ip6tables', $retval); // Debian, Ubuntu, Fedora if ($retval === 0) { /* Get the data of the log */ $data['output'] .= '

ip6tables -S (ipv6)

'.shell_exec('ip6tables -S 2>/dev/null'); /* * At this moment, there is no state (maybe later) */ $state = 'no_state'; } else { $state = 'no_state'; $data = ''; } $res = array(); $res['server_id'] = $server_id; $res['type'] = $type; $res['data'] = $data; $res['state'] = $state; /* * Insert the data into the database */ $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . 'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)'; $app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']); /* The new data is written, now we can delete the old one */ $this->_tools->delOldRecords($res['type'], $res['server_id']); parent::onRunJob(); } /* this function is optional if it contains no custom code */ public function onAfterRun() { global $app; parent::onAfterRun(); } } ?>