?? index.php
字號:
<?php/* * kannel-status.php -- display a summarized kannel status page * * This php script acts as client for the status.xml output of * Kannel's bearerbox and aggregates information about smsc link * status and message flow. It is the first step to provide an * external Kannel Control Center interface via HTTP. * * Stipe Tolj <stolj@wapme.de> * Copyright (c) 2003 Kannel Group. */include("xmlfunc.php");/* config section: define which Kannel status URLs to monitor */$configs = array( array( "base_url" => "http://kannel.yourdomain.com:13000", "status_passwd" => "foobar", "admin_passwd" => "", "name" => "Kannel 1" ), array( "base_url" => "http://kannel.yourdomain.com:23000", "status_passwd" => "foobar", "admin_passwd" => "", "name" => "Kannel 2" ), array( "base_url" => "http://kannel.yourdomain.com:33000", "status_passwd" => "foobar", "admin_passwd" => "", "name" => "Kannel 3" ) );/* some constants */$CONST_QUEUE_ERROR = 100;$depth = array();$status = array();/* set php internal error reporting level */error_reporting(0); ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head> <meta http-equiv="refresh" content="<?php /* determine if we have a set refresh rate, default to 60s */ $refresh = $HTTP_GET_VARS[refresh]; $timeout = (!empty($refresh)) ? $refresh : 60; echo "$timeout; URL=$_SERVER[REQUEST_URI]"; ?>"> <title>Kannel Status</title> <link href="kannel.css" rel="stylesheet" type="text/css"> <script src="kannel.js" type="text/javascript"></script></head><body><!-- the header block showing some basic information --><table width=100% cellspacing=0 cellpadding=0 border=0><tr><td valign=top> <h3>Kannel Status Monitor</h3></td><td valign=top align=left class=text> Current date and time: <br /> <b><?php echo date("Y-m-d H:i:s"); ?></b></td><td valign=top align=right class=text> Refrash rate: <br /> <?php $t_down = ceil($timeout / 2); $t_up = ceil($timeout * 2); $purl = parse_url($_SERVER['REQUEST_URI']); $base_uri = $purl[path]; ?> <a class=href href="<?php echo $base_uri."?refresh=".$t_down; ?>"><?php echo $t_down; ?>s</a> | <b><?php echo $timeout; ?>s</b> | <a class=href href="<?php echo $base_uri."?refresh=".$t_up; ?>"><?php echo $t_up; ?>s</a></td></tr></table><table width=100% cellspacing=0 cellpadding=5 border=0><tr><td valign=top align=left class=text> <?php echo sizeof($configs); ?> instance(s) configured for this monitor: <br /></td><td valign=top align=right class=text> Admin commands:</td></tr> <?php /* loop through all configured URLs */ foreach ($configs as $inst => $config) { echo "<tr><td class=text valign=top align=left>\n"; $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, "startElement", "endElement"); /* get the status.xml URL of one config */ $url = $config["base_url"]."/status.xml?password=".$config["status_passwd"]; $status[$inst] = ""; /* open the file description to the URL */ if (($fp = fopen($url, "r"))) { echo "<span class=green>($inst) (".$config["name"].") <b>$url</b></span> <br /> \n"; /* read the XML input */ while (!feof($fp)) { $status[$inst] .= fread($fp, 200000); } } else { echo "<span class=red>($inst) (".$config["name"].") <b>$url</b></span> <br /> \n"; } fclose($fp); /* get the status of this bearerbox */ $s = XPathValue("gateway/status", $status[$inst]); if (ereg("(.*), uptime (.*)d (.*)h (.*)m (.*)s", $s, $regs)) { $ts = ($regs[2]*24*60*60) + ($regs[3]*60*60) + ($regs[4]*60) + $regs[5]; echo " "; echo "<b>$regs[1]</b>, "; echo "started ".date("Y-m-d H:i:s", mktime()-$ts); $bb_time[$inst] = mktime()-$ts; echo ", uptime $regs[2]d $regs[3]h $regs[4]m $regs[5]s <br />\n"; } ?> </td><td class=text valign=top align=right> <a class=href href="#" onClick="admin_url('suspend', '<?php echo $config["base_url"]."/suspend"; ?>', '<?php echo $config["admin_passwd"]; ?>');">suspend</a> | <a class=href href="#" onClick="admin_url('isolate', '<?php echo $config["base_url"]."/isolate"; ?>', '<?php echo $config["admin_passwd"]; ?>');">isolate</a> | <a class=href href="#" onClick="admin_url('resume', '<?php echo $config["base_url"]."/resume"; ?>', '<?php echo $config["admin_passwd"]; ?>');">resume</a> <br/> <a class=href href="#" onClick="admin_url('flush-dlr', '<?php echo $config["base_url"]."/flush-dlr"; ?>', '<?php echo $config["admin_passwd"]; ?>');">flush-dlr</a> | <a class=href href="#" onClick="admin_url('shutdown', '<?php echo $config["base_url"]."/shutdown"; ?>', '<?php echo $config["admin_passwd"]; ?>');">shutdown</a> | <a class=href href="#" onClick="admin_url('restart', '<?php echo $config["base_url"]."/restart"; ?>', '<?php echo $config["admin_passwd"]; ?>');">restart</a> </td></tr> <?php /* if (!xml_parse($xml_parser, $status[$url], feof($fp))) { die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser))); } */ xml_parser_free($xml_parser); }?></table><h4>Overall SMS traffic</h4><p id=bord><table width=100% cellspacing=0 cellpadding=5 border=1><tr><td valign=top align=right class=text> Received (MO)</td><td valign=top align=right class=text> Inbound (MO)</td><td valign=top align=right class=text> Sent (MT)</td><td valign=top align=right class=text> Outbound (MT)</td><td valign=top align=right class=text> Queued (MO)</td><td valign=top align=right class=text> Queued (MT)</td></tr><tr><td valign=top align=right class=text> <?php $sum = 0; foreach ($configs as $inst => $config) { $mo[$inst] = XPathValue("gateway/sms/received/total", $status[$inst]); $sum += $mo[$inst]; echo "($inst) <b>".nf($mo[$inst])."</b> msgs<br />\n"; } echo "<hr size=1>\n"; echo "(all) <b>".nf($sum)."</b> msgs<br />\n"; ?></td><td valign=top align=right class=text> <?php $sum = 0; foreach ($configs as $inst => $config) { $in[$inst] = XPathValue("gateway/sms/inbound", $status[$inst]); $sum += $in[$inst]; echo "($inst) <b>".nfd($in[$inst])."</b> msgs/s<br />\n"; } echo "<hr size=1>\n"; echo "(all) <b>".nfd($sum)."</b> msgs/s<br />\n"; ?></td><td valign=top align=right class=text> <?php $sum = 0; foreach ($configs as $inst => $config) { $mt[$inst] = XPathValue("gateway/sms/sent/total", $status[$inst]); $sum += $mt[$inst]; echo "($inst) <b>".nf($mt[$inst])."</b> msgs<br />\n"; } echo "<hr size=1>\n"; echo "(all) <b>".nf($sum)."</b> msgs<br />\n"; ?></td><td valign=top align=right class=text> <?php $sum = 0; foreach ($configs as $inst => $config) { $out[$inst] = XPathValue("gateway/sms/outbound", $status[$inst]); $sum += $out[$inst]; echo "($inst) <b>".nfd($out[$inst])."</b> msgs/s<br />\n"; } echo "<hr size=1>\n"; echo "(all) <b>".nfd($sum)."</b> msgs/s<br />\n"; ?></td><td valign=top align=right class=text> <?php $sum = 0; foreach ($configs as $inst => $config) { $mo_q[$inst] = XPathValue("gateway/sms/received/queued", $status[$inst]); $sum += $mo_q[$inst]; echo "($inst) ".nf($mo_q[$inst])." msgs<br />\n"; } echo "<hr size=1>\n"; echo "(all) "; if ($sum > $CONST_QUEUE_ERROR) { echo "<span class=red>".nf($sum)." msgs</span>"; } else { echo nf($sum)." msgs"; } echo " <br />\n"; ?></td><td valign=top align=right class=text> <?php $sum = 0; foreach ($configs as $inst => $config) { $mt_q[$inst] = XPathValue("gateway/sms/sent/queued", $status[$inst]); $sum += $mt_q[$inst]; echo "($inst) ".nf($mt_q[$inst])." msgs<br />\n"; } echo "<hr size=1>\n"; echo "(all) "; if ($sum > $CONST_QUEUE_ERROR) { echo "<span class=red>".nf($sum)." msgs</span>"; } else { echo nf($sum)." msgs"; } echo " <br />\n"; ?></td></tr></table></p><h4>Box connections</h4><p id=bord><table width=100% cellspacing=0 cellpadding=1 border=0><tr><td valign=top align=center class=text> Instance</td><td valign=top class=text> Type</td><td valign=top class=text> ID</td><td valign=top class=text> IP</td><td valign=top align=right class=text>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -