[ Lab 5.1 ] Puppet‐Based Nagios Monitoring Setup - smitja21/group-a-oe2 GitHub Wiki
Part 1: Install the Puppet Nagios Plugin
Task 1: Install the Puppet Nagios Core module on mgmt-a
Task 1: Install the Puppet Nagios Core module on mgmt-a
Task 2: Create the module directory structure
Task 3: Write init.pp
Task 4: Write install.pp
Task 5: Apply the install class and verify
Had an error was include was spelt with an s. Was resolved and worked as expected after
Service and Config was yet to be setup, it needed to be commented out
- Paste the output of id nagios. What UID was assigned? Note that Puppet did not create this user — which command confirms that?
group-a@mgmt-a:~$ id nagios uid=116(nagios) gid=126(nagios) groups=126(nagios)
UID stands for unique identifier
group-a@mgmt-a:$ getent passwd nagios
nagios:x:116:126::/var/lib/nagios:/usr/sbin/nologin
group-a@mgmt-a:$
Shows the user was created independently
- Can you access http:///nagios4 in a browser? What do you see? (You cannot log in yet — the password file does not exist.)
Was able to access but was required to skip ahead to task 8 and edit config to un restrict the ip
- Was the a2enmod cgi exec resource applied? How can you tell from the agent run output?
Was shown in logs when agent was ran. Where is shows that is was executed successfully
3.2 Phase 2: Config Class
Task 6: Create the htpasswd.users file for the web interface
Task 7: Copy the Nagios default config into the module
Task 8: Write config.pp
Task 9: Apply the config class and diagnose errors
After commenting out references to the service in the config.pp it then worked
Permission errors fixed above, by giving correct perms and adding nagios to the puppet group
sudo usermod -aG puppet nagios
-
Document the output of cat /etc/nagios4/conf.d/ppt_hosts.cfg. What did Puppet generate? Does the syntax look like standard Nagios host definition format?
-
Run sudo nagios4 -v /etc/nagios4/nagios.cfg. This validates the Nagios configuration without starting the daemon. Paste the final summary lines. Are there any errors?
-
Why does the conf.d directory have group puppet rather than nagios or www-data? Who writes files into this directory, and why does that determine the group ownership?
Task 10: Write service.pp
Task 11: Apply the complete module and verify
Due to an issue in the config, I had to change db-x to db-a
- Paste the output of sudo systemctl status nagios4. Is it active (running)?
group-a@mgmt-a:/opt/puppetlabs/puppet/modules/nagios/manifests$ sudo systemctl status nagios4 ● nagios4.service - nagios4 Loaded: loaded (/lib/systemd/system/nagios4.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2026-03-23 21:13:49 UTC; 18min ago Docs: man:nagios4 Process: 166801 ExecStartPre=sh -c nagiospipe=$$(sed -n "s/^command_file=(.*)/\1/p" ${NAGIOSCFG}> Main PID: 166803 (nagios4) Tasks: 6 (limit: 4692) Memory: 22.2M CPU: 391ms CGroup: /system.slice/nagios4.service ├─166803 /usr/sbin/nagios4 /etc/nagios4/nagios.cfg ├─166805 /usr/sbin/nagios4 --worker /var/lib/nagios4/rw/nagios.qh ├─166806 /usr/sbin/nagios4 --worker /var/lib/nagios4/rw/nagios.qh ├─166807 /usr/sbin/nagios4 --worker /var/lib/nagios4/rw/nagios.qh ├─166808 /usr/sbin/nagios4 --worker /var/lib/nagios4/rw/nagios.qh └─166809 /usr/sbin/nagios4 /etc/nagios4/nagios.cfg
Mar 23 21:13:49 mgmt-a.oe2.org.nz nagios4[166803]: wproc: Registry request: name=Core Worker 166808;pi> Mar 23 21:13:49 mgmt-a.oe2.org.nz nagios4[166803]: wproc: Registry request: name=Core Worker 166807;pi> Mar 23 21:13:49 mgmt-a.oe2.org.nz nagios4[166803]: wproc: Registry request: name=Core Worker 166808;pi> Mar 23 21:13:49 mgmt-a.oe2.org.nz nagios4[166803]: wproc: Registry request: name=Core Worker 166807;pi> Mar 23 21:13:49 mgmt-a.oe2.org.nz nagios4[166803]: wproc: Registry request: name=Core Worker 166806;pi> Mar 23 21:13:49 mgmt-a.oe2.org.nz nagios4[166803]: wproc: Registry request: name=Core Worker 166806;pi> Mar 23 21:13:49 mgmt-a.oe2.org.nz nagios4[166803]: Warning: Host 'db-a.oe2.org.nz' has no default cont> Mar 23 21:13:49 mgmt-a.oe2.org.nz nagios4[166803]: Warning: Host 'db-a.oe2.org.nz' has no default cont> Mar 23 21:13:49 mgmt-a.oe2.org.nz nagios4[166803]: Successfully launched command file worker with pid > Mar 23 21:13:49 mgmt-a.oe2.org.nz nagios4[166803]: Successfully launched command file worker with pid > lines 1-27/27 (END)
Yes it's running
- Paste the last 10 lines of /var/log/nagios4/nagios.log. Can you find a line
group-a@mgmt-a:~$ tail -n 10 /var/log/nagios4/nagios.log [1774300429] qh: core query handler registered [1774300429] qh: echo service query handler registered [1774300429] qh: help for the query handler registered [1774300429] wproc: Successfully registered manager as @wproc with query handler [1774300429] wproc: Registry request: name=Core Worker 166805;pid=166805 [1774300429] wproc: Registry request: name=Core Worker 166808;pid=166808 [1774300429] wproc: Registry request: name=Core Worker 166807;pid=166807 [1774300429] wproc: Registry request: name=Core Worker 166806;pid=166806 [1774300429] Warning: Host 'db-a.oe2.org.nz' has no default contacts or contactgroups defined! [1774300429] Successfully launched command file worker with pid 166809
indicating Nagios successfully read the configuration and started monitoring? 3. Run the agent a second time. Does anything change? Why should nothing change on a correctly configured system?
Nothing changed as everything was correctly applied previously; if something did change, there may be something changing config where it should be modified in Puppet instead.
Part 3: Access and Interpret the Web Interface
Task 12: Log in to the Nagios web dashboard
Task 13
- Take a screenshot of the Nagios web interface showing the host list. Does dbx. oe2.org.nz appear? What is its current status? (It may show as PENDING for the first few minutes while Nagios runs its initial checks.)
- Click on db-x in the host list. What information does Nagios display about it? Can you find the check-host-alive check and its last result?