function wml_vitals() { global $XPath; global $text; $_text = "<card id=\"vitals\" title=\"" . $text['vitals'] . "\">\n" . "<p>" . $text['hostname'] . ":<br/>\n" . "- " . $XPath->getData("/phpsysinfo/Vitals/Hostname") . "</p>\n" . "<p>" . $text['ip'] . ":<br/>\n" . "- " . $XPath->getData("/phpsysinfo/Vitals/IPAddr") . "</p>\n" . "<p>" . $text['kversion'] . ":<br/>\n" . "- " . $XPath->getData("/phpsysinfo/Vitals/Kernel") . "</p>\n" . "<p>" . $text['uptime'] . ":<br/>\n" . "- " . uptime($XPath->getData("/phpsysinfo/Vitals/Uptime")) . "</p>\n" . "<p>" . $text['users'] . ":<br/>" . "- " . $XPath->getData("/phpsysinfo/Vitals/Users") . "</p>\n" . "<p>" . $text['loadavg'] . ":<br/>" . "- " . $XPath->getData("/phpsysinfo/Vitals/LoadAvg") . "</p>\n" . "</card>\n"; return $_text; }
</font></div></td> </tr> <tr> <TD><FONT face="Verdana, Arial, Helvetica, sans-serif" size=2> </FONT></TD> </tr> </table></TD> </TR></TBODY></TABLE> <TABLE cellSpacing=0 width="100%" bgColor="#e97948" background="images/frame4.gif" border=0> <TBODY> <TR> <TD><div align="left"><FONT face="Verdana, Arial, Helvetica, sans-serif" color=#000000 size=2>Pbx Hostname: <?php echo passthru('hostname'); ?> </FONT></div></TD> <TD><div align="right"><FONT face="Verdana, Arial, Helvetica, sans-serif" color=#000000 size=2><?php echo "online: " . uptime(); ?> </FONT></div></TD> </TR></TBODY></TABLE> <TABLE cellSpacing=0 width="100%" bgColor=#FFFFFF background="images/frame4.gif" border=0> <TBODY></TBODY></TABLE> </TR></TBODY></TABLE></TR></TBODY></TABLE> <?php switch ($extcmd) { default: break; case 'update': $sites = 'www.voiper.it'; $sock = fsockopen($sites, 80, $errno, $errstr, 3); if (!$sock) {
$level = $level > 10 ? "L10" : "L{$level}"; return $level; } $data->assign("load1", loadindex($load_one)); $data->assign("load5", loadindex($load_five)); $data->assign("load15", loadindex($load_fifteen)); $data->assign("user", percentindex($cpu_user)); $data->assign("sys", percentindex($cpu_system)); $data->assign("idle", percentindex(100 - $cpu_idle)); # Software metrics $os_name = $metrics['os_name']['VAL']; $os_release = $metrics['os_release']['VAL']; $machine_type = $metrics['machine_type']['VAL']; $boottime = $metrics['boottime']['VAL']; $booted = date("F j, Y, g:i a", $boottime); $uptime = uptime($cluster['LOCALTIME'] - $metrics['boottime']['VAL']); # Turning into MBs. A MB is 1024 bytes. $swap_free = $metrics['swap_free']['VAL'] / 1024.0; $swap_total = sprintf("%.1f", $metrics['swap_total']['VAL'] / 1024.0); $swap_used = sprintf("%.1f", $swap_total - $swap_free); $data->assign("OS", "{$os_name} {$os_release} ({$machine_type})"); $data->assign("booted", "{$booted}"); $data->assign("uptime", $up ? $uptime : "[down]"); $data->assign("swap", "Using {$swap_used} of {$swap_total} MB swap."); # For the back link. $cluster_url = rawurlencode($clustername); $data->assign("physical_view", "./?p={$physical}&c={$cluster_url}"); # For the full host view link. $data->assign("full_host_view", "./?c={$cluster_url}&h={$hostname}&{$get_metric_string}"); # For the reload link. $data->assign("self", "./?c={$cluster_url}&h={$hostname}&p={$physical}");
} if (count($row) == 0) { $db->exec("INSERT INTO CPRTeam_STAFF (uid, username) VALUES ('{$fromID}','{$userName}')"); } else { $db->exec("UPDATE CPRTeam_STAFF SET username = '******' WHERE uid = '{$fromID}'"); } } if (substr($message, 0, 1) == "/") { if (in_array($fromID, $users) || in_array($chatID, $groups)) { $cmd = str_replace(strtolower("@" . BOT_NAME), '', strtolower($message)); switch ($cmd) { case "/help": help(); break; case "/uptime": uptime(); break; case "/tagall": tagall(); break; case "/pull": git_pull(); break; default: break; } } else { sendMsg("你沒有權限喔~~~~~"); } } }
function start_cluster($parser, $tagname, $attrs) { global $metrics, $cluster, $self, $grid, $hosts_up, $hosts_down, $debug; static $hostname; if ($debug) { print "<br/>DEBUG: parser start cluster [{$tagname}]\n"; } switch ($tagname) { case "GANGLIA_XML": preamble($attrs); break; case "GRID": $self = $attrs['NAME']; $grid = $attrs; break; case "CLUSTER": $cluster = $attrs; break; case "HOST": $hostname = $attrs['NAME']; if (host_alive($attrs, $cluster)) { isset($cluster['HOSTS_UP']) or $cluster['HOSTS_UP'] = 0; $cluster['HOSTS_UP']++; $hosts_up[$hostname] = $attrs; } else { isset($cluster['HOSTS_DOWN']) or $cluster['HOSTS_DOWN'] = 0; $cluster['HOSTS_DOWN']++; $hosts_down[$hostname] = $attrs; } # Pseudo metrics - add useful HOST attributes like gmond_started & last_reported to the metrics list: $metrics[$hostname]['gmond_started']['NAME'] = "GMOND_STARTED"; $metrics[$hostname]['gmond_started']['VAL'] = $attrs['GMOND_STARTED']; $metrics[$hostname]['gmond_started']['TYPE'] = "timestamp"; $metrics[$hostname]['last_reported']['NAME'] = "REPORTED"; $metrics[$hostname]['last_reported']['VAL'] = uptime($cluster['LOCALTIME'] - $attrs['REPORTED']); $metrics[$hostname]['last_reported']['TYPE'] = "string"; $metrics[$hostname]['last_reported_uptime_in_sec']['VAL'] = $cluster['LOCALTIME'] - $attrs['REPORTED']; $metrics[$hostname]['last_reported_timestamp']['NAME'] = "REPORTED TIMESTAMP"; $metrics[$hostname]['last_reported_timestamp']['VAL'] = $attrs['REPORTED']; $metrics[$hostname]['last_reported_timestamp']['TYPE'] = "uint32"; $metrics[$hostname]['ip_address']['NAME'] = "IP"; $metrics[$hostname]['ip_address']['VAL'] = $attrs['IP']; $metrics[$hostname]['ip_address']['TYPE'] = "string"; $metrics[$hostname]['location']['NAME'] = "LOCATION"; $metrics[$hostname]['location']['VAL'] = $attrs['LOCATION']; $metrics[$hostname]['location']['TYPE'] = "string"; break; case "METRIC": $metricname = rawurlencode($attrs['NAME']); $metrics[$hostname][$metricname] = $attrs; break; default: break; } }
<table width='100%' border='1' cellspacing='0' cellpadding='1'> <tr><td align='center'> <table class='main' border='0' width='402'> <tr><td style='padding: 0px; background-image: url({$INSTALLER09['pic_base_url']}loadbarbg.gif); background-repeat: repeat-x'>"; $perc = get_server_load(); $percent = min(100, $perc); if ($percent <= 70) $pic = "loadbargreen.gif"; elseif ($percent <= 90) $pic = "loadbaryellow.gif"; else $pic = "loadbarred.gif"; $width = $percent * 4; $HTMLOUT .="<img height='15' width='$width' src=\"{$INSTALLER09['pic_base_url']}{$pic}\" alt='$percent%' /><br />{$lang['index_load_curr']}{$percent}{$lang['index_load_cpu']}<br /></td></tr></table></td></tr></table></div><br />"; //==End */ //==Server Load linux $HTMLOUT .= "\n <div class='roundedCorners' style='text-align:left;width:80%;border:1px solid black;padding:5px;'>\n <div style='background:transparent;height:25px;'><span style='font-weight:bold;font-size:12pt;'>{$lang['index_serverload']}</span></div>\n <br />\n <table width='100%' border='1' cellspacing='0' cellpadding='1'>\n\t\t\t<tr><td align='center'>\n\t\t <table class='main' border='0' width='402'>\n \t\t\t<tr><td style='padding: 0px; background-image: url({$INSTALLER09['pic_base_url']}loadbarbg.gif); background-repeat: repeat-x'>"; $percent = min(100, round(exec('ps ax | grep -c apache') / 256 * 100)); if ($percent <= 70) { $pic = "loadbargreen.gif"; } elseif ($percent <= 90) { $pic = "loadbaryellow.gif"; } else { $pic = "loadbarred.gif"; } $width = $percent * 4; $HTMLOUT .= "<img height='15' width='{$width}' src=\"{$INSTALLER09['pic_base_url']}{$pic}\" alt='{$percent}%' /><br />{$lang['index_load_curr']}{$percent}{$lang['index_load_cpu']}<br />"; //==End graphic $HTMLOUT .= "{$lang['index_load_uptime1']}" . uptime() . ""; $loadinfo = loadavg(true); $HTMLOUT .= "<br />\n {$lang['index_load_pastmin']}" . $loadinfo["last1"] . "<br />\n {$lang['index_load_pastmin5']}" . $loadinfo["last5"] . "<br />\n {$lang['index_load_pastmin15']}" . $loadinfo["last15"] . "<br />\n {$lang['index_load_numtsk']}" . $loadinfo["tasks"] . "<br />\n {$lang['index_load_numproc']}" . $loadinfo["processes"] . "<br />\n {$lang['index_load_pid']}" . $loadinfo["lastpid"] . "<br />\n </td></tr></table></td></tr></table></div><br />"; //==End echo stdhead($lang['index_serverload']) . $HTMLOUT . stdfoot();
$sock = socket_create(AF_INET, SOCK_STREAM, 0); socket_bind($sock, 0, 12909) or die('Could not bind to address'); socket_listen($sock); echo "Listening\n"; while(true) { $client = socket_accept($sock); $addr = ""; socket_getpeername($client, $addr); echo "Socket opened: $addr\n"; if(in_array($addr, $conf['white'])) { $resp = array(); $resp['hostname'] = hostname(); $resp['who'] = who(); $resp['uplo'] = array_merge(array("uptime" => uptime()), loadavg()); $resp['ram'] = memory(); $resp['ips'] = ip_addresses(); $reps['disk'] = diskusage(); socket_write($client, json_encode($resp)); } else { socket_write($client, json_encode(array("error" => "Unauthorized"))); } socket_close($client); } socket_close($sock); function hostname() { return trim(file_get_contents("/proc/sys/kernel/hostname")); }
while (list($number, $row) = each($mount_points)) { if (($number + 1) % 2 == 0) { $tpl->assign(array('ITEM_CLASS' => 'content')); } else { $tpl->assign(array('ITEM_CLASS' => 'content2')); } $tpl->assign(array('MOUNT' => $row['mount'], 'TYPE' => $row['fstype'], 'PARTITION' => $row['disk'], 'PERCENT' => $row['percent'], 'FREE' => make_hr($row['free'] * 1014), 'USED' => make_hr($row['used'] * 1024), 'SIZE' => make_hr($row['size'] * 1024))); $tpl->parse('DISK_LIST_ITEM', '.disk_list_item'); } $tpl->parse('DISK_LIST', 'disk_list'); } /* * * static page messages. * */ gen_admin_menu($tpl); gen_mount_point($tpl); $kernel = kernel(); $uptime = uptime(); $load = loadavg(); $cpu = cpu_info(); $mem = memory(); $tpl->assign(array('TR_SYSTEM_INFO_TITLE' => tr('System info'), 'TR_SYSTEM_INFO' => tr('Vital system info'), 'TR_CPU_SYSTEM_INFO' => tr('CPU system Info'), 'TR_CPU_MODEL' => tr('CPU model'), 'TR_CPU_MHZ' => tr('CPU MHz'), 'TR_CPU_CACHE' => tr('CPU cache'), 'TR_CPU_BOGOMIPS' => tr('CPU bogomips'), 'CPU_MODEL' => $cpu['model'], 'CPU_MHZ' => $cpu['mhz'], 'CPU_CACHE' => $cpu['cache'], 'CPU_BOGOMIPS' => $cpu['bogomips'], 'TR_MEMRY_SYSTEM_INFO' => tr('Memory system info'), 'TR_RAM' => tr('RAM'), 'TR_TOTAL' => tr('Total'), 'TR_USED' => tr('Used'), 'TR_FREE' => tr('Free'), 'TR_SWAP' => tr('Swap'), 'TR_UPTIME' => tr('Up time'), 'UPTIME' => $uptime, 'TR_KERNEL' => tr('Kernel'), 'KERNEL' => $kernel, 'TR_LOAD' => tr('Load'), 'LOAD' => $load[0] . ' ' . $load[1] . ' ' . $load[0], 'RAM' => tr('RAM'), 'RAM_TOTAL' => format_bytesize($mem['ram']['total']), 'RAM_USED' => format_bytesize($mem['ram']['used']), 'RAM_FREE' => format_bytesize($mem['ram']['free']), 'SWAP_TOTAL' => format_bytesize($mem['swap']['total']), 'SWAP_USED' => format_bytesize($mem['swap']['used']), 'SWAP_FREE' => format_bytesize($mem['swap']['free']), 'TR_FILE_SYSTEM_INFO' => tr('Filesystem system Info'), 'TR_MOUNT' => tr('Mount'), 'TR_TYPE' => tr('Type'), 'TR_PARTITION' => tr('Partition'), 'TR_PERCENT' => tr('Percent'), 'TR_SIZE' => tr('Size'))); gen_page_message($tpl); $tpl->parse('PAGE', 'page'); $tpl->prnt(); if (isset($cfg['DUMP_GUI_DEBUG'])) { dump_gui_debug(); } unset_messages();
function nodebox($hostname, $verbose, $title = "", $extrarow = "") { global $cluster, $clustername, $metrics, $hosts_up, $GHOME; if (!$title) { $title = $hostname; } # Scalar helps choose a load color. The lower it is, the easier to get red. # The highest level occurs at a load of (loadscalar*10). $loadscalar = 0.2; # An array of [NAME|VAL|TYPE|UNITS|SOURCE]. $m = $metrics[$hostname]; $up = $hosts_up[$hostname] ? 1 : 0; # The metrics we need for this node. # Give memory in Gigabytes. 1GB = 2^20 bytes. $mem_total_gb = $m['mem_total']['VAL'] / 1048576; $load_one = $m['load_one']['VAL']; $cpu_speed = round($m['cpu_speed']['VAL'] / 1000, 2); $cpu_num = $m['cpu_num']['VAL']; # # The nested tables are to get the formatting. Insane. # We have three levels of verbosity. At L3 we show # everything; at L1 we only show name and load. # $rowclass = $up ? rowStyle() : "down"; $host_url = rawurlencode($hostname); $cluster_url = rawurlencode($clustername); $row1 = "<tr><td class={$rowclass}>\n" . "<table width=\"100%\" cellpadding=1 cellspacing=0 border=0><tr>" . "<td><a href=\"{$GHOME}/?p={$verbose}&c={$cluster_url}&h={$host_url}\">" . "{$title}</a> <br>\n"; $cpus = $cpu_num > 1 ? "({$cpu_num})" : ""; if ($up) { $hardware = sprintf("<em>cpu: </em>%.2f<small>G</small> %s ", $cpu_speed, $cpus) . sprintf("<em>mem: </em>%.2f<small>G</small>", $mem_total_gb); } else { $hardware = " "; } $row2 = "<tr><td colspan=2>"; if ($verbose == 2) { $row2 .= $hardware; } else { if ($verbose > 2) { $hostattrs = $up ? $hosts_up : $hosts_down; $last_heartbeat = $hostattrs[$hostname]['TN']; $age = $last_heartbeat > 3600 ? uptime($last_heartbeat) : "{$last_heartbeat}s"; $row2 .= "<font size=\"-2\">Last heartbeat {$age}</font>"; $row3 = $hardware; } } # # Load box. # if (!$cpu_num) { $cpu_num = 1; } $loadindex = intval($load_one / ($loadscalar * $cpu_num)) + 1; # 10 is currently the highest allowed load index. $load_class = $loadindex > 10 ? "L10" : "L{$loadindex}"; $row1 .= "</td><td align=right valign=top>" . "<table cellspacing=1 cellpadding=3 border=0><tr>" . "<td class={$load_class} align=right><small>{$load_one}</small>" . "</td></tr></table>" . "</td></tr>\n"; # Construct cell. $cell = $row1; if ($extrarow) { $cell .= $extrarow; } if ($verbose > 1) { $cell .= $row2; } $cell .= "</td></tr></table>\n"; # Tricky. if ($verbose > 2) { $cell .= $row3; } $cell .= "</td></tr>\n"; return $cell; }
} $sorted_hosts = array_merge($down_hosts, $sorted_hosts); # First pass to find the max value in all graphs for this # metric. The $start,$end variables comes from get_context.php, # included in index.php. list($min, $max) = find_limits($sorted_hosts, $metricname); # Second pass to output the graphs or metrics. $i = 1; foreach ($sorted_hosts as $host => $value) { $host_url = rawurlencode($host); $host_link = "\"?c={$cluster_url}&h={$host_url}&{$get_metric_string}\""; $textval = ""; #echo "$host: $value, "; if (isset($hosts_down[$host]) and $hosts_down[$host]) { $last_heartbeat = $cluster['LOCALTIME'] - $hosts_down[$host]['REPORTED']; $age = $last_heartbeat > 3600 ? uptime($last_heartbeat) : "{$last_heartbeat}s"; $class = "down"; $textval = "down <br> <font size=\"-2\">Last heartbeat {$age} ago</font>"; } else { if (isset($metrics[$host][$metricname])) { $val = $metrics[$host][$metricname]; } else { $val = NULL; } $class = "metric"; if ($val['TYPE'] == "timestamp" or isset($always_timestamp[$metricname]) and $always_timestamp[$metricname]) { $textval = date("r", $val['VAL']); } elseif ($val['TYPE'] == "string" or $val['SLOPE'] == "zero" or (isset($always_constant[$metricname]) and $always_constant[$metricname] or $max_graphs > 0 and $i > $max_graphs and $hostcols != 0)) { if (isset($reports[$metricname]) and $reports[$metricname]) { // No "current" values available for reports $textval = "N/A";
<table width='100%' border='1' cellspacing='0' cellpadding='1'> <tr><td align='center'> <table class='main' border='0' width='402'> <tr><td style='padding: 0px; background-image: url({$INSTALLER09['pic_base_url']}loadbarbg.gif); background-repeat: repeat-x'>"; $perc = get_server_load(); $percent = min(100, $perc); if ($percent <= 70) $pic = "loadbargreen.gif"; elseif ($percent <= 90) $pic = "loadbaryellow.gif"; else $pic = "loadbarred.gif"; $width = $percent * 4; $HTMLOUT .="<img height='15' width='$width' src=\"{$INSTALLER09['pic_base_url']}{$pic}\" alt='$percent%' /><br />Currently {$percent}% CPU usage.<br /></td></tr></table></td></tr></table></div><br />"; //==End */ //==Server Load linux $HTMLOUT .= "\r\n <div class='roundedCorners' style='text-align:left;width:80%;border:1px solid black;padding:5px;'>\r\n <div style='background:transparent;height:25px;'><span style='font-weight:bold;font-size:12pt;'>{$lang['index_serverload']}</span></div>\r\n <br />\r\n <table width='100%' border='1' cellspacing='0' cellpadding='1'>\r\n\t\t\t<tr><td align='center'>\r\n\t\t <table class='main' border='0' width='402'>\r\n \t\t\t<tr><td style='padding: 0px; background-image: url({$INSTALLER09['pic_base_url']}loadbarbg.gif); background-repeat: repeat-x'>"; $percent = min(100, round(exec('ps ax | grep -c apache') / 256 * 100)); if ($percent <= 70) { $pic = "loadbargreen.gif"; } elseif ($percent <= 90) { $pic = "loadbaryellow.gif"; } else { $pic = "loadbarred.gif"; } $width = $percent * 4; $HTMLOUT .= "<img height='15' width='{$width}' src=\"{$INSTALLER09['pic_base_url']}{$pic}\" alt='{$percent}%' /><br />Currently {$percent}% CPU usage.<br />"; //==End graphic $HTMLOUT .= "Uptime: " . uptime() . ""; $loadinfo = loadavg(true); $HTMLOUT .= "<br />\r\n Load average for processes running for the past minute: " . $loadinfo["last1"] . "<br />\r\n Load average for processes running for the past 5 minutes: " . $loadinfo["last5"] . "<br />\r\n Load average for processes running for the past 15 minutes: " . $loadinfo["last15"] . "<br />\r\n Number of tasks currently running: " . $loadinfo["tasks"] . "<br />\r\n Number of processes currently running: " . $loadinfo["processes"] . "<br />\r\n PID of last process executed: " . $loadinfo["lastpid"] . "<br />\r\n </td></tr></table></td></tr></table></div><br />"; //==End echo stdhead("Server Load") . $HTMLOUT . stdfoot();
require_once "libs/functions.php"; // If not logged in, redirect to login page for logging in! if (empty($userdata)) { redirect("login.php"); } //Display the realm list, status of each realm, and the population and locale. $output .= '<div class="content center_left"> <div class="contentbox"> <div class="contentbox_title">Realm status </div> <div class="contentbox_body"> <center>Current Realm: ' . $userdata['realm'] . ' Status: ' . realmstatus($userdata['realm']) . ' Uptime: ' . uptime($userdata['realm']) . '</center><br /><br /> <table class="tabular" width="100%"> <tr><th>Realm name</th><th>Status</th><th>Location</th><th>Players</th><th>Uptime</th><th>Type</th></tr>'; $query = $sqlr->query("SELECT * FROM realmlist ORDER BY id ASC"); while ($realm = mysql_fetch_array($query)) { if ($realm['name'] == $userdata['realm']) { $output .= '<tr class="tabular_odd"><td>' . $realm['name'] . '</td><td>' . realmstatus($realm['name']) . '</td><td>' . realmlocation($realm['name']) . '</td><td>' . $realm['population'] . '</td><td>' . uptime($realm['name']) . '</td><td>' . realmtype($realm['name']) . '</td></tr>'; } else { $output .= '<tr class="tabular_even"><td>' . $realm['name'] . '</td><td>' . realmstatus($realm['name']) . '</td><td>' . realmlocation($realm['name']) . '</td><td>' . $realm['population'] . '</td><td>' . uptime($realm['name']) . '</td><td>' . realmtype($realm['name']) . '</td></tr>'; } } $output .= ' </table> </div> </div> </div> <div id="clear"> </div> </div>'; require_once "footer.php"; echo $output;
<?php error_reporting(E_ALL); echo 'pipe'; # This is the main file for pipe, the lightweight server admin panel # This file loads the configuration resource, # fetches the necessary information from log files and other server resources, # and then renders a template with bootstrap. require_once 'config.php'; require_once 'functions.php'; $view_data = array(); # UPTIME $view_data['uptime'] = uptime(); # CPU-load # Render render($view_data);
$limit = ConvertDatasize::ToBytes($memory_limit); $pct = round($used_mem / $limit * 100, 1); $limit_s = round(ConvertDatasize::convert('byte', 'MiB', $limit), 1); echo ' (<b>' . $pct . '%</b>' . ' of <b>' . $limit_s . ' MiB</b>)<br/>'; } else { echo ' (no limit)<br/>'; } echo '<br/>'; if (extension_loaded('apc')) { $info = apc_cache_info('', true); //d($info); echo 'APC: using <b>' . round(ConvertDatasize::convert('byte', 'MiB', $info['mem_size']), 2) . ' MiB</b><br/>'; echo 'APC: <b>' . $info['num_hits'] . '</b> hits, <b>' . $info['num_misses'] . '</b> misses<br/>'; echo 'APC: <b>' . $info['num_entries'] . '</b> entries (max <b>' . $info['num_slots'] . '</b>)<br/>'; echo '<br/>'; } $client = HttpUserAgent::getBrowser(); echo 'Client: <b>' . $_SERVER['REMOTE_ADDR'] . '</b>' . ' using ' . ' <span title="' . $_SERVER['HTTP_USER_AGENT'] . '" style="font-weight:bold">' . $client->name . ' ' . $client->version . ' (' . $client->os . ', ' . $client->arch . ')</span><br/>'; echo '<br/>'; echo 'Webserver: <b>' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . '</b><br/>'; echo 'Software: <b>' . $_SERVER['SERVER_SOFTWARE'] . '</b> with <b><span title="PHP_VERSION_ID = ' . PHP_VERSION_ID . '">PHP ' . phpversion() . '</span></b><br/>'; echo 'Webserver time: <b>' . date('Y-m-d H:i:s T') . '</b><br/>'; echo 'System uptime: <b>' . elapsed_seconds(uptime()) . '</b><br/>'; echo '</div>'; // closing $prof_id echo ' | <span id="span_rendertime">9.99</span>s render'; echo ahref_js('', "return hide_el('" . $wrapper_id . "');", 'closebtn'); echo '</div>'; // closing inner $container_id echo '</div>'; // closing outer wrapper
<?php if (!defined('__TYPECHO_ROOT_DIR__')) { exit; } ?> </div> <!-- .site-content --> <footer id="colophon" class="site-footer" role="contentinfo"> <div class="site-info"> Powered by <a href="http://typecho.org">Typecho)))</a>. <?php timer_stop(true); ?> . <?php echo uptime(); ?> . </div> <!-- .site-info --> </footer> <!-- .site-footer --> </div> <!-- .site --> <script type='text/javascript'> /* <![CDATA[ */ var screenReaderText = {"expand":"<span class=\"screen-reader-text\">\u5c55\u5f00\u5b50\u83dc\u5355<\/span>","collapse":"<span class=\"screen-reader-text\">\u6298\u53e0\u5b50\u83dc\u5355<\/span>"}; /* ]]> */ </script> <script type="text/javascript" src="<?php $this->options->themeUrl('public/twentyfifteen.js');
function getHostOverViewData($hostname, $metrics, $cluster, $hosts_up, $hosts_down, $always_timestamp, $always_constant, $data) { $data->assign("extra", template("host_extra.tpl")); $data->assign("host", $hostname); $data->assign("node_image", node_image($metrics)); if ($hosts_up) { $data->assign("node_msg", "This host is up and running."); } else { $data->assign("node_msg", "This host is down."); } # No reason to go on if this node is down. if ($hosts_down) { return; } foreach ($metrics as $name => $v) { if ($v['TYPE'] == "string" or $v['TYPE'] == "timestamp" or isset($always_timestamp[$name]) and $always_timestamp[$name]) { $s_metrics[$name] = $v; } elseif ($v['SLOPE'] == "zero" or isset($always_constant[$name]) and $always_constant[$name]) { $c_metrics[$name] = $v; } } # in case this is not defined, set to LOCALTIME so uptime will be 0 in the display $boottime = null; if (isset($metrics['boottime']['VAL'])) { $boottime = $metrics['boottime']['VAL']; } else { $boottime = $cluster['LOCALTIME']; } # Add the uptime metric for this host. Cannot be done in ganglia.php, # since it requires a fully-parsed XML tree. The classic contructor problem. $s_metrics['uptime']['TYPE'] = "string"; $s_metrics['uptime']['VAL'] = uptime($cluster['LOCALTIME'] - $boottime); $s_metrics['uptime']['TITLE'] = "Uptime"; # Add the gmond started timestamps & last reported time (in uptime format) from # the HOST tag: $s_metrics['gmond_started']['TYPE'] = "timestamp"; $s_metrics['gmond_started']['VAL'] = $hosts_up['GMOND_STARTED']; $s_metrics['gmond_started']['TITLE'] = "Gmond Started"; $s_metrics['last_reported']['TYPE'] = "string"; $s_metrics['last_reported']['VAL'] = uptime($cluster['LOCALTIME'] - $hosts_up['REPORTED']); $s_metrics['last_reported']['TITLE'] = "Last Reported"; $s_metrics['ip_address']['TITLE'] = "IP Address"; $s_metrics['ip_address']['VAL'] = $hosts_up['IP']; $s_metrics['ip_address']['TYPE'] = "string"; $s_metrics['location']['TITLE'] = "Location"; $s_metrics['location']['VAL'] = $hosts_up['LOCATION']; $s_metrics['location']['TYPE'] = "string"; # String metrics if (is_array($s_metrics)) { $s_metrics_data = array(); ksort($s_metrics); foreach ($s_metrics as $name => $v) { # RFM - If units aren't defined for metric, make it be the empty string !array_key_exists('UNITS', $v) and $v['UNITS'] = ""; if (isset($v['TITLE'])) { $s_metrics_data[$name]["name"] = $v['TITLE']; } else { $s_metrics_data[$name]["name"] = $name; } if ($v['TYPE'] == "timestamp" or isset($always_timestamp[$name]) and $always_timestamp[$name]) { $s_metrics_data[$name]["value"] = date("r", $v['VAL']); } else { $s_metrics_data[$name]["value"] = $v['VAL'] . " " . $v['UNITS']; } } } $data->assign("s_metrics_data", $s_metrics_data); # Constant metrics. $c_metrics_data = null; if (isset($c_metrics) and is_array($c_metrics)) { $c_metrics_data = array(); ksort($c_metrics); foreach ($c_metrics as $name => $v) { if (isset($v['TITLE'])) { $c_metrics_data[$name]["name"] = $v['TITLE']; } else { $c_metrics_data[$name]["name"] = $name; } $c_metrics_data[$name]["value"] = "{$v['VAL']} {$v['UNITS']}"; } } $data->assign("c_metrics_data", $c_metrics_data); }
} } } } # Add the uptime metric for this host. Cannot be done in ganglia.php, # since it requires a fully-parsed XML tree. The classic contructor problem. $s_metrics['uptime']['TYPE'] = "string"; $s_metrics['uptime']['VAL'] = uptime($cluster['LOCALTIME'] - $metrics['boottime']['VAL']); $s_metrics['uptime']['TITLE'] = "Uptime"; # Add the gmond started timestamps & last reported time (in uptime format) from # the HOST tag: $s_metrics['gmond_started']['TYPE'] = "timestamp"; $s_metrics['gmond_started']['VAL'] = $hosts_up['GMOND_STARTED']; $s_metrics['gmond_started']['TITLE'] = "Gmond Started"; $s_metrics['last_reported']['TYPE'] = "string"; $s_metrics['last_reported']['VAL'] = uptime($cluster['LOCALTIME'] - $hosts_up['REPORTED']); $s_metrics['last_reported']['TITLE'] = "Last Reported"; # Show string metrics if (is_array($s_metrics)) { ksort($s_metrics); foreach ($s_metrics as $name => $v) { # RFM - If units aren't defined for metric, make it be the empty string !array_key_exists('UNITS', $v) and $v['UNITS'] = ""; $tpl->newBlock("string_metric_info"); if (isset($v['TITLE'])) { $tpl->assign("name", $v['TITLE']); } else { $tpl->assign("name", $name); } if ($v['TYPE'] == "timestamp" or isset($always_timestamp[$name]) and $always_timestamp[$name]) { $tpl->assign("value", date("r", $v['VAL']));
function get_host_metric_graphs($showhosts, $hosts_up, $hosts_down, $user, $conf, $metrics, $metricname, $sort, $clustername, $get_metric_string, $cluster, $always_timestamp, $reports_metricname, $clustergraphsize, $range, $start, $end, $cs, $ce, $vlabel, $data) { $sorted_hosts = array(); $down_hosts = array(); if ($showhosts == 0) { return; } foreach ($hosts_up as $host => $val) { // If host_regex is defined if (isset($user['host_regex']) && !preg_match("/" . $user['host_regex'] . "/", $host)) { continue; } $load = get_load($host, $metrics); $host_load[$host] = $load; if ($metricname == "load_one") { $sorted_hosts[$host] = $load; } else { if (isset($metrics[$host][$metricname])) { $sorted_hosts[$host] = $metrics[$host][$metricname]['VAL']; } else { $sorted_hosts[$host] = ""; } } } // foreach hosts_up foreach ($hosts_down as $host => $val) { $down_hosts[$host] = -1.0; } $data->assign("node_legend", 1); if (!is_array($hosts_up)) { return; } switch ($sort) { case "descending": arsort($sorted_hosts); break; case "by name": uksort($sorted_hosts, "strnatcmp"); break; default: case "ascending": asort($sorted_hosts); break; } $sorted_hosts = array_merge($down_hosts, $sorted_hosts); if (isset($user['max_graphs'])) { $max_graphs = $user['max_graphs']; } else { $max_graphs = $conf['max_graphs']; } // First pass to find the max value in all graphs for this // metric. The $start,$end variables comes from get_context.php, // included in index.php. // Do this only if person has not selected a maximum set of graphs to display if ($max_graphs == 0 && $showhosts == 1) { $cs = $user['cs']; if ($cs and (is_numeric($cs) or strtotime($cs))) { $start = $cs; } $ce = $user['ce']; if ($ce and (is_numeric($ce) or strtotime($ce))) { $end = $ce; } list($min, $max) = find_limits($clustername, $sorted_hosts, $metricname, $start, $end, $metrics, $conf, $rrd_options); } // Second pass to output the graphs or metrics. $i = 1; // Initialize overflow list $overflow_list = array(); $overflow_counter = 1; $cluster_url = rawurlencode($clustername); $size = isset($clustergraphsize) ? $clustergraphsize : 'small'; if ($conf['hostcols'] == 0) { // enforce small size in multi-host report $size = 'small'; } // set host zoom class based on the size of the graph shown if (isset($conf['zoom_support']) && $conf['zoom_support'] === true) { $additional_host_img_html_args = "class=host_{$size}_zoomable"; } foreach ($sorted_hosts as $host => $value) { if (isset($hosts_down[$host]) and $hosts_down[$host] && isset($conf['cluster_hide_down_hosts']) && $conf['cluster_hide_down_hosts']) { // If we're hiding DOWN hosts, we skip to next iteration of the loop. continue; } $host_url = $case_sensitive_hostnames ? rawurlencode($host) : strtolower(rawurlencode($host)); $host_link = "\"?c={$cluster_url}&h={$host_url}&{$get_metric_string}\""; $textval = ""; //echo "$host: $value, "; if (isset($hosts_down[$host]) and $hosts_down[$host]) { $last_heartbeat = $cluster['LOCALTIME'] - $hosts_down[$host]['REPORTED']; $age = $last_heartbeat > 3600 ? uptime($last_heartbeat) : "{$last_heartbeat}s"; $class = "down"; $textval = "down <br> <font size=\"-2\">Last heartbeat {$age} ago</font>"; } else { if (isset($metrics[$host][$metricname])) { $val = $metrics[$host][$metricname]; } else { $val = NULL; } $class = "metric"; if ($val['TYPE'] == "timestamp" or isset($always_timestamp[$metricname]) and $always_timestamp[$metricname]) { $textval = date("r", $val['VAL']); } elseif ($val['TYPE'] == "string" or $val['SLOPE'] == "zero" or (isset($always_constant[$metricname]) and $always_constant[$metricname] or $max_graphs > 0 and $i > $max_graphs)) { if (isset($reports_metricname) and $reports_metricname) { // No "current" values available for reports $textval = "N/A"; } else { $textval = "{$val['VAL']}"; } if (isset($val['UNITS'])) { $textval .= " {$val['UNITS']}"; } } } $graphargs = "z={$size}&c={$cluster_url}&h={$host_url}"; if (isset($host_load[$host])) { $load_color = load_color($host_load[$host]); $graphargs .= "&l={$load_color}&v={$val['VAL']}"; } $graphargs .= "&r={$range}&su=1&st={$cluster['LOCALTIME']}"; if ($cs) { $graphargs .= "&cs=" . rawurlencode($cs); } if ($ce) { $graphargs .= "&ce=" . rawurlencode($ce); } // If we want scaling to be the same in clusterview we need to set // $max and $min values if ($showhosts == 1 && $max_graphs == 0) { $graphargs .= "&x={$max}&n={$min}"; } if (isset($vlabel)) { $graphargs .= "&vl=" . urlencode($vlabel); } if ($textval) { $cell = "<td class={$class}>" . "<b><a href={$host_link}>{$host}</a></b><br>" . "<i>{$metricname}:</i> <b>{$textval}</b></td>"; } else { $cell = "<td><div><font style='font-size: 8px'>{$host}</font><br><a href={$host_link}><img {$additional_host_img_html_args} src=\"./graph.php?"; $cell .= (isset($reports_metricname) and $reports_metricname) ? "g={$metricname}" : "m={$metricname}"; $cell .= "&{$graphargs}\" title=\"{$host}\" border=0 style=\"padding:2px;\"></a></div></td>"; } if ($conf['hostcols'] == 0) { $pre = "<td><a href={$host_link}><img src=\"./graph.php?g="; $post = "&{$graphargs}\" {$additional_host_img_html_args} title=\"{$host}\" border=0 style=\"padding:2px;\"></a></td>"; $cell .= $pre . "load_report" . $post; $cell .= $pre . "mem_report" . $post; $cell .= $pre . "cpu_report" . $post; $cell .= $pre . "network_report" . $post; } // Check if max_graphs is set. // If it put cells in an overflow list since that one is hidden by default if ($max_graphs > 0 and $i > $max_graphs) { $overflow_list[$host]["metric_image"] = $cell; if (!($overflow_counter++ % $conf['hostcols'])) { $overflow_list[$host]["br"] = "</tr><tr>"; } else { $overflow_list[$host]["br"] = ""; } } else { $sorted_list[$host]["metric_image"] = $cell; if (!($i++ % $conf['hostcols'])) { $sorted_list[$host]["br"] = "</tr><tr>"; } else { $sorted_list[$host]["br"] = ""; } } // end of if ($max_graphs > 0 and $i > $max_graphs ) { } // foreach sorted_hosts $data->assign("sorted_list", $sorted_list); // If there is an overflow list. These are hosts for which we don't show graphs // just names if (count($overflow_list) > 0) { $data->assign("overflow_list_header", '<p><table width=80%><tr><td align=center class=metric> <a href="#" id="overflow_list_button"onclick="$(\'#overflow_list\').toggle();" class="button ui-state-default ui-corner-all" title="Toggle overflow list">Show more hosts (' . ($overflow_counter - 1) . ')</a> </td></tr></table> <div style="display: none;" id="overflow_list"><table> <tr> '); $data->assign("overflow_list_footer", "</div></tr></table></div>"); } else { $data->assign("overflow_list_header", ""); $data->assign("overflow_list_footer", ""); } $data->assign("overflow_list", $overflow_list); }
$starttime = $mtime[1] + $mtime[0]; if (!get_cfg_var('register_globals')) { foreach ($HTTP_GET_VARS as $key => $val) { ${$key} = $val; } foreach ($HTTP_POST_VARS as $key => $val) { ${$key} = $val; } } if (!$style) { $style = $defstyle; } $PHP_SELF = $HTTP_SERVER_VARS[PHP_SELF] ? $HTTP_SERVER_VARS[PHP_SELF] : $HTTP_SERVER_VARS[SCRIPT_NAME]; $phpos = PHP_OS; if ($phpos == 'BSD' || $phpos == 'FreeBSD' || $phpos == 'Linux' || $phpos == 'NetBSD' || $phpos == 'OpenBSD' || $phpos == 'Darwin') { $osinfo = uptime(); } else { $osinfo = '对不起' . $phpos . '系统不支持'; } if (get_cfg_var('safemode')) { $safemode = '是'; } else { $safemode = '否'; } if (get_cfg_var('file_uploads') == '1') { $upsize = get_cfg_var('upload_max_filesize'); } else { $upsize = '不允许上传'; } if (isset($_SERVER['SERVER_ADMIN'])) { $adminmail = "<a href=\"mailto:" . $_SERVER['SERVER_ADMIN'] . "\" title=\"发送邮件\">" . $_SERVER['SERVER_ADMIN'] . '</a>';