如何部署Icinga客戶端

来源:http://www.cnblogs.com/ivictor/archive/2016/01/06/5106198.html
-Advertisement-
Play Games

Icinga客戶端的部署相對於伺服器端來說,簡單很多。對於伺服器端來說,如果要通過以下這種方式來監控伺服器,必須包含三個組件,Icinga內核,Icinga插件,NRPE(Nagios Remote Plugin Executor)。對於Icinga客戶端來說,只需要部署Icinga插件和NRPE。...


Icinga客戶端的部署相對於伺服器端來說,簡單很多。對於伺服器端來說,如果要通過以下這種方式來監控伺服器,必須包含三個組件,Icinga內核,Icinga插件,NRPE(Nagios Remote Plugin Executor)。對於Icinga客戶端來說,只需要部署Icinga插件和NRPE。

icinga 中文化項目的下載地址為:http://sourceforge.net/projects/icinga-cn/files/

其中,Icinga插件,NRPE均在icinga plugins目錄中。

在這裡,我下載了nagios-cn-plugins-2.0.3.tar.xz和icinga-nrpe-2.14.tar.gz。

 

新建icinga用戶

# useradd icinga -s /sbin/nologin

 

安裝nagios-cn-plugins

# cd /usr/src/

# tar xvf /root/nagios-cn-plugins-2.0.3.tar.xz 

# cd nagios-cn-plugins-2.0.3/

# ./configure --prefix=/usr/local/icinga

最後輸出如下:

config.status: creating po/Makefile
            --with-apt-get-command: 
              --with-ping6-command: /usr/sbin/ping6 -n -U -w %d -c %d %s
               --with-ping-command: /usr/bin/ping -n -U -w %d -c %d %s
               --with-package-name: nagios-plugins
               --with-nagios-user: 
               --with-nagios-group: 
                       --with-ipv6: yes
                      --with-mysql: no
                    --with-openssl: yes
                     --with-gnutls: no
               --enable-extra-opts: yes
                       --with-perl: /usr/bin/perl
             --enable-perl-modules: no
                     --with-cgiurl: /nagios/cgi-bin
               --with-trusted-path: /bin:/sbin:/usr/bin:/usr/sbin
                   --enable-libtap: no

# make

# make install

 

設置許可權

# chown -R icinga.icinga /usr/local/icinga/

 

安裝NRPE

# cd /usr/src/

# tar xvf /root/icinga-nrpe-2.14.tar.gz 

# cd icinga-nrpe-2.14/

# ./configure --enable-command-args

最後輸出如下:

*** Configuration summary for nrpe 2.14 12-21-2012 ***:

 General Options:
 -------------------------
 NRPE port:    5666
 NRPE user:    icinga
 NRPE group:   icinga
 Icinga user:  icinga
 Icinga group: icinga


Review the options above for accuracy.  If they look okay,
type 'make all' to compile the NRPE daemon and client.

按照提示,

# make all

輸出結果如下:

*** Compile finished ***

  make install
     - This installs files in /usr/local/icinga

  make install-plugin
     - This installs init-script files in /usr/local/icinga/libexec

  make install-init
     - This installs init-script files in /etc/init.d

  make install-xinetd
     - This installs sample-config/nrpe.xinetd in /etc/xinit.d

  make install-init-freebsd
     - This installs init-script.freebsd files in /etc/init.d

  make install-init-debian
     - This installs init-script.debian files in /etc/init.d

  make install-init-suse
     - This installs init-script.suse files in /etc/init.d

  make install-daemon-config
     - This installs the Nrpe config file in /usr/local/icinga/etc

If the NRPE daemon and client compiled without any errors, you
can continue with the installation or upgrade process.

Read the PDF documentation (NRPE.pdf) for information on the next
steps you should take to complete the installation or upgrade.

對於Linux系統,可運行make install, make install-plugin,make install-init,make install-xinetd, make install-daemon-config。各項的具體作用可參考上述的說明。

修改NRPE的配置文件

# vim /usr/local/icinga/etc/nrpe.cfg 

在allowed_hosts後面添加Icinga服務端的地址

allowed_hosts=127.0.0.1,192.168.244.145

 

啟動NRPE服務

# /etc/init.d/icinga-nrpe start

Starting icinga-nrpe (via systemctl):  Warning: Unit file of icinga-nrpe.service changed on disk, 'systemctl daemon-reload' recommended.
                                                           [  OK  ]

# systemctl daemon-reload

# /etc/init.d/icinga-nrpe start

查看5666埠是否開啟監聽

# netstat -ntlup | grep 5666

tcp        0      0 0.0.0.0:5666            0.0.0.0:*               LISTEN      26517/nrpe

 

在服務端上進行驗證

# /usr/local/icinga/libexec/check_nrpe -H 192.168.244.146

其中192.168.244.146是客戶端的地址

如果輸出的是NRPE的版本號:

NRPE v2.14

則代表服務端和客戶端已建立通信。

 

總結:

1. 如果在服務端上進行驗證時,報以下錯誤:

CHECK_NRPE: Error - Could not complete SSL handshake.

一般是NRPE的配置文件沒有修改,或防火牆規則阻止了Icinga服務端和NRPE進程之間的連接。

2. 系統賬號的shell使用 /sbin/nologin ,此時無法登陸系統,即使給了密碼也不行。

所謂“無法登陸”指的僅是這個用戶無法使用bash或其他shell來登陸系統而已,並不是說這個賬號就無法使用系統資源。舉例來說,各個系統賬號中,列印作業有lp這個賬號管理,www伺服器有apache這個賬號管理,他們都可以進行系統程式的工作,但就是無法登陸主機而已。有時候有些服務,比如郵件服務,大部分都是用來接收主機的郵件而已,並不需要登陸。假如有賬號試圖連接我的主機取得shell,我們就可以拒絕。另外,如果我想要讓某個具有 /sbin/nologin 的用戶知道,他們不能登陸主機時,可以新建 /etc/nologin.txt 這個文件,在文件內面寫上不能登陸的原因,當用戶登錄時,屏幕上就會出現這個文件裡面的內容。

 

參考:

http://docs.icinga.org/latest/en/nrpe.html

http://blog.chinaunix.net/uid-28216282-id-3373188.html

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • json序列化和反序列化幫助類:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Runtime.Serialization;using System.Runt...
  • // /// 遞歸獲取文件夾目錄下文件 /// /// 需要遞歸遍歷的文件夾 /// 遍歷規則『委托』 public static void LoopFolder(string pathName, Action fileRul...
  • 前臺: ...
  • 這裡的數據指的大概就是欄位(貌似這章有些東西也是過時了,因為現在的.NET已經發展了很久了,包括Java也是)1、自封裝欄位(其實就是屬性啦,過時了)修改點:直接訪問欄位,但是與欄位間的耦合關係逐漸變得笨拙做法:為這個欄位建立一個取值/設值函數,並且只以這些函數來訪問數據好吧,現在明白屬性是怎麼來的...
  • (此文章同時發表在本人微信公眾號“dotNET每日精華文章”,歡迎右邊二維碼來關註。) 題記:新年第一篇文章,就來談談關於時間的簡單技術問題:該用DateTime還是DateTimeOffset?該用Now還是UtcNow? 首先需要說明的是.NET中出現兩個保存時間的數據結構是由於歷史的原因。Da...
  • JavaScript中一個重要的概念就是閉包,閉包在JavaScript中有大量的應用,但是你知道麽?C#也可以創建Closure。下麵就介紹一下如何在C#中創建神奇的閉包。 在這之前,我們必須先知道如何在C#中定義函數1 //函數定義,參數為string,返回為string2 Func m...
  • -----------------------------U盤安裝windows7操作系統簡述。
  • @hcy 敬請訪問:http://blog.sina.com.cn/iihcyMicrosoft公司從1983年開始研製Windows系統,最初的研製目標是在MS-DOS的基礎上提供一個多任務的圖形用戶界面。第一個版本的Windows 1.0於1985年問世,它是一個具有圖形用戶界面的系統軟體。19...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...