3 function get_category_link($category,$header)
5 return "<a href='siteactions.php?category=$category'>$header</a>";
7 function rt_link ($ref, $id)
9 $slink = sprintf("<a href='https://rt.planet-lab.org/Ticket/Display.html".
10 "?user=guest&pass=guest&id=%s'>%s #%s</a>", $id, $ref, $id);
14 function history_link($nodename)
16 return sprintf("<a href='siteactions.php?history=%s'>%s</a>", $nodename, $nodename);
21 function Event($event_record)
23 $this->data = $event_record;
25 public function getTime()
27 if ( array_key_exists('time', $this->data) )
29 $stime=strftime("%Y/%m/%d %H:%M", $this->data['time']);
35 public function getField($field)
37 if ( array_key_exists($field, $this->data ) )
39 # truncate the stage_ part.
40 #event['stage'] = event['stage'][6:]
41 if ( is_array($this->data[$field]) and $field != "info" ):
42 $ret = $this->data[$field][0];
43 elseif ( is_array($this->data[$field]) and $field == "info" ):
44 $ar = $this->data[$field];
45 $ret = sprintf("%s -> %s", $ar[1] , $ar[2]);
47 $ret = $this->data[$field];
55 public function getRTTicket()
57 if ( array_key_exists('ticket_id', $this->data) and
58 $this->data['ticket_id'] != "" )
60 $rt_ticket = $this->data['ticket_id'];
61 $slink = rt_link("Monitor", $rt_ticket);
63 } elseif ( array_key_exists('found_rt_ticket', $this->data) and
64 $this->data['found_rt_ticket'] != "" ) {
65 $rt_ticket = $this->data['found_rt_ticket'];
66 $slink = rt_link("Support", $rt_ticket);
68 $slink = "No tickets";
74 include 'database.php';
76 $act_all = $p->load("act_all");
77 $plcdb_hn2lb = $p->load("plcdb_hn2lb");
78 $findbad = $p->load("findbadnodes");
79 $findbadnodes = array_keys($findbad['nodes']);
83 $all_hosts = array_keys($act_all);
84 foreach ( $all_hosts as $nodename):
85 $diag_nodelist = $act_all[$nodename];
86 if ( array_key_exists($nodename, $plcdb_hn2lb) )
87 $lb = $plcdb_hn2lb[$nodename];
88 if ( ! array_key_exists($lb, $sickdb) )
89 $sickdb[$lb] = array();
90 $sickdb[$lb][$nodename] = $diag_nodelist;
93 if ( array_key_exists('history', $_GET) )
95 $history_nodename = $_GET['history'];
96 $all_loginbases = array($plcdb_hn2lb[$history_nodename]);
99 $all_loginbases = array_keys($sickdb);
100 sort($all_loginbases);
101 $get_history = FALSE;
106 foreach ( $all_loginbases as $loginbase ):
107 $nodedict = $sickdb[$loginbase];
108 $hosts = array_keys($nodedict);
110 if ( $get_history ) {
111 $nodename = $history_nodename;
112 foreach ( $act_all[$nodename] as $event_record ):
114 $event = new Event($event_record);
116 $row['loginbase'] = $loginbase;
117 $row['hostname'] = history_link($nodename);
118 $row['time'] = $event->getTime();
119 $row['ticket_id'] = $event->getRTTicket();
120 foreach ( array('category', 'action', 'stage', 'info') as $field )
122 $row[$field] = $event->getField($field);
126 } elseif ( ! $get_history ) {
127 foreach ( $hosts as $nodename ):
128 if ( count($act_all[$nodename]) == 0 ) continue;
130 $event = new Event($act_all[$nodename][0]);
132 $row['loginbase'] = $loginbase;
133 $row['hostname'] = history_link($nodename);
134 #$row['time'] = "<pre>" . print_r($act_all[$nodename][0], TRUE) . "</pre>";
135 $row['time'] = $event->getTime();
136 $row['ticket_id'] = $event->getRTTicket();
137 $row['plcstate'] = $event->data['plcnode']['boot_state'];
138 $row['currentcategory'] = $findbad['nodes'][$nodename]['values']['category'] .
139 "-" . $findbad['nodes'][$nodename]['values']['state'];
140 foreach ( array('category', 'action', 'stage', 'info') as $field )
142 $row[$field] = $event->getField($field);
151 <title>siteactions.php</title>
156 <table width=80% border=1>
159 <th><?= get_category_link("loginbase", "SiteID") ?></th>
160 <th><?= get_category_link("hostname", "Hostname") ?></th>
161 <?php if ( $get_history ): ?>
162 <th><?= get_category_link("time", "Time") ?></th>
164 <th><?= get_category_link("ticket_id", "RT Ticket") ?></th>
165 <th><?= get_category_link("category", "Last Category") ?></th>
166 <?php if ( $get_history ): ?>
167 <th><?= get_category_link("action", "Action") ?></th>
169 <th><?= get_category_link("currentcategory", "Current Category") ?></th>
170 <th><?= get_category_link("action", "Last Action") ?></th>
172 <th><?= get_category_link("stage", "Stage") ?></th>
173 <th><?= get_category_link("info", "Info") ?></th>
176 <?php foreach ( $display as $row ): ?>
178 <td><?= $count ?></td>
179 <td><?= $row['loginbase'] ?></td>
180 <td><?= $row['hostname'] ?></td>
181 <?php if ( $get_history ): ?>
182 <td nowrap><?= $row['time'] ?></td>
184 <td nowrap><?= $row['ticket_id'] ?></td>
185 <td><?= $row['category'] ?>/<?= $row['plcstate'] ?></td>
186 <?php if ( ! $get_history ): ?>
187 <td><?= $row['currentcategory'] ?></td>
189 <td><?= $row['action'] ?></td>
190 <td><?= $row['stage'] ?></td>
191 <td nowrap><?= $row['info'] ?></td>
193 <?php $count += 1; ?>