溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

nagios監(jiān)控windows及l(fā)inux從而實(shí)現(xiàn)飛信報(bào)警

發(fā)布時(shí)間:2020-06-21 09:09:17 來(lái)源:網(wǎng)絡(luò) 閱讀:989 作者:only223wym 欄目:移動(dòng)開(kāi)發(fā)

nagios主要功能是實(shí)現(xiàn)報(bào)警

yum環(huán)境搭建:

[root@localhost~]#mount/dev/cdrom/mnt/cdrom/

mount:blockdevice/dev/cdromiswrite-protected,mountingread-only

[root@localhost~]#vim/etc/yum.repos.d/rhel-debuginfo.repo

[rhel-server]

name=RedHatEnterpriseLinuxserver

baseurl=file:///mnt/cdrom/Server

enabled=1

gpgcheck=1

gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release

安裝步驟

安裝lamp環(huán)境

yuminstallmysqlmysql-develhttpdphpphp-gdphp-mbstring

測(cè)試lamp環(huán)境

創(chuàng)建一個(gè)組nagcmd

[root@localhostnagios-3.2.1]#groupaddnagcmd

創(chuàng)建一個(gè)賬號(hào)nagios

[root@localhostnagios-3.2.1]#useradd-mnagios

加入組

[root@localhostnagios-3.2.1]#usermod-a-Gnagcmdnagios

將apache賬號(hào)也添加進(jìn)來(lái)

[root@localhostnagios-3.2.1]#usermod-a-Gnagcmdapache

解壓縮

cdnagios-cn-3.2.3

配置

./configure--with-command-group=nagcmd--enable-event-broker

或者

./configure--with-command-group=nagcmd--prefix=/usr/local/nagios--sysconfdir=/etc/nagios--enable-event-broker

root@localhostnagios-3.2.1]#makeall

[root@localhostnagios-3.2.1]#makeinstall

(-Thisinstallstheinitscriptin/etc/rc.d/init.d)

makeinstall-commandmode

-Thisinstallsandconfigurespermissionsonthe

directoryforholdingtheexternalcommandfile

makeinstall-config

-Thisinstallssampleconfigfilesin/usr/local/nagios/etc

進(jìn)入nagios目錄

cd/usr/local/nagios/

在http服務(wù)器的配置目錄(conf.d)下形成nagiosweb程序

cdnagios-cn-3.2.3

makeinstall-webconf

創(chuàng)建一個(gè)登陸nagiosweb程序的用戶這個(gè)賬號(hào)在以后通過(guò)web登陸nagios認(rèn)證時(shí)使用

htpasswd-c/usr/local/nagios/etc/htpasswd.usersnagiosadmin

啟動(dòng)apache

servicehttpdstartchkconfighttpdon

安裝nagios插件

./configure(perfix=/usr/local/nagios)--with-nagios-user=nagios--with-nagios-group=nagios

或者

./configure--with-nagios-user=nagios--with-nagios-group=nagios

make

makeinstall

將nagios服務(wù)加入chkconfig管理之類

chkconfig--addnagios

chkconfig--addnagios

檢查nagios的配置文件的語(yǔ)法是否正確

/usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios.cfg

可以將/usr/local/nagios/bin加入命令搜索路徑中

vim.bashrc

..bashrc重新讀取環(huán)境文件

可以將/usr/local/nagios/etc/nagios.cfg設(shè)置為一個(gè)連接

ln-s/usr/local/nagios/etc/nagios.cfg/etc/nagios.cfg

檢查語(yǔ)法

nagios-v/etc/nagios.cfg

啟動(dòng)nagios服務(wù)

啟動(dòng)httpd服務(wù)

編輯vim/usr/local/nagios/etc/nagios.cfg

注釋36行#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg

重啟nagios會(huì)報(bào)錯(cuò),原因,是無(wú)可監(jiān)控

打開(kāi)該文件中的其他主機(jī)比如windows

39cfg_file=/usr/local/nagios/etc/objects/windows.cfg

重啟服務(wù)

windows檢測(cè)客戶端配置

Snmp161

Nsclienrt12489check_nt

Nrpe5666

naclient改變里面的ns.ini

然后從其windows上的ncclient

在nagios服務(wù)器上,更改object下的window。dfg定義

重啟nagios服務(wù)

nagios監(jiān)控windows及l(fā)inux從而實(shí)現(xiàn)飛信報(bào)警

nagios監(jiān)控windows及l(fā)inux從而實(shí)現(xiàn)飛信報(bào)警

nagios監(jiān)控windows及l(fā)inux從而實(shí)現(xiàn)飛信報(bào)警

nagios監(jiān)控windows及l(fā)inux從而實(shí)現(xiàn)飛信報(bào)警

linux客戶段安裝

先創(chuàng)建賬號(hào)nagios

[root@localhost~]#yuminstallmysqlmysql-serverhttpdmysql-devel

[root@localhost~]#useraddnagios

安裝插件

./configure(perfix=/usr/local/nagios)--with-nagios-user=nagios--with-nagios-group=nagios

或者

./configure--with-nagios-user=nagios--with-nagios-group=nagios

make&&makeinstall

安裝nrpe(客戶端和服務(wù)端都需要)

#tar-zxvfnrpe-2.12.tar.gz

#cdnrpe-2.12.tar.gz

#./configure--with-nrpe-user=nagios\

--with-nrpe-group=nagios\

--with-nagios-user=nagios\

--with-nagios-group=nagios\

--enable-command-args\

--enable-ssl

#makeall

#makeinstall-plugin

#makeinstall-daemon

#makeinstall-daemon-config

編輯客戶端nrpe配置文件

vim/usr/local/nagios/etc/nrpe.cfg

(allowed_hosts=192.168.101.102(服務(wù)器地址))

以進(jìn)程的方式啟動(dòng)nrpe

/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe.cfg-d

nrpe服務(wù)器段

1.#./configure--with-nrpe-user=nagios\

--with-nrpe-group=nagios\

--with-nagios-user=nagios\

--with-nagios-group=nagios\

--enable-command-args\

--enable-ssl

#makeall

#makeinstall-plugin

2.commands.cfg定義外部構(gòu)件nrpe

vim/usr/local/nagios/etc/objects/commands.cfg

增加

definecommand{

command_namecheck_nrpe

command_line$USER1$/check_nrpe-H$HOSTADDRESS$-c$ARG1$

}

3.為了監(jiān)控linux系統(tǒng)修改nagios.cfg

vim/usr/local/nagios/etc/nagios.cfg

添加一行

cfg_file=/usr/local/nagios/etc/objects/mylinux.cfg

4.在/usr/local/nagios/etc/objects創(chuàng)建mylinux.cfg

definehost{

uselinux-server;Inheritdefaultvaluesfromatemplate

host_namemylinux;Thenamewe'regivingtothishost

aliasmylinux;Alongernameassociatedwiththehost

address192.168.101.110;IPaddressofthehost

}

defineservice{

usegeneric-service

host_namemylinux

service_descriptioncheck-swap

check_commandcheck_nrpe!check_swap

}

defineservice{

usegeneric-service

host_namemylinux

service_descriptioncheck_load

check_commandcheck_nrpe!check_load

}

defineservice{

usegeneric-service

host_namemylinux

service_descriptioncheck-disk

check_commandcheck_nrpe!check_had1

}

defineservice{

usegeneric-service

host_namemylinux

service_descriptioncheck_user

check_commandcheck_nrpe!check_users

}

defineservice{

usegeneric-service

host_namemylinux

service_descriptioncheck_procs

check_commandcheck_nrpe!check_total_procs

}

改變數(shù)組

chownnagios.nagiosmylinux.cfg

5實(shí)現(xiàn)飛信報(bào)警

腳本(附件下載)

a、將飛信的文檔傳入linux系統(tǒng),將庫(kù)文件放入/usr/lib目錄

chmoda+xfetion

b、使用下列命令測(cè)試./fetion--mobile=15136848083--pwd=lsx885--to15136848083--msg-type=0--msg-utf8$HOSTNAME

c.編輯vim/usr/local/nagios/etc/objects/contacts.cfg(這個(gè)文件可以不修改)

vim/usr/local/nagios/etc/objects/templates.cfg

34service_notification_commandsnotify-service-by-fetion;sendservicenotificationsviaemail

35host_notification_commandsnotify-service-by-fetion;sendhostnotificationsviaemail

d。定義命令

vim/usr/local/nagios/etc/objects/commands.cfg

definecommand{

command_namenotify-service-by-fetion

command_line/usr/bin/fetion--mobile=15136848083--pwd=lsx885--to15136848083--msg-type=0--msg-utf8$HOSTNAME

}

check_nrpe語(yǔ)法:

check_nrpe...-c<command>[-a<argument><argument><argument>]

check_nrpe的內(nèi)置命令:

·CheckAlwaysCRITICAL(check)

·CheckAlwaysOK(check)

·CheckAlwaysWARNING(check)

·CheckCPU(check)

·CheckCRITICAL(check)

·CheckCounter(check)

·CheckEventLog/CheckEventLog(check)

·CheckFile(check)

·CheckFileSize(check)

·CheckMem(check)

·CheckMultiple(check)

·CheckOK(check)

·CheckProcState(check)

·CheckServiceState(check)

·CheckTaskSched/CheckTaskSched(check)

·CheckUpTime(check)

·CheckVersion(check)

·CheckWARNING(check)

·CheckWMI/CheckWMI(check)

·CheckWMIValue(check)

用法如:

#check_nrpe...-cCheckCPU-awarn=80crit=90time=20mtime=10stime=4

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI