| 1 | == Creating a nagios monitor == |
| 2 | This page explains how to create a nagios monitor configuration in [wiki:how-to/puppet puppet]. You will need to make changes to get the correct configuration for the type of monitoring. |
| 3 | |
| 4 | === Set up an executable === |
| 5 | These files are stored in puppet/modules/mayfirst/files/monitor-utils/ you can |
| 6 | find examples of different versions of monitoring scripts there. |
| 7 | |
| 8 | === Set up a cronjob === |
| 9 | projects/puppet/modules/mayfirst/templates/monitor-utils/cron.d/mf-monitor |
| 10 | |
| 11 | You'll need to add your script to this directory. |
| 12 | |
| 13 | === Add to utils.pp === |
| 14 | puppet/modules/mayfirst/manifests/utils.pp |
| 15 | |
| 16 | The code should look something like this, with the correct file from the executable specified.: |
| 17 | |
| 18 | {{{ |
| 19 | file { "/usr/local/sbin/mf-monitor-mailq": |
| 20 | source => "puppet:///modules/mayfirst/monitor-utils/mf-monitor-mailq", |
| 21 | ensure => present, |
| 22 | mode => 755, |
| 23 | owner => "root", |
| 24 | group => "root" |
| 25 | } |
| 26 | }}} |
| 27 | |
| 28 | === Define hostgroup === |
| 29 | projects/puppet/modules/mayfirst/files/nagios/nagios3/conf.d/ |
| 30 | |
| 31 | This code section should look something like this: |
| 32 | |
| 33 | {{{ |
| 34 | define hostgroup { |
| 35 | hostgroup_name mailq-servers |
| 36 | alias Mail Check Servers |
| 37 | } |
| 38 | }}} |
| 39 | |
| 40 | === Define nagios command === |
| 41 | puppet/modules/mayfirst/files/nagios/nagios3/commands.cfg |
| 42 | |
| 43 | Should look like this: |
| 44 | |
| 45 | {{{ |
| 46 | define command{ |
| 47 | command_name check-upgrade |
| 48 | command_line /usr/local/share/nagios/plugins/mf-nagios-check-upgrade '$HOSTNAME$' |
| 49 | } |
| 50 | }}} |
| 51 | === Create parsing script === |
| 52 | You will also need to create a script that parses the output of the monitoring |
| 53 | files. |
| 54 | |
| 55 | projects/puppet/modules/mayfirst/files/nagios/nagios-plugins/plugins/mf-SCRIPT-NAME |
| 56 | |
| 57 | You can model scripts that already exist to check this. |
| 58 | |
| 59 | === Finally add the hostgroup to nagios manifest === |
| 60 | |
| 61 | projects/puppet/modules/mayfirst/manifests/nagios.pp |
| 62 | |
| 63 | One example for standard_hostgroups is: |
| 64 | {{{ |
| 65 | if ( $include_standard_hostgroups == true ) { |
| 66 | $standard_hostgroups = [ 'df-servers', 'upgrade-servers', 'mailq-servers' ] |
| 67 | $assigned_hostgroups = concat($hostgroups, $standard_hostgroups) |
| 68 | } else { |
| 69 | $assigned_hostgroups = $hostgroups |
| 70 | |
| 71 | } |
| 72 | }}} |
| 73 | |
| 74 | This is from 'define m_nagios_host'. |
| 75 | |
| 76 | '''Make sure all executable scripts have execute permissions''' |