* * * * * <user> wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies '; $message_conf_cron .= str_replace( ENTERPRISE_DIR.'/meta/', '', ui_get_full_url(false) ); $message_conf_cron .= ENTERPRISE_DIR.'/'.EXTENSIONS_DIR; $message_conf_cron .= '/cron/cron.php >>'; $message_conf_cron .= $config['homedir'].'/log/cron.log'; } if (isset($config['cron_last_run']) === true) { $message_conf_cron .= __('Last execution').': '; $message_conf_cron .= date('Y/m/d H:i:s', $config['cron_last_run']); $message_conf_cron .= __('Please, make sure process is not locked.'); } $url = '__url__/index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist'; if (is_metaconsole() === true) { $url = '__url__index.php?sec=extensions&sec2=enterprise/extensions/cron'; } $this->notify( [ 'type' => 'NOTIF.CRON.CONFIGURED', 'title' => __('DiscoveryConsoleTasks is not configured.'), 'message' => __($message_conf_cron), 'url' => $url, ] ); } else { $this->cleanNotifications('NOTIF.CRON.CONFIGURED'); } } /** * Search for messages. * * @return void */ public function getUMMessages() { global $config; include_once $config['homedir'].'/include/functions_update_manager.php'; if (update_manager_verify_registration() === false) { // Console not subscribed. return; } // Avoid contact for messages too much often. if (isset($config['last_um_check']) === true && time() < $config['last_um_check'] ) { return; } // Only ask for messages once every 2 hours. $future = (time() + 2 * SECONDS_1HOUR); config_update_value('last_um_check', $future, true); $messages = update_manager_get_messages(); if (is_array($messages) === true) { $source_id = get_notification_source_id( 'Official communication' ); foreach ($messages as $message) { if (isset($message['url']) === false) { $message['url'] = '#'; } $this->notify( [ 'type' => 'NOTIF.UPDATEMANAGER.MESSAGES.'.$message['id'], 'title' => $message['subject'], 'message' => base64_decode($message['message_html']), 'url' => $message['url'], ], $source_id ); } } } /** * Check if all servers and console versions are the same * * @return void */ public function checkConsoleServerVersions() { global $config; // List all servers except satellite server. $server_version_list = db_get_all_rows_sql( sprintf( 'SELECT `name`, `version` FROM tserver WHERE server_type != %d GROUP BY `version`', SERVER_TYPE_ENTERPRISE_SATELLITE ) ); $missed = 0; if (is_array($server_version_list) === true) { foreach ($server_version_list as $server) { if (strpos( $server['version'], (string) floor((int) $config['current_package']) ) === false ) { $missed++; $title_ver_misaligned = __( '%s version misaligned with Console', $server['name'] ); $message_ver_misaligned = __( 'Server %s and this console have different versions. This might cause several malfunctions. Please, update this server.', $server['name'] ); $this->notify( [ 'type' => 'NOTIF.SERVER.MISALIGNED', 'title' => __($title_ver_misaligned), 'message' => __($message_ver_misaligned), 'url' => '__url__/index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online', ] ); break; } } } // Cleanup notifications if exception is recovered. if ($missed == 0) { $this->cleanNotifications('NOTIF.SERVER.MISALIGNED'); } } /** * Check if AllowOveride is None or All. * * @return void */ public function checkAllowOverrideEnabled() { global $config; $message = 'If AllowOverride is disabled, .htaccess will not works.'; if (PHP_OS == 'FreeBSD') { $message .= '
Please check /usr/local/etc/apache24/httpd.conf to resolve this problem.'; } else { $message .= 'Please check /etc/httpd/conf/httpd.conf to resolve this problem.'; } // Get content file. if (PHP_OS == 'FreeBSD') { $file = file_get_contents('/usr/local/etc/apache24/httpd.conf'); } else { $file = file_get_contents('/etc/httpd/conf/httpd.conf'); } $file_lines = preg_split("#\r?\n#", $file, -1, PREG_SPLIT_NO_EMPTY); $is_none = false; $i = 0; foreach ($file_lines as $line) { $i++; // Check Line and content. if (preg_match('/ AllowOverride/', $line) && $i === 311) { $result = explode(' ', $line); if ($result[5] == 'None') { $is_none = true; $this->notify( [ 'type' => 'NOTIF.ALLOWOVERRIDE.MESSAGE', 'title' => __('AllowOverride is disabled'), 'message' => __($message), 'url' => '__url__/index.php', ] ); } } } // Cleanup notifications if AllowOverride is All. if (!$is_none) { $this->cleanNotifications('NOTIF.ALLOWOVERRIDE.MESSAGE'); } } /** * Check if AllowOveride is None or All. * * @return void */ public function checkHaStatus() { global $config; enterprise_include_once('include/class/DatabaseHA.class.php'); $cluster = new DatabaseHA(); $nodes = $cluster->getNodes(); foreach ($nodes as $node) { if ($node['status'] == HA_DISABLED) { continue; } $cluster_master = $cluster->isClusterMaster($node); $db_master = $cluster->isDBMaster($node); $message = 'The roles played by node '.$node['host'].' are out of sync: Role in the cluster: Master Role in the database: Slave Desynchronized operation in the node'; if ((int) $db_master !== (int) $cluster_master) { $this->notify( [ 'type' => 'NOTIF.HAMASTER.MESSAGE', 'title' => __('Desynchronized operation on the node '.$node['host']), 'message' => __($message), 'url' => '__url__/index.php?sec=gservers&sec2=enterprise/godmode/servers/HA_cluster', ] ); } else { $this->cleanNotifications('NOTIF.HAMASTER.MESSAGE'); } } } /** * Check if Pandora console log file remains in old location. * * @return void */ public function checkPandoraConsoleLogOldLocation() { global $config; if (file_exists($config['homedir'].'/pandora_console.log')) { $title_pandoraconsole_old_log = __( 'Pandora FMS console log file changed location', $config['homedir'] ); $message_pandoraconsole_old_log = __( 'Pandora FMS console log file has been moved to new location %s/log. Currently you have an outdated and inoperative version of this file at %s. Please, consider deleting it.', $config['homedir'], $config['homedir'] ); $url = 'https://pandorafms.com/manual/en/quickguides/general_quick_guide#solving_problems_where_to_look_and_who_to_ask'; if ($config['language'] == 'es') { $url = 'https://pandorafms.com//manual/es/quickguides/general_quick_guide#solucion_de_problemas_donde_mirar_a_quien_preguntar'; } $this->notify( [ 'type' => 'NOTIF.PANDORACONSOLE.LOG.OLD', 'title' => __($title_pandoraconsole_old_log), 'message' => __($message_pandoraconsole_old_log), 'url' => $url, ] ); } else { $this->cleanNotifications('NOTIF.PANDORACONSOLE.LOG.OLD'); } } /** * Check if audit log file remains in old location. * * @return void */ public function checkAuditLogOldLocation() { global $config; if (file_exists($config['homedir'].'/audit.log')) { $title_audit_old_log = __( 'Pandora FMS audit log file changed location', $config['homedir'] ); $message_audit_old_log = __( 'Pandora FMS audit log file has been moved to new location %s/log. Currently you have an outdated and inoperative version of this file at %s. Please, consider deleting it.', $config['homedir'], $config['homedir'] ); $this->notify( [ 'type' => 'NOTIF.AUDIT.LOG.OLD', 'title' => __($title_audit_old_log), 'message' => __($message_audit_old_log), 'url' => '#', ] ); } else { $this->cleanNotifications('NOTIF.AUDIT.LOG.OLD'); } } /** * Verifies the status of synchronization queue and warns if something is * not working as expected. * * @return void */ public function checkSyncQueueLength() { global $config; if (is_metaconsole() !== true) { return; } $sync = new PandoraFMS\Enterprise\Metaconsole\Synchronizer(true); $counts = $sync->getQueues(true); if (count($counts) === 0) { // Clean all. $this->cleanNotifications('NOTIF.SYNCQUEUE.LENGTH.%'); } $items_min = (isset($config['sync_queue_items_max']) === true) ? $config['sync_queue_items_max'] : 0; if (is_numeric($items_min) !== true && $items_min <= 0) { $items_min = self::MIN_SYNC_QUEUE_LENGTH; } foreach ($counts as $node_id => $count) { if ($count < $items_min) { $this->cleanNotifications('NOTIF.SYNCQUEUE.LENGTH.'.$node_id); } else { try { $node = new PandoraFMS\Enterprise\Metaconsole\Node($node_id); $url = '__url__/index.php?sec=advanced&sec2=advanced/metasetup&tab=consoles'; $this->notify( [ 'type' => 'NOTIF.SYNCQUEUE.LENGTH.'.$node_id, 'title' => __('Node %s sync queue length exceeded, ', $node->server_name()), 'message' => __( 'Synchronization queue lenght for node %s is %d items, this value should be 0 or lower than %d, please check the queue status.', $node->server_name(), $count, $items_min ), 'url' => $url, ] ); } catch (\Exception $e) { // Clean, exception in node finding. $this->cleanNotifications('NOTIF.SYNCQUEUE.LENGTH.'.$node_id); } } } } /** * Verifies the status of synchronization queue and warns if something is * not working as expected. * * @return void */ public function checkSyncQueueStatus() { if (is_metaconsole() !== true) { return; } $sync = new PandoraFMS\Enterprise\Metaconsole\Synchronizer(true); $queues = $sync->getQueues(); if (count($queues) === 0) { // Clean all. $this->cleanNotifications('NOTIF.SYNCQUEUE.STATUS.%'); } foreach ($queues as $node_id => $queue) { if (count($queue) === 0) { $this->cleanNotifications('NOTIF.SYNCQUEUE.STATUS.'.$node_id); continue; } $item = $queue[0]; if (empty($item->error()) === false) { try { $node = new PandoraFMS\Enterprise\Metaconsole\Node($node_id); $url = '__url__/index.php?sec=advanced&sec2=advanced/metasetup&tab=consoles'; $this->notify( [ 'type' => 'NOTIF.SYNCQUEUE.STATUS.'.$node_id, 'title' => __('Node %s sync queue failed, ', $node->server_name()), 'message' => __( 'Node %s cannot process synchronization queue due %s, please check the queue status.', $node->server_name(), $item->error() ), 'url' => $url, ] ); } catch (\Exception $e) { // Clean, exception in node finding. $this->cleanNotifications('NOTIF.SYNCQUEUE.STATUS.'.$node_id); } } } } /** * Chechs if an agent has a dependency eror on omnishell * * @return void */ public function checkLibaryError() { $sql = 'SELECT COUNT(errorlevel) from tremote_command_target WHERE errorlevel = 2'; $error_dependecies = db_get_sql($sql); if ($error_dependecies > 0) { $this->notify( [ 'type' => 'NOTIF.AGENT.LIBRARY', 'title' => __('Agent dependency error'), 'message' => __( 'There are omnishell agents with dependency errors', ), 'url' => '__url__/index.php?sec=gextensions&sec2=enterprise/tools/omnishell', ] ); } } }