How to add your ID as admin in nagios ?
In this post, we will see how to add our ID as admin in nagios.
We assume the nagios is already configured on your server and now you want to add your name into admin profile.
Lets see it stepwise to understand better.
1. Add in contacts configuration
[root@nagios-server nagios]# cat etc/objects/contacts.cfg ############################################################################### # CONTACTS.CFG - SAMPLE CONTACT/CONTACTGROUP DEFINITIONS # # # NOTES: This config file provides you with some example contact and contact # group definitions that you can reference in host and service # definitions. # # You don't need to keep these definitions in a separate file from your # other object definitions. This has been done just to make things # easier to understand. # ############################################################################### ############################################################################### # # CONTACTS # ############################################################################### # Just one contact defined by default - the Nagios admin (that's you) # This contact definition inherits a lot of default values from the # 'generic-contact' template which is defined elsewhere. define contact { contact_name nagiosadmin ; Short name of user use generic-contact ; Inherit default values from generic-contact template (defined above) alias Nagios Admin ; Full name of user email process-nagios-sj@ngelinux.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ****** } define contact { contact_name newuser ; Short name of user use generic-contact ; Inherit default values from generic-contact template (defined above) alias Nagios Admin3 ; Full name of user email newuser@ngelinux.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ****** } define contactgroup { contactgroup_name admins alias Nagios Administrators members nagiosadmin,newuser }
2. Add in all services under templates.cfg file.
[root@nagios-server objects]# sed -i 's/contacts nagiosadmin/contacts nagiosadmin,newuser/g' templates.cfg ## Check if its added [root@nagios-server objects]# grep -ir newuser * contacts.cfg: contact_name ngeuser ; Short name of user contacts.cfg: email ngeuserj@ngelinux.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ****** contacts.cfg: members nagiosadmin,newuser templates.cfg: contacts nagiosadmin,newuser templates.cfg: contacts nagiosadmin,newuser templates.cfg: contacts nagiosadmin,newuser templates.cfg: contacts nagiosadmin,newuser templates.cfg: contacts nagiosadmin,newuser templates.cfg: contacts nagiosadmin,newuser templates.cfg: contacts nagiosadmin,newuser templates.cfg: contacts nagiosadmin,newuser templates.cfg: contacts nagiosadmin,newuser templates.cfg: contacts nagiosadmin,newuser templates.cfg: contacts nagiosadmin,newuser templates.cfg: contacts nagiosadmin,newuser templates.cfg: contacts nagiosadmin,newuser templates.cfg: contacts nagiosadmin,newuser templates.cfg: contacts nagiosadmin,newuser templates.cfg: contacts nagiosadmin,newuser templates.cfg: contacts nagiosadmin,newuser
3. Verify the new nagios configuration
[root@nagios-server objects]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg Nagios Core 4.4.3 Copyright (c) 2009-present Nagios Core Development Team and Community Contributors Copyright (c) 1999-2009 Ethan Galstad Last Modified: 2019-01-15 License: GPL Website: https://www.nagios.org Reading configuration data... Read main config file okay... Read object config files okay... Running pre-flight check on configuration data... Checking objects... Checked 11867 services. Checked 1523 hosts. Checked 11 host groups. Checked 1 service groups. Checked 5 contacts. Checked 1 contact groups. Checked 138 commands. Checked 5 time periods. Checked 0 host escalations. Checked 0 service escalations. Checking for circular paths... Checked 1523 hosts Checked 20428 service dependencies Checked 0 host dependencies Checked 5 timeperiods Checking global event handlers... Checking obsessive compulsive processor commands... Checking misc settings... Total Warnings: 0 Total Errors: 0 Things look okay - No serious problems were detected during the pre-flight check [root@nagios-server objects]#
4. If all is fine in above report, restart nagios service.
# service nagios restart