You are here

function nagios_check_session_anon in Nagios Monitoring 7

Same name and namespace in other branches
  1. 8 nagios.module \nagios_check_session_anon()
  2. 5 nagios.module \nagios_check_session_anon()
  3. 6 nagios.module \nagios_check_session_anon()

Report the number of anonymous sessions.

Return value

array

File

./nagios.module, line 1047

Code

function nagios_check_session_anon() {
  $interval = REQUEST_TIME - 900;

  // Last 15 minutes
  // sess_count() no longer exists in Drupal 7. Replace with a custom query.

  //$count = (int) sess_count($interval, TRUE);
  $count = (int) db_query("SELECT COUNT(*) FROM {sessions} WHERE timestamp >= :timestamp AND uid = :uid", [
    ':timestamp' => $interval,
    ':uid' => 0,
  ])
    ->fetchField();
  $data = [
    'status' => NAGIOS_STATUS_OK,
    'type' => 'perf',
    'text' => $count,
  ];
  return [
    'key' => 'SAN',
    'data' => $data,
  ];
}