function new_relic_rpm_reporting in New Relic 7
Main page for New Relic reporting. List all the applications on this API Key.
1 string reference to 'new_relic_rpm_reporting'
- new_relic_rpm_menu in ./
new_relic_rpm.module - Implements hook_menu().
File
- ./
new_relic_rpm.reports.inc, line 11 - Reporting page callbacks.
Code
function new_relic_rpm_reporting() {
// If no API key is set, break here and error out.
$api_key = variable_get('new_relic_rpm_api_key', '');
if (empty($api_key)) {
drupal_set_message(t('You need to enter your New Relic API key from your New Relic account settings page before you are able to view reports within Drupal. Visit the <a href="@settings">New Relic Drupal admin page</a> to enter your API key.', array(
'@settings' => url('admin/config/development/new-relic-rpm'),
)), 'error');
return '<h2>' . t('API key not found.') . '</h2>';
}
// Get basic app health.
// This is also our first check for a bad key/access denied.
// Only hit the REST API every 60 seconds.
if ($_SESSION['new_relic_rpm_health_time'] < $_SERVER['REQUEST_TIME'] - 60 || !$_SESSION['new_relic_rpm_health_xml']) {
$app_health = new_relic_rpm_curl('https://rpm.newrelic.com/accounts.xml?include=application_health');
}
else {
$app_health = $_SESSION['new_relic_rpm_health_xml'];
}
// Error out of the return is False, store data if it is good.
if (!$app_health || trim($app_health) == '') {
drupal_set_message(t('The New Relic REST API has denied your key. Either the key you entered on the <a href="@settings">New Relic Drupal admin page</a> is incorrect, or you have not enabled API access for this application within the New Relic website.', array(
'@settings' => url('admin/config/development/new-relic-rpm'),
)), 'error');
return '<h2>' . t('API access denied.') . '</h2>';
}
else {
$_SESSION['new_relic_rpm_health_time'] = $_SERVER['REQUEST_TIME'];
$_SESSION['new_relic_rpm_health_xml'] = $app_health;
}
return new_relic_rpm_render_health($app_health);
}