python CheckMK - 代理双面插件和CMK检查Symmetrix
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python CheckMK - 代理双面插件和CMK检查Symmetrix相关的知识,希望对你有一定的参考价值。
#!/usr/bin/python
from subprocess import Popen, PIPE
import os
def check_failed_disks(out):
output_list = out.strip().split()
if len(output_list) > 4:
#failed disks will be reported in the stdout
sym_id = output_list[3]
number_of_failed_disks = output_list[7]
report_line = "%s %s" % (sym_id, number_of_failed_disks)
return report_line
else:
sym_id = output_list[3]
report_line = "%s 0" % sym_id
return report_line
SID_l = ["2199", "1025", "1047", "1472", "1474", "1378", "1048", "2200", "2201", "2202"]
SID_Hannover = ["2202"]
SID_Leipzig = ["2201"]
SID_Usingen = ["2200"]
SID_Darmstadt = ["1378", "1048"]
SID_Local = ["2199", "1025", "1047", "1472", "1474"]
print '<<<Symmetrix_failedDisks>>>'
for SID in SID_l:
if SID in SID_Hannover:
os.environ['SYMCLI_CONNECT'] = "SYM_H"
elif SID in SID_Leipzig:
os.environ['SYMCLI_CONNECT'] = "SYM_L"
elif SID in SID_Usingen:
os.environ['SYMCLI_CONNECT'] = "SYM_U"
elif SID in SID_Darmstadt:
os.environ['SYMCLI_CONNECT'] = "SYM_DA"
else:
os.unsetenv("SYMCLI_CONNECT")
proc = Popen(['/usr/symapi/bin/symdisk', '-sid', SID, "list", "-failed"], stdout=PIPE, stderr=PIPE)
stdout, stderr = proc.communicate()
output_line = check_failed_disks(stdout)
print output_line
#!/usr/bin/python
import os
from subprocess import Popen, PIPE
symcfg = '/usr/symapi/bin/symcfg'
############################################################################################
# fk3bc01b04:/usr/lib/check_mk_agent/plugins # /usr/symapi/bin/symcfg -sid 2202 list
#
# # S Y M M E T R I X
#
# Mcode Cache Num Phys Num Symm
# SymmID Attachment Model Version Size (MB) Devices Devices
#
# 000292602202 Local VMAX-1 5876 86016 12 4410
#
#############################################################################################
def get_status_info(os_environ, SID):
if os_environ == "local":
os.unsetenv("SYMCLI_CONNECT")
else:
os.environ['SYMCLI_CONNECT'] = os_environ
proc = Popen([symcfg, '-sid', SID, 'list'], stdout=PIPE, stderr=PIPE)
stdout, stderr = proc.communicate()
return stdout, stderr
info_string = '<<<Symmetrix_Config_Status>>>'
print info_string
#HANNOVER
os_environ = "SYM_H"
SID_l = ["2202"]
for SID in SID_l:
out, err = get_status_info(os_environ, SID)
if not err:
err = "0"
print "Symmetrix ID :%s ErrorCode :%s" % (out.split()[23],err) #gefaehrlich, ob es immer 23. index ist?
#LEIPZIG
os_environ = "SYM_L"
SID_l = ["2201"]
for SID in SID_l:
out, err = get_status_info(os_environ, SID)
if not err:
err = "0"
print "Symmetrix ID :%s ErrorCode :%s" % (out.split()[23],err) #gefaehrlich, ob es immer 23. index ist?
#USINGEN
os_environ = "SYM_U"
SID_l = ["2200"]
for SID in SID_l:
out, err = get_status_info(os_environ, SID)
if not err:
err = "0"
print "Symmetrix ID :%s ErrorCode :%s" % (out.split()[23],err) #gefaehrlich, ob es immer 23. index ist?
#DARMSADT
os_environ = "SYM_DA"
SID_l = ["1378","1048"]
for SID in SID_l:
out, err = get_status_info(os_environ, SID)
if not err:
err = "0"
print "Symmetrix ID :%s ErrorCode :%s" % (out.split()[23],err) #gefaehrlich, ob es immer 23. index ist?
#Localhost
os_environ = "local"
SID_l = ["2199","1025","1047","1472","1474"]
for SID in SID_l:
out, err = get_status_info(os_environ, SID)
if not err:
err = "0"
print "Symmetrix ID :%s ErrorCode :%s" % (out.split()[23],err) #gefaehrlich, ob es immer 23. index ist?
#fk3bc01b04:/usr/lib/check_mk_agent/plugins # ./check_symmetrix_cfg_list
#<<<Symmetrix_Config_Status>>>
#Symmetrix ID :000292602202 ErrorCode :0
#Symmetrix ID :000292602201 ErrorCode :0
#Symmetrix ID :000292602200 ErrorCode :0
#Symmetrix ID :000298701378 ErrorCode :0
#Symmetrix ID :000294901048 ErrorCode :0
#Symmetrix ID :000292602199 ErrorCode :0
#Symmetrix ID :000294901025 ErrorCode :0
#Symmetrix ID :000294901047 ErrorCode :0
#Symmetrix ID :000298701472 ErrorCode :0
#Symmetrix ID :000298701474 ErrorCode :0
#!/usr/bin/python
def inventory_symmetrix_config(info):
# print info
inventory = []
for line in info:
host_id = line[2].replace(":","")
inventory.append((host_id,None))
return inventory
def check_symmetrix_config(item, params, info):
for token in info:
host_id = token[2].replace(":","")
if host_id == item:
if token[-1] == ":0":
return (0, "System %s returned no error messages" % host_id)
else:
return (1, "Error on System, pls check the cfg.")
check_info["Symmetrix_Config_Status"] = {
'check_function': check_symmetrix_config,
'inventory_function': inventory_symmetrix_config,
'service_description': 'Symmetrix Config Check %s',
}
以上是关于python CheckMK - 代理双面插件和CMK检查Symmetrix的主要内容,如果未能解决你的问题,请参考以下文章