X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=www%2Fsiteactions.php;fp=www%2Fsiteactions.php;h=7d935013f976ecd8ed2a5739e7c02b2bae061a22;hb=7fb16f5280e051758cfe5de4bf034f4be3f275a3;hp=0000000000000000000000000000000000000000;hpb=8ed0efd101dc969d4d0218829a3c0f689607f0e2;p=monitor.git diff --git a/www/siteactions.php b/www/siteactions.php new file mode 100644 index 0000000..7d93501 --- /dev/null +++ b/www/siteactions.php @@ -0,0 +1,198 @@ +$header"; +} +function rt_link ($ref, $id) +{ + $slink = sprintf("%s #%s", $id, $ref, $id); + return $slink; +} + +function history_link($nodename) +{ + return sprintf("%s", $nodename, $nodename); +} + +class Event +{ + function Event($event_record) + { + $this->data = $event_record; + } + public function getTime() + { + if ( array_key_exists('time', $this->data) ) + { + $stime=strftime("%Y/%m/%d %H:%M", $this->data['time']); + return $stime; + } else { + return ""; + } + } + public function getField($field) + { + if ( array_key_exists($field, $this->data ) ) + { + # truncate the stage_ part. + #event['stage'] = event['stage'][6:] + if ( is_array($this->data[$field]) and $field != "info" ): + $ret = $this->data[$field][0]; + elseif ( is_array($this->data[$field]) and $field == "info" ): + $ar = $this->data[$field]; + $ret = sprintf("%s -> %s", $ar[1] , $ar[2]); + else: + $ret = $this->data[$field]; + endif; + } else { + $ret = " "; + } + return $ret; + + } + public function getRTTicket() + { + if ( array_key_exists('ticket_id', $this->data) and + $this->data['ticket_id'] != "" ) + { + $rt_ticket = $this->data['ticket_id']; + $slink = rt_link("Monitor", $rt_ticket); + + } elseif ( array_key_exists('found_rt_ticket', $this->data) and + $this->data['found_rt_ticket'] != "" ) { + $rt_ticket = $this->data['found_rt_ticket']; + $slink = rt_link("Support", $rt_ticket); + } else { + $slink = "No tickets"; + } + return $slink; + } +} + +include 'soltesz.php'; +$p = new Pickle(); +$act_all = $p->load("act_all"); +$plcdb_hn2lb = $p->load("plcdb_hn2lb"); +$findbad = $p->load("findbadnodes"); +$findbadnodes = array_keys($findbad['nodes']); + +$sickdb = array(); + +$all_hosts = array_keys($act_all); +foreach ( $all_hosts as $nodename): + $diag_nodelist = $act_all[$nodename]; + if ( array_key_exists($nodename, $plcdb_hn2lb) ) + $lb = $plcdb_hn2lb[$nodename]; + if ( ! array_key_exists($lb, $sickdb) ) + $sickdb[$lb] = array(); + $sickdb[$lb][$nodename] = $diag_nodelist; +endforeach; + +if ( array_key_exists('history', $_GET) ) +{ + $history_nodename = $_GET['history']; + $all_loginbases = array($plcdb_hn2lb[$history_nodename]); + $get_history = TRUE; +} else { + $all_loginbases = array_keys($sickdb); + sort($all_loginbases); + $get_history = FALSE; +} + +$display = array(); + +foreach ( $all_loginbases as $loginbase ): + $nodedict = $sickdb[$loginbase]; + $hosts = array_keys($nodedict); + sort($hosts); + if ( $get_history ) { + $nodename = $history_nodename; + foreach ( $act_all[$nodename] as $event_record ): + + $event = new Event($event_record); + $row = array(); + $row['loginbase'] = $loginbase; + $row['hostname'] = history_link($nodename); + $row['time'] = $event->getTime(); + $row['ticket_id'] = $event->getRTTicket(); + foreach ( array('category', 'action', 'stage', 'info') as $field ) + { + $row[$field] = $event->getField($field); + } + $display[] = $row; + endforeach; + } elseif ( ! $get_history ) { + foreach ( $hosts as $nodename ): + if ( count($act_all[$nodename]) == 0 ) continue; + + $event = new Event($act_all[$nodename][0]); + $row = array(); + $row['loginbase'] = $loginbase; + $row['hostname'] = history_link($nodename); + #$row['time'] = "
" . print_r($act_all[$nodename][0], TRUE) .  "
"; + $row['time'] = $event->getTime(); + $row['ticket_id'] = $event->getRTTicket(); + $row['plcstate'] = $event->data['plcnode']['boot_state']; + $row['currentcategory'] = $findbad['nodes'][$nodename]['values']['category'] . + "-" . $findbad['nodes'][$nodename]['values']['state']; + foreach ( array('category', 'action', 'stage', 'info') as $field ) + { + $row[$field] = $event->getField($field); + } + + $display[] = $row; + endforeach; + } +endforeach; +?> + +siteactions.php + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Count
/
+ + +