find(); $bes_lst = BalancingEventSelectorQuery::create()->findByAedId($aed_id); foreach ($abm_lst as $abm) { $abm_id = $abm->getId(); if ($abm->getEvtSelMode()->getValue() == SelectMode::SM_EXCL) { $prc_abm = TRUE; foreach ($bes_lst as $bes) { if ($bes->getAbmId() == $abm_id) { $prc_abm = FALSE; break; } } } else { $prc_abm = FALSE; foreach ($bes_lst as $bes) { if ($bes->getAbmId() == $abm_id) { $prc_abm = TRUE; break; } } } if ($prc_abm) { if ($alm_stat->getValue() != AlarmStatus::AS_CLEAR) { // calculate new unconfirmed balance $old_ufd_bal = $abm->getUncfdAstaBal(); $ufd_bal = $abm->getUncfdAstaBal(); $abm->setUncfdAstaBal($ufd_bal->accu($alm_stat)); $abm->save(); $max_alm_stat = $alm_stat; } if ($alm_stat->getValue() == AlarmStatus::AS_CLEAR || $thr_alm_clr) { // recalculate alarm balance $calc_bal = $abm->getRecalculatedBalance(); // reset unused severities $old_ufd_bal = $abm->getUncfdAstaBal(); $ufd_bal = $abm->getUncfdAstaBal(); $abm->setUncfdAstaBal($ufd_bal->cut($calc_bal)); $cfd_bal = $abm->getCfdAstaBal(); $abm->setCfdAstaBal($cfd_bal->cut($calc_bal)); // check for forgotten severities $calc_bal->substract($cfd_bal); $abm->setUncfdAstaBal($ufd_bal->join($calc_bal)); $abm->save(); // determine new unconfirmed max alarm status for escalation check $max_alm_stat = $ufd_bal->max(); } // escalation if new max unconfirmed alarm status higher than old // or recently cleared if (( $old_ufd_bal->max()->less($max_alm_stat) || ( $max_alm_stat->getValue() == AlarmStatus::AS_CLEAR && $max_alm_stat->less($old_ufd_bal->max()) ) ) && count($esc_host_sel = $abm->getEscHostSel()) > 0) { // determine escalation host addresses if (!isset($amh_lst)) $amh_lst = AlarmingManagementHostQuery::create()->find(); $host_lst = array(); foreach ($amh_lst as $amh) { if (in_array($amh->getId(), $esc_host_sel)) { $host_lst[] = $amh; } } if (!isset($myhost)) { $myhost = AlarmingManagementHostQuery::create()->findOneByLocal(true); if ($myhost === null) throw new Exception("no local management host."); $myhostname = $myhost->getHostAddr(); if ($myhostname->equals(new HostAddr(HostAddrSel::NAME, "localhost"))) { // thats too generic, try a better name $hostname = shell_exec("hostname"); //TODO: Das muss das CR hinten weg! if ($hostname > "") $myhostname = new HostAddr(HostAddrSel::NAME, $hostname); else throw new Exception("Cannot get a reasonable hostname."); } } // store escalation info $inst_addr_sel = InstAddrSel::fromHostAddrSel($myhostname->getSelector()); $esc_inf_lst[] = array( 'tgt_hosts' => $host_lst, 'inst' => new InstAddr($inst_addr_sel->getValue(), $myhostname->getValue()), 'event' => new EventSpec(EventSel::ABM_ESC, $abm->getName()), 'sevty' => new AlarmSevty($max_alm_stat->getValue()) ); } } } } } ?>