diff options
| author | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-03-11 11:21:34 +0000 |
|---|---|---|
| committer | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-03-11 11:21:34 +0000 |
| commit | 419b228afeba243106a8757543cde23bbdd03189 (patch) | |
| tree | 331a7c47e32f2ca254ca261e6bf650b596c54383 /frontends/php/include/events.inc.php | |
| parent | 9b1c6e98efe2a2a793b959df384db1a337a212ff (diff) | |
| download | zabbix-419b228afeba243106a8757543cde23bbdd03189.tar.gz zabbix-419b228afeba243106a8757543cde23bbdd03189.tar.xz zabbix-419b228afeba243106a8757543cde23bbdd03189.zip | |
- Zabbix1.5.b commit (Artem)
git-svn-id: svn://svn.zabbix.com/trunk@5468 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include/events.inc.php')
| -rw-r--r-- | frontends/php/include/events.inc.php | 216 |
1 files changed, 3 insertions, 213 deletions
diff --git a/frontends/php/include/events.inc.php b/frontends/php/include/events.inc.php index 452238c6..bbfc2bc1 100644 --- a/frontends/php/include/events.inc.php +++ b/frontends/php/include/events.inc.php @@ -19,225 +19,15 @@ **/ ?> <?php - function event_source2str($sourceid) - { - switch($sourceid) - { + function event_source2str($sourceid){ + switch($sourceid){ case EVENT_SOURCE_TRIGGERS: return S_TRIGGERS; case EVENT_SOURCE_DISCOVERY: return S_DISCOVERY; default: return S_UNKNOWN; } } - function get_history_of_triggers_events($start,$num, $groupid=0, $hostid=0){ - global $USER_DETAILS; - $config = select_config(); - - $show_unknown = get_profile('web.events.show_unknown',0); - - $sql_from = $sql_cond = ""; - - $availiable_groups= get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST, null, null, get_current_nodeid()); - $availiable_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_LIST, null, null, get_current_nodeid()); - - if($hostid > 0){ - $sql_cond = " and h.hostid=".$hostid; - } - elseif($groupid > 0){ - $sql_from = ", hosts_groups hg "; - $sql_cond = " and h.hostid=hg.hostid and hg.groupid=".$groupid; - } - else{ - $sql_from = ", hosts_groups hg "; - $sql_cond = " and h.hostid in (".$availiable_hosts.") "; - } - -//--- - $triggers = array(); - $trigger_list = ''; - - $sql = 'SELECT DISTINCT t.triggerid,t.priority,t.description,t.expression,h.host,t.type '. - ' FROM triggers t, functions f, items i, hosts h '.$sql_from. - ' WHERE '.DBin_node('t.triggerid'). - ' AND t.triggerid=f.triggerid '. - ' AND f.itemid=i.itemid '. - ' AND i.hostid=h.hostid '. - ' AND h.status='.HOST_STATUS_MONITORED. - $sql_cond; - - $rez = DBselect($sql); - while($rowz = DBfetch($rez)){ - $triggers[$rowz['triggerid']] = $rowz; - $trigger_list.=$rowz['triggerid'].','; - } - - $trigger_list = '('.trim($trigger_list,',').')'; - $sql_cond=($show_unknown == 0)?(' AND e.value<>'.TRIGGER_VALUE_UNKNOWN.' '):(''); - - $table = new CTableInfo(S_NO_EVENTS_FOUND); - $table->SetHeader(array( - make_sorting_link(S_TIME,'e.eventid'), - is_show_subnodes() ? S_NODE : null, - $hostid == 0 ? S_HOST : null, - S_DESCRIPTION, - S_VALUE, - S_SEVERITY, - S_DURATION, - ($config['event_ack_enable'])?S_ACK:NULL, - S_ACTIONS - )); - - if(!empty($triggers)){ - $sql = 'SELECT e.eventid, e.objectid as triggerid, e.clock, e.value, e.acknowledged '. - ' FROM events e '. - ' WHERE '.zbx_sql_mod('e.object',1000).'='.EVENT_OBJECT_TRIGGER. - ' AND e.objectid IN '.$trigger_list. - $sql_cond. - order_by('e.eventid'); - - $result = DBselect($sql,10*($start+$num)); - } - - $accessible_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY); - - $col=0; - $skip = $start; - - while(!empty($triggers) && ($col<$num) && ($row=DBfetch($result))){ - - if($skip > 0){ - if(($show_unknown == 0) && ($row['value'] == TRIGGER_VALUE_UNKNOWN)) continue; - $skip--; - continue; - } - - if($row["value"] == TRIGGER_VALUE_FALSE){ - $value=new CCol(S_OFF,"off"); - } - elseif($row["value"] == TRIGGER_VALUE_TRUE){ - $value=new CCol(S_ON,"on"); - } - else{ - $value=new CCol(S_UNKNOWN_BIG,"unknown"); - } - - $row = array_merge($triggers[$row['triggerid']],$row); - if((0 == $show_unknown) && (!event_initial_time($row,$show_unknown))) continue; - - $duration = zbx_date2age($row['clock']); - if($next_event = get_next_event($row,$show_unknown)){ - $duration = zbx_date2age($row['clock'],$next_event['clock']); - } -//actions - $actions= new CTable(' - '); - - $sql='SELECT COUNT(a.alertid) as all'. - ' FROM alerts a,functions f,items i,events e'. - ' WHERE a.eventid='.$row['eventid']. - ' AND e.eventid = a.eventid'. - ' AND f.triggerid=e.objectid '. - ' AND i.itemid=f.itemid '. - ' AND i.hostid IN ('.$available_hosts.') '; - - - $alerts=DBfetch(DBselect($sql)); - - if(isset($alerts['all']) && ($alerts['all'] > 0)){ - $mixed = 0; -// Sent - $sql='SELECT COUNT(a.alertid) as sent '. - ' FROM alerts a,functions f,items i,events e'. - ' WHERE a.eventid='.$row['eventid']. - ' AND a.status='.ALERT_STATUS_SENT. - ' AND e.eventid = a.eventid'. - ' AND f.triggerid=e.objectid '. - ' AND i.itemid=f.itemid '. - ' AND i.hostid IN ('.$available_hosts.') '; - - $tmp=DBfetch(DBselect($sql)); - $alerts['sent'] = $tmp['sent']; - $mixed+=($alerts['sent'])?ALERT_STATUS_SENT:0; -// In progress - $sql='SELECT COUNT(a.alertid) as inprogress '. - ' FROM alerts a,functions f,items i,events e'. - ' WHERE a.eventid='.$row['eventid']. - ' AND a.status='.ALERT_STATUS_NOT_SENT. - ' AND e.eventid = a.eventid'. - ' AND f.triggerid=e.objectid '. - ' AND i.itemid=f.itemid '. - ' AND i.hostid IN ('.$available_hosts.') '; - - $tmp=DBfetch(DBselect($sql)); - $alerts['inprogress'] = $tmp['inprogress']; -// Failed - $sql='SELECT COUNT(a.alertid) as failed '. - ' FROM alerts a,functions f,items i,events e'. - ' WHERE a.eventid='.$row['eventid']. - ' AND a.status='.ALERT_STATUS_FAILED. - ' AND e.eventid = a.eventid'. - ' AND f.triggerid=e.objectid '. - ' AND i.itemid=f.itemid '. - ' AND i.hostid IN ('.$available_hosts.') '; - - $tmp=DBfetch(DBselect($sql)); - $alerts['failed'] = $tmp['failed']; - $mixed+=($alerts['failed'])?ALERT_STATUS_FAILED:0; - - - if($alerts['inprogress']){ - $status = new CSpan(S_IN_PROGRESS,'orange'); - } - else if(ALERT_STATUS_SENT == $mixed){ - $status = new CSpan(S_OK,'green'); - } - else if(ALERT_STATUS_FAILED == $mixed){ - $status = new CSpan(S_FAILED,'red'); - } - else{ - $tdl = new CCol(($alerts['sent'])?(new CSpan($alerts['sent'],'green')):SPACE); - $tdl->AddOption('width','10'); - - $tdr = new CCol(($alerts['failed'])?(new CSpan($alerts['failed'],'red')):SPACE); - $tdr->AddOption('width','10'); - - $status = new CRow(array($tdl,$tdr)); - } - - $actions->AddRow($status); - } -//-------- - - if($config['event_ack_enable']){ - if($row['acknowledged'] == 1){ - $ack=new CLink(S_YES,'acknow.php?eventid='.$row['eventid'],'action'); - } - else{ - $ack= new CLink(S_NO,'acknow.php?eventid='.$row['eventid'],'on'); - } - } - - $table->AddRow(array( - date("Y.M.d H:i:s",$row["clock"]), - get_node_name_by_elid($row['triggerid']), - $hostid == 0 ? $row['host'] : null, - new CLink( - expand_trigger_description_by_data($row, ZBX_FLAG_EVENT), - "tr_events.php?triggerid=".$row["triggerid"],"action" - ), - $value, - new CCol(get_severity_description($row["priority"]), get_severity_style($row["priority"])), - $duration, - ($config['event_ack_enable'])?$ack:NULL, - $actions - )); - - $col++; - } - return $table; - } - - function get_history_of_discovery_events($start,$num) - { + function get_history_of_discovery_events($start,$num){ $db_events = DBselect('select distinct e.source,e.object,e.objectid,e.clock,e.value from events e'. ' where e.source='.EVENT_SOURCE_DISCOVERY.' order by e.clock desc', 10*($start+$num) |
