<?php /** * Observium * * This file is part of Observium. * * @package observium * @subpackage poller * @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited * */ if (!empty($agent_data['app']['zimbra'])) { $app_id = discover_app($device, 'zimbra'); update_application($app_id, array()); foreach ($agent_data['app']['zimbra'] as $key => $value) { # key is "vm", "mysql" etc, value is the csv output $zimbra[$key] = parse_csv($value); } if (is_array($zimbra['mtaqueue'])) { /* timestamp, KBytes, requests 04/23/2013 18:19:30, 0, 0 */ rrdtool_update_ng($device, 'zimbra-mtaqueue', array('kBytes' => $zimbra['mtaqueue'][0]['KBytes'], 'requests' => $zimbra['mtaqueue'][0]['requests'])); } if (is_array($zimbra['fd'])) { /* timestamp, fd_count, mailboxd_fd_count 04/23/2013 18:40:53, 5216, 1451 */
$rrd_queries .= "DS:numQueries:DERIVE:600:0:125000000000 "; $rrd_queries .= "DS:numQueryUDP:DERIVE:600:0:125000000000 \\\n DS:numQueryUDP6:DERIVE:600:0:125000000000 \\\n DS:numQueryTCP:DERIVE:600:0:125000000000 \\\n DS:numQueryTCP6:DERIVE:600:0:125000000000 \\\n DS:numQueryEDNS:DERIVE:600:0:125000000000 \\\n DS:numQueryEDNSErr:DERIVE:600:0:125000000000 \\\n DS:numQueryRecieveErr:DERIVE:600:0:125000000000 \\\n DS:numQueryTransferErr:DERIVE:600:0:125000000000 \\\n DS:numRequestAXFR:DERIVE:600:0:125000000000 \\\n DS:numQueryTruncated:DERIVE:600:0:125000000000 \\\n DS:numQueryDropped:DERIVE:600:0:125000000000 \\\n DS:numQueriesWoAA:DERIVE:600:0:125000000000 \\\n "; rrdtool_create($device, $rrd_filename, "" . $rrd_queries); foreach ($dns_qtype as $qtype) { $rrd_values[] = $nsd["num.type.{$qtype}"]; } $rrd_values[] = $nsd["num.class.IN"]; foreach ($dns_rcode as $rcode) { $rrd_values[] = $nsd["num.rcode.{$rcode}"]; } $rrd_values[] = $nsd["num.opcode.IN"]; $rrd_values[] = $nsd["num.queries"]; foreach (array('num.udp', 'num.udp6', 'num.tcp', 'num.tcp6', 'num.edns', 'num.ednserr', 'num.rxerr', 'num.txerr', 'num.raxfr', 'num.truncated', 'num.dropped', 'num.answer_wo_aa') as $key) { $rrd_values[] = $nsd[$key]; } update_application($app_id, $nsd); rrdtool_update($device, $rrd_filename, "N:" . implode(':', $rrd_values)); unset($rrd_values); $serverNum = 0; while (1) { if (isset($nsd["server{$serverNum}.queries"])) { $rrd_filename = "app-nsd-server{$serverNum}.rrd"; rrdtool_create($device, $rrd_filename, "DS:numQueries:DERIVE:600:0:125000000000"); rrdtool_update($device, $rrd_filename, "N:" . $nsd["server{$serverNum}.queries"]); $serverNum++; } else { break; } } unset($serverNum); }
<?php /** * Observium * * This file is part of Observium. * * @package observium * @subpackage poller * @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited * */ // Correct output of the agent script should look like this: //<<<exim-mailqueue>>> //frozen:173 //bounces:1052 //total:2496 //active:2323 if (!empty($agent_data['app']['exim-mailqueue'])) { $app_id = discover_app($device, 'exim-mailqueue'); foreach (explode("\n", $agent_data['app']['exim-mailqueue']) as $line) { list($item, $value) = explode(":", $line, 2); $exim_data[trim($item)] = trim($value); } update_application($app_id, $exim_data); rrdtool_update_ng($device, 'exim-mailqueue', $exim_data, $app_id); unset($line, $item, $value, $exim_data, $app_id); } // EOF
* * @package observium * @subpackage poller * @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited * */ if (!empty($agent_data['app']['mysql'])) { $app_id = discover_app($device, 'mysql'); $map = array(); foreach (explode("\n", $agent_data['app']['mysql']) as $str) { list($key, $value) = explode(":", $str); $map[$key] = trim($value); } // General Stats $mapping = array('IDBLBSe' => 'cr', 'IBLFh' => 'ct', 'IBLWn' => 'cu', 'IBLWn' => 'cu', 'SRows' => 'ck', 'SRange' => 'cj', 'SMPs' => 'ci', 'SScan' => 'cl', 'IBIRd' => 'ai', 'IBIWr' => 'aj', 'IBILg' => 'ak', 'IBIFSc' => 'ah', 'IDBRDd' => 'b2', 'IDBRId' => 'b0', 'IDBRRd' => 'b3', 'IDBRUd' => 'b1', 'IBRd' => 'ae', 'IBCd' => 'af', 'IBWr' => 'ag', 'TLIe' => 'b5', 'TLWd' => 'b4', 'IBPse' => 'aa', 'IBPDBp' => 'ac', 'IBPFe' => 'ab', 'IBPMps' => 'ad', 'TOC' => 'bc', 'OFs' => 'b7', 'OTs' => 'b8', 'OdTs' => 'b9', 'IBSRs' => 'ay', 'IBSWs' => 'ax', 'IBOWs' => 'az', 'QCs' => 'c1', 'QCeFy' => 'bu', 'MaCs' => 'bl', 'MUCs' => 'bf', 'ACs' => 'bd', 'AdCs' => 'be', 'TCd' => 'bi', 'Cs' => 'bn', 'IBTNx' => 'a5', 'KRRs' => 'a0', 'KRs' => 'a1', 'KWR' => 'a2', 'KWs' => 'a3', 'QCQICe' => 'bz', 'QCHs' => 'bv', 'QCIs' => 'bw', 'QCNCd' => 'by', 'QCLMPs' => 'bx', 'CTMPDTs' => 'cn', 'CTMPTs' => 'cm', 'CTMPFs' => 'co', 'IBIIs' => 'au', 'IBIMRd' => 'av', 'IBIMs' => 'aw', 'IBILog' => 'al', 'IBISc' => 'am', 'IBIFLg' => 'an', 'IBFBl' => 'aq', 'IBIIAo' => 'ap', 'IBIAd' => 'as', 'IBIAe' => 'at', 'SFJn' => 'cd', 'SFRJn' => 'ce', 'SRe' => 'cf', 'SRCk' => 'cg', 'SSn' => 'ch', 'SQs' => 'b6', 'BRd' => 'cq', 'BSt' => 'cp', 'CDe' => 'c6', 'CIt' => 'c4', 'CISt' => 'ca', 'CLd' => 'c8', 'CRe' => 'c7', 'CRSt' => 'cc', 'CSt' => 'c5', 'CUe' => 'c3', 'CUMi' => 'c9'); $values = array(); foreach ($mapping as $key => $value) { $values[$key] = $map[$value]; } rrdtool_update_ng($device, 'mysql', $values, $app_id); // Process state statistics // Derr, not sure what the key part of the array is for, apart from some documentation, as d* is passed from agent into RRD. $mapping_status = array('State_closing_tables' => 'd2', 'State_copying_to_tmp_table' => 'd3', 'State_end' => 'd4', 'State_freeing_items' => 'd5', 'State_init' => 'd6', 'State_locked' => 'd7', 'State_login' => 'd8', 'State_preparing' => 'd9', 'State_reading_from_net' => 'da', 'State_sending_data' => 'db', 'State_sorting_result' => 'dc', 'State_statistics' => 'dd', 'State_updating' => 'de', 'State_writing_to_net' => 'df', 'State_none' => 'dg', 'State_other' => 'dh'); $valuesb = array(); foreach ($mapping_status as $key => $value) { $valuesb[$value] = $map[$value]; } update_application($app_id, array_merge($values, $valuesb)); rrdtool_update_ng($device, 'mysql-status', $valuesb, $app_id); } // EOF
function db_save_application($name, $hostid, $applicationid = null, $templateid = 0) { if (!is_string($name)) { error('Incorrect parameters for "db_save_application"'); return false; } $host = get_host_by_hostid($hostid); $hostids = array(); $db_hosts = get_hosts_by_templateid($host['hostid']); while ($db_host = DBfetch($db_hosts)) { $hostids[] = $db_host['hostid']; } $sql = 'SELECT applicationid FROM applications WHERE name=' . zbx_dbstr($name) . ' AND ' . DBcondition('hostid', $hostids); $lower_app = DBfetch(DBselect($sql)); if ($lower_app) { error(S_APPLICATION . SPACE . "'{$name}'" . SPACE . S_ALREADY_EXISTS_IN_LINKED_HOSTS_SMALL); return false; } $sql = 'SELECT applicationid FROM applications WHERE name=' . zbx_dbstr($name) . ' AND hostid=' . $hostid; if (!is_null($applicationid)) { $sql .= ' AND applicationid<>' . $applicationid; } $db_app = DBfetch(DBselect($sql)); if ($db_app && $templateid == 0) { error(S_APPLICATION . SPACE . "'{$name}'" . SPACE . S_ALREADY_EXISTS_SMALL); return false; } if ($db_app && !is_null($applicationid)) { // delete old application with same name delete_application($db_app['applicationid']); } if ($db_app && is_null($applicationid)) { // if found application with same name update them, adding not needed $applicationid = $db_app['applicationid']; } if (is_null($applicationid)) { $applicationid_new = get_dbid('applications', 'applicationid'); $sql = 'INSERT INTO applications (applicationid, name, hostid, templateid) ' . " VALUES ({$applicationid_new}, " . zbx_dbstr($name) . ", {$hostid}, {$templateid})"; if ($result = DBexecute($sql)) { info(S_ADDED_NEW_APPLICATION . SPACE . $host['host'] . ':' . $name); } } else { $old_app = get_application_by_applicationid($applicationid); $result = DBexecute('UPDATE applications SET name=' . zbx_dbstr($name) . ', hostid=' . $hostid . ', templateid=' . $templateid . ' WHERE applicationid=' . $applicationid); if ($result) { info(S_UPDATED_APPLICATION . SPACE . $host['host'] . ':' . $old_app['name']); } } if (!$result) { return $result; } if (is_null($applicationid)) { // create application for childs $applicationid = $applicationid_new; $db_childs = get_hosts_by_templateid($hostid); while ($db_child = DBfetch($db_childs)) { // recursion $result = add_application($name, $db_child['hostid'], $applicationid); if (!$result) { break; } } } else { $db_applications = get_applications_by_templateid($applicationid); while ($db_app = DBfetch($db_applications)) { // recursion $result = update_application($db_app['applicationid'], $name, $db_app['hostid'], $applicationid); if (!$result) { break; } } } if ($result) { return $applicationid; } if ($templateid == 0) { delete_application($applicationid); } return false; }
<?php /** * Observium * * This file is part of Observium. * * @package observium * @subpackage poller * @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited * */ if (!empty($agent_data['app']['asterisk'])) { $app_id = discover_app($device, 'asterisk'); foreach (explode("\n", $agent_data['app']['asterisk']) as $line) { list($key, $val) = explode(":", $line); $asterisk_data[trim($key)] = intval(trim($val)); } update_application($app_id, $asterisk_data); rrdtool_update_ng($device, 'asterisk', $asterisk_data, $app_id); unset($key, $line, $val, $asterisk_data, $app_id); } // EOF
function db_save_application($name, $hostid, $applicationid = null, $templateid = 0) { if (!is_string($name)) { error("Incorrect parameters for 'db_save_application'"); return false; } if (is_null($applicationid)) { $result = DBselect('SELECT * FROM applications WHERE name=' . zbx_dbstr($name) . ' AND hostid=' . $hostid); } else { $result = DBselect('SELECT * ' . ' FROM applications ' . ' WHERE name=' . zbx_dbstr($name) . ' AND hostid=' . $hostid . ' AND applicationid<>' . $applicationid); } $db_app = DBfetch($result); if ($db_app && $templateid == 0) { error('Application "' . $name . '" already exists'); return false; } if ($db_app && $applicationid != null) { // delete old application with same name delete_application($db_app["applicationid"]); } if ($db_app && $applicationid == null) { // if found application with same name update them, adding not needed $applicationid = $db_app["applicationid"]; } $host = get_host_by_hostid($hostid); if (is_null($applicationid)) { $applicationid_new = get_dbid('applications', 'applicationid'); $sql = 'INSERT INTO applications (applicationid,name,hostid,templateid) ' . " VALUES ({$applicationid_new}," . zbx_dbstr($name) . ",{$hostid},{$templateid})"; if ($result = DBexecute($sql)) { info("Added new application " . $host["host"] . ":{$name}"); } } else { $old_app = get_application_by_applicationid($applicationid); if ($result = DBexecute('UPDATE applications ' . ' SET name=' . zbx_dbstr($name) . ',hostid=' . $hostid . ',templateid=' . $templateid . ' WHERE applicationid=' . $applicationid)) { info("Updated application " . $host["host"] . ":" . $old_app["name"]); } } if (!$result) { return $result; } if (is_null($applicationid)) { // create application for childs $applicationid = $applicationid_new; $db_childs = get_hosts_by_templateid($hostid); while ($db_child = DBfetch($db_childs)) { // recursion $result = add_application($name, $db_child["hostid"], $applicationid); if (!$result) { break; } } } else { $db_applications = get_applications_by_templateid($applicationid); while ($db_app = DBfetch($db_applications)) { // recursion $result = update_application($db_app["applicationid"], $name, $db_app["hostid"], $applicationid); if (!$result) { break; } } } if ($result) { return $applicationid; } if ($templateid == 0) { delete_application($applicationid); } return false; }
/** * Observium * * This file is part of Observium. * * @package observium * @subpackage poller * @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited * */ if (is_array($agent_data['app']['openvpn'])) { foreach ($agent_data['app']['openvpn'] as $key => $entry) { if (substr($key, 0, 9) == 'loadstats') { list(, $instance) = explode('-', $key, 2); $loadstats[$instance] = array(); # SUCCESS: nclients=1,bytesin=484758,bytesout=180629 foreach (explode(',', str_replace('SUCCESS: ', '', $entry)) as $keyvalue) { list($key, $value) = explode('=', $keyvalue, 2); $loadstats[$instance][$key] = $value; } } } } foreach ($loadstats as $instance => $data) { $app_id = discover_app($device, 'openvpn', $instance); update_application($app_id, $data); rrdtool_update_ng($device, 'openvpn', $data, $instance); } unset($loadstats); // EOF
<?php /** * Observium * * This file is part of Observium. * * @package observium * @subpackage poller * @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited * */ if (!empty($agent_data['app']['postfix_qshape'])) { $app_id = discover_app($device, 'postfix_qshape'); foreach (explode("\n", $agent_data['app']['postfix_qshape']) as $line) { list($item, $value) = explode(":", $line, 2); $queue_data[trim($item)] = trim($value); } rrdtool_update_ng($device, 'postfix-qshape', $queue_data); update_application($app_id, $queue_data); unset($queue_data, $item, $value); } // EOF
<?php /** * Observium * * This file is part of Observium. * * @package observium * @subpackage poller * @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited * */ if (!empty($agent_data['app']['ntpd'])) { $app_id = discover_app($device, 'ntpd'); foreach (explode("\n", $agent_data['app']['ntpd']) as $line) { list($item, $value) = explode(":", $line, 2); $ntpd_data[trim($item)] = trim($value); } $ntpd_type = isset($ntpd_data['server']) ? "server" : "client"; switch ($ntpd_type) { case 'server': rrdtool_update_ng($device, 'ntpd-server', $ntpd_data, $app_id); break; case 'client': rrdtool_update_ng($device, 'ntpd-client', $ntpd_data, $app_id); break; } update_application($app_id, $ntpd_data); unset($ntpd_type, $app_id, $ntpd_data); } // EOF
<?php /** * Observium * * This file is part of Observium. * * @package observium * @subpackage poller * @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited * */ if (!empty($agent_data['app']['postgresql'])) { $app_id = discover_app($device, 'postgresql'); foreach (explode("\n", $agent_data['app']['postgresql']) as $line) { list($item, $value) = explode(":", $line, 2); $pgsql_data[trim($item)] = trim($value); } // there are differences between stats in postgresql 8.x and 9.x // if $pgsql_data['version'] rrdtool_update_ng($device, 'postgresql', $pgsql_data, $app_id); update_application($app_id, $pgsql_data); unset($app_id, $pgsql_data, $item, $value, $line); } // EOF
function update_workflow(&$application, $approved = true, $data = null) { $approver_email = ''; // Update the application record if ($application->approval_level == 0) { // Being submitted /* $application->approval_level = 1; $approver_email = $application->manager_email; } else if ($application->approval_level == 1) { // Manager $application->approval_1_comment = $data->comment; $application->approval_1_date = time(); if (!$approved) { $application->approval_state = 1; // Rejected } else*/ if ($application->self_funding == 0) { $application->approval_level = 2; // Funder $application->funding_id = $data->funding_organisation; if ($application->funding_id == 0) { // 'Other Organisation' $application->funding_organisation = ''; $application->funder_email = $data->funder_email; // Must have been given } else { // A known organisation with a fixed email address $organisation = read_organisation($application->funding_id); $application->funding_organisation = $organisation->name; $application->funder_email = $organisation->email; } $approver_email = $application->funder_email; } else { $application->approval_level = 3; // Brookes $hls = get_complete_user_data('username', 'hls'); $approver_email = $hls->email; } } else { if ($application->approval_level == 2) { // Funder $application->approval_2_comment = $data->comment; $application->approval_2_date = time(); if (!$approved) { $application->approval_state = 1; // Rejected } else { $application->approval_level = 3; // Brookes // Store the funding details if ($application->funding_organisation != '') { // NHS trust (previously selected by the manager) $application->funding_method = $data->funding_method; $application->funder_name = $data->funder_name; if ($application->funding_method == 1) { // Invoice $application->invoice_ref = $data->invoice_ref; $application->invoice_address = $data->invoice_address; $application->invoice_email = $data->invoice_email; $application->invoice_phone = $data->invoice_phone; $application->invoice_contact = $data->invoice_contact; } } else { // Must be an invoice to a non-NHS organisation $application->funding_method = 0; $application->funding_organisation = $data->organisation; $application->invoice_ref = $data->invoice_ref; $application->invoice_address = $data->invoice_address; $application->invoice_email = $data->invoice_email; $application->invoice_phone = $data->invoice_phone; $application->invoice_contact = $data->invoice_contact; } $hls = get_complete_user_data('username', 'hls'); $approver_email = $hls->email; } } else { // Brookes $application->approval_3_comment = $data->comment; $application->approval_3_date = time(); if (!$approved) { $application->approval_state = 1; // Rejected } else { $application->approval_state = 2; // It ends here } } } update_application($application); // Update the stored approval requests and send notification emails update_approver($application, $approver_email); }
$crashplan_data = json_decode($agent_data['app']['crashplan']['server'], TRUE); if (is_array($crashplan_data['data']['servers'])) { # [serverName] => crashplan.luciad.com # [totalBytes] => 16995951050752 # [usedBytes] => 16322661449728 # [usedPercentage] => 96 # [freeBytes] => 673289601024 # [freePercentage] => 4 # [coldBytes] => 3762904182328 # [coldPercentageOfUsed] => 23 # [coldPercentageOfTotal] => 22 # [archiveBytes] => 11678769817966 # [selectedBytes] => 19313807393642 # [remainingBytes] => 379281681813 # [inboundBandwidth] => 53 # [outboundBandwidth] => 67 # [orgCount] => 1 # [userCount] => 83 # [computerCount] => 97 # [onlineComputerCount] => 27 # [backupSessionCount] => 0 foreach ($crashplan_data['data']['servers'] as $crashplan_server) { $crashplan_servers[] = $crashplan_server['serverName']; update_application($app_id, $crashplan_data); rrdtool_update_ng($device, 'crashplan', array('totalBytes' => $crashplan_server['totalBytes'], 'usedBytes' => $crashplan_server['usedBytes'], 'usedPercentage' => $crashplan_server['usedPercentage'], 'freeBytes' => $crashplan_server['freeBytes'], 'freePercentage' => $crashplan_server['freePercentage'], 'coldBytes' => $crashplan_server['coldBytes'], 'coldPctOfUsed' => $crashplan_server['coldPercentageOfUsed'], 'coldPctOfTotal' => $crashplan_server['coldPercentageOfTotal'], 'archiveBytes' => $crashplan_server['archiveBytes'], 'selectedBytes' => $crashplan_server['selectedBytes'], 'remainingBytes' => $crashplan_server['remainingBytes'], 'inboundBandwidth' => $crashplan_server['inboundBandwidth'], 'outboundBandwidth' => $crashplan_server['outboundBandwidth'], 'orgCount' => $crashplan_server['orgCount'], 'userCount' => $crashplan_server['userCount'], 'computerCount' => $crashplan_server['computerCount'], 'onlineComputerCount' => $crashplan_server['onlineComputerCount'], 'backupSessionCount' => $crashplan_server['backupSessionCount']), $crashplan_server['serverName']); } # Set list of servers as device attribute so we can use it in the web interface set_dev_attrib($device, 'crashplan_servers', json_encode($crashplan_servers)); } } // EOF
<?php /** * Observium * * This file is part of Observium. * * @package observium * @subpackage poller * @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited * */ // FIXME - INSTANCES if (!empty($agent_data['app']['shoutcast'])) { $app_id = discover_app($device, 'shoutcast'); // Polls shoutcast statistics from agent script $servers = explode("\n", $agent_data['app']['shoutcast']); $data = array(); foreach ($servers as $item => $server) { $server = trim($server); if (!empty($server)) { $data = explode(";", $server); list($host, $port) = explode(":", $data[0], 2); $stats[$data[0]] = array('bitrate' => $data[1], 'traf_in' => $data[2], 'traf_out' => $data[3], 'current' => $data[4], 'status' => $data[5], 'peak' => $data[6], 'max' => $data[7], 'unique' => $data[8]); rrdtool_update_ng($device, 'shoutcast', $stats[$data[0]], "{$app_id}-" . $host . "_" . $port); } } update_application($app_id, $stats); unset($app_id, $host, $port, $data, $servers, $server, $item); } // EOF
$API->error($API->LANG->_('There is something wrong with your torrent file')); } // do not preform cheks on torrents //$torrent->announce(false); //$torrent->announce(array('http://pixi.appaddict.org:2710/announce')); $magnet = $torrent->magnet(); } require_once 'itgw.inc.php'; $data = get_itunes_info($trackid, $type, $store); if (!$appdata && !$data) { $API->TPL->assign('trackid', $trackid); $API->TPL->display('no-app-error-itunes.tpl'); die; } elseif ($data) { $data['last_parse_itunes'] = $data; update_application($data, $trackid); } if (!$appdata && $data) { if ($data['price'] == 'Free') { $paidfreeapps = $API->DB->query_row("SELECT (SELECT COUNT(DISTINCT links.trackid) FROM links LEFT JOIN apps ON links.trackid=apps.trackid WHERE apps.price='Free' AND links.uploader_id={$API->account['id']}) AS free, (SELECT COUNT(DISTINCT links.trackid) FROM links LEFT JOIN apps ON links.trackid=apps.trackid WHERE apps.price!='Free' AND links.uploader_id={$API->account['id']}) AS paid"); $paid_apps = $paidfreeapps['paid']; $free_apps = $paidfreeapps['free']; if ($free_apps > $paid_apps) { $API->error($API->LANG->_('FREE_CONTENT_UPLOAD_ERROR', $paid_apps, $free_apps)); } } $success = upload_application($data); if (!$success) { $API->error($API->LANG->_('There is an error with your upload.')); } } elseif (!$data) {
if (!uint_in_array($db_host['groupid'], $groups)) { continue; } $host = get_host_by_hostid($db_host['hostid']); $result &= update_host_status($db_host['hostid'], $status); /* add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_HOST, 'Old status ['.$host['status'].'] '.'New status ['.$status.']');*/ } $result = DBend($result); show_messages($result, S_HOST_STATUS_UPDATED, S_CANNOT_UPDATE_HOST); unset($_REQUEST['activate']); } if ($_REQUEST['config'] == 4 && isset($_REQUEST['save'])) { DBstart(); if (isset($_REQUEST['applicationid'])) { $result = update_application($_REQUEST['applicationid'], $_REQUEST['appname'], $_REQUEST['apphostid']); $action = AUDIT_ACTION_UPDATE; $msg_ok = S_APPLICATION_UPDATED; $msg_fail = S_CANNOT_UPDATE_APPLICATION; $applicationid = $_REQUEST['applicationid']; } else { $applicationid = add_application($_REQUEST['appname'], $_REQUEST['apphostid']); $action = AUDIT_ACTION_ADD; $msg_ok = S_APPLICATION_ADDED; $msg_fail = S_CANNOT_ADD_APPLICATION; } $result = DBend($applicationid); show_messages($result, $msg_ok, $msg_fail); if ($result) { add_audit($action, AUDIT_RESOURCE_APPLICATION, S_APPLICATION . ' [' . $_REQUEST['appname'] . ' ] [' . $applicationid . ']'); unset($_REQUEST['form']);
<?php /** * Observium * * This file is part of Observium. * * @package observium * @subpackage poller * @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited * */ if (!empty($agent_data['app']['apache'])) { $app_id = discover_app($device, 'apache'); list($total_access, $total_kbyte, $cpuload, $uptime, $reqpersec, $bytespersec, $bytesperreq, $busyworkers, $idleworkers, $score_wait, $score_start, $score_reading, $score_writing, $score_keepalive, $score_dns, $score_closing, $score_logging, $score_graceful, $score_idle, $score_open) = explode("\n", $agent_data['app']['apache']); update_application($app_id, array('access' => $total_access, 'kbyte' => $total_kbyte, 'cpu' => $cpuload, 'uptime' => $uptime, 'reqpersec' => $reqpersec, 'bytespersec' => $bytespersec, 'byesperreq' => $bytesperreq, 'busyworkers' => $busyworkers, 'idleworkers' => $idleworkers, 'sb_wait' => $score_wait, 'sb_start' => $score_start, 'sb_reading' => $score_reading, 'sb_writing' => $score_writing, 'sb_keepalive' => $score_keepalive, 'sb_dns' => $score_dns, 'sb_closing' => $score_closing, 'sb_logging' => $score_logging, 'sb_graceful' => $score_graceful, 'sb_idle' => $score_idle, 'sb_open' => $score_open)); rrdtool_update_ng($device, 'apache', array('access' => $total_access, 'kbyte' => $total_kbyte, 'cpu' => $cpuload, 'uptime' => $uptime, 'reqpersec' => $reqpersec, 'bytespersec' => $bytespersec, 'byesperreq' => $bytesperreq, 'busyworkers' => $busyworkers, 'idleworkers' => $idleworkers, 'sb_wait' => $score_wait, 'sb_start' => $score_start, 'sb_reading' => $score_reading, 'sb_writing' => $score_writing, 'sb_keepalive' => $score_keepalive, 'sb_dns' => $score_dns, 'sb_closing' => $score_closing, 'sb_logging' => $score_logging, 'sb_graceful' => $score_graceful, 'sb_idle' => $score_idle, 'sb_open' => $score_open), $app_id); } // EOF
* Observium * * This file is part of Observium. * * @package observium * @subpackage poller * @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited * */ //<<<app-vmwaretools>>> //vmtotalmem:2051 //vmswap:117 //vmballoon:1302 //vmmemres:256 //vmmemlimit:U //vmspeed:2660000000 //vmcpulimit:U //vmcpures:0 if (!empty($agent_data['app']['vmwaretools'])) { $app_id = discover_app($device, 'vmwaretools'); // Parse the data, first try key:value format foreach (explode("\n", $agent_data['app']['vmwaretools']) as $line) { // Parse key:value line list($key, $value) = explode(':', $line, 2); $values[$key] = $value; } rrdtool_update_ng($device, 'vmwaretools', $values, $app_id); update_application($app_id, $values); unset($values, $app_id); } // EOF
/** * Update Applications * * @param _array $applications * @param array $app_data['name'] * @param array $app_data['hostid'] * @return boolean */ public static function update($applications) { $applications = zbx_toArray($applications); $applicationids = zbx_objectValues($applications, 'applicationid'); try { self::BeginTransaction(__METHOD__); $options = array('applicationids' => $applicationids, 'editable' => 1, 'output' => API_OUTPUT_EXTEND, 'preservekeys' => 1); $upd_applications = self::get($options); foreach ($applications as $anum => $application) { if (!isset($upd_applications[$application['applicationid']])) { self::exception(ZBX_API_ERROR_PERMISSIONS, S_NO_PERMISSIONS); } } foreach ($applications as $anum => $application) { $application_db_fields = $upd_applications[$application['applicationid']]; $host = reset($application_db_fields['hosts']); if (!check_db_fields($application_db_fields, $application)) { self::exception(ZBX_API_ERROR_PARAMETERS, S_INCORRECT_FIELDS_FOR_APPLICATIONS); } $result = update_application($application['applicationid'], $application['name'], $host['hostid']); if (!$result) { self::exception(ZBX_API_ERROR_PARAMETERS, S_CANNOT_UPDATE_APPLICATION); } } self::EndTransaction(true, __METHOD__); return array('applicationids' => $applicationids); } catch (APIException $e) { self::EndTransaction(false, __METHOD__); $error = $e->getErrors(); $error = reset($error); self::setError(__METHOD__, $e->getCode(), $error); return false; } }
if ($application->approval_state > 0) { // Already finally approved or rejected? $message = get_string('application_unavailable', 'local_obu_application'); } else { $message = ''; } $mform = new mdl_redirect_form(null, $parameters); if ($mform->is_cancelled()) { redirect($home); } if ($mform_data = $mform->get_data()) { if ($mform_data->submitbutton == get_string('save', 'local_obu_application')) { if ($application->approval_level == 1) { $application->manager_email = $approver_email; } else { $application->funder_email = $approver_email; } update_application($application); update_approver($application, $approver_email); // Update the approvals and send notification emails redirect($home); } } echo $OUTPUT->header(); echo $OUTPUT->heading($heading); if ($message) { notice($message, $url); } else { $mform->display(); } echo $OUTPUT->footer();
ep:(?P<ep>\\S+)\\s+ wo:(?P<wo>\\S+)\\s+ oos:(?P<oos>\\S+)\\R ~xm'; $outerkeys = array("version", "api", "proto", "srcversion"); $innerkeys = array("devno", "cs", "ro", "ds", "rep", "io", 'ns', 'nr', 'dw', 'dr', 'al', 'bm', 'lo', 'pe', 'ua', 'ap', 'ep', 'wo', 'oos'); $output = array(); preg_match_all($outerregex, $agent_data['app']['drbd'] . PHP_EOL, $matches, PREG_SET_ORDER); foreach ($matches as $match) { foreach ($outerkeys as $key) { $arr[$key] = $match[$key]; } preg_match_all($innerregex, $match["devices"], $innermatches, PREG_SET_ORDER); $arr["devices"] = array(); foreach ($innermatches as $innermatch) { $tmp = array(); foreach ($innerkeys as $key) { $tmp[$key] = $innermatch[$key]; } $arr["devices"][] = $tmp; } $output = $arr; } foreach ($output['devices'] as $drbd_dev) { $app_instance = "drbd" . $drbd_dev['devno']; $app_id = discover_app($device, 'drbd', $app_instance); update_application($app_id, $drbd_dev); rrdtool_update_ng($device, 'drbd', $drbd_dev, $app_instance); unset($drbd_dev); } // EOF