From: Maxious Date: Tue, 21 Feb 2012 03:34:26 +0000 Subject: Add amon monitoring hook X-Git-Url: http://maxious.lambdacomplex.org/git/?p=busui.git&a=commitdiff&h=4ed61cd206388249695e0f8c69bcb5be4a1cbdd1 --- Add amon monitoring hook --- --- /dev/null +++ b/.gitmodules @@ -1,1 +1,4 @@ +[submodule "lib/amon-php"] + path = lib/amon-php + url = https://github.com/martinrusev/amon-php.git --- a/include/common-template.inc.php +++ b/include/common-template.inc.php @@ -184,20 +184,20 @@ } $serviceAlerts = Array(); $globalAlerts = getServiceAlertsAsArray("agency", "0"); - if ($globalAlerts != nullarray) { + if ($globalAlerts != null) { // echo "getting alerts due to network wide"; $serviceAlerts = array_merge($serviceAlerts, $globalAlerts); } if (isset($stopid)) { $stopAlerts = getServiceAlertsAsArray("stop", $stopid); - if ($stopAlerts != nullarray) { + if ($stopAlerts != null) { // echo "getting alerts due to stop $stopid"; $serviceAlerts = array_merge($serviceAlerts, $stopAlerts); } } if (isset($routeid)) { $routeAlerts = getServiceAlertsAsArray("route", $routeid); - if ($routeAlerts != nullarray) { + if ($routeAlerts != null) { // echo "getting alerts due to route $routeid"; $serviceAlerts = array_merge($serviceAlerts, $routeAlerts); } @@ -229,7 +229,7 @@ s.parentNode.insertBefore(ga, s); })();"; $googleAnalyticsImageUrl = googleAnalyticsGetImageUrl(); - echo ''; + echo ''; } echo "\n"; } --- a/include/common-transit.inc.php +++ b/include/common-transit.inc.php @@ -172,7 +172,8 @@ if (sizeof($informedEntities) > 0) { $affectsFilteredEntities = true; - $informed_count++; + foreach ($informedEntities as $informedEntity) { + $informed_count++; $informed = Array(); $es = new transit_realtime\EntitySelector(); if ($informedEntity['informed_class'] == "agency") { @@ -190,6 +191,7 @@ $es->setTrip($td); } $alert->addInformedEntity($es); +} } if ($current_alert['cause'] != "") { $alert->setCause(constant("transit_realtime\Alert\Cause::" . $current_alert['cause'])); @@ -216,7 +218,7 @@ if ($current_alert['description'] != "") { $tsDescriptionText = new transit_realtime\TranslatedString(); $tDescriptionText = new transit_realtime\TranslatedString\Translation(); - $tDescriptionText->setText($current_alert['description']); + $tDescriptionText->setText(trim($current_alert['description'])); $tDescriptionText->setLanguage("en"); $tsDescriptionText->addTranslation($tDescriptionText); $alert->setDescriptionText($tsDescriptionText); @@ -243,7 +245,7 @@ return $codec->encode($alerts); } else { - return nullarray; + return null; } } --- a/include/common.inc.php +++ b/include/common.inc.php @@ -51,13 +51,20 @@ || strstr($_SERVER['PHP_SELF'], "lib/") || strstr($_SERVER['PHP_SELF'], "geo/") || strstr($_SERVER['PHP_SELF'], "include/") - || strstr($_SERVER['PHP_SELF'], "servicealerts/")) + || strstr($_SERVER['PHP_SELF'], "rtpis/")) { $basePath = "../"; +} function isDebugServer() { return php_sapi_name() == "cli" || strstr(php_uname('n'),"actbus") || isset($_SERVER['SERVER_NAME']) && ( $_SERVER['SERVER_NAME'] == "azusa" || $_SERVER['SERVER_NAME'] == "vanille" || $_SERVER['SERVER_NAME'] == "localhost" || $_SERVER['SERVER_NAME'] == "127.0.0.1" || $_SERVER['SERVER_NAME'] == "192.168.1.8" || $_SERVER['SERVER_NAME'] == "192.168.178.24"); +} + +if (isset($_SERVER['SERVER_NAME']) && $_SERVER['SERVER_NAME'] == "maxious.xen.prgmr.com") { +// Set the exception handler +require $basePath."/lib/amon-php/amon.php"; +Amon::setup_exception_handler(); } include_once ("common-geo.inc.php"); --- a/include/db/route-dao.inc.php +++ b/include/db/route-dao.inc.php @@ -59,7 +59,12 @@ databaseError($conn->errorInfo()); return Array(); } - return $query->fetchAll(); + $results = $query->fetchAll(); + if (is_array($results)) { + return $results; + } else { + return Array($results); + } } function getRouteDescription($routeID, $directionID) { $trip = getRouteNextTrip($routeID, $directionID); @@ -120,7 +125,7 @@ function getRouteNextTrip($routeID, $directionID) { global $conn; - $query = "select routes.route_id,direction_id,trips.trip_id,trip_headsign,departure_time from routes join trips on trips.route_id = routes.route_id + $query = "select routes.route_id,direction_id,trips.trip_id,trip_headsign,departure_time,service_id from routes join trips on trips.route_id = routes.route_id join stop_times on stop_times.trip_id = trips.trip_id where arrival_time between :currentTime and :futureTime and routes.route_id = :routeID and trips.direction_id = :directionID order by arrival_time limit 1"; --- /dev/null +++ b/lib/amon-php --- a/routeList.php +++ b/routeList.php @@ -50,17 +50,17 @@ echo '