<?php /* * Created on Sep 9, 2008 * * Owner: George */ include "../xvf.php"; $cOption = 'demo'; echo template_begin(); echo ptitle("OpenInviter Example - Source Code", 'dark'); echo "<div width='955' style='overflow:auto;border:1px dashed;'>"; echo highlight_file('index.php', true); echo "</div><br><center><a href='/demo/'>back to example</a></center>"; echo template_end();
function _view1() { global $form; $agid = $form['agid']; $sql_from = " FROM agent AG"; $sql_where = " WHERE AG.id='{$agid}'"; $qry = "SELECT AG.* {$sql_from} {$sql_where}"; //dd($qry); $ret = db_query($qry); $row = mysql_fetch_assoc($ret); ptitle('Agent Raw Data', 1); print <<<EOS <table border='1' class='mmdata'> EOS; $keys = array_keys($row); foreach ($keys as $key) { print <<<EOS <tr> <th>{$key}</th> <td class='l'>{$row[$key]}</td> </tr> EOS; } print <<<EOS </table> EOS; }
// checked if any one if ($lgac or $lgam or $lgdb or $lgjm or $lgmn or $lgud) { $cflag = true; } if (!$cflag) { $lgac = 'on'; // check one of them } // session save $_SESSION['lgchks'] = array($lgac, $lgam, $lgdb, $lgjm, $lgmn, $lgud); return array($lgac, $lgam, $lgdb, $lgjm, $lgmn, $lgud); } ### function }}} pagehead($page_title); _style(); ptitle('Log View'); ## {{ print <<<EOS <table border='0'> <form name='form' method='get' action='{$self}'> <tr> <td> <input type='hidden' name='mode' value='{$mode}'> <input type='submit' value='OK' style="width:50;height:50;"> </td> <td> EOS; list($lgac, $lgam, $lgdb, $lgjm, $lgmn, $lgud) = _getvalue_checkboxes(); $cflag = false;
<?php include "common.php"; ### function {{{ ### function }}} pagehead(); ptitle('Health Monitor'); $url1_title = "http://amga.kisti.re.kr/health/"; $url1 = "http://amga.kisti.re.kr/health/"; $url2_title = "http://150.183.158.172/health/"; $url2 = "http://150.183.249.51:9005/health/"; $attr = " align='center'"; $atr2 = " width='481' height='225' border='1'"; print <<<EOS <table border='0'> <tr> <td {$attr} colspan='2'><a href='{$url1}' target='_blank'>{$url1_title}</a></td> </tr> <tr> <td {$attr}><a href='{$url1}/loadavg.html'><img src='{$url1}/loadavg-3hours.png' {$atr2}></a></td> <td {$attr}><a href='{$url1}/loadavg.html'><img src='{$url1}/loadavg-32hours.png' {$atr2}></a></td> </tr> <tr> <td {$attr} colspan='2'><a href='{$url2}' target='_blank'>{$url2_title}</a></td> </tr> <tr> <td {$attr}><a href='{$url2}/loadavg.html'><img src='{$url2}/loadavg-3hours.png' {$atr2}></a></td> <td {$attr}><a href='{$url2}/loadavg.html'><img src='{$url2}/loadavg-32hours.png' {$atr2}></a></td> </tr> </table>
function _view() { global $form; global $env; $mjid = $form['mjid']; ##{{ ptitle('Subjob Statistics', 1); $qry = "SELECT X.*, A.host\n FROM (SELECT COUNT(*) count, status, agent_id FROM job WHERE metajob_id='{$mjid}' GROUP BY status, agent_id) X\n LEFT JOIN Agent A ON X.agent_id=A.id\n ORDER BY A.host"; //dd($qry); $ret = db_query($qry); $info = array(); $aids = array(); while ($row = mysql_fetch_assoc($ret)) { //dd($row); $count = $row['count']; $status = $row['status']; $aid = $row['agent_id']; $host = $row['host']; if ($aid == '') { continue; } $aids[$aid] = true; $info[$aid][$status] += $count; $info[$aid]['host'] = $host; } //dd($info); print <<<EOS <table border='1' class='mmdata'> <tr> <th>#</th> <th>agent_id</th> <th>host</th> <th>preparing</th> <th>running</th> <th>done</th> <th>failed</th> <th>(Total)</th> </tr> EOS; $cnt = 0; $sum = array(); foreach ($aids as $aid => $t) { $cnt++; //dd($aid); $vsum = 0; $v1 = $info[$aid]['preparing']; $sum['v1'] += $v1; $vsum += $v1; $v2 = $info[$aid]['running']; $sum['v2'] += $v2; $vsum += $v2; $v3 = $info[$aid]['done']; $sum['v3'] += $v3; $vsum += $v3; $v4 = $info[$aid]['failed']; $sum['v4'] += $v4; $vsum += $v4; $sum['vsum'] += $vsum; $host = $info[$aid]['host']; unset($info[$aid]); print <<<EOS <tr> <td>{$cnt}</td> <td>{$aid}</td> <td>{$host}</td> <td>{$v1}</td> <td>{$v2}</td> <td>{$v3}</td> <td>{$v4}</td> <td>{$vsum}</td> </tr> EOS; } print <<<EOS <tr> <th></th> <th></th> <th>Total</th> <th>{$sum['v1']}</th> <th>{$sum['v2']}</th> <th>{$sum['v3']}</th> <th>{$sum['v4']}</th> <th>{$sum['vsum']}</th> </tr> </table> EOS; //dd($info); ##}} $select_items = "MJ.*, U.userid, U.service_Infra_id, A.name appname"; $sql_join = " JOIN User U ON MJ.user_id=U.id" . " JOIN application A ON MJ.app_id=A.id"; $qry = "SELECT {$select_items} FROM metajob MJ {$sql_join} WHERE MJ.id='{$mjid}' {$sql_order}"; //dd($qry); $ret = db_query($qry); $row = mysql_fetch_assoc($ret); //dd($row); ptitle('Metajob Raw Data', 1); print <<<EOS <table border='1' class='mmdata'> EOS; $keys = array_keys($row); //dd($keys); $jsdl = $row['JSDL']; $jsdl = htmlspecialchars($jsdl); $jsdl = nl2br($jsdl); $row['JSDL'] = $jsdl; foreach ($keys as $key) { //print $key; print <<<EOS <tr> <th>{$key}</th> <td class='l'>{$row[$key]}</td> </tr> EOS; } print <<<EOS </table> EOS; }
header("Content-type: application/octetstream"); header("Cache-Control: no-cache"); header("Pragma: no-cache"); header("Expires: -1"); $path = $conf['htcaas_php_path']; $command = <<<EOS {$path}/cli/cli.tar.php "{$a}" EOS; passthru($command); exit; } if ($mode == 'view') { pagehead(); $sjid = $form['sjid']; $mjid = $form['mjid']; if ($sjid) { ptitle("Result List of a SubJob id={$sjid}"); } else { if ($mjid) { ptitle("Result List of a MetaJob id={$mjid}"); } else { die('Error' . ':' . __FILE__ . ':' . __LINE__); } } _view($sjid, $mjid); pagetail(); exit; } pagehead(); pagetail(); exit;
while ($row = mysql_fetch_assoc($ret)) { $cnt++; $id = $row['id']; $var = array(); //$var['agents'] = span_link('agents', "_list1('$id')"); $fields = array(); $fields[] = array($cnt, ''); _push($fields, $items, $row, $var); print "<tr>"; for ($i = 0; $i < count($fields); $i++) { list($str, $attr) = $fields[$i]; table_data_text($str, $attr, $nowrap = 1); } print "</tr>"; } $script = <<<EOS /* function _list1(id) { var url = "agent.php?mode=view&userid="+id; document.location.href = url; } */ EOS; table_close($script); } ### function }}} pagehead(); ptitle('User List'); _view(); pagetail(); exit;
</td> <td valign='top'> loadavg (3 hours)<br> <img src='/health/loadavg-3hours.png'><br> loadavg (32 hours)<br> <img src='/health/loadavg-32hours.png'><br> </td> </tr> </table> <a href='/health/'>health monitor</a> EOS; } ### function }}} pagehead('Server Monitor'); _style(); ptitle('Server Monitor'); ## {{ print <<<EOS <table border='0'> <form name='form' method='get' action='{$self}'> <tr> <td> <input type='hidden' name='mode' value='{$mode}'> <input type='submit' value='OK' style="width:50;height:50;"> </td> <td> EOS; if ($form['ckrf']) { $ck = ' checked';
} $fields[] = array($value, $atr1); } print "<tr>"; for ($i = 0; $i < count($fields); $i++) { list($str, $attr) = $fields[$i]; table_data_text($str, $attr, $nowrap = 1); } print "</tr>"; } $script = <<<EOS function _list_results(subjob_id) { var url = "result.php?mode=view&sjid="+subjob_id; document.location.href = url; } EOS; table_close($script); } ### function }}} if ($mode == 'view') { pagehead(); $mjid = $form['id']; ptitle("SubJobs list of a MetaJob id={$mjid}"); _style(); _view(); pagetail(); exit; } pagehead(); pagetail(); exit;