Sei sulla pagina 1di 12

3/31/2015

6NagiosCommandLineOptionsExplainedwithExamples

GoogleMapsAPI
BuildAndCustomizeYourOwnMapsWithGoogleMapsAPI.LearnMore!

Home
FreeeBook
Contact
About
StartHere

6NagiosCommandLineOptionsExplainedwithExamples
byRameshNatarajanonJanuary23,2012
9

Tweet

Thisarticleexplainsvariouscommandlineoptionsthatareavailableforthenagioscommand.

1.StartNagiosDaemonUsingnagiosd
TypicallyyouwouldexecuteservicenagiosstarttostarttheNagiosdaemon,whichreallycallsthe/etc/rc.d/init.d/nagiosscript.
Youllseethefollowinglineinsidethe/etc/rc.d/init.d/nagiosscriptfortheNagiosstartup:
$NagiosBind$NagiosCfgFile

So,youcanalsomanuallystartNagiosdaemonasshownbelow.
http://www.thegeekstuff.com/2012/01/nagioscommand/

1/12

3/31/2015

6NagiosCommandLineOptionsExplainedwithExamples

#/usr/local/nagios/bin/nagiosd/usr/local/nagios/etc/nagios.cfg

TheadvantageofmanuallystartingtheNagiosdaemonisthatyoucanruntwoNagiosinstanceononeserver.Ifyouliketorunasmalltest
instancewhereyoucanplayaroundwithvariousconfigurationfiles,andNagiosoptions,createanagiostest.cfgthatpointstodifferent
configurationobjectdirectoriesthanthenagios.cfg,andthenstartthetestinstanceusingnagiostest.cfgfileasshownbelow.
#/usr/local/nagios/bin/nagiosd/usr/local/nagios/etc/nagiostest.cfg

IfyouarenewtoNagios,firstinstallNagios,andconfigureittomonitoraLinuxserver.

2.VerifyNagiosConfigurationsUsingnagiosv
Anytimeyoumakechangestotheconfigurationfiles,beforeyourestarttheNagiosdaemon,verifytheconfigurationchanges(forsyntax
errors,andotherinvalidconfigurationerrors)usingnagiosvoptionasshownbelow.

Taste the power of Urzza


HovertoExpand

#/usr/local/nagios/bin/nagiosv/usr/local/nagios/etc/nagios.cfg
Readingconfigurationdata...
Readmainconfigfileokay...
Processingobjectconfigfile'/usr/local/nagios/etc/objects/commands.cfg'...
Processingobjectconfigfile'/usr/local/nagios/etc/objects/contacts.cfg'...
Processingobjectconfigfile'/usr/local/nagios/etc/objects/timeperiods.cfg'...
Processingobjectconfigfile'/usr/local/nagios/etc/objects/templates.cfg'...
Processingobjectconfigdirectory'/usr/local/nagios/etc/servers'...
Readobjectconfigfilesokay...
http://www.thegeekstuff.com/2012/01/nagioscommand/

2/12

3/31/2015

6NagiosCommandLineOptionsExplainedwithExamples

Runningpreflightcheckonconfigurationdata...
Checkingservices...Checked450services.
Checkinghosts...Checked135hosts.
Checkingcontacts...Checked12contacts.
..
Checkingforcircularpathsbetweenhosts...
Checkingforcircularhostandservicedependencies...
TotalWarnings:0
TotalErrors:0
ThingslookokayNoseriousproblemsweredetectedduringthepreflightcheck

Ifthisfindsanyissues,itwillgivepropermessageabouttheissue.Attheendthiswillalsodisplaythetotalcountforbothwarningsand
errors.Makesureitsays0here.

3.DisplayProcessingInfoandSchedulingInfousingnagioss
Whenyouhaveahugeconfigurationfileswithseveralobjects,nagiosmighttakelittlelongertostart.Usingnagiossoption,youcansee
howmuchtimeNagiosmightspendprocesingconfigurationfiles.Thisalsogivesanapproximateestimationonhowmuchtimeyoumight
saveifyoucachetheconfigurationobjects.Howtocacheconfigurationobjectsduringstartupisexplainedinthenextitem.
#/usr/local/nagios/bin/nagioss/usr/local/nagios/etc/nagios.cfg

Ivesplittheoutputoftheabovecommandintomultiplesectionsasshownbelow.
Objectconfigurationprocessingtimessectiondisplaysthefollowinginformation.Inthisexample,thetotaltimeittooktoprocessthe
configurationobjectsiswaylessthanasecond.So,cachingtheobjectsmightnotgiveyouanyvisibledifference,eventhoughtitsaysyou
couldsave4.36%bycachingtheobjects.Whenyouhaveahugeconfigurationfile,youlldefinitelyseesomehighnumbershere.
OBJECTCONFIGPROCESSINGTIMES(*=Potentialforprecachesavingswithuoption)

Read:0.002094sec
Resolve:0.000046sec*
RecombContactgroups:0.000019sec*
RecombHostgroups:0.000012sec*
DupServices:0.000017sec*
RecombServicegroups:0.000001sec*
Duplicate:0.000004sec*
Inherit:0.000003sec*
RecombContacts:0.000000sec*
http://www.thegeekstuff.com/2012/01/nagioscommand/

3/12

3/31/2015

6NagiosCommandLineOptionsExplainedwithExamples

Sort:0.000001sec*
Register:0.000142sec
Free:0.000021sec
============
TOTAL:0.002360sec*=0.000103sec(4.36%)estimatedsavings

Configurationverificationtimessectiondisplaystheamountoftimeitwilltaketoverifytheconfigurationduringstartup.
CONFIGVERIFICATIONTIMES(*=Potentialforspeedupwithxoption)

ObjectRelationships:0.000102sec
CircularPaths:0.000001sec*
Misc:0.000117sec
============
TOTAL:0.000220sec*=0.000001sec(0.5%)estimatedsavings

Evenschedulingtimessectiondisplaystheamountoftimeitwilltakewhileprocessingvariouseventsmentionedbelow.
EVENTSCHEDULINGTIMES

Getserviceinfo:0.000084sec
Gethostinfoinfo:0.000023sec
Getserviceparams:0.000009sec
Scheduleservicetimes:0.000124sec
Scheduleserviceevents:0.010329sec
Gethostparams:0.000001sec
Schedulehosttimes:0.000029sec
Schedulehostevents:0.000003sec
============
TOTAL:0.010602sec

Thefollowingsectiondisplaysbothhostandserviceschedulinginformation.
HOSTSCHEDULINGINFORMATION

Totalhosts:3
Totalscheduledhosts:3
Hostintercheckdelaymethod:SMART
Averagehostcheckinterval:300.00sec
Hostintercheckdelay:100.00sec
Maxhostcheckspread:30min
Firstscheduledcheck:SunNov2710:40:442011
Lastscheduledcheck:SunNov2710:44:042011
SERVICESCHEDULINGINFORMATION
http://www.thegeekstuff.com/2012/01/nagioscommand/

4/12

3/31/2015

6NagiosCommandLineOptionsExplainedwithExamples

Totalservices:8
Totalscheduledservices:8
Serviceintercheckdelaymethod:SMART
Averageservicecheckinterval:600.00sec
Intercheckdelay:75.00sec
Interleavefactormethod:SMART
Averageservicesperhost:2.67
Serviceinterleavefactor:3
Maxservicecheckspread:30min
Firstscheduledcheck:SunNov2710:44:292011
Lastscheduledcheck:SunNov2710:53:142011

Finally,theperformancesuggestionssectionwilllistsallpossibleperformancetunningsuggestionsforyourspecificconfigurationsfiles.
PERFORMANCESUGGESTIONS

Ihavenosuggestionsthingslookokay.

4.PrecacheNagiosConfigObjectsusingnagiosp
Whenyouhaveabigconfigurationfilewithseveralobjects,youmightsaveenoughtimeduringNagiosstartupbycachingtheconfiguration
objects.
Theprecacheconfigurationinformationwillbestoredinthe/usr/local/nagios/var/objects.precachefile.Ifyouvenevercreatedthepre
cacheconfigurationfilesbefore,thisfilewillnotbepresent.Ifyouwanttochangethelocationoftheprecachefile,changethe
precached_object_filedirectiveinthenagios.cfgfile.
Tocreatetheprecacheconfigurationfiles,usepoptionasshownbelow.
#/usr/local/nagios/bin/nagiospv/usr/local/nagios/etc/nagios.cfg

Aftertheabovecommand,theobjects.precachefilewillbecreated.Ifyouviewthisfile,youcanseethatallNagiosobjectdefinitionsare
listedhere.Asitsaysinthebeginningofthisprecachefile,donotmodifythisfilemanually.IfyouliketomodifyanyNagiosobject,
modifytheappropriateconfigurationfile,andregeneratetheprecachefileagain.
#more/usr/local/nagios/var/objects.precache

5.UsePrecachedNagiosConfigObjectsusingnagiosu
Aftercreatingtheprecacheobjectsasshownabove,stopNagiosdaemon,andstartitusinguoptionasshownbelow.Insteadofreadingthe
http://www.thegeekstuff.com/2012/01/nagioscommand/

5/12

3/31/2015

6NagiosCommandLineOptionsExplainedwithExamples

nagiosconfigurationfilesagain,itwillsimplyusethecachedobjectsthatwereearliercreatedfromthe
/usr/local/nagios/var/objects.precachedirectory.
#/usr/local/nagios/bin/nagiosud/usr/local/nagios/etc/nagios.cfg

6.SkipCircularPathCheckusingnagiosx
Duringthestartup,Nagioscheckstomakesureyoudonthaveanycircularpathsinanyofyourobjectdefinitions.Duringstartup,Nagios
willmakesureitdoesntendupinanydeadlocksituationbyverifyingcircularpaths.Ifyouhavelotofconfigurationobjects,thecircular
pathcheckmighttakesometime.
IfyouhaveaworkingNagiosconfiguration,thatyouaresuredoesnthaveanycircularpaths,youcaninstructNagiostoskipthischeck
duringstartupusingnagiosxasshownbelow.
/usr/local/nagios/bin/nagiosxd/usr/local/nagios/etc/nagios.cfg

ForfasterNagiosstartup,usebothuandxoptiontogetherasshownbelow,whichwilluseprecacheobjectsandskipcircularpathchecks.
/usr/local/nagios/bin/nagiosuxd/usr/local/nagios/etc/nagios.cfg
9

Tweet

>Addyourcomment

Ifyouenjoyedthisarticle,youmightalsolike..
1. 50LinuxSysadminTutorials
2. 50MostFrequentlyUsedLinuxCommands(WithExamples)
3. Top25BestLinuxPerformanceMonitoringandDebuggingTools
4. Mommy,Ifoundit!15PracticalLinuxFindCommandExamples
5. Linux101Hacks2ndEditioneBook

http://www.thegeekstuff.com/2012/01/nagioscommand/

AwkIntroduction7AwkPrintExamples
AdvancedSedSubstitutionExamples
8EssentialVimEditorNavigationFundamentals
25MostFrequentlyUsedLinuxIPTablesRulesExamples
TurbochargePuTTYwith12PowerfulAddOns

6/12

3/31/2015

6NagiosCommandLineOptionsExplainedwithExamples

{2commentsreadthembeloworaddone}
1hdazJanuary23,2012at8:53am
Thanksforthearticle,
Arethereanycustomnagiosbashscriptsyouhavecreatedthatyoufinduseful?
Regards
hdaz
2jalalhajigholamaliJanuary23,2012at2:09pm
Hi,
Thanksalotforanicearticle
LeaveaComment
Name
Email
Website

http://www.thegeekstuff.com/2012/01/nagioscommand/

7/12

3/31/2015

6NagiosCommandLineOptionsExplainedwithExamples

Notifymeoffollowupcommentsviaemail
Submit

Previouspost:TCPAttacks:TCPSequenceNumberPredictionandTCPResetAttacks
Nextpost:HowtoSetupRsyslogRemoteLoggingonLinux(CentralLogServer)
RSS|Email|Twitter|Facebook|Google+
Search

EBOOKS
http://www.thegeekstuff.com/2012/01/nagioscommand/

8/12

3/31/2015

6NagiosCommandLineOptionsExplainedwithExamples

Linux101Hacks2ndEditioneBookPracticalExamplestoBuildaStrongFoundationinLinux
Bash101HackseBookTakeControlofYourBashCommandLineandShellScripting
SedandAwk101HackseBookEnhanceYourUNIX/LinuxLifewithSedandAwk
Vim101HackseBookPracticalExamplesforBecomingFastandProductiveinVimEditor
NagiosCore3eBookMonitorEverything,BeProactive,andSleepWell

POPULARPOSTS
12AmazingandEssentialLinuxBooksToEnrichYourBrainandLibrary
50UNIX/LinuxSysadminTutorials
50MostFrequentlyUsedUNIX/LinuxCommands(WithExamples)
HowToBeProductiveandGetThingsDoneUsingGTD
30ThingsToDoWhenyouareBoredandhaveaComputer
LinuxDirectoryStructure(FileSystemStructure)ExplainedwithExamples
LinuxCrontab:15AwesomeCronJobExamples
GetaGripontheGrep!15PracticalGrepCommandExamples
UnixLSCommand:15PracticalExamples
15ExamplesToMasterLinuxCommandLineHistory
Top10OpenSourceBugTrackingSystem
ViandVimMacroTutorial:HowToRecordandPlay
Mommy,Ifoundit!15PracticalLinuxFindCommandExamples
15AwesomeGmailTipsandTricks
15AwesomeGoogleSearchTipsandTricks
http://www.thegeekstuff.com/2012/01/nagioscommand/

9/12

3/31/2015

6NagiosCommandLineOptionsExplainedwithExamples

RAID0,RAID1,RAID5,RAID10ExplainedwithDiagrams
CanYouTopThis?15PracticalLinuxTopCommandExamples
Top5BestSystemMonitoringTools
Top5BestLinuxOSDistributions
HowToMonitorRemoteLinuxHostusingNagios3.0
AwkIntroductionTutorial7AwkPrintExamples
HowtoBackupLinux?15rsyncCommandExamples
TheUltimateWgetDownloadGuideWith15AwesomeExamples
Top5BestLinuxTextEditors
PacketAnalyzer:15TCPDUMPCommandExamples
TheUltimateBashArrayTutorialwith15Examples
3StepstoPerformSSHLoginWithoutPasswordUsingsshkeygen&sshcopyid
UnixSedTutorial:AdvancedSedSubstitutionExamples
UNIX/Linux:10NetstatCommandExamples
TheUltimateGuideforCreatingStrongPasswords
6StepstoSecureYourHomeWirelessNetwork
TurbochargePuTTYwith12PowerfulAddOns

CATEGORIES
LinuxTutorials
VimEditor
SedScripting
AwkScripting
BashShellScripting
NagiosMonitoring
OpenSSH
IPTablesFirewall
ApacheWebServer
MySQLDatabase
PerlProgramming
GoogleTutorials
UbuntuTutorials
PostgreSQLDB
HelloWorldExamples
CProgramming
C++Programming
DELLServerTutorials
http://www.thegeekstuff.com/2012/01/nagioscommand/

10/12

3/31/2015

6NagiosCommandLineOptionsExplainedwithExamples

OracleDatabase
VMwareTutorials
Ramesh Natarajan
Follow

AboutTheGeekStuff

MynameisRameshNatarajan.Iwillbepostinginstructionguides,howto,troubleshootingtipsandtricksonLinux,
database,hardware,securityandweb.Myfocusistowritearticlesthatwilleitherteachyouorhelpyouresolveaproblem.Read
moreaboutRameshNatarajanandtheblog.

SupportUs
Supportthisblogbypurchasingoneofmyebooks.
Bash101HackseBook
SedandAwk101HackseBook
Vim101HackseBook
NagiosCore3eBook

ContactUs

http://www.thegeekstuff.com/2012/01/nagioscommand/

11/12

3/31/2015

6NagiosCommandLineOptionsExplainedwithExamples

EmailMe:UsethisContactFormtogetintouchmewithyourcomments,questionsorsuggestionsaboutthissite.Youcanalso
simplydropmealinetosayhello!.
FollowusonGoogle+
FollowusonTwitter
BecomeafanonFacebook
Copyright20082014RameshNatarajan.Allrightsreserved|TermsofService

http://www.thegeekstuff.com/2012/01/nagioscommand/

12/12

Potrebbero piacerti anche