You are here

function _prod_monitor_db_connect_check in Production check & Production monitor 7

Same name and namespace in other branches
  1. 6 prod_monitor/prod_monitor.module \_prod_monitor_db_connect_check()

Perform separate dbconnect check. We cannot incorporate this at the side of prod_check as this would make no sense at all when the DB is down.

6 calls to _prod_monitor_db_connect_check()
drush_prod_monitor_fetch in prod_monitor/prod_monitor.drush.inc
Fetch data callback.
prod_monitor_cron in prod_monitor/prod_monitor.module
Implementation of hook_cron()
prod_monitor_fetch_all_data_batcher in prod_monitor/includes/prod_monitor.admin.inc
Batch fetching of all site info.
prod_monitor_fetch_data in prod_monitor/includes/prod_monitor.admin.inc
Callback to fetch site data
prod_monitor_overview_form_submit in prod_monitor/includes/prod_monitor.admin.inc
Submit function

... See full list

File

prod_monitor/prod_monitor.module, line 540

Code

function _prod_monitor_db_connect_check($id, $site_info) {

  // Execute only if setup properly.
  if (empty($site_info['settings']['dbconnect_path'])) {
    return;
  }

  // Do the check.
  $dbconnect_path = rtrim($site_info['url'], '/') . '/' . $site_info['settings']['dbconnect_path'];
  $response = drupal_http_request($dbconnect_path);
  if ($response->code !== '200' && $response->data !== 'OK') {

    // Update status to notify the user of the problem!
    $site_info['status'] = PROD_MONITOR_REQUIREMENT_ERROR;
    $response->data = 'NOK';
  }

  // ALWAYS get stored site data as it should have been updated right before
  // calling this function!
  $site_data = _prod_monitor_get_site($id, 'data');

  // Add data to site and save.
  $site_data['data']['prod_mon']['prod_check_dbconnect'] = $response->code . ' ' . $response->data;

  // Store site data
  $site = new stdClass();
  $site->id = $id;
  if (isset($site_info['status'])) {
    $site->status = $site_info['status'];
  }
  $site->data = serialize($site_data['data']);
  $site->lastupdate = REQUEST_TIME;
  $result = drupal_write_record('prod_monitor_sites', $site, array(
    'id',
  ));
}