2017-07-05 21 views
0

我有檢查的過程 進口子如何check_mk寫手動檢查

s = subprocess.check_output('tasklist', shell=True) 
if "cmd.exe" in s: 
    if "java.exe" not in str(s): 
     print "selenium server is not up" 
    if "FreeSSHDService.exe" not in str(s): 
     print "SSH is not up" 
    else: 
     print "Everything is awesome" 

我想加上check_mk儀表板檢查一個Python腳本,什麼都添加此檢查,其中的步驟我必須搭起這個腳本。

import subprocess 

s = subprocess.check_output('tasklist', shell=True) 
if "cmd.exe" in s: 
    if "java.exe" not in str(s): 
     return 2, "selenium server is not up") 
    if "FreeSSHDService.exe" not in str(s): 
     return 2, "SSH is not up" 
    else: 
     return 0, "Everything is awesome" 

回答

0

首先我假設你要檢查的節點是基於微軟Windows,在這種情況下,我不能幫你多少,因爲我的專業是關於UNIX和Linux操作系統。

web link將幫助您檢查您的基於Windows的節點,特別是paragrah 10. Extending the Windows agent

在Linux中,一旦安裝了check_mk_agent,根據您想進入check_mk膽量的深度有三種方法。在Windows中,我認爲有相同的方法。

  1. 作爲本地服務:您複製的Python代碼到local文件夾,無論它位於Windows和編輯check_mk.ini配置文件的[global]部分,使運行pypyc文件擴展名。

  2. 作爲MRPE檢查:你讓你的Python程序根據Nagios output check format打印輸出和編輯根據the notes in the paragraph 10.2check_ini配置文件的[mrpe]部分。作爲缺點,WARNING和CRITICAL值/範圍在check_ini文件中被固定 - 它們不能在WATO中更改。

  3. 作爲check_mk代理:您將您的python程序變成check_mk代理。我認爲這是最困難的方式,因爲每個check_mk代理必須在check_mk服務器中有一個對應的定義/聲明/清單文件,以便在WATO中使用並配置其參數。我從來沒有寫過一個,但如果你熱衷於,你應該閱讀this guidelines

此致敬意。