$agent_time)); $graphs['agent'] = TRUE; // Store raw output in device attribute for debugging purposes (showtech page) if ($config['unix-agent']['debug']) { set_dev_attrib($device, 'unixagent_raw', str_compress($agent_raw)); } foreach (explode("<<<", $agent_raw) as $section) { list($section, $data) = explode(">>>", $section); $sa = ''; $sb = ''; $sc = ''; # DO -NOT- ADD NEW CASES BELOW -- use <<>> in your application script switch ($section) { // Compatibility with versions of scripts with and without app- // Disabled for DRBD because it falsely detects the check_mk output case "drbd": $sa = "app"; $sb = "drbd"; break; case "apache": $sa = "app"; $sb = "apache"; break; case "mysql": $sa = "app"; $sb = "mysql"; break; case "nginx": $sa = "app"; $sb = "nginx"; break; # FIXME why is this here? New application scripts should just return app-$foo case "freeradius": $sa = "app"; $sb = "freeradius"; break; case "postfix_qshape": $sa = "app"; $sb = "postfix_qshape"; break; case "postfix_mailgraph": $sa = "app"; $sb = "postfix_mailgraph"; break; # Workaround for older script where we didn't split into 3 possible parts yet case "app-powerdns-recursor": $sa = "app"; $sb = "powerdns-recursor"; $sc = ""; break; case "app-exim-mailqueue": $sa = "app"; $sb = "exim-mailqueue"; $sc = ""; break; default: // default section name: "app-some-sc" list($sa, $sb, $sc) = explode("-", $section, 3); } # DO -NOT- ADD NEW CASES ABOVE -- use <<>> in your application script if ($section != "app-drbd" && !empty($sa) && !empty($sb)) { if (!empty($sc)) { $agent_data[$sa][$sb][$sc] = trim($data); } else { $agent_data[$sa][$sb] = trim($data); } } else { $agent_data[$section] = trim($data); } } $agent_sensors = array(); # Init to empty to be able to use array_merge() later on print_debug_vars($agent_data, 1); include("unix-agent/packages.inc.php"); include("unix-agent/munin-plugins.inc.php"); foreach (array_keys($agent_data) as $key) { if (file_exists($config['install_dir'].'/includes/polling/unix-agent/'.$key.'.inc.php')) { print_debug('Including: unix-agent/'.$key.'.inc.php'); include($config['install_dir'].'/includes/polling/unix-agent/'.$key.'.inc.php'); } else { print_warning("No include: ".$key); } } if (is_array($agent_data['app'])) { foreach (array_keys($agent_data['app']) as $key) { if (file_exists('includes/polling/applications/'.$key.'.inc.php')) { echo(" "); // FIXME Currently only used by drbd to get $app['app_instance'] - shouldn't the drbd parser get instances from somewhere else? // $app = @dbFetchRow("SELECT * FROM `applications` WHERE `device_id` = ? AND `app_type` = ?", array($device['device_id'],$key)); // print_debug('Including: applications/'.$key.'.inc.php'); // echo($key); //include('includes/polling/applications/'.$key.'.inc.php'); $valid_applications[$key] = $key; } } } // Processes // FIXME unused if (!empty($agent_data['ps'])) { echo("\nProcesses: "); foreach (explode("\n", $agent_data['ps']) as $process) { $process = preg_replace("/\((.*),(\d*),(\d*),([\d\.]*)\)\ (.*)/", "\\1|\\2|\\3|\\4|\\5", $process); list($user, $vsz, $rss, $pcpu, $command) = explode("|", $process, 5); $processlist[] = array('user' => $user, 'vsz' => $vsz, 'rss' => $rss, 'pcpu' => $pcpu, 'command' => $command); } #print_vars($processlist); echo("\n"); } } echo("Sensors: "); foreach (array_keys($config['sensor_types']) as $sensor_class) { check_valid_sensors($device, $sensor_class, $valid['sensor'], 'agent'); } echo("\n"); echo("Virtual machines: "); check_valid_virtual_machines($device, $valid['vm'], 'agent'); echo("\n"); //} // EOF