drush_nagios
Functions
Helper functions

Functions

 _nagios_get_update_info ()
 
 _nagios_get_db_update_info ()
 
 _nagios_parse_update_info ($update_info)
 
 _nagios_get_drupal_status_info ()
 
 _nagios_parse_drupal_status_info ($requirements)
 
 _nagios_print_message ($parsed_update_info)
 
 _nagios_exit_status ($parsed_update_info)
 

Detailed Description

Helper functions

Function Documentation

_nagios_exit_status (   $parsed_update_info)

Return exit status for nagios

Parameters
array$parsed_update_info
Return values
int
  • NAGIOS_OK (0) if monitored site is up to date,
  • NAGIOS_WARNING (1) if there are updates, requirements warnings or unsupported modules available
  • NAGIOS_CRITICAL(2) if there are security or requirement warnings updates available

Definition at line 847 of file nagios.inc.

_nagios_get_db_update_info ( )

Get pending database update information

Returns
array An array with an update indicator 'has_updates' (boolean) and an array 'db_updates' keyed on the corresponding modules which includes
  • pending, array of pending updates, keyed update number
  • start, update number

Example:

1  Array
2  (
3  [has_updates] => 1
4  [db_updates] => Array
5  (
6  [system] => Array
7  (
8  [pending] => Array
9  (
10  [7073] => 7073 - Add binary to {file_managed}, in case system_update_7034() was run without it.
11  [7074] => 7074 - This update has been removed and will not run.
12  [7076] => 7076 - Convert menu_links query strings into arrays.
13  [7077] => 7077 - Revert {file_managed}.filename changed to a binary column.
14  [7078] => 7078 - Add binary to {date_formats}.format.
15  )
16 
17  [start] => 7073
18  )
19 
20  [dblog] => Array
21  (
22  [pending] => Array
23  (
24  [7002] => 7002 - Add an index to the severity column in the watchdog database table.
25  )
26 
27  [start] => 7002
28  )
29 
30  [field] => Array
31  (
32  [pending] => Array
33  (
34  [7002] => 7002 - Split the all-inclusive field_bundle_settings variable per bundle.
35  [7003] => 7003 - Add the FieldInfo class to the class registry.
36  )
37 
38  [start] => 7002
39  )
40  [locale] => Array
41  (
42  [pending] => Array
43  (
44  [7004] => 7004 - Remove duplicates in {locales_source}.
45  [7005] => 7005 - Increase {locales_languages}.formula column's length.
46  )
47 
48  [start] => 7004
49  )
50 
51  [node] => Array
52  (
53  [pending] => Array
54  (
55  [7013] => 7013 - Change {node}.vid default value from 0 to NULL to avoid deadlock issues on MySQL.
56  )
57 
58  [start] => 7013
59  )
60 
61  [user] => Array
62  (
63  [pending] => Array
64  (
65  [7018] => 7018 - Ensure there is an index on {users}.picture.
66  )
67 
68  [start] => 7018
69  )
70 
71  )
72 
73 )
See also
update_main_prepare()
update_get_update_list()
drupal_get_schema_versions()

Definition at line 164 of file nagios.inc.

_nagios_get_drupal_status_info ( )

Get Drupals status and requirement informations.

Returns
array An array key on requirement, which contains at least:
  • title, Readable status/requirement
  • value, its value Optional:
  • severity, Status code
  • description, more details
  • weight
    1 Array
    2 (
    3  [drupal] => Array
    4  (
    5  [title] => Drupal
    6  [value] => 6.33
    7  [severity] => -1
    8  [weight] => -10
    9  )
    10 
    11  [webserver] => Array
    12  (
    13  [title] => Web server
    14  [value] => Apache/2.4.10 (Debian)
    15  )
    16 
    17  [php] => Array
    18  (
    19  [title] => PHP
    20  [value] => <a href="/admin/reports/status/php">5.6.0-1</a>
    21  )
    22 
    23  [php_register_globals] => Array
    24  (
    25  [title] => PHP register globals
    26  [value] => Disabled
    27  )
    28 
    29  [php_memory_limit] => Array
    30  (
    31  [title] => PHP memory limit
    32  [value] => 128M
    33  )
    34 
    35  [mysql] => Array
    36  (
    37  [title] => MySQL database
    38  [value] => <a href="/admin/reports/status/sql">5.5.39</a>
    39  )
    40 
    41  [settings.php] => Array
    42  (
    43  [value] => Protected
    44  [title] => Configuration file
    45  )
    46 
    47  [files_htaccess] => Array
    48  (
    49  [title] => Files directory
    50  [value] => Not fully protected
    51  [severity] => 2
    52  [description] => See <a href="http://drupal.org/SA-CORE-2013-003">http://drupal.org/SA-CORE-2013-003</a> for information about the recommended .htaccess file which should be added to the <em>sites/netzaffe.de/files</em> directory to help protect against arbitrary code execution.
    53  )
    54 
    55  [cron] => Array
    56  (
    57  [title] => Cron maintenance tasks
    58  [severity] => 0
    59  [value] => Last run 1 hour 18 min ago
    60  [description] => You can <a href="/admin/reports/status/run-cron">run cron manually</a>.
    61  )
    62 
    63  [file system] => Array
    64  (
    65  [title] => File system
    66  [value] => Writable (<em>public</em> download method)
    67  )
    68 
    69  [update] => Array
    70  (
    71  [title] => Database updates
    72  [severity] => 0
    73  [value] => Up to date
    74  )
    75 
    76  [update access] => Array
    77  (
    78  [value] => Protected
    79  [title] => Access to update.php
    80  )
    81 
    82  [unicode] => Array
    83  (
    84  [title] => Unicode library
    85  [value] => PHP Mbstring Extension
    86  [severity] => 0
    87  )
    88 
    89  [update status] => Array
    90  (
    91  [value] => Enabled
    92  [title] => Update notifications
    93  )
    94 
    95  [http requests] => Array
    96  (
    97  [title] => HTTP request status
    98  [value] => Fails
    99  [severity] => 2
    100  [description] => Your system or network configuration does not allow Drupal to access web pages, resulting in reduced functionality. This could be due to your webserver configuration or PHP settings, and should be resolved in order to download information about available updates, fetch aggregator feeds, sign in via OpenID, or use other network-dependent services.
    101  )
    102 
    103  [update_core] => Array
    104  (
    105  [title] => Drupal core update status
    106  [value] => No update data available
    107  [severity] => 1
    108  [reason] => -2
    109  [description] => No information is available about potential new releases for currently installed modules and themes. To check for updates, you may need to <a href="/admin/reports/status/run-cron?destination=admin%2Fsettings%2Flanguage">run cron</a> or you can <a href="/admin/reports/updates/check?destination=admin%2Fsettings%2Flanguage">check manually</a>. Please note that checking for available updates can take a long time, so please be patient.
    110  )
    111 
    112  [captcha_wrong_response_counter] => Array
    113  (
    114  [title] => CAPTCHA
    115  [value] => Already 61082 blocked form submissions
    116  [severity] => -1
    117  )
    118 
    119  [0] => Array
    120  (
    121  [title] => GeSHi filter
    122  [value] => Found GeSHi library version <em>1.0.8</em>
    123  [severity] => 0
    124  )
    125 
    126  [image_import_dir] => Array
    127  (
    128  [title] => Image import
    129  [value] => Import directory <em>sites/netzaffe.de/files/images/import</em> does not exist or is not writable.
    130  [description] => The import directory <em>sites/netzaffe.de/files/images/import</em> either does not exist or does not grant the web container write permission. Either <a href="/admin/settings/image/image_import">choose</a> a different directory or create the <em>sites/netzaffe.de/files/images/import</em> directory and grant write permissions. The Image import module will not function until this is corrected.
    131  [severity] => 2
    132  )
    133 
    134  [image_toolkit] => Array
    135  (
    136  [value] => The <em>gd</em> toolkit is installed.
    137  [severity] => 0
    138  [title] => Image toolkit
    139  )
    140 
    141  [image_dirs] => Array
    142  (
    143  [value] => Exists (<em>sites/netzaffe.de/files/images</em>).
    144  [severity] => 0
    145  [title] => Image module directories
    146  )
    147 
    148  [page_title_version] => Array
    149  (
    150  [title] => Page title version
    151  [value] => Enabled (<code>page_title</code> table contains 0 rows)
    152  [severity] => 0
    153  )
    154 
    155  [tagadelic] => Array
    156  (
    157  [severity] => 0
    158  [title] => Tagadelic
    159  [value] => No incompatible modules enabled.
    160  )
    161 
    162  [xmlsitemap_directory] => Array
    163  (
    164  [title] => XML sitemap cache directory
    165  [value] => Writable
    166  )
    167 
    168  [xmlsitemap_generated] => Array
    169  (
    170  [title] => XML sitemap
    171  [value] => Last attempted generation on 2014-10-25 14:34 (1 hour 18 min ago).
    172  [severity] => 0
    173  )
    174 
    175 )
See also
system_status()

Definition at line 628 of file nagios.inc.

_nagios_get_update_info ( )

Get list of installed projects and return their update status information via drush functions

Returns
$update_info An array provided by drush´s _pm_get_update_info()
See also
drush_get_extensions()
drush_get_projects()
_pm_get_update_info()

Definition at line 52 of file nagios.inc.

_nagios_parse_drupal_status_info (   $requirements)

Parses the requirements by _nagios_get_drupal_status_info()

Returns
array An associative array with uneeded drupal requirements with requirement_violation as indicator and items grouped by their severities(requirement_warning, requirement_error) and ignored.
1 Array
2 (
3  [requirement_violation] => 1
4  [requirement_warning] => Array
5  (
6  [cron] => Array
7  (
8  [title] => Cron maintenance tasks
9  [value] => Last run 1 week 2 days ago
10  [description] => You can <a href="/admin/reports/status/run-cron">run cron manually</a>.
11  [severity] => 1
12  )
13 
14  [xmlsitemap_generated] => Array
15  (
16  [title] => XML sitemap
17  [value] => Last attempted generation on 2014-10-25 14:34 (1 week 2 days ago).
18  [severity] => 1
19  )
20  )
21  [requirement_error] => Array
22  (
23  [files_htaccess] => Array
24  (
25  [title] => Files directory
26  [value] => Not fully protected
27  [description] => See <a href="http://drupal.org/SA-CORE-2013-003">http://drupal.org/SA-CORE-2013-003</a> for information about the recommended .htaccess file which should be added to the <em>sites/netzaffe.de/files</em> directory to help protect against arbitrary code execution.
28  [severity] => 2
29  )
30 
31 
32  [http requests] => Array
33  (
34  [title] => HTTP request status
35  [value] => Fails
36  [description] => Your system or network configuration does not allow Drupal to access web pages, resulting in reduced functionality. This could be due to your webserver configuration or PHP settings, and should be resolved in order to download information about available updates, fetch aggregator feeds, sign in via OpenID, or use other network-dependent services.
37  [severity] => 2
38  )
39  )
40 
41  [ignored] => Array
42  (
43  [unicode] => Array
44  (
45  [title] => Unicode library
46  [value] => Error
47  [severity] => 2
48  )
49  )
50 )
See also
install.inc

Definition at line 699 of file nagios.inc.

_nagios_parse_update_info (   $update_info)

Parses supplied update info and get type of update and corresponding informations

Parameters
array$update_infoUpdate information
Return values
arrayAn array with an update indicator 'has_updates' (boolean) and keyed on the following serverities which contain the corresponding projects
  • updates
  • security_updates
  • not_supported
  • ignored (ignore Option)
  • update_not_checked
  • update_revoked
  • up_to_date
  • unknown

Projects array keys

  • project_type
  • existing_version
  • latest_version
  • release_link
  • severity

Example called with –ignore=cnr,devel :

1 Array
2 (
3  [has_updates] => 1
4  [updates] => Array
5  (
6  [mimemail] => Array
7  (
8  [project_type] => module
9  [existing_version] => 7.x-1.x-dev
10  [latest_version] => 7.x-1.x-dev
11  [release_link] => http://drupal.org/node/95867
12  [severity] => Aktualisierung verfügbar
13  )
14 
15  [password_policy] => Array
16  (
17  [project_type] => module
18  [existing_version] => 7.x-1.0-beta1
19  [latest_version] => 7.x-1.0-beta2
20  [release_link] => http://drupal.org/node/1331478
21  [severity] => Aktualisierung verfügbar
22  )
23 
24  )
25 
26  [security_updates] => Array
27  (
28  [ckeditor] => Array
29  (
30  [project_type] => module
31  [existing_version] => 7.x-1.3
32  [latest_version] => 7.x-1.6
33  [release_link] => http://drupal.org/node/1337106
34  [severity] => SECURITY UPDATE available
35  )
36 
37  )
38 
39  [not_supported] => Array
40  (
41  )
42 
43  [ignored] => Array
44  (
45  )
46 
47  [update_not_checked] => Array
48  (
49  )
50 
51  [update_revoked] => Array
52  (
53  )
54 
55  [ignored] => Array
56  (
57  [cnr] => Array
58  (
59  [project_type] => module
60  [existing_version] => 7.x-4.1
61  [latest_version] => 7.x-4.22
62  [release_link] => http://drupal.org/node/1344032
63  [severity] => Aktualisierung verfügbar
64  )
65 
66  [devel] => Array
67  (
68  [project_type] => module
69  [existing_version] => 7.x-1.0
70  [latest_version] => 7.x-1.2
71  [release_link] => http://drupal.org/node/1226936
72  [severity] => SECURITY UPDATE available
73  )
74 
75  )
76  [up_to_date] => Array
77  (
78  [drupal] => Array
79  (
80  [project_type] => core
81  [existing_version] => 7.9
82  [latest_version] => 7.9
83  [release_link] => http://drupal.org/node/1322736
84  [severity] => Aktualisierung verfügbar
85  )
86 
87  )
88 
89 )

Definition at line 346 of file nagios.inc.

_nagios_print_message (   $parsed_update_info)

Monitores a single Drupal site for module and core updates

Print a message for nagios

Return values
void

Definition at line 731 of file nagios.inc.