log(__CLASS__, "processAlarm($inst_addr, $evt_time, $evt_spec, $serv_infl, $perc_sev, $src_host_name, $src_host_addr)"); try { $if = new AlarmManagement(); $serv_infl_inst = null; if ($serv_infl) $serv_infl_inst = new ServInfl($serv_infl); $perc_sev_inst = null; if ($perc_sev) $perc_sev_inst = new AlarmSevty($perc_sev); $if->processAlarm ( new InstAddr($inst_addr), // instance address $evt_time, // event time new EventSpec($evt_spec), // event specification $serv_infl_inst, // service influence $perc_sev_inst, // perceived severity $src_host_name, // source host name (local if null) new HostAddr($src_host_addr));// source host address } catch(Exception $e) { $logger->logException(__CLASS__, $e); return 99; } return 0; } /** * Set or reset an alarm (full featured) * @return int to be defined (greater 0: error values) * @param string $inst_addr Instance Address: alarm source * @param int $evt_time UNIX time * @param string $evt_spec Event Specification: alarm course * @param string $serv_infl Service influence: SRV_AFF, SRV_NAFF, SRV_IDP * @param string $perc_sev perceived severity * @param string $src_host_name source host name (local if null) * @param string $src_host_addr source host address */ public function processAlarmAsync ( $inst_addr, // instance address $evt_time, // event time $evt_spec, // event specification $serv_infl = null, // service influence $perc_sev = null, // perceived severity $src_host_name, // source host name (local if null) $src_host_addr // source host address ) { require_once 'util/XmlFormatter.php'; $logger = Logger::getInstance(); $logger->log(__CLASS__, "processAlarmAsync ( InstAddr $inst_addr, evt_time $evt_time, EventSpec $evt_spec, ServInfl $serv_infl, AlarmSevty $perc_sev, src_host_name $src_host_name, src_host_addr $src_host_addr)"); // write xml file $xmlFormatter = new XmlFormatter(); $xmlFormatter->initResult(); // write root element $attrs = array (); $xmlFormatter->formatElement(XmlFormatter::FC_BEG, "RemoteCall", null, $attrs); // write action element $attrs["interface"] = "AlarmManagement"; $attrs["procedure"] = "processAlarm"; $xmlFormatter->formatElement(XmlFormatter::FC_BEG, "action", null, $attrs); // add parameters $param = array(); $param["name"] = "InstanceAddress"; $param["value"] = $inst_addr; $xmlFormatter->formatElement(XmlFormatter::FC_SGL, "parameter", null, $param); $param["name"] = "EventTime"; $param["value"] = $evt_time; $xmlFormatter->formatElement(XmlFormatter::FC_SGL, "parameter", null, $param); $param["name"] = "EventSpecification"; $param["value"] = $evt_spec; $xmlFormatter->formatElement(XmlFormatter::FC_SGL, "parameter", null, $param); $param["name"] = "ServiceInfluence"; $param["value"] = $serv_infl; $xmlFormatter->formatElement(XmlFormatter::FC_SGL, "parameter", null, $param); if($perc_sev != "") { $param["name"] = "AlarmSeverity"; $param["value"] = $perc_sev; $xmlFormatter->formatElement(XmlFormatter::FC_SGL, "parameter", null, $param); } $param["name"] = "SourceHostName"; $param["value"] = $src_host_name; $xmlFormatter->formatElement(XmlFormatter::FC_SGL, "parameter", null, $param); $param["name"] = "SourceHostAddress"; $param["value"] = $src_host_addr; $xmlFormatter->formatElement(XmlFormatter::FC_SGL, "parameter", null, $param); $xmlFormatter->formatElement(XmlFormatter::FC_END, null, null, null); $xmlFormatter->finish(); // write xml to file $xml = $xmlFormatter->printIt(); $fn = "/tmp/request".rand().".xml.tmp"; $fp = fopen($fn, 'w'); fwrite($fp, $xml); fclose($fp); // async execution $ret = shell_exec("/usr/share/php/SysAl/AlarmInterface/RemoteInterface/call_php_async $fn"); if ($ret === null) return 99; $ret = trim($ret); if ($ret != "0") { $logger->log(__CLASS__, "call_php_async failed: $ret"); return 99; } return 0; } }