91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

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

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

自制python腳本監控Esxi底層DELL硬盤(利用python自帶模塊 paramiko)

發布時間:2020-08-20 18:46:35 來源:網絡 閱讀:247 作者:normanjin 欄目:系統運維

自制python腳本監控Esxi底層DELL硬盤(利用python自帶模塊 paramiko)
[root@localhost libexec]# cd /usr/local/nagios/libexec
[root@localhost libexec]# vi datadomain.py
#!/usr/bin/env python
import paramiko
import re
import sys
#0 ok; 1 warning; 2 critical; 3 unknown
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ip = "10.10.254.11"
user = "sysadmin"
passwd = "11111111111111"
ssh.connect(ip,22,user,passwd)
stdin,stdout,stderr = ssh.exec_command("disk status")
outmsg,errmsg = stdout.read(),stderr.read()
keyvalue=outmsg.find('7')
if int(keyvalue) <> -1:
print "Disk ok !"
sys.exit(0)
else:
print "Disk goes wrong!"
sys.exit(2)
ssh.close()
腳本注解:當keyvalue等于-1,說明數量沒有7,也就是硬盤有問題了。

先在commands.cfg中添加命令。
[root@localhost libexec]# vi /usr/local/nagios/etc/objects/commands.cfg
define command {
command_name datadomain
command_line sudo $USER1$/datadomain.py
}

在nagios.cfg中添加以下內容
[root@localhost libexec]# vi /usr/local/nagios/etc/nagios.cfg

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

定義主機和服務:在/usr/local/nagios/etc/objects中新建datadomain.cfg
[root@localhost libexec]# vi /usr/local/nagios/etc/objects/datadomain.cfg
define host{
use EMC DataDomain 2200
host_name EMC DataDomain 2200
alias EMC DataDomain 2200
address 10.10.254.11
}

define service{
use generic-service
host_name EMC DataDomain 2200
service_description EMC DataDomain 2200
check_command datadomain
notifications_enabled 1
}

然后必須在templates.cfg中添加以下內容
[root@localhost libexec]# vi /usr/local/nagios/etc/objects/templates.cfg

define host{
name EMC DataDomain 2200 ; The name of this host template
use generic-host ; This template inherits other values from the generic-host template
check_period 24x7 ; By default, EMC DataDomain 2200 hosts are checked round the clock
check_interval 5 ; Actively check the host every 10 minutes
retry_interval 1 ; Schedule host check retries at 10 minute intervals
max_check_attempts 10 ; Check each EMC DataDomain 2200 host 10 times (max)
check_command check-host-alive ; Default command to check EMC DataDomain 2200 hosts
notification_period workhours ; EMC DataDomain 2200 admins hate to be woken up, so we only notify during the day
; Note that the notification_period variable is being overridden from
; the value that is inherited from the generic-host template!
notification_interval 120 ; Resend notifications every 2 hours
notification_options d,u,r ; Only send notifications for specific host states
contact_groups admins ; Notifications get sent to the admins by default
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
}

添加sudo權限
[root@localhost libexec]# visudo
nagios ALL=(ALL) NOPASSWD:/usr/local/nagios/libexec/datadomain.py

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

贞丰县| 县级市| 汉源县| 邢台市| 通化县| 石狮市| 永昌县| 尚志市| 合肥市| 二手房| 紫金县| 常德市| 六安市| 绍兴市| 曲松县| 阳春市| 陈巴尔虎旗| 奇台县| 长乐市| 南开区| 安远县| 延川县| 灵石县| 阜宁县| 镇雄县| 宣武区| 凌海市| 宁国市| 巫山县| 扶风县| 揭阳市| 哈尔滨市| 钦州市| 临沧市| 木里| 萨嘎县| 镇安县| 双桥区| 彭泽县| 错那县| 清远市|