Hướng dẫn sử dụng và cài đặt Nagios trên Linux

13 74 0
Hướng dẫn sử dụng và cài đặt Nagios trên Linux

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Nagios là một công cụ giám sát mã nguồn mở tuyệt vời, nó cung cấp cho bạn môi trường giám sát toàn diện hơn để luôn theo dõi tất cả các máy mạng của bạn cho dù bạn đang ở trong trung tâm dữ liệu hay chỉ trong phòng thí nghiệm nhỏ của bạn. Với Nagios, bạn có thể giám sát các máy chủ từ xa của mình và các dịch vụ của chúng từ xa trên một cửa sổ duy nhất. Nó hiển thị cảnh báo và cho biết nếu có sự cố xảy ra trong máy chủ của bạn, điều này cuối cùng giúp chúng tôi phát hiện một số sự cố trước khi chúng xảy ra. Nó giúp chúng tôi giảm thời gian downtime và tổn thất kinh doanh. Gần đây, Nagios đã phát hành phiên bản mới nhất Nagios Core 4.4.5 và bản phát hành ổn định mới nhất của plugin Nagios 2.2.1 Bài viết này nhằm hướng dẫn bạn những hướng dẫn dễ dàng về cách cài đặt Nagios Core 4.4.5 mới nhất từ nguồn (tarball) trên các bản phân phối CentOS 678

Hướng dẫn cài đặt Nagios 4.4.5 CenOS Nagios công cụ giám sát mã nguồn mở tuyệt vời, cung cấp cho bạn mơi trường giám sát tồn diện để ln theo dõi tất máy / mạng bạn cho dù bạn trung tâm liệu hay phịng thí nghiệm nhỏ bạn Với Nagios, bạn giám sát máy chủ từ xa dịch vụ chúng từ xa cửa sổ Nó hiển thị cảnh báo cho biết có cố xảy máy chủ bạn, điều cuối giúp phát số cố trước chúng xảy Nó giúp chúng tơi giảm thời gian down-time tổn thất kinh doanh Gần đây, Nagios phát hành phiên Nagios Core 4.4.5 phát hành ổn định plugin Nagios 2.2.1 Bài viết nhằm hướng dẫn bạn hướng dẫn dễ dàng cách cài đặt Nagios Core 4.4.5 từ nguồn (tarball) phân phối CentOS 6/7/8 Trong vòng 30 phút, bạn giám sát máy cục mình, khơng có quy trình cài đặt nâng cao cài đặt hoạt động 100% hầu hết máy chủ Linux ngày Xin lưu ý: Các hướng dẫn cài đặt hiển thị viết dựa phân phối CentOS Linux Cài đặt Nagios 4.4.5 Plugin Nagios 2.2.1 Nếu bạn làm theo hướng dẫn cách xác, bạn kết thúc với thơng tin sau Nagios plugin cài đặt thư mục / usr / local / nagios Nagios định cấu hình để giám sát số dịch vụ máy cục bạn (Sử dụng đĩa, Tải CPU, Người dùng tại, Tổng số trình, v.v.) Giao diện web Nagios có http: // localhost / nagios Bước 1: Cài đặt phần phụ thuộc bắt buộc Chúng ta cần cài đặt Apache, PHP số thư viện gcc, glibc, glibc-common thư viện GD thư viện phát triển trước cài đặt Nagios 4.4.5 với nguồn Và để làm vậy, sử dụng trình cài đặt gói mặc định yum [root@leoodz]# yum install -y httpd httpd-tools php gcc glibc glibc-common gd gd-devel make net-snmp Bước 2: Tạo người dùng nhóm Nagios Tạo người dùng nagios lệnh useradd tài khoản nhóm nagcmd đặt mật [root@leoodz]# useradd nagios [root@leoodz]# groupadd nagcmd Tiếp theo, thêm người dùng nagios người dùng apache vào nhóm nagcmd lệnh usermod [root@leoodz]# usermod -G nagcmd nagios [root@leoodz]# usermod -G nagcmd apache Bước 3: Tải xuống Nagios Core 4.4.5 Plugin Nagios 2.2.1 Tạo thư mục để cài đặt Nagios bạn tất tải xuống tương lai [root@leoodz]# mkdir /root/nagios [root@leoodz]# cd /root/nagios Bây tải xuống gói Nagios Core 4.4.5 plugin Nagios 2.2.1 lệnh wget [root@leoodz nagios~]# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.5.tar.gz [root@leoodz nagios~]# wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz Bước 4: Giải nén Nagios Core plugin [root@leoodz nagios~]# tar -xvf nagios-4.4.5.tar.gz [root@leoodz nagios~]# tar -xvf nagios-plugins-2.2.1.tar.gz Khi bạn giải nén tarball lệnh tar, hai thư mục xuất thư mục [root@leoodz nagios ~]# ls -l total 13520 drwxrwxr-x 18 root root 4096 Aug 20 17:43 nagios-4.4.5 -rw-r r root root 11101966 Aug 20 17:48 nagios-4.4.5.tar.gz drwxr-xr-x 15 root root 4096 Apr 19 12:04 nagios-plugins-2.2.1 -rw-r r root root 2728818 Apr 19 12:04 nagios-plugins-2.2.1.tar.gz Cài đặt cấu hình Nagios Core Bây giờ, cấu hình Nagios Core để làm cần vào thư mục Nagios chạy tệp cấu hình thứ diễn tốt đẹp, cuối hiển thị đầu dạng sau Vui lòng xem bên [root@leoodz nagios~]# cd nagios-4.4.5/ [root@leoodz nagios-4.4.5 ]# /configure with-command-group=nagcmd Nếu bạn làm xác kết lệnh sau Creating sample config files in sample-config/ *** Configuration summary for nagios 4.4.5 2019-08-20 ***: General Options: Nagios executable: nagios Nagios user/group: nagios,nagios Command user/group: nagios,nagcmd Event Broker: yes Install ${prefix}: /usr/local/nagios Install ${includedir}: /usr/local/nagios/include/nagios Lock file: /run/nagios.lock Check result directory: /usr/local/nagios/var/spool/checkresults Init directory: /lib/systemd/system Apache conf.d directory: /etc/httpd/conf.d Mail program: /usr/bin/mail Host OS: linux-gnu IOBroker Method: epoll Web Interface Options: HTML URL: http://localhost/nagios/ CGI URL: http://localhost/nagios/cgi-bin/ Traceroute (used by WAP): /usr/bin/traceroute Review the options above for accuracy If they look okay, type 'make all' to compile the main program and CGIs Sau cấu hình, cần biên dịch cài đặt tất tệp nhị phân lệnh make all and make install, cài đặt tất thư viện cần thiết máy bạn tiến hành thêm [root@leoodz nagios-4.4.5 ]# make all [root@leoodz nagios-4.4.5 ]# make install Kết quả: *** Compile finished *** If the main program and CGIs compiled without any errors, you can continue with testing or installing Nagios as follows (type 'make' without any arguments for a list of all possible options): make test - This runs the test suite make install - This installs the main program, CGIs, and HTML files make install-init - This installs the init script in /lib/systemd/system make install-daemoninit - This will initialize the init script in /lib/systemd/system make install-groups-users - This adds the users and groups if they not exist make install-commandmode - This installs and configures permissions on the directory for holding the external command file make install-config - This installs *SAMPLE* config files in /usr/local/nagios/etc You'll have to modify these sample files before you can use Nagios Read the HTML documentation for more info on doing this Pay particular attention to the docs on object configuration files, as they determine what/how things get monitored! make install-webconf - This installs the Apache config file for the Nagios web interface make install-exfoliation - This installs the Exfoliation theme for the Nagios web interface make install-classicui - This installs the classic theme for the Nagios web interface Lệnh sau cài đặt tập lệnh init cho Nagios [root@leoodz nagios-4.4.5 ]# make install-init Để làm cho Nagios hoạt động từ dòng lệnh, cần cài đặt chế độ lệnh [root@leoodz nagios-4.4.5 ]# make install-commandmode Tiếp theo, cài đặt tệp Nagios mẫu, vui lòng chạy lệnh sau [root@leoodz nagios-4.4.5 ]# make install-config Kết quả: /usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc /usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc/objects /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/nagios.cfg /usr/local/nagios/etc/nagios.cfg /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/cgi.cfg /usr/local/nagios/etc/cgi.cfg /usr/bin/install -c -b -m 660 -o nagios -g nagios sample-config/resource.cfg /usr/local/nagios/etc/resource.cfg /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/templates.cfg /usr/local/nagios/etc/objects/templates.cfg /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/commands.cfg /usr/local/nagios/etc/objects/commands.cfg /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/contacts.cfg /usr/local/nagios/etc/objects/contacts.cfg /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/templateobject/timeperiods.cfg /usr/local/nagios/etc/objects/timeperiods.cfg /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/localhost.cfg /usr/local/nagios/etc/objects/localhost.cfg /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/windows.cfg /usr/local/nagios/etc/objects/windows.cfg /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/printer.cfg /usr/local/nagios/etc/objects/printer.cfg /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/switch.cfg /usr/local/nagios/etc/objects/switch.cfg *** Config files installed *** Remember, these are *SAMPLE* config files You'll need to read the documentation for more information on how to actually define services, hosts, etc to fit your particular needs Bước 5: Tùy chỉnh cấu hình Nagios Mở tệp “contact.cfg” sửa phần email contact # vi /usr/local/nagios/etc/objects/contacts.cfg Kết quả: ############################################################################## # ############################################################################## # # # 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 use generic-contact template (defined above) alias email ADDRESS **** Nagios Admin ; Short name of user ; Inherit default values from generic-contact ; Full name of user NHẬP EMAIL CỦA BẠN Ở ĐÂY } Bước 6: Cài đặt cấu hình giao diện web cho Nagios ; *** CHANGE THIS TO YOUR EMAIL Chúng ta hồn tất cấu hình phần backend, cấu hình Web Interface cho Nagios lệnh sau Lệnh cài đặt cấu hình giao diện Web cho Nagios người dùng quản trị web tạo “nagiosadmin” [root@leoodz nagios-4.4.5 ]# make install-webconf Trong bước này, tạo mật cho “nagiosadmin” Sau thực lệnh này, vui lòng cung cấp mật hai lần ghi nhớ mật mật sử dụng bạn đăng nhập vào giao diện Web Nagios [root@leoodz nagios-4.4.5]# htpasswd -s -c /usr/local/nagios/etc/htpasswd.users nagiosadmin New password: Re-type new password: Adding password for user nagiosadmin Khởi động lại Apache để cài đặt có hiệu lực [root@leoodz nagios-4.4.5]# systemctl start httpd.service Bước 7: Biên dịch cài đặt plugin Nagios Chúng ta tải xuống plugin Nagios / root / nagios, Hãy truy cập vào cấu hình cài đặt theo hướng dẫn bên [root@leoodz nagios-4.4.5]# cd /root/nagios [root@leoodz nagios]# cd nagios-plugins-2.2.1/ [root@leoodz nagios-plugins-2.2.1]# /configure with-nagios-user=nagios with-nagiosgroup=nagios [root@leoodz nagios-plugins-2.2.1]# make [root@leoodz nagios-plugins-2.2.1]# make install Bước 8: Xác minh tệp cấu hình Nagios (kiểm tra ta làm xác hết chưa) Bây tất hồn tất với cấu hình Nagios đến lúc xác minh để làm vậy, vui lịng nhập lệnh sau Nếu thứ sn sẻ, hiển thị tương tự đầu bên [root@leoodz nagios]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg Kết quả: Nagios Core 4.4.5 Copyright (c) 2009-present Nagios Core Development Team and Community Contributors Copyright (c) 1999-2009 Ethan Galstad Last Modified: 2019-08-20 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 services Checked hosts Checked host groups Checked service groups Checked contacts Checked contact groups Checked 24 commands Checked time periods Checked host escalations Checked service escalations Checking for circular paths Checked hosts Checked service dependencies Checked host dependencies Checked timeperiods Checking global event handlers Checking obsessive compulsive processor commands Checking misc settings Total Warnings: Total Errors: Things look okay - No serious problems were detected during the pre-flight check Bước 9: Làm Nagios khởi động CentOS Để làm cho Nagios hoạt động khởi động lại, cần thêm nagios httpd lệnh chkconfig systemctl CentOS [root@leoodz ]# chkconfig add nagios [root@leoodz ]# chkconfig level 35 nagios on [root@leoodz ]# chkconfig add httpd [root@leoodz ]# chkconfig level 35 httpd on CentOS 7/8 [root@leoodz ]# systemctl enable nagios [root@leoodz ]# systemctl enable httpd Khởi động lại Nagios để cài đặt có hiệu lực [root@leoodz ]# service nagios start [CentOS 6] [root@leoodz ]# systemctl start nagios.service [CentOS 7/8] Bước 10: Đăng nhập vào giao diện web Nagios Nagios bạn sẵn sàng hoạt động, vui lịng mở trình duyệt bạn “http: // IP bạn / nagios” “http: // FQDN / nagios” cung cấp tên người dùng “nagiosadmin” mật ... Nagios / root / nagios, Hãy truy cập vào cấu hình cài đặt theo hướng dẫn bên [root@leoodz nagios- 4.4.5]# cd /root /nagios [root@leoodz nagios] # cd nagios- plugins-2.2.1/ [root@leoodz nagios- plugins-2.2.1]#... 1: Cài đặt phần phụ thuộc bắt buộc Chúng ta cần cài đặt Apache, PHP số thư viện gcc, glibc, glibc-common thư viện GD thư viện phát triển trước cài đặt Nagios 4.4.5 với nguồn Và để làm vậy, sử dụng. .. interface Lệnh sau cài đặt tập lệnh init cho Nagios [root@leoodz nagios- 4.4.5 ]# make install-init Để làm cho Nagios hoạt động từ dòng lệnh, cần cài đặt chế độ lệnh [root@leoodz nagios- 4.4.5 ]#

Ngày đăng: 22/02/2021, 11:48

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan