Weitere ähnliche Inhalte
Ähnlich wie Nagios intro (20)
Kürzlich hochgeladen (20)
Nagios intro
- 4. o MRTG
• (Multi Router Traffic Grapher), is free software for monitoring and measuring the traffic load on network links. It
allows the user to see traffic load on a network over time in graphical form.
o RRDTool
• (Round-Robin Database Tool) aims to handle time series data such as network bandwidth, temperatures or CPU load.
The data is stored in a circular buffer based database, thus the system storage footprint remains constant over time.
o Nagios
• is a free and open source computer-software application that monitors systems, networks and infrastructure
o Ganglia
• is a scalable, distributed monitoring tool for high-performance computing systems, clusters and network
o Cacti
• is an open-source, web-based network monitoring and graphing tool designed as a front-end application for the open-
source, industry-standard data logging tool RRDtool
History
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY4
- 5. Monitor Tool
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY5
1995 1999 2000 200720042001
- 6. o Nagios, now known as Nagios Core, is a free and open source computer-software
application that monitors systems, networks and infrastructure. Nagios offers
monitoring and alerting services for servers, switches, applications and services. It
alerts users when things go wrong and alerts them a second time when the problem
has been resolved.
About Nagios
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY6
Ref: Nagios
Ref: wiki
- 7. Nagios Core vs Nagios XI
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY7
Ref: Feature-Comparison
- 10. o OS:
• CentOS 7
o Package:
• nagios-4.3.4, nagios-plugins-2.2.1
Environment
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY10
- 11. o # disable selinux
o nagios:~ # sed s'/SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
nagios:~ # reboot
o # install package
o nagios:~ # yum install epel-release
nagios:~ # yum install nagios nagios-plugins-all
o # start and enable service
o nagios:~ # systemctl start nagios
nagios:~ # systemctl start httpd
nagios:~ # systemctl enble nagios
nagios:~ # systemctl enble httpd
Install
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY11
- 12. o # verify config
o nagios:~ # nagios -v /etc/nagios/nagios.cfg
o # setup web account and password
o nagios:~ # htpasswd -c /etc/nagios/passwd nagiosadmin
o # config firewall
o nagios:~ # firewall-cmd --zone=public --add-port=80/tcp --permanent
nagios:~ # firewall-cmd --reload
Setting
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY12
- 15. o nagios.cfg
• main config
o cgi.cfg
• cgi config
o resource.cfg
• define multiple resourc
o objects
• define hosts, host groups, contacts, contact groups,
services, etc
o passwd
• web access account and password
Folder Structure
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY16
- 16. © 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY17
Ref: Object Overview
- 17. o define object-type{
object-specific variable
}
o define host{
use linux-server
host_name localhost
alias localhost
address 127.0.0.1
}
o Hosts are one of the central objects in the monitoring logic
o Host Groups are groups of one or more hosts
o Services are one of the central objects in the monitoring
logic
o Service Groups are groups of one or more service
o Contacts are people involved in the notification process
o Contact Groups are groups of one or more contacts
o Commands are used to tell Nagios what programs, scripts,
etc. it should execute to perform
o Timeperiods are used to control
Syntax Type Object
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY18
Ref: Object Configuration Overview
- 18. © 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY19
Ref: Object Configuration Overview
- 19. localhost example
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY20
commands.cfg
templates.cfg
localhost.cfg
- 22. o Step 1. Require Package
o Nagios:~ # yum install bc net-snmp-utils
o Step 2. Download check_qnap
o Step 3. Install
o nagios:~ # chmod +x check_qnap
nagios:~ # cp check_qnap /usr/lib64/nagios/plugins/
nagios:~ # /usr/lib64/nagios/plugins/check_qnap <qnap_ip> public diskused 90 95
o Step 4. Setup object
o nagios:~ # vi /etc/nagios/conf.d/nas.cfg
Add QNAP Plugins
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY23
- 28. o NRPE
• is used for performing active checks in Nagios
o NSCA
• is used for performing passive checks in Nagios
Remote Monitor
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY29
Ref: Nagios Core Addons
- 29. o NRPE, Nagios Remote Plugin Executor, is an
addon that allows you to execute plugins on
remote Linux/Unix hosts. This is useful if you
need to monitor local resources/attributes like
disk usage, CPU load, memory usage, etc. on a
remote host. Similiar functionality can be
accomplished by using the check_by_ssh plugin,
although it can impose a higher CPU load on
the monitoring machine - especially if you are
monitoring hundreds or thousands of hosts.
NRPE
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY30
- 30. o NSCA, Nagios Service Check Acceptor, is an
addon that allows you to send passive check
results from remote Linux/Unix hosts to the
Nagios Core daemon running on the
monitoring server. This is very useful in
distributed and redundant/failover monitoring
setups.
NSCA
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY31
- 31. o Step 1. Install
o remote:~ # yum install nagios-plugins-all
remote:~ # yum install nrpe
o Step 2. Configuration
o remote:~ # vi /etc/nagios/nrpe.cfg
allowed_hosts=<nagios_ip>
dont_blame_nrpe=1
command[check_disk]=/usr/lib64/nagios/plugins/check_disk $ARG1$
command[secure_check_disk]=/usr/lib64/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$
command[check_all_disk]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -e
o Step 3. Start Service
o remote:~ # systemctl start nrpe
remote:~ # systemctl enable nrpe
o Step 4. Setup firewall
o remote:~ # firewall-cmd --zone=public --add-port=5666/tcp --permanent
remote:~ # firewall-cmd --reload
Install NRPE on Remote
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY32
- 32. o Step 1. Install
o nagios:~ # yum install nagios-plugins-nrpe
o Step 2. Test
o nagios:~ # /usr/lib64/nagios/plugins/check_nrpe -H <remote_ip> -c check_disk -a '-w 20% -c 10% -p /'
o Step 3. Configure
o nagios:~ # vi /etc/nagios/conf.d/nodes.cfg
o Step 3. Restart Service
o nagios:~ # systemctl restart nagios
Install NRPE on Nagios
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY33
- 33. Nagios Config For NRPE
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY34
remote host must define the
command on nrpe.conf
- 35. o n2rrd
o Nagiosgraph
o PNP4Nagios
RRDTool On Nagios
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY36
- 36. o Synchronous Mode
o Bulk Mode
o Bulk Mode with NPCD
o Bulk Mode with npcdmod
o Gearman Mode
Mode
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY37
Ref: Modes
- 37. o The “synchronous mode” is the
simplest and easiest to set up. Nagios
will call the perl script
process_perfdata.pl for every service
and host, respectively, to process the
data. The synchronous mode will work
very good up to about 1,000 services in
a 5 minute interval.
Synchronous Mode
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY38
- 38. o In bulk mode Nagios writes the necessary data
to a temporary file. After expiration of a
defined time the file will be processed in one
piece and deleted afterwards.
o The number of calls of process_perfdata.pl will
be reduced to a fraction. Depending on time
and the amount of collected data there will be
much less system calls. Instead,
process_perfdata.pl will run longer.
o Note Using this mode you should keep an eye
on the runtime of process_perfdata.pl. While it
is running to process data nagios will not
execute any checks.
Bulk Mode
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY39
- 39. o Nagios again uses a temporary file to store the
data and executes a command after expiration
of a certain time. Instead of immediate
processing by process_perfdata.pl the file is
moved to a spool directory. As moving a file
inside the same filesystem nearly takes no time
nagios is able to execute crucial work
immediately.
o The NPCD daemon (Nagios Performance C
Daemon) will monitor the directory for new
files and will pass the names to
process_perfdata.pl. Processing of performance
data is decoupled completely from nagios.
NPCD itself is able to start multiple thread for
processing the data.
Bulk Mode with NPCD
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY40
- 40. o This scenario includes npcdmod.o, an
NEB-module. This module reduces the
configuration of the “Bulk Mode with
NPCD” to a mere two lines in
nagios.cfg
o This mode is similar to “Bulk Mode
with NPCD” and it is exactly the same
functionality and the same
performance.
Bulk Mode with npcdmod
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY41
- 41. o Since version 0.6.12 PNP4Nagios can be
driven as a gearman worker. This way
large Nagios environments are possible
using mod_gearman. Nagios and
PNP4Nagios can be run on different
machines.
Gearman Mode
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY42
- 43. o Step 1. Install package
o nagios:~ # yum install rrdtool rrdtool-perl
nagios:~ # yum install pnp4nagios
o Step 2. Restart service
o nagios:~ # systemctl restart httpd
o Step 3. Test
o http://<nagios_ip>/pnp4nagios
Install
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY44
- 44. o Step 1. Download pnp-metrics-api
o nagios:~ # wget https://github.com/lingej/pnp-metrics-
api/raw/master/application/controller/api.php -O
/usr/share/nagios/html/pnp4nagios/application/controllers/api.php
o Step 2. Test
o nagios:~ # curl -s -u ‘<user>:<password>’
http://<nagios_ip>/pnp4nagios/index.php/api/hosts
Install pnp-metrics-api
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY45
- 45. o Step 1. Update nagios.cfg
o nagios:~ # vi /etc/nagios/nagios.cfg
...
# modify below
process_performance_data=1
enable_environment_macros=1
host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdata
Configuration - nagios.cfg (Bulk mode)
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY46
Ref: Configuration
- 46. o # service performance data
o service_perfdata_file=/var/log/pnp4nagios/service-perfdata
service_perfdata_file_template=DATATYPE::SERVICEPERFDATAtTIMET::$TIMET$tHOSTNAME::$HOSTNAME$tSERVICE
DESC::$SERVICEDESC$tSERVICEPERFDATA::$SERVICEPERFDATA$tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$tHO
STSTATE::$HOSTSTATE$tHOSTSTATETYPE::$HOSTSTATETYPE$tSERVICESTATE::$SERVICESTATE$tSERVICESTATETYPE::$
SERVICESTATETYPE$
service_perfdata_file_mode=a
service_perfdata_file_processing_interval=15
service_perfdata_file_processing_command=process-service-perfdata-file
o # host performance data starting with Nagios
o host_perfdata_file=/var/log/pnp4nagios/host-perfdata
host_perfdata_file_template=DATATYPE::HOSTPERFDATAtTIMET::$TIMET$tHOSTNAME::$HOSTNAME$tHOSTPERFDATA:
:$HOSTPERFDATA$tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$tHOSTSTATE::$HOSTSTATE$tHOSTSTATETYPE::$HOSTSTAT
ETYPE$
host_perfdata_file_mode=a
host_perfdata_file_processing_interval=15
host_perfdata_file_processing_command=process-host-perfdata-file
Configuration - nagios.cfg (Bulk mode)
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY47
- 47. o Step 2. Update commands.cfg
o nagios:~ # vi /etc/nagios/objects/commands.cfg
...
# modify below
define command{
command_name process-service-perfdata-file
command_line /usr/libexec/pnp4nagios/process_perfdata.pl --bulk /var/log/pnp4nagios/service-
perfdata
}
define command{
command_name process-host-perfdata-file
command_line /usr/libexec/pnp4nagios/process_perfdata.pl --bulk /var/log/pnp4nagios/host-
perfdata
}
o
Configuration - commands.cfg
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY48
Ref: Configuration
- 48. o Step 3. Update templates.cfg
o nagios:~ # vi /etc/nagios/objects/templates.cfg
...
# add below
define host {
name host-pnp
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_
register 0
}
define service {
name srv-pnp
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
register 0
}
o
Configuration - templates.cfg
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY49
Ref: Configuration
- 49. o Step 4. Update localhost.cfg
o nagios:~ # vi /etc/nagios/objects/localhost.cfg
...
# modifty below
define host{
use linux-server,host-pnp
host_name localhost
alias localhost
address 127.0.0.1
}
...
define service{
use local-service,srv-pnp
host_name localhost
service_description Root Partition
check_command check_local_disk!20%!10%!/
}
o
Configuration - localhost.cfg
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY50
Ref: Configuration
- 52. o Grafana is an open-source, general purpose dashboard and graph composer, which
runs as a web application. It supports graphite, InfluxDB or opentsdb as backends.
Introduction
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY53
Ref: Grafana Labs
- 53. o Step 1. Require Package
o nagios:~ # yum install initscripts fontconfig urw-fonts
o Step 2. Install
o nagios:~ # yum install https://s3-us-west-2.amazonaws.com/grafana-
releases/release/grafana-4.6.3-1.x86_64.rpm
nagios:~ # systemctl start grafana-server.service
nagios:~ # systemctl enable grafana-server.service
o Step 3. Install plugin
o nagios:~ # grafana-cli plugins install sni-pnp-datasource
nagios:~ # systemctl restart grafana-server.service
o Step 4. Firewall
o nagios:~ # firewall-cmd --zone=public --add-port=3000/tcp --permanent
nagios:~ # firewall-cmd --reload
Install
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY54
Ref: PNP4Nagios and Grafana
- 57. o Type choose PNP
o URL key in pnp4nagios
o Access select proxy
o Click Basic Auth
Create Data Source
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY58
Hinweis der Redaktion
- nagios:~ # ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-rrdtool=/usr/bin/rrdtool
- nagios:~ # ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-rrdtool=/usr/bin/rrdtool