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.
This commit is contained in:
Sebastian Grewe 2013-08-05 17:45:56 +02:00
parent 2cddc27130
commit 367f057e6d
2 changed files with 36 additions and 112 deletions

View File

@ -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

View File

@ -10,43 +10,43 @@
<th>Message</th>
</thead>
<tbody>
{foreach $CRONSTATUS as $cron=>$v}
{foreach $CRONSTATUS as $cron => $data}
<tr>
<td>{$cron}</td>
{foreach $v as $event}
{foreach $data as $name => $event}
<td>
{if $event.STATUS.type == 'okerror'}
{if $event.STATUS.value == 0}
{if $event.type == 'okerror'}
{if $event.value == 0}
<font color="green">OK</font>
{else}
<font color="red">ERROR</font>
{/if}
{else if $event.STATUS.type == 'message'}
<i>{$event.STATUS.value}</i>
{else if $event.STATUS.type == 'yesno'}
<img src="{$PATH}/images/{if $event.STATUS.value == 1}success{else}error{/if}.gif" />
{else if $event.STATUS.type == 'time'}
{if $event.STATUS.value > 60}
{else if $event.type == 'message'}
<i>{$event.value}</i>
{else if $event.type == 'yesno'}
<img src="{$PATH}/images/{if $event.value == 1}success{else}error{/if}.gif" />
{else if $event.type == 'time'}
{if $event.value > 60}
<font color="orange">
{else if $event.STATUS.value > 120}
{else if $event.value > 120}
<font color="red">
{else}
<font color="green">
{/if}
{$event.STATUS.value|default:"0"|number_format:"2"} seconds
{$event.value|default:"0"|number_format:"2"} seconds
</font>
{else if $event.STATUS.type == 'date'}
{if ($smarty.now - 180) > $event.STATUS.value}
{else if $event.type == 'date'}
{if ($smarty.now - 180) > $event.value}
<font color="red">
{else if ($smarty.now - 120) > $event.STATUS.value}
{else if ($smarty.now - 120) > $event.value}
<font color="orange">
{else}
<font color="green">
{/if}
{$event.STATUS.value|date_format:"%m/%d %H:%M:%S"}
{$event.value|date_format:"%m/%d %H:%M:%S"}
</font>
{else}
{$event.STATUS.value|default:""}
{$event.value|default:""}
{/if}
</td>
{/foreach}