monitoring_demo.install in Monitoring 7
Install file of the monitoring_demo module.
File
test/monitoring_demo.installView source
<?php
/**
* @file
* Install file of the monitoring_demo module.
*/
/**
* Implements hook_enable().
*
* Executes setup of monitoring sensors to provide the demo functionality.
*/
function monitoring_demo_enable() {
require_once drupal_get_path('module', 'monitoring') . '/monitoring.setup.inc';
// Set the front page to monitoring-demo.
variable_set('site_frontpage', 'monitoring-demo');
// Create a few nodes and comments as sample data for some sensors.
$node = _monitoring_setup_create_node(array(
'type' => 'article',
));
_monitoring_setup_create_comment($node);
_monitoring_setup_create_comment($node);
_monitoring_setup_create_node();
$node = _monitoring_setup_create_node(array(
'type' => 'article',
));
_monitoring_setup_create_comment($node);
_monitoring_setup_create_comment($node);
_monitoring_setup_create_comment($node);
_monitoring_setup_create_node();
$sensor_manager = monitoring_sensor_manager();
// Setup search API.
monitoring_setup_search_api();
$sensor_manager
->resetCache();
$indexes = search_api_index_load_multiple(FALSE);
// Enable sensor for the index created above.
if (!empty($indexes)) {
foreach ($indexes as $index) {
$sensor_manager
->enableSensor('search_api_' . $index->machine_name);
}
}
// Enable content sensors.
$sensor_manager
->enableSensor('node_new_all');
$sensor_manager
->enableSensor('node_new_page');
$sensor_manager
->enableSensor('node_new_article');
$sensor_manager
->enableSensor('comment_new');
// Generate watchdog entries.
// Watchdog sensors are enabled by default, no need to enable them here.
for ($i = 0; $i < 20; $i++) {
watchdog('sensor_demo', _monitoring_setup_random_name(), array(), WATCHDOG_ERROR);
watchdog('sensor_demo', _monitoring_setup_random_name(), array(), WATCHDOG_NOTICE);
}
for ($i = 0; $i < 10; $i++) {
watchdog('sensor_demo', _monitoring_setup_random_name(), array(), WATCHDOG_INFO);
watchdog('sensor_demo', _monitoring_setup_random_name(), array(), WATCHDOG_WARNING);
}
for ($i = 0; $i < 50; $i++) {
watchdog('page not found', 'not/found');
}
// Enable Enabled modules and Disappeared sensors for the "interactive" demo.
$sensor_manager
->enableSensor('monitoring_enabled_modules');
$sensor_manager
->enableSensor('monitoring_disappeared_sensors');
}
Functions
Name | Description |
---|---|
monitoring_demo_enable | Implements hook_enable(). |