You are here

drupalmonitor_connector.module in Drupalmonitor 7

This file is the core of drupalmonitor_connector

File

drupalmonitor_connector.module
View source
<?php

/**
 * @file
 * This file is the core of drupalmonitor_connector
 */
define('DRUPALMONITOR_VERSION', '7.x-1.13');

/**
 * Implements hook_menu().
 */
function drupalmonitor_connector_menu() {
  $items['drupalmonitor'] = array(
    'title' => 'Drupalmonitor connector',
    'page callback' => 'drupalmonitor_connector_page_data',
    'access arguments' => array(
      'access drupalmonitor api',
    ),
    'type' => MENU_CALLBACK,
    'description' => 'Output drupalmonitor metrics',
    'file' => 'drupalmonitor_connector.pages.inc',
  );
  $items['admin/config/system/drupalmonitor'] = array(
    'title' => 'Drupalmonitor.com',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'drupalmonitor_connector_settings_form',
    ),
    'access arguments' => array(
      'administer drupalmonitor',
    ),
    'description' => 'Manage settings for Drupalmonitor connector module. (Security hash, Logging)',
    'file' => 'drupalmonitor_connector.admin.inc',
  );
  return $items;
}

/**
 * Implements hook_permission().
 */
function drupalmonitor_connector_permission() {
  return array(
    'administer drupalmonitor' => array(
      'title' => t('View Drupalmonitor settings page'),
      'description' => t('Allow user to change settings on the Drupalmonitor settings page.'),
    ),
    'access drupalmonitor api' => array(
      'title' => t('Access the Drupalmonitor API'),
      'description' => t('Allow Drupalmonitor.com crawler to access /drupalmonitor.'),
    ),
  );
}

/**
 * Register shutdown function.
 */
function drupalmonitor_connector_boot() {
  register_shutdown_function('drupalmonitor_connector_shutdow');
}

/**
 * Save log entry to db for performance monitoring.
 */
function drupalmonitor_connector_shutdow() {
  if (variable_get('drupalmonitor_performance_monitoring', 1) == 1) {
    db_insert('drupalmonitor_log')
      ->fields(array(
      'q' => $_GET['q'],
      'memory' => memory_get_peak_usage(),
      'dt' => REQUEST_TIME,
      'execution_time' => timer_read('page'),
    ))
      ->execute();
  }
}

Functions

Namesort descending Description
drupalmonitor_connector_boot Register shutdown function.
drupalmonitor_connector_menu Implements hook_menu().
drupalmonitor_connector_permission Implements hook_permission().
drupalmonitor_connector_shutdow Save log entry to db for performance monitoring.

Constants

Namesort descending Description
DRUPALMONITOR_VERSION @file This file is the core of drupalmonitor_connector