1. Start Nagios Daemon Using nagios -d
Typically you would execute “service nagios start” to start the Nagios daemon, which really calls the /etc/rc.d/init.d/nagios script.You’ll see the following line inside the /etc/rc.d/init.d/nagios script for the Nagios startup:
$NagiosBin -d $NagiosCfgFileSo, you can also manually start Nagios daemon as shown below.
# /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfgThe advantage of manually starting the Nagios daemon is that you can run two Nagios instance on one server. If you like to run a small test instance where you can play around with various configuration files, and Nagios options, create a nagios-test.cfg that points to different configuration object directories than the nagios.cfg, and then start the test instance using nagios-test.cfg file as shown below.
# /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios-test.cfgIf you are new to Nagios, first install Nagios, and configure it to monitor a Linux server.
2. Verify Nagios Configurations Using nagios -v
Anytime you make changes to the configuration files, before you restart the Nagios daemon, verify the configuration changes (for syntax errors, and other invalid configuration errors) using nagios -v option as shown below.# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg Reading configuration data... Read main config file okay... Processing object config file '/usr/local/nagios/etc/objects/commands.cfg'... Processing object config file '/usr/local/nagios/etc/objects/contacts.cfg'... Processing object config file '/usr/local/nagios/etc/objects/timeperiods.cfg'... Processing object config file '/usr/local/nagios/etc/objects/templates.cfg'... Processing object config directory '/usr/local/nagios/etc/servers'... Read object config files okay... Running pre-flight check on configuration data... Checking services...Checked 450 services. Checking hosts... Checked 135 hosts. Checking contacts...Checked 12 contacts. .. Checking for circular paths between hosts... Checking for circular host and service dependencies... Total Warnings: 0 Total Errors: 0 Things look okay - No serious problems were detected during the pre-flight checkIf this finds any issues, it will give proper message about the issue. At the end this will also display the total count for both warnings and errors. Make sure it says 0 here.
3. Display Processing Info and Scheduling Info using nagios -s
When you have a huge configuration files with several objects, nagios might take little longer to start. Using nagios -s option, you can see how much time Nagios might spend procesing configuration files. This also gives an approximate estimation on how much time you might save if you cache the configuration objects. How to cache configuration objects during startup is explained in the next item.# /usr/local/nagios/bin/nagios -s /usr/local/nagios/etc/nagios.cfgI’ve split the output of the above command into multiple sections as shown below.
Object configuration processing times section displays the following information. In this example, the total time it took to process the configuration objects is way less than a second. So, caching the objects might not give you any visible difference, even thought it says you could save 4.36% by caching the objects. When you have a huge configuration file, you’ll definitely see some high numbers here.
OBJECT CONFIG PROCESSING TIMES (* = Potential for precache savings with -u option) ---------------------------------- Read: 0.002094 sec Resolve: 0.000046 sec * Recomb Contactgroups: 0.000019 sec * Recomb Hostgroups: 0.000012 sec * Dup Services: 0.000017 sec * Recomb Servicegroups: 0.000001 sec * Duplicate: 0.000004 sec * Inherit: 0.000003 sec * Recomb Contacts: 0.000000 sec * Sort: 0.000001 sec * Register: 0.000142 sec Free: 0.000021 sec ============ TOTAL: 0.002360 sec * = 0.000103 sec (4.36%) estimated savingsConfiguration verification times section displays the amount of time it will take to verify the configuration during startup.
CONFIG VERIFICATION TIMES (* = Potential for speedup with -x option) ---------------------------------- Object Relationships: 0.000102 sec Circular Paths: 0.000001 sec * Misc: 0.000117 sec ============ TOTAL: 0.000220 sec * = 0.000001 sec (0.5%) estimated savingsEven scheduling times section displays the amount of time it will take while processing various events mentioned below.
EVENT SCHEDULING TIMES ------------------------------------- Get service info: 0.000084 sec Get host info info: 0.000023 sec Get service params: 0.000009 sec Schedule service times: 0.000124 sec Schedule service events: 0.010329 sec Get host params: 0.000001 sec Schedule host times: 0.000029 sec Schedule host events: 0.000003 sec ============ TOTAL: 0.010602 secThe following section displays both host and service scheduling information.
HOST SCHEDULING INFORMATION --------------------------- Total hosts: 3 Total scheduled hosts: 3 Host inter-check delay method: SMART Average host check interval: 300.00 sec Host inter-check delay: 100.00 sec Max host check spread: 30 min First scheduled check: Sun Nov 27 10:40:44 2011 Last scheduled check: Sun Nov 27 10:44:04 2011 SERVICE SCHEDULING INFORMATION ------------------------------- Total services: 8 Total scheduled services: 8 Service inter-check delay method: SMART Average service check interval: 600.00 sec Inter-check delay: 75.00 sec Interleave factor method: SMART Average services per host: 2.67 Service interleave factor: 3 Max service check spread: 30 min First scheduled check: Sun Nov 27 10:44:29 2011 Last scheduled check: Sun Nov 27 10:53:14 2011Finally, the performance suggestions section will lists all possible performance tunning suggestions for your specific configurations files.
PERFORMANCE SUGGESTIONS ----------------------- I have no suggestions - things look okay.
4. Pre-cache Nagios Config Objects using nagios -p
When you have a big configuration file with several objects, you might save enough time during Nagios startup by caching the configuration objects.The precache configuration information will be stored in the /usr/local/nagios/var/objects.precache file. If you’ve never created the pre-cache configuration files before, this file will not be present. If you want to change the location of the precache file, change the precached_object_file directive in the nagios.cfg file.
To create the pre-cache configuration files, use -p option as shown below.
# /usr/local/nagios/bin/nagios -pv /usr/local/nagios/etc/nagios.cfgAfter the above command, the objects.precache file will be created. If you view this file, you can see that all Nagios object definitions are listed here. As it says in the beginning of this precache file, do not modify this file manually. If you like to modify any Nagios object, modify the appropriate configuration file, and regenerate the pre-cache file again.
# more /usr/local/nagios/var/objects.precache
5. Use Pre-cached Nagios Config Objects using nagios -u
After creating the pre-cache objects as shown above, stop Nagios daemon, and start it using -u option as shown below. Instead of reading the nagios configuration files again, it will simply use the cached objects that were earlier created from the /usr/local/nagios/var/objects.precache directory.# /usr/local/nagios/bin/nagios -ud /usr/local/nagios/etc/nagios.cfg
6. Skip Circular Path Check using nagios -x
During the startup, Nagios checks to make sure you don’t have any circular paths in any of your object definitions. During startup, Nagios will make sure it doesn’t end-up in any deadlock situation by verifying circular paths. If you have lot of configuration objects, the circular path check might take some time.If you have a working Nagios configuration, that you are sure doesn’t have any circular paths, you can instruct Nagios to skip this check during startup using nagios -x as shown below.
/usr/local/nagios/bin/nagios -xd /usr/local/nagios/etc/nagios.cfgFor faster Nagios startup, use both -u and -x option together as shown below, which will use pre-cache objects and skip circular path checks.
/usr/local/nagios/bin/nagios -uxd /usr/local/nagios/etc/nagios.cfg
No comments:
Post a Comment