나기오스 nagios 정리

bin-20170422-14.tar.gz

etc-20170422-14.tar.gz

include-20170422-14.tar.gz

libexec-20170422-14.tar.gz

sbin-20170422-14.tar.gz

share-20170422-14.tar.gz

var-20170422-14.tar.gz

nagios.install.manual.docx

check_memory

nrpe.cfg

Slack push

commands.cfg 와 templates.cfg 수정.

commands.cfg

# notify host by slack-AS-Real

define command {

command_name notify-host-by-slack-AS-Real

command_line /home/nagios/nagios.alert.slack.as.real.sh “$HOSTSTATE$ : $HOSTNAME$ [$LONGDATETIME$] $HOSTADDRESS$ : $HOSTOUTPUT$”

# notify service by slack-AS-Real

define command {

command_name notify-service-by-slack-AS-Real

command_line /home/nagios/nagios.alert.slack.as.real.sh “$SERVICESTATE$ : $HOSTALIAS$ [$LONGDATETIME$] $SERVICEDESC$ : $SERVICEOUTPUT$”

templates.cfg

define contact{

name AS-Real-contact

service_notification_period 24×7

host_notification_period 24×7

service_notification_options w,u,c,r,f,s

host_notification_options d,u,r,f,s

service_notification_commands notify-service-by-email-AS-Real, notify-service-by-slack-AS-Real

host_notification_commands notify-host-by-email-AS-Real, notify-host-by-slack-AS-Real

register 0

중국에서는 슬랙이 안되므로 프록시 이용.

cat nagios.alert.slack.as.real.sh

#!/bin/bash

msg=”${1}”

.com 이 푸시 프록시 서버가 되며, 프록시 서버의

post.php 파일

$_channel=$_POST[“channel”];

$_msg=$_POST[“msg”];

$_msg=str_replace(‘ ‘,’_’,$_msg);

#echo $_channel.”-“.$_msg;

$data1 = shell_exec(“/home/apache/slack.push.sh ‘$_channel’ ‘$_msg'”);

/home/apache/slack.push.sh 파일

#!/bin/bash

channel=”${1}”

msg=”${2}”

msg=`echo $msg | sed “s/_/ /g”`

record_file=”/root/data/slack.01.txt”

/bin/date >> ${record_file}

/bin/echo ${1} >> ${record_file}

/bin/echo “——————————————-” >> ${record_file}

/bin/echo “” >> ${record_file}

result=`echo “${msg}” | grep PING`

if [ “${result}” == “” ]

Client – Linux

centos 7

Normal

/* Style Definitions */

table.MsoNormalTable

{mso-style-name:”표준 표”;

mso-tstyle-rowband-size:0;

mso-tstyle-colband-size:0;

mso-style-noshow:yes;

mso-style-priority:99;

mso-style-qformat:yes;

mso-style-parent:””;

mso-padding-alt:0cm 5.4pt 0cm 5.4pt;

mso-para-margin-top:0cm;

mso-para-margin-right:0cm;

mso-para-margin-bottom:10.0pt;

mso-para-margin-left:0cm;

text-align:justify;

text-justify:inter-ideograph;

line-height:115%;

mso-pagination:widow-orphan;

font-size:10.0pt;

font-family:”맑은 고딕”;

mso-ascii-font-family:”맑은 고딕”;

mso-ascii-theme-font:minor-latin;

mso-fareast-font-family:”맑은 고딕”;

mso-fareast-theme-font:minor-fareast;

mso-hansi-font-family:”맑은 고딕”;

mso-hansi-theme-font:minor-latin;

mso-font-kerning:1.0pt;}

useradd nagios

passwd nagios

rpm -Uvh

rpm -Uvh

rpm -Uvh

yum –enablerepo epel install -y nagios-plugins-all nrpe

Normal

/* Style Definitions */

table.MsoNormalTable

{mso-style-name:”표준 표”;

mso-tstyle-rowband-size:0;

mso-tstyle-colband-size:0;

mso-style-noshow:yes;

mso-style-priority:99;

mso-style-qformat:yes;

mso-style-parent:””;

mso-padding-alt:0cm 5.4pt 0cm 5.4pt;

mso-para-margin-top:0cm;

mso-para-margin-right:0cm;

mso-para-margin-bottom:10.0pt;

mso-para-margin-left:0cm;

text-align:justify;

text-justify:inter-ideograph;

line-height:115%;

mso-pagination:widow-orphan;

font-size:10.0pt;

font-family:”맑은 고딕”;

mso-ascii-font-family:”맑은 고딕”;

mso-ascii-theme-font:minor-latin;

mso-fareast-font-family:”맑은 고딕”;

mso-fareast-theme-font:minor-fareast;

mso-hansi-font-family:”맑은 고딕”;

mso-hansi-theme-font:minor-latin;

mso-font-kerning:1.0pt;}

check_memory

/etc/nagios/nrpe.cfg

allowed_hosts=

1.0.1.1,1.1.1.2

dont_blame_nrpe=1

Normal

/* Style Definitions */

table.MsoNormalTable

{mso-style-name:”표준 표”;

mso-tstyle-rowband-size:0;

mso-tstyle-colband-size:0;

mso-style-noshow:yes;

mso-style-priority:99;

mso-style-qformat:yes;

mso-style-parent:””;

mso-padding-alt:0cm 5.4pt 0cm 5.4pt;

mso-para-margin-top:0cm;

mso-para-margin-right:0cm;

mso-para-margin-bottom:10.0pt;

mso-para-margin-left:0cm;

text-align:justify;

text-justify:inter-ideograph;

line-height:115%;

mso-pagination:widow-orphan;

font-size:10.0pt;

font-family:”맑은 고딕”;

mso-ascii-font-family:”맑은 고딕”;

mso-ascii-theme-font:minor-latin;

mso-fareast-font-family:”맑은 고딕”;

mso-fareast-theme-font:minor-fareast;

mso-hansi-font-family:”맑은 고딕”;

mso-hansi-theme-font:minor-latin;

mso-font-kerning:1.0pt;}

iptables -N NRPE

iptables -I INPUT -s 0/0 -p tcp –dport 5666

-j NRPE

iptables -I NRPE -s 1.1.1.1 -j ACCEPT

iptables -A NRPE -s 0/0 -j DROP

/etc/init.d/iptables save

service nrpe start

chkconfig nrpe on

Client – Windows

아직 sms 발송은 못봄.

답글 남기기

이메일은 공개되지 않습니다. 필수 입력창은 * 로 표시되어 있습니다.