Sunteți pe pagina 1din 7

sharmith's blog: How to Install and configure NAGIOS for monitoring...

http://sharmith.blogspot.com/2012/10/NAGIOS-for-monitoring-CISC...

Followers

F r i d a y, O c t o b e r 5 , 2 0 1 2

with Google Friend Connect

How to Install and configure NAGIOS for monitoring CISCO device on FEDORA
Nagios Nagios is an open source free monitoring tool which is widely used by people to monitor their infrastructure devices and to create reports on the availability of the services. This tool has the capability to alert the status of services or devices in realtime, based on your configuration on to a web based dashboard, email, sms etc Ethan Galstad created this wonderful monitoring tool and is currently supported by him and a group of developers actively maintaining the plugins for it which are official and unofficial. It is licensed under GNU version . Nagios has got the ability to monitor services, hosts and anything else which have the ability to send collected data via a networ! to specifically written plugins. Nagios collects information with the help of "N#$ and agents installed on the remote systems. I am trying to e%plain over here the installation of Nagios on a &inu% system running 'edora and the configuration re(uired on it to ma!e the application useful for monitoring your networ! devices li!e )outers, switches, firewalls, loadbalancers and services li!e *"#T$, $+$,, -TT$, NNT$, I.#$, "N#$, 'T$, ""-/ with the usage of different plugins available at sites given below. Download Sites: Nagios .ore0 http011www.nagios.org1download1core1than!s1 2ddons0 *clients/ http011www.nagios.org1download1addons1 $lugins0 http011www.nagios.org1download1plugins1 or Nagios E%change h p://exchange.nagios.org 'rontends0 *GUI/ http011www.nagios.org1download1frontends1

Members (5)

Already a member? Sign in

About Me

sharmith ramesh

I am the only one and your search lasts here 0/ 9iew my complete profile

Blog Archive

:6 *;/ +ctober * / -ow to Install and configure N2GI+" for monitoring... <ac!up "cript in &inu% 2ugust * / =uly *6/ =une *6/ #ay *6/

Prerequisites
Run all steps from this document with root permissions. The following command can be run to switch to a root shell. >su root *** This will prompt for root user password. After entering the same the prompt will change to root. #

Issue the command 3pwd4 to chec! the present directory 5pwd Install the dependency pac!ages and applications
#yum install -y wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp

To start with I will detail the steps for installing the Nagios .ore pac!age from the source to a linu% fedora distribution. "tep 6 7ou could download the source pac!age from the lin!s given above or by running the command given below.
Run the following commands in your terminal: To change the directory to temporary folder #cd /tmp #wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.4.1.tar.gz #wget http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz

This will download Nagios core pac!age and the re(uired plugins. "tep .reating User accounts and Group
#useradd nagios #groupadd nagcmd #usermod -a -G nagcmd nagios

"tep , E%tracting the downloaded pac!ages


#tar zxvf nagios-3.4.1.tar.gz #tar zxvf nagios-plugins-1.4.15.tar.gz

"tep 8 +nce you e%tract the file you will get a folder with the name 3nagios4. .hange to the directory and configure.
#cd nagios

1 of 7

1/26/2014 6:32 PM

sharmith's blog: How to Install and configure NAGIOS for monitoring...

http://sharmith.blogspot.com/2012/10/NAGIOS-for-monitoring-CISC...

#./configure --with-command-group=nagcmd #make all #make install #make install-init #make install-config #make install-commandmode #make install-webconf

#cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/ #chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers

For verifying the configuration:


#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg This should give zero errors and zero warnings before restarting the nagios service. Starting the Nagios service #/etc/init.d/nagios start Starting the Web service #/etc/init.d/httpd start

.reate a >efault User for ?eb 2ccess.


Add a default user for Web Interface Access: #htpasswd c /usr/local/nagios/etc/htpasswd.users nagiosadmin *** You will be prompted for a password for the account

Nagios Plugin Installation


After extracting the plugin file with the tar command as explained earlier. #cd /tmp/nagios-plugins-1.4.15 #./configure --with-nagios-user=nagios --with-nagios-group=nagios #make #make install

Nagios Service Setup


The following commands will register the Nagios daemon to be run upon system startup. #chkconfig --add nagios #chkconfig --level 35 nagios on #chkconfig --add httpd #chkconfig --level 35 httpd

Web Access:
After completing the steps followed above and verifying the configurations without any errors or warnings, you should be able to access the Nagios tool GUI with web by issuing the command in the url of your browser. Edit the section of the IP with the IP of your system. http:///nagios **** Log in with the credentials you chose while adding the nagiosadmin user to the htpasswd.users file.

Configuration of agios for !onitoring your critical services and devices"

-ere I will introduce you to the main configuration files which are re(uired for ma!ing the configuration changes for ma!ing the tool ready as per our re(uirement. Important configuration files and locations: 6/ #ain nagios configuration file 1usr1local1nagios1etc1nagios.cfg @@@@ 2ll the below mentioned files locations and some configuration parameters are mentioned over in this file. / ,,/ 'ile for storing paths for useraccount to plugins and eventhandlers 1usr1local1nagios1etc1resource.cfg 'or setting the configurations for the tool GUI 1usr1local1nagios1etc1cgi.cfg 'or defining the device or service configuration parameters. Eg0A1usr1local1nagios1etc1obBects1switch.cfg 1usr1local1nagios1etc1obBects1)outer6.cfg >efining -ost Information file0 *Useful for ma!ing the host or service appear on the map/ 51usr1local1nagios1etc1obBects hoste%tinfo.cfg

88/

CC/

DD/

>efining generic service template file0 *Used while creating -ost or "ervice for inheriting the configuration/ 51usr1local1nagios1etc1obBects1templates.cfg >efining Timeperiods template file0 *Timeperiods used in -ost and services configuration/ 51usr1local1nagios1etc1obBects1timeperiods.cfg

;;/

2 of 7

1/26/2014 6:32 PM

sharmith's blog: How to Install and configure NAGIOS for monitoring...

http://sharmith.blogspot.com/2012/10/NAGIOS-for-monitoring-CISC...

EE/

>efining commands and its synta% with parameters0 1usr1local1nagios1etc1obBects1commands.cfg >efining contacts to be notified and their availability time0 51usr1local1nagios1etc1obBects1contacts.cfg

FF/

Detail of device to be monitored : -ostname0 )outer6 Ip address0 6.6.6.6 "N#$ "tring0 public Interface0 GigabitEthernet:1: , 'astEthernet :1:1: On the isco !outer: accessAlist permit . . . snmpAserver community public )+ snmpAserver host GIpAaddressH snmpAserver enable traps snmp authentication lin!down lin!up coldstart warmstart snmpAserver enable traps memory snmpAserver enable traps cpuIthreshold

@@@@ 2ccess list number and )+ number should match. #ention any other traps which you want to be notified as per your re(uirement. reate a configuration file for the device under the directory "#usr#local#nagios#etc#ob$ects#% Template for Networ! device in router.cfg 5vi 1usr1local1nagios1etc1obBects1router.cfg 5555555555555555555555555555555555555555555555555555555555555555555555555555555 5555555555555555555555555555555555555555555555555555555555555555555555555555555 5 5 -+"T >E'INITI+N" 5 5555555555555555555555555555555555555555555555555555555555555555555555555555555 5555555555555555555555555555555555555555555555555555555555555555555555555555555 5 >efine the )outer that weJll be monitoring define hostG use genericAswitch K Inherit default values from a template name myrouter alias myrouters K 2 longer name associated with the switch hostgroups routers K -ost groups this switch is associated with register : H

5555555555555555555555555555555555555555555555555555555555555555555555555555555 5555555555555555555555555555555555555555555555555555555555555555555555555555555 5 5 -+"T G)+U$ >E'INITI+N" 5 5555555555555555555555555555555555555555555555555555555555555555555555555555555 5555555555555555555555555555555555555555555555555555555555555555555555555555555 5 .reate a new hostgroup for routerss define hostgroupG hostgroupIname routers K The name of the hostgroup alias Networ! )outers K &ong name of the group H 5555555555555555555555555555555555555555555555555555555555555555555555555555555 To save the file Esc L "hift 0w( "ave and e%it the configuration @@@ $lease note the 3register :4 parameter in the configuration. This defines that the configuration is a dummy file or template. This template will be referenced for use in other host <efore creating this file you need to ma!e sure that you have the plugins mentioned below for wor!ing of this configuration. &ocate these files in 1ur1local1nagios1libe%ec1 !e&uired 'lugins: chec!Iping chec!IsnmpIload.pl chec!IsnmpImemIv6 chec!Isnmp

5vi 1usr1local1nagios1etc1obBects1)outer6.cfg 5555555555555555555555555555555555555555555555555555555555555555555555555555555 5555555555555555555555555555555555555555555555555555555555555555555555555555555 5 5 -+"T >E'INITI+N" 5 5555555555555555555555555555555555555555555555555555555555555555555555555555555 5555555555555555555555555555555555555555555555555555555555555555555555555555555

3 of 7

1/26/2014 6:32 PM

sharmith's blog: How to Install and configure NAGIOS for monitoring...

http://sharmith.blogspot.com/2012/10/NAGIOS-for-monitoring-CISC...

55555555555555555555555555555555555555555555555555555555555555555555555555555555 define hostG use genericArouter K Inherit default values from a template mentioned above hostIname )outer6 5555555 -ostname as defined on the device alias ?2N A)outer K 2 longer name associated with the switch address 6.6.6.6 555555 I$ address of the device parents "witch 55555 To which device is this connected. ?ith E%act hostname hostgroups ?2NA>evices 55555 Group to which this device will be listed I.+##UNIT7 public 5555 "N#$ string H 55555555555555555555555555555555555555555555555555555555555555555555555555555555 5555555555555555555 -+"T E%tended Information 555555555555555555555555555555555555 define hoste%tinfoG hostIname )outer6 5 dIcoords 8:,8: iconIimage cisco.png 55555 $lace the logo 1usr1local1nagios1share1images1logos1 vrmlIimage cisco.png 55555 $lace the logo 1usr1local1nagios1share1images1logos1 statusmapIimage cisco.png 5555 2bove location H 555555555555555555555555555555555555555555555555555555555555555555555555555555555 5555555555555555555555555555555555555555555555555555555555555555555555555555555 5555555555555555555555555555555555555555555555555555555555555555555555555555555 5 5 "E)9I.E >E'INITI+N" 5 5555555555555555555555555555555555555555555555555555555555555555555555555555555 5555555555555555555555555555555555555555555555555555555555555555555555555555555 55555555555 #onitoring )outer Uptime 5555555555555555 define serviceG use genericAservice K Inherit values from a template hostIname )outer6 serviceIdescription Uptime chec!Icommand chec!IsnmpMA. public Ao sysUpTime.: H 55555555555 #onitoring )outer 2vailability with $ING 5555555555555555 define serviceG use genericAservice K Inherit values from a template hostIname )outer6 K The name of the host the service is associated with serviceIdescription $ING K The service description chec!Icommand chec!IpingM ::.:, :NMD::.:,D:N K The command used to monitor the service normalIchec!Iinterval 6 K .hec! the service every 6 minutes under normal conditions retryIchec!Iinterval 6 K )eAchec! the service every minute until its final1hard state is determined H 55555555555 #onitoring )outer .$U &oad "tatus 5555555555555555 define serviceG use genericAservice hostIname )outer6 serviceIdescription .$UI&oad chec!Icommand chec!IsnmpIload.plMpublicMciscoM8:,8:,8:MD:,D:,D: normalIchec!Iinterval 6 retryIchec!Iinterval 6 notificationIoptions w,c,r contactIgroups 8O; 55555555 #ention the contact group name defined in contacts.cfg H 55555555555 #onitoring )outer #emory 5555555555555555 define serviceG use genericAservice K Inherit values from a template hostIname )outer6 serviceIdescription #emory chec!Icommand chec!IsnmpImemIv6MpublicMAIMD:M;: 5555 ?arning to D:N and .ritical to ;:N normalIchec!Iinterval 6 retryIchec!Iinterval 6 notificationIoptions w,c,r contactIgroups 8O; 55555555 #ention the contact group name defined in contacts.cfg H

55555555555 #onitoring Interface "tatus 5555555555555555 define serviceG use genericAservice K Inherit values from a template hostIname )outer6 serviceIdescription GigabitEthernet:1: 555 Name of the Interface for identification chec!Icommand chec!IsnmpMA. public Ao if+per"tatus.6 Ar 6 Am )'.6 6,A#I< H define serviceG use genericAservice K Inherit values from a template hostIname )outer6 serviceIdescription 'astEthernet:1:1: chec!Icommand chec!IsnmpMA. public Ao if+per"tatus.8 Ar 6 Am )'.6 6,A#I< H 5555555555555#onitoring <andwidth 1 Traffic )ate 555555555555555555555555 555555 7ou need to have already #)TG running and graphing for this device interface define serviceG

4 of 7

1/26/2014 6:32 PM

sharmith's blog: How to Install and configure NAGIOS for monitoring...

http://sharmith.blogspot.com/2012/10/NAGIOS-for-monitoring-CISC...

use genericAservice K Inherit values from a template hostIname )outer6 serviceIdescription 'astEthernet:1:1: <andwidth Usage chec!Icommand chec!IlocalImrtgtrafM1var1lib1mrtg 16.6.6.6I8.logM29GM6::::::, ::::::MC::::::,C::::::M6: H

5555555555555555555555555555555555555555555555555555555555555555555555555555 55555555555555555 EN> +' 'I&E 55555555555555555555555555555555555555555555555 To save the file Esc L "hift 0w( "ave the file )outer6.cfg and e%it If you want to ensure that a specific port1interface on the router is in an up state, you could add a service definition li!e this. 7ou can usually find the +I>s that can be monitored on a router by running the following command *replace 6.6.6.6 with the I$ address of the switch/0 5snmpwal! Av6 Ac public 6.6.6.6 Am 2&& .6 L )otuer6.t%t 5cat )outer6.t%t +r 5 vi )outer6.t%t This file will contain the +I>Ps used by the device, which can be used while configuring. "ample contents of )outer6.t%t if>escr.6 Q "T)ING0 GigabitEthernet:1: if>escr. Q "T)ING0 GigabitEthernet:16 if>escr., Q "T)ING0 <ac!planeAGigabitEthernet:1, if>escr.8 Q "T)ING0 'astEthernet:1:1: if>escr.C Q "T)ING0 'astEthernet:1:16 if>escr.D Q "T)ING0 "erial:161: if>escr.; Q "T)ING0 "erial:1616

(a)e the number mentioned after "ifDescr*% In "ifOperStatus*% onfigurations to be done in the commands*cfg file: 2dd the lines as given below for chec!ing memory and .$U load of cisco. 5vi 1usr1local1nagios1etc1obBects1commands.cfg 555555555555555555555555555555555555.isco A &oad R #emory55555555555555555555555555555555555555555555 5 J.iscoI.$UJ command definition define commandG commandIname chec!IsnmpIload.pl commandIline SU"E)6S1chec!IsnmpIload.pl A. S2)G6S A- S-+"T2>>)E""S SU"E);S AT S2)G S Aw S2)G,S Ac S2)G8S S2)GCS H 5J.iscoImemoryJ .isco memory chec! define commandG commandIname chec!IsnmpImemIv6 commandIline SU"E)6S1chec!IsnmpImem.pl A- S-+"T2>>)E""S A. S2)G6S SU"E);S S2)G S Aw S2)G,S Ac S2)G8S S2)GCS H 5555555555555555555555555555555555555555555555555555555555555555555555555555555555 555

onfigurations to be done in the nagios*cfg file: @@@$lease ta!e precaution that all the configuration files with uncommented should be present 5 +<=E.T .+N'IGU)2TI+N 'I&E*"/ 5 These are the obBect configuration files in which you define hosts, 5 host groups, contacts, contact groups, services, etc. 5 7ou can split your obBect definitions across several config files 5 if you wish *as shown below/, or !eep them all in a single config file. 5 7ou can specify individual obBect config files as shown below0 cfgIfileQ1usr1local1nagios1etc1obBects1commands.cfg cfgIfileQ1usr1local1nagios1etc1obBects1contacts.cfg cfgIfileQ1usr1local1nagios1etc1obBects1timeperiods.cfg cfgIfileQ1usr1local1nagios1etc1obBects1templates.cfg 5 >efinitions for monitoring a router1switch cfgIfileQ1usr1local1nagios1etc1obBects1router.cfg cfgIfileQ1usr1local1nagios1etc1obBects1)outer6.cfg cfgIfileQ1usr1local1nagios1etc1obBects1"witch .cfg 55555 5 -ost Template configuration file %edtemplateIconfigIfileQ1usr1local1nagios1etc1obBects1hoste%tinfo.cfg

5 2>#INI"T)2T+) E#2I&1$2GE) 2>>)E""E" 5 The email and pager address of a global administrator *li!ely you/. 5 Nagios never uses these values itself, but you can access them by 5 using the S2>#INE#2I&S and S2>#IN$2GE)S macros in your notification 5 commands.

5 of 7

1/26/2014 6:32 PM

sharmith's blog: How to Install and configure NAGIOS for monitoring...

http://sharmith.blogspot.com/2012/10/NAGIOS-for-monitoring-CISC...

adminIemailQnagiosTlocalhost adminIpagerQpagenagiosTlocalhost To save the file Esc L "hift 0w(

+a)e the configuration changes in cgi*cfg file: 5vi 1usr1local1nagios1etc1cgi.cfg 5 #2IN .+N'IGU)2TI+N 'I&E 5 This tells the .GIs where to find your main configuration file. 5 The .GIs will read the main and host config files for any other 5 data they might need. mainIconfigIfileQ1usr1local1nagios1etc1nagios.cfg useIauthenticationQ6 5 G&+<2& -+"T1"E)9I.E .+##2N> 2..E"" authoriUedIforIallIserviceIcommandsQnagiosadmin authoriUedIforIallIhostIcommandsQnagiosadmin 5 $ING "7NT2O pingIsynta%Q1bin1ping An AU Ac C S-+"T2>>)E""S

5 )E')E"- )2TE 5 This option allows you to specify the refresh rate in seconds 5 of various .GIs *status, statusmap, e%tinfo, and outages/. refreshIrateQ,: 5 E".2$E -T#& T2G" escapeIhtmlItagsQ6

5 "+UN> +$TI+N" 5 Note0 2ll audio files must be placed in the 1media subdirectory 5 under the -T#& path *i.e. 1usr1local1nagios1share1media1/. hostIunreachableIsoundQwarning.wav hostIdownIsoundQwarning.wav serviceIcriticalIsoundQwarning.wav To save the file Esc L "hift 0w(

There are many more fine tuning you can do on this file as per your re(uirement eg0A #2$", &ayout, etc. 9erify the configuration by issuing the command as given below0 5 1usr1local1nagios1bin1nagios Av 1usr1local1nagios1etc1nagios.cfg +utput should be as given below before starting or restarting nagios. Total ?arnings0 : Total Errors0 : Things loo! o!ay A No serious problems were detected during the preAflight chec!

)estart the Nagios if all loo!s fine 5service nagios restart +r 51usr1local1nagios1bin1nagios Ad 1usr1local1nagios1etc1nagios.cfg 2fter this the configurations will reflect in the ?eb GUI >ashboard.
http:///nagios

'or further documentation please refer the official site. http011nagios.sourceforge.net1docs1,I:1toc.html

$osted by sharmith ramesh at 808C 2# &abels0 .isco .$U &oad, .isco #emory Utilisation, .isco #onitoring, Interface <andwidth Graphing, Interface Uptime "tatus, Nagios

No comments:

6 of 7

1/26/2014 6:32 PM

sharmith's blog: How to Install and configure NAGIOS for monitoring...

http://sharmith.blogspot.com/2012/10/NAGIOS-for-monitoring-CISC...

7 of 7

1/26/2014 6:32 PM

S-ar putea să vă placă și