function drd_server_heartbeat in Drupal Remote Dashboard Server 6.2
Same name and namespace in other branches
- 7.2 drd_server.module \drd_server_heartbeat()
Return value
string
1 string reference to 'drd_server_heartbeat'
- drd_server_xmlrpc in ./
drd_server.module - Implementation of hook_xmlrpc().
File
- ./
drd_server.module, line 400
Code
function drd_server_heartbeat() {
$args = func_get_args();
$valid = _drd_server_validate_request($args);
if ($valid !== TRUE) {
return $valid;
}
$period = array_shift($args);
/**
* Session count is "borrowed" from the admin_menu module, credit to their maintainers.
*/
$interval = REQUEST_TIME - variable_get('user_block_seconds_online', 900);
$heartbeat = array(
'count' => array(
'user' => array(
'all' => _drd_server_count('users', 'uid'),
'sessions' => _drd_server_count_session($interval, TRUE),
'auth' => _drd_server_count_session($interval, FALSE),
),
'content' => array(
'node' => _drd_server_count('node', 'nid'),
'comment' => _drd_server_count('comments', 'cid'),
),
),
'file' => array(
'temp' => _drd_server_count_file(0),
'perm' => _drd_server_count_file(1),
),
'watchdog' => array(
'emergency' => 0,
'alert' => _drd_server_count_watchdog(WATCHDOG_ALERT, $period),
'critical' => _drd_server_count_watchdog(WATCHDOG_CRITICAL, $period),
'error' => _drd_server_count_watchdog(WATCHDOG_ERROR, $period),
'warning' => _drd_server_count_watchdog(WATCHDOG_WARNING, $period),
'notice' => _drd_server_count_watchdog(WATCHDOG_NOTICE, $period),
'info' => _drd_server_count_watchdog(WATCHDOG_INFO, $period),
'debug' => _drd_server_count_watchdog(WATCHDOG_DEBUG, $period),
),
);
$heartbeat['detail'] = array(
'user' => array(
'title' => t('User'),
'content' => array(
format_plural($heartbeat['count']['user']['auth'], '@count authenticated user', '@count authenticated users'),
format_plural($heartbeat['count']['user']['sessions'], '@count user session', '@count user sessions'),
format_plural($heartbeat['count']['user']['all'], '@count registered user', '@count registered users'),
),
),
'content' => array(
'title' => t('Content'),
'content' => array(
format_plural($heartbeat['count']['content']['node'], '@count node', '@count nodes'),
format_plural($heartbeat['count']['content']['comment'], '@count comment', '@count comments'),
),
),
'file' => array(
'title' => t('Files'),
'content' => array(
format_plural($heartbeat['file']['temp']['count'], '@count temporary file with %size', '@count temporary files with %size', array(
'%size' => format_size($heartbeat['file']['temp']['size']),
)),
format_plural($heartbeat['file']['perm']['count'], '@count permanent file with %size', '@count permanent files with %size', array(
'%size' => format_size($heartbeat['file']['perm']['size']),
)),
),
),
'watchdog' => array(
'title' => t('Watchdog'),
'content' => array(),
),
);
foreach ($heartbeat['watchdog'] as $key => $value) {
$heartbeat['detail']['watchdog']['content'][$key] = format_plural($value, '@count %severity entry', '@count %severity entries', array(
'%severity' => $key,
));
}
drupal_alter('drd_server_heartbeat', $heartbeat);
return drd_server_result('drd.heartbeat', $heartbeat);
}