From 367f057e6d6414f0a0ca7c03d4b05a7d27b268bb Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Mon, 5 Aug 2013 17:45:56 +0200 Subject: [PATCH] Refactored monitoring page * Allow easier addition of new crons to the monitor list * Make the data generation dynamic instead of hard to adjust lists Fixes #559 upon merge. --- public/include/pages/admin/monitoring.inc.php | 114 +++--------------- .../mmcFE/admin/monitoring/default.tpl | 34 +++--- 2 files changed, 36 insertions(+), 112 deletions(-) diff --git a/public/include/pages/admin/monitoring.inc.php b/public/include/pages/admin/monitoring.inc.php index 627223d8..8b587398 100644 --- a/public/include/pages/admin/monitoring.inc.php +++ b/public/include/pages/admin/monitoring.inc.php @@ -9,106 +9,30 @@ if (!$user->isAuthenticated() || !$user->isAdmin($_SESSION['USERDATA']['id'])) { die("404 Page not found"); } -// Fetch settings to propagate to template -$aCronStatus = array( - 'statistics' => array ( - array( 'NAME' => 'Exit Code', 'STATUS' => $monitoring->getStatus('statistics_status') ), - array( 'NAME' => 'Active', 'STATUS' => $monitoring->getStatus('statistics_active') ), - array( 'NAME' => 'Runtime', 'STATUS' => $monitoring->getStatus('statistics_runtime') ), - array( 'NAME' => 'Start Time', 'STATUS' => $monitoring->getStatus('statistics_starttime') ), - array( 'NAME' => 'End Time', 'STATUS' => $monitoring->getStatus('statistics_endtime') ), - array( 'NAME' => 'Last Message', 'STATUS' => $monitoring->getStatus('statistics_message') ), - ), - 'auto_payout' => array ( - array( 'NAME' => 'Exit Code', 'STATUS' => $monitoring->getStatus('auto_payout_status') ), - array( 'NAME' => 'Active', 'STATUS' => $monitoring->getStatus('auto_payout_active') ), - array( 'NAME' => 'Runtime', 'STATUS' => $monitoring->getStatus('auto_payout_runtime') ), - array( 'NAME' => 'Start Time', 'STATUS' => $monitoring->getStatus('auto_payout_starttime') ), - array( 'NAME' => 'End Time', 'STATUS' => $monitoring->getStatus('auto_payout_endtime') ), - array( 'NAME' => 'Last Message', 'STATUS' => $monitoring->getStatus('auto_payout_message') ), - ), - 'manual_payout' => array ( - array( 'NAME' => 'Exit Code', 'STATUS' => $monitoring->getStatus('manual_payout_status') ), - array( 'NAME' => 'Active', 'STATUS' => $monitoring->getStatus('manual_payout_active') ), - array( 'NAME' => 'Runtime', 'STATUS' => $monitoring->getStatus('manual_payout_runtime') ), - array( 'NAME' => 'Start Time', 'STATUS' => $monitoring->getStatus('manual_payout_starttime') ), - array( 'NAME' => 'End Time', 'STATUS' => $monitoring->getStatus('manual_payout_endtime') ), - array( 'NAME' => 'Last Message', 'STATUS' => $monitoring->getStatus('manual_payout_message') ), - ), - 'archive_cleanup' => array ( - array( 'NAME' => 'Exit Code', 'STATUS' => $monitoring->getStatus('archive_cleanup_status') ), - array( 'NAME' => 'Active', 'STATUS' => $monitoring->getStatus('archive_cleanup_active') ), - array( 'NAME' => 'Runtime', 'STATUS' => $monitoring->getStatus('archive_cleanup_runtime') ), - array( 'NAME' => 'Start Time', 'STATUS' => $monitoring->getStatus('archive_cleanup_starttime') ), - array( 'NAME' => 'End Time', 'STATUS' => $monitoring->getStatus('archive_cleanup_endtime') ), - array( 'NAME' => 'Last Message', 'STATUS' => $monitoring->getStatus('archive_cleanup_message') ), - ), - 'blockupdate' => array ( - array( 'NAME' => 'Exit Code', 'STATUS' => $monitoring->getStatus('blockupdate_status') ), - array( 'NAME' => 'Active', 'STATUS' => $monitoring->getStatus('blockupdate_active') ), - array( 'NAME' => 'Runtime', 'STATUS' => $monitoring->getStatus('blockupdate_runtime') ), - array( 'NAME' => 'Start Time', 'STATUS' => $monitoring->getStatus('blockupdate_starttime') ), - array( 'NAME' => 'End Time', 'STATUS' => $monitoring->getStatus('blockupdate_endtime') ), - array( 'NAME' => 'Last Message', 'STATUS' => $monitoring->getStatus('blockupdate_message') ), - ), - 'findblock' => array ( - array( 'NAME' => 'Exit Code', 'STATUS' => $monitoring->getStatus('findblock_status') ), - array( 'NAME' => 'Active', 'STATUS' => $monitoring->getStatus('findblock_active') ), - array( 'NAME' => 'Runtime', 'STATUS' => $monitoring->getStatus('findblock_runtime') ), - array( 'NAME' => 'Start Time', 'STATUS' => $monitoring->getStatus('findblock_starttime') ), - array( 'NAME' => 'End Time', 'STATUS' => $monitoring->getStatus('findblock_endtime') ), - array( 'NAME' => 'Last Message', 'STATUS' => $monitoring->getStatus('findblock_message') ), - ), - 'notifications' => array ( - array( 'NAME' => 'Exit Code', 'STATUS' => $monitoring->getStatus('notifications_status') ), - array( 'NAME' => 'Active', 'STATUS' => $monitoring->getStatus('notifications_active') ), - array( 'NAME' => 'Runtime', 'STATUS' => $monitoring->getStatus('notifications_runtime') ), - array( 'NAME' => 'Start Time', 'STATUS' => $monitoring->getStatus('notifications_starttime') ), - array( 'NAME' => 'End Time', 'STATUS' => $monitoring->getStatus('notifications_endtime') ), - array( 'NAME' => 'Last Message', 'STATUS' => $monitoring->getStatus('notifications_message') ), - ), - 'tickerupdate' => array ( - array( 'NAME' => 'Exit Code', 'STATUS' => $monitoring->getStatus('tickerupdate_status') ), - array( 'NAME' => 'Active', 'STATUS' => $monitoring->getStatus('tickerupdate_active') ), - array( 'NAME' => 'Runtime', 'STATUS' => $monitoring->getStatus('tickerupdate_runtime') ), - array( 'NAME' => 'Start Time', 'STATUS' => $monitoring->getStatus('tickerupdate_starttime') ), - array( 'NAME' => 'End Time', 'STATUS' => $monitoring->getStatus('tickerupdate_endtime') ), - array( 'NAME' => 'Last Message', 'STATUS' => $monitoring->getStatus('tickerupdate_message') ), - ) -); -// Payout system specifics +// Default crons to monitor +$aCrons = array('statistics','auto_payout','manual_payout','archive_cleanup','blockupdate','findblock','notifications','tickerupdate'); + +// Special cases, only add them if activated switch ($config['payout_system']) { -case 'pplns': - $aCronStatus['pplns_payout'] = array ( - array( 'NAME' => 'Exit Code', 'STATUS' => $monitoring->getStatus('pplns_payout_status') ), - array( 'NAME' => 'Active', 'STATUS' => $monitoring->getStatus('pplns_payout_active') ), - array( 'NAME' => 'Runtime', 'STATUS' => $monitoring->getStatus('pplns_payout_runtime') ), - array( 'NAME' => 'Start Time', 'STATUS' => $monitoring->getStatus('pplns_payout_starttime') ), - array( 'NAME' => 'End Time', 'STATUS' => $monitoring->getStatus('pplns_payout_endtime') ), - array( 'NAME' => 'Last Message', 'STATUS' => $monitoring->getStatus('pplns_payout_message') ), - ); - break; -case 'pps': - $aCronStatus['pps_payout'] = array( - array( 'NAME' => 'Exit Code', 'STATUS' => $monitoring->getStatus('pps_payout_status') ), - array( 'NAME' => 'Active', 'STATUS' => $monitoring->getStatus('pps_payout_active') ), - array( 'NAME' => 'Runtime', 'STATUS' => $monitoring->getStatus('pps_payout_runtime') ), - array( 'NAME' => 'Start Time', 'STATUS' => $monitoring->getStatus('pps_payout_starttime') ), - array( 'NAME' => 'End Time', 'STATUS' => $monitoring->getStatus('pps_payout_endtime') ), - array( 'NAME' => 'Last Message', 'STATUS' => $monitoring->getStatus('pps_payout_message') ), - ); +case 'pplns'||'pps': + $aCrons[] = $config['payout_system']; break; case 'prop': - $aCronStatus['proportional_payout'] = array( - array( 'NAME' => 'Exit Code', 'STATUS' => $monitoring->getStatus('proportional_payout_status') ), - array( 'NAME' => 'Active', 'STATUS' => $monitoring->getStatus('proportional_payout_active') ), - array( 'NAME' => 'Runtime', 'STATUS' => $monitoring->getStatus('proportional_payout_runtime') ), - array( 'NAME' => 'Start Time', 'STATUS' => $monitoring->getStatus('proportional_payout_starttime') ), - array( 'NAME' => 'End Time', 'STATUS' => $monitoring->getStatus('proportional_payout_endtime') ), - array( 'NAME' => 'Last Message', 'STATUS' => $monitoring->getStatus('proportional_payout_message') ), - ); + $aCrons[] = 'proportional'; break; } + +// Data array for template +foreach ($aCrons as $strCron) { + $aCronStatus[$strCron] = array( + 'exit' => $monitoring->getStatus($strCron . '_status'), + 'active' => $monitoring->getStatus($strCron . '_active'), + 'runtime' => $monitoring->getStatus($strCron . '_runtime'), + 'starttime' => $monitoring->getStatus($strCron . '_starttime'), + 'endtime' => $monitoring->getStatus($strCron . '_endtime'), + 'message' => $monitoring->getStatus($strCron . '_message'), + ); +} $smarty->assign("CRONSTATUS", $aCronStatus); // Tempalte specifics diff --git a/public/templates/mmcFE/admin/monitoring/default.tpl b/public/templates/mmcFE/admin/monitoring/default.tpl index 07831059..556d77c4 100644 --- a/public/templates/mmcFE/admin/monitoring/default.tpl +++ b/public/templates/mmcFE/admin/monitoring/default.tpl @@ -10,43 +10,43 @@ Message -{foreach $CRONSTATUS as $cron=>$v} +{foreach $CRONSTATUS as $cron => $data} {$cron} - {foreach $v as $event} + {foreach $data as $name => $event} - {if $event.STATUS.type == 'okerror'} - {if $event.STATUS.value == 0} + {if $event.type == 'okerror'} + {if $event.value == 0} OK {else} ERROR {/if} - {else if $event.STATUS.type == 'message'} - {$event.STATUS.value} - {else if $event.STATUS.type == 'yesno'} - - {else if $event.STATUS.type == 'time'} - {if $event.STATUS.value > 60} + {else if $event.type == 'message'} + {$event.value} + {else if $event.type == 'yesno'} + + {else if $event.type == 'time'} + {if $event.value > 60} - {else if $event.STATUS.value > 120} + {else if $event.value > 120} {else} {/if} - {$event.STATUS.value|default:"0"|number_format:"2"} seconds + {$event.value|default:"0"|number_format:"2"} seconds - {else if $event.STATUS.type == 'date'} - {if ($smarty.now - 180) > $event.STATUS.value} + {else if $event.type == 'date'} + {if ($smarty.now - 180) > $event.value} - {else if ($smarty.now - 120) > $event.STATUS.value} + {else if ($smarty.now - 120) > $event.value} {else} {/if} - {$event.STATUS.value|date_format:"%m/%d %H:%M:%S"} + {$event.value|date_format:"%m/%d %H:%M:%S"} {else} - {$event.STATUS.value|default:""} + {$event.value|default:""} {/if} {/foreach}