Added NSX and SRM Checks
This commit is contained in:
parent
471f5cbdde
commit
50f7e378fe
BIN
Check_NSX-1.4.mkp
Normal file
BIN
Check_NSX-1.4.mkp
Normal file
Binary file not shown.
BIN
SRM-1.0.mkp
Normal file
BIN
SRM-1.0.mkp
Normal file
Binary file not shown.
1440
local/share/check_mk/agents/special/agent_nsx
Normal file
1440
local/share/check_mk/agents/special/agent_nsx
Normal file
File diff suppressed because it is too large
Load Diff
173
local/share/check_mk/agents/special/agent_srm
Normal file
173
local/share/check_mk/agents/special/agent_srm
Normal file
@ -0,0 +1,173 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- encoding: utf-8; py-indent-offset: 4 -*-
|
||||
# +------------------------------------------------------------------+
|
||||
# | ____ _ _ __ __ _ __ |
|
||||
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
|
||||
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
|
||||
# | | |___| | | | __/ (__| < | | | | . \ |
|
||||
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
|
||||
# | |
|
||||
# | Copyright Mathias Kettner 2018 mk@mathias-kettner.de |
|
||||
# +------------------------------------------------------------------+
|
||||
#
|
||||
# This file is part of Check_MK.
|
||||
# The official homepage is at http://mathias-kettner.de/check_mk.
|
||||
#
|
||||
# check_mk is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation in version 2. check_mk is distributed
|
||||
# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
|
||||
# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more de-
|
||||
# tails. You should have received a copy of the GNU General Public
|
||||
# License along with GNU Make; see the file COPYING. If not, write
|
||||
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
# Boston, MA 02110-1301 USA.
|
||||
|
||||
import re
|
||||
import sys, getopt
|
||||
import requests
|
||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning # pylint: disable=import-error
|
||||
from HTMLParser import HTMLParser
|
||||
|
||||
def usage():
|
||||
sys.stderr.write("""Check_MK VMWare SRM
|
||||
|
||||
USAGE: agent_srm [OPTIONS] HOST
|
||||
|
||||
OPTIONS:
|
||||
-h, --help Show this help message and exit
|
||||
--address Host address
|
||||
--no-cert-check Disable certificate check
|
||||
""")
|
||||
sys.exit(1)
|
||||
|
||||
short_options = "h"
|
||||
long_options = ["help", "address=", "demo", "no-cert-check"]
|
||||
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], short_options, long_options)
|
||||
except getopt.GetoptError, err:
|
||||
sys.stderr.write("%s\n" % err)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
opt_demo = False
|
||||
opt_cert = True
|
||||
args_dict = {}
|
||||
resources = []
|
||||
|
||||
for o,a in opts:
|
||||
if o in [ "--address" ]:
|
||||
args_dict["address"] = a
|
||||
elif o in [ "--demo" ]:
|
||||
opt_demo = True
|
||||
elif o in [ "--no-cert-check" ]:
|
||||
opt_cert = False
|
||||
elif o in [ "-h", "--help" ]:
|
||||
usage()
|
||||
|
||||
class HTMLTableParser(HTMLParser):
|
||||
def __init__(
|
||||
self,
|
||||
decode_html_entities=False,
|
||||
data_separator=' ',
|
||||
):
|
||||
|
||||
HTMLParser.__init__(self)
|
||||
|
||||
self._parse_html_entities = decode_html_entities
|
||||
self._data_separator = data_separator
|
||||
|
||||
self._in_td = False
|
||||
self._in_th = False
|
||||
self._current_table = []
|
||||
self._current_row = []
|
||||
self._current_cell = []
|
||||
self.tables = []
|
||||
|
||||
def handle_starttag(self, tag, attrs):
|
||||
if tag == 'td':
|
||||
self._in_td = True
|
||||
if tag == 'th':
|
||||
self._in_th = True
|
||||
|
||||
def handle_data(self, data):
|
||||
if self._in_td or self._in_th:
|
||||
self._current_cell.append(data.strip())
|
||||
|
||||
def handle_charref(self, name):
|
||||
|
||||
if self._parse_html_entities:
|
||||
self.handle_data(self.unescape('&#{};'.format(name)))
|
||||
|
||||
def handle_endtag(self, tag):
|
||||
if tag == 'td':
|
||||
self._in_td = False
|
||||
elif tag == 'th':
|
||||
self._in_th = False
|
||||
|
||||
if tag in ['td', 'th']:
|
||||
final_cell = self._data_separator.join(self._current_cell).strip()
|
||||
self._current_row.append(final_cell)
|
||||
self._current_cell = []
|
||||
elif tag == 'tr':
|
||||
self._current_table.append(self._current_row)
|
||||
self._current_row = []
|
||||
elif tag == 'table':
|
||||
self.tables.append(self._current_table)
|
||||
self._current_table = []
|
||||
|
||||
parser=HTMLTableParser()
|
||||
|
||||
def query(url):
|
||||
if opt_cert == False:
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning) # pylint: disable=no-member
|
||||
response = requests.get(url, verify=opt_cert)
|
||||
raw_html = response.text
|
||||
return raw_html
|
||||
output_lines = []
|
||||
def output(line):
|
||||
output_lines.append(line)
|
||||
|
||||
def query_srm():
|
||||
if opt_demo:
|
||||
return parser.feed(srm_status)
|
||||
url = "https://%(address)s:9086/" % args_dict
|
||||
return parser.feed(query(url))
|
||||
|
||||
def process_srm_info():
|
||||
output("<<<vcenter_srm:sep(9)>>>")
|
||||
query_srm()
|
||||
local_connection = parser.tables[0]
|
||||
remote_connection = parser.tables[1]
|
||||
i=2
|
||||
for row in local_connection:
|
||||
if str(row[0]) == "Service":
|
||||
output("LocalConnection %s\t%s\t%s" % (row[1],local_connection[i][1],local_connection[i+2][1]))
|
||||
i+=5
|
||||
|
||||
i=2
|
||||
for row in remote_connection:
|
||||
if str(row[0]) == "Service":
|
||||
output("RemoteConnection %s\t%s\t%s" % (row[1],local_connection[i][1],remote_connection[i+2][1]))
|
||||
i+=5
|
||||
|
||||
def main():
|
||||
try:
|
||||
process_srm_info()
|
||||
sys.stdout.write("\n".join(output_lines) + "\n")
|
||||
except Exception, e:
|
||||
sys.stderr.write("Connection error: %s" % e)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
srm_status = \
|
||||
"""
|
||||
<!DOCTYPE html>
|
||||
<html><head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=windows-1252"><style></style></head><body><h3>VMware vCenter Site Recovery Manager 6.5.1.6014840</h3><p>Name: <b>buc01m01vc01.test</b>, UUID: <b>d8fd8aea-a3ed-46e9-857e-509b80784c53</b>, Extension key: <b>com.vmware.vcDr</b></p><h4>VMware vCenter Server 6.5.0 build-7515524</h4><hr><p><a href="https://buc01m01srm01.test:9086/vcdr/vmomi/drserviceversions.xml">Supported VMODL versions</a></p><p><a href="https://buc01m01srm01.test:9086/vcdr/vmomi/drversion.xml">Inherent VMODL version</a></p><hr><h4>Local Connections</h4><table><tbody><tr><td>--------------------</td><td>--------------------------------------------------------------------------------</td></tr><tr><td>Service</td><td>com.vmware.cis.vcenterserver</td></tr><tr><td>URL</td><td>https://buc01m01vc01.test:443/sdk</td></tr><tr><td>Thumbprint</td><td>unknown</td></tr><tr><td>Status</td><td style="color:#080;">Connected</td></tr><tr><td>--------------------</td><td>--------------------------------------------------------------------------------</td></tr><tr><td>Service</td><td>com.vmware.cis.cs.inventory</td></tr><tr><td>URL</td><td>https://buc01m01vc01.test:443/invsvc/vmomi/sdk</td></tr><tr><td>Thumbprint</td><td>unknown</td></tr><tr><td>Status</td><td style="color:#080;">Connected</td></tr><tr><td>--------------------</td><td>--------------------------------------------------------------------------------</td></tr><tr><td>Service</td><td>com.vmware.cis.cs.lookup</td></tr><tr><td>URL</td><td>https://buc01psc01.test:443/lookupservice/sdk</td></tr><tr><td>Thumbprint</td><td>unknown</td></tr><tr><td>Status</td><td style="color:#080;">Connected</td></tr><tr><td>--------------------</td><td>--------------------------------------------------------------------------------</td></tr><tr><td>Service</td><td>com.vmware.cis.cs.identity</td></tr><tr><td>URL</td><td>https://buc01psc01.test/sso-adminserver/sdk/vsphere.local</td></tr><tr><td>Thumbprint</td><td>unknown</td></tr><tr><td>Status</td><td style="color:#080;">Connected</td></tr><tr><td>--------------------</td><td>--------------------------------------------------------------------------------</td></tr><tr><td>Service</td><td>com.vmware.cis.cs.authorization</td></tr><tr><td>URL</td><td>https://buc01m01vc01.test:443/invsvc/vmomi/sdk</td></tr><tr><td>Thumbprint</td><td>unknown</td></tr><tr><td>Status</td><td style="color:#080;">Connected</td></tr><tr><td>--------------------</td><td>--------------------------------------------------------------------------------</td></tr><tr><td>Service</td><td>com.vmware.cis.cs.license</td></tr><tr><td>URL</td><td>https://buc01psc01.test:443/ls/sdk</td></tr><tr><td>Thumbprint</td><td>unknown</td></tr><tr><td>Status</td><td style="color:#080;">Connected</td></tr><tr><td>--------------------</td><td>--------------------------------------------------------------------------------</td></tr></tbody></table><h4>Paired with remote SRM with name 'clj01m01vc01.test' and uuid 'acf7df22-01bb-439a-b27e-9f8b83e23233'</h4><h4>Remote Connections</h4><table><tbody><tr><td>--------------------</td><td>--------------------------------------------------------------------------------</td></tr><tr><td>Service</td><td>com.vmware.cis.vcenterserver</td></tr><tr><td>URL</td><td>https://clj01m01vc01.test:443/sdk</td></tr><tr><td>Thumbprint</td><td>unknown</td></tr><tr><td>Status</td><td style="color:#080;">Connected</td></tr><tr><td>--------------------</td><td>--------------------------------------------------------------------------------</td></tr><tr><td>Service</td><td>com.vmware.dr.vcDr</td></tr><tr><td>URL</td><td>https://clj01m01srm01.test:9086/vcdr/vmomi/sdk</td></tr><tr><td>Thumbprint</td><td>unknown</td></tr><tr><td>Status</td><td style="color:#080;">Connected</td></tr><tr><td>--------------------</td><td>--------------------------------------------------------------------------------</td></tr><tr><td>Service</td><td>com.vmware.cis.cs.lookup</td></tr><tr><td>URL</td><td>https://clj01psc01.test:443/lookupservice/sdk</td></tr><tr><td>Thumbprint</td><td>unknown</td></tr><tr><td>Status</td><td style="color:#080;">Connected</td></tr><tr><td>--------------------</td><td>--------------------------------------------------------------------------------</td></tr><tr><td>Service</td><td>com.vmware.cis.cs.identity</td></tr><tr><td>URL</td><td>https://clj01psc01.test/sso-adminserver/sdk/vsphere.local</td></tr><tr><td>Thumbprint</td><td>unknown</td></tr><tr><td>Status</td><td style="color:#080;">Connected</td></tr><tr><td>--------------------</td><td>--------------------------------------------------------------------------------</td></tr></tbody></table></body></html>"""
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
14
local/share/check_mk/checkman/nsx_backup
Normal file
14
local/share/check_mk/checkman/nsx_backup
Normal file
@ -0,0 +1,14 @@
|
||||
title: VMWare NSX: Backup time
|
||||
agents: agent_nsx
|
||||
catalog: Miscellaneous
|
||||
license: GPL
|
||||
distribution: check_mk
|
||||
description:
|
||||
This check monitors the date of last backup.
|
||||
item:
|
||||
Backup service.
|
||||
|
||||
perfdata:
|
||||
none
|
||||
inventory:
|
||||
One service called "NSX Backups".
|
15
local/share/check_mk/checkman/nsx_components
Normal file
15
local/share/check_mk/checkman/nsx_components
Normal file
@ -0,0 +1,15 @@
|
||||
title: VMWare NSX: Components status
|
||||
agents: agent_nsx
|
||||
catalog: Miscellaneous
|
||||
license: GPL
|
||||
distribution: check_mk
|
||||
description:
|
||||
This check monitors the status of VMWare NSX Components
|
||||
item:
|
||||
The item is composed from the Component Type.
|
||||
|
||||
perfdata:
|
||||
none
|
||||
inventory:
|
||||
All NSX Components defined will be inventorized.
|
||||
|
19
local/share/check_mk/checkman/nsx_controllers
Normal file
19
local/share/check_mk/checkman/nsx_controllers
Normal file
@ -0,0 +1,19 @@
|
||||
title: VMWare NSX: Controllers status
|
||||
agents: agent_nsx
|
||||
catalog: Miscellaneous
|
||||
license: GPL
|
||||
distribution: check_mk
|
||||
description:
|
||||
This check monitors the status of VMWare NSX Constrollers
|
||||
• Deploying - controller is being deployed and the procedure has not completed yet.
|
||||
• Removing - controller is being removed and the procedure has not completed yet.
|
||||
• Running - controller has been deployed and can respond to API invocation.
|
||||
• Unknown - controller has been deployed but fails to respond to API invocation.
|
||||
item:
|
||||
The item is composed from the Controller-id.
|
||||
|
||||
perfdata:
|
||||
none
|
||||
inventory:
|
||||
All NSX Controllers defined will be inventorized.
|
||||
|
15
local/share/check_mk/checkman/nsx_cpu
Normal file
15
local/share/check_mk/checkman/nsx_cpu
Normal file
@ -0,0 +1,15 @@
|
||||
title: VMWare NSX: CPU usage of NSX
|
||||
agents: agent_nsx
|
||||
catalog: Miscellaneous
|
||||
license: GPL
|
||||
distribution: check_mk
|
||||
description:
|
||||
This check monitors the CPU usage.
|
||||
item:
|
||||
Memory used
|
||||
|
||||
perfdata:
|
||||
One graph for CPU used in percentage
|
||||
inventory:
|
||||
One service called "CPU Utilization".
|
||||
|
15
local/share/check_mk/checkman/nsx_edges
Normal file
15
local/share/check_mk/checkman/nsx_edges
Normal file
@ -0,0 +1,15 @@
|
||||
title: VMWare NSX: Edges status
|
||||
agents: agent_nsx
|
||||
catalog: Miscellaneous
|
||||
license: GPL
|
||||
distribution: check_mk
|
||||
description:
|
||||
This check monitors the status of VMWare NSX Edges
|
||||
item:
|
||||
The item is composed from the edge-id.
|
||||
|
||||
perfdata:
|
||||
none
|
||||
inventory:
|
||||
All NSX edges defined will be inventorized.
|
||||
|
15
local/share/check_mk/checkman/nsx_mem
Normal file
15
local/share/check_mk/checkman/nsx_mem
Normal file
@ -0,0 +1,15 @@
|
||||
title: VMWare NSX: Memory usage of NSX
|
||||
agents: agent_nsx
|
||||
catalog: Miscellaneous
|
||||
license: GPL
|
||||
distribution: check_mk
|
||||
description:
|
||||
This check monitors the memory usage.
|
||||
item:
|
||||
Memory used
|
||||
|
||||
perfdata:
|
||||
Two graphs for memory used and all memory
|
||||
inventory:
|
||||
One service called "Memory Usage".
|
||||
|
14
local/share/check_mk/checkman/nsx_memory
Normal file
14
local/share/check_mk/checkman/nsx_memory
Normal file
@ -0,0 +1,14 @@
|
||||
title: VMWare NSX: Memory usage of NSX
|
||||
agents: agent_nsx
|
||||
catalog: Miscellaneous
|
||||
license: GPL
|
||||
distribution: check_mk
|
||||
description:
|
||||
This check monitors the memory usage.
|
||||
item:
|
||||
Memory used
|
||||
|
||||
perfdata:
|
||||
Two graphs for memory used and all memory
|
||||
inventory:
|
||||
One service called "Memory Usage".
|
15
local/share/check_mk/checkman/nsx_storage
Normal file
15
local/share/check_mk/checkman/nsx_storage
Normal file
@ -0,0 +1,15 @@
|
||||
title: VMWare NSX: Storage usage of NSX
|
||||
agents: agent_nsx
|
||||
catalog: Miscellaneous
|
||||
license: GPL
|
||||
distribution: check_mk
|
||||
description:
|
||||
This check monitors the storage usage.
|
||||
item:
|
||||
Memory used
|
||||
|
||||
perfdata:
|
||||
One graph for storage used in bytes, autoscaled
|
||||
inventory:
|
||||
One service called "Storage used".
|
||||
|
14
local/share/check_mk/checkman/nsx_vcenter_connection
Normal file
14
local/share/check_mk/checkman/nsx_vcenter_connection
Normal file
@ -0,0 +1,14 @@
|
||||
title: VMWare NSX: vCenter Connection
|
||||
agents: agent_nsx
|
||||
catalog: Miscellaneous
|
||||
license: GPL
|
||||
distribution: check_mk
|
||||
description:
|
||||
This check monitors the state of vCenter Connection.
|
||||
item:
|
||||
vCenter Connection
|
||||
|
||||
perfdata:
|
||||
none
|
||||
inventory:
|
||||
One service called "vCenter Connection".
|
41
local/share/check_mk/checks/agent_nsx
Normal file
41
local/share/check_mk/checks/agent_nsx
Normal file
@ -0,0 +1,41 @@
|
||||
#!/usr/bin/python
|
||||
# -*- encoding: utf-8; py-indent-offset: 4 -*-
|
||||
# +------------------------------------------------------------------+
|
||||
# | ____ _ _ __ __ _ __ |
|
||||
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
|
||||
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
|
||||
# | | |___| | | | __/ (__| < | | | | . \ |
|
||||
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
|
||||
# | |
|
||||
# | Copyright Mathias Kettner 2017 mk@mathias-kettner.de |
|
||||
# +------------------------------------------------------------------+
|
||||
#
|
||||
# This file is part of Check_MK.
|
||||
# The official homepage is at http://mathias-kettner.de/check_mk.
|
||||
#
|
||||
# check_mk is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation in version 2. check_mk is distributed
|
||||
# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
|
||||
# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more de-
|
||||
# tails. You should have received a copy of the GNU General Public
|
||||
# License along with GNU Make; see the file COPYING. If not, write
|
||||
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
# Boston, MA 02110-1301 USA.
|
||||
|
||||
def agent_nsx_arguments(params, hostname, ipaddress):
|
||||
args = ''
|
||||
args += "--address=%s " % hostname
|
||||
args += "--user=%s " % params["user"]
|
||||
args += "--password=%s " % params["password"]
|
||||
|
||||
if "nsx_resource" in params:
|
||||
for domain in params["nsx_resource"]:
|
||||
args += "--nsx_resource=%s " % domain
|
||||
if "cert" in params and params["cert"] == False:
|
||||
args += "--no-cert-check "
|
||||
return args
|
||||
|
||||
special_agent_info['nsx'] = agent_nsx_arguments
|
||||
|
36
local/share/check_mk/checks/agent_srm
Normal file
36
local/share/check_mk/checks/agent_srm
Normal file
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/python
|
||||
# -*- encoding: utf-8; py-indent-offset: 4 -*-
|
||||
# +------------------------------------------------------------------+
|
||||
# | ____ _ _ __ __ _ __ |
|
||||
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
|
||||
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
|
||||
# | | |___| | | | __/ (__| < | | | | . \ |
|
||||
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
|
||||
# | |
|
||||
# | Copyright Mathias Kettner 2017 mk@mathias-kettner.de |
|
||||
# +------------------------------------------------------------------+
|
||||
#
|
||||
# This file is part of Check_MK.
|
||||
# The official homepage is at http://mathias-kettner.de/check_mk.
|
||||
#
|
||||
# check_mk is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation in version 2. check_mk is distributed
|
||||
# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
|
||||
# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more de-
|
||||
# tails. You should have received a copy of the GNU General Public
|
||||
# License along with GNU Make; see the file COPYING. If not, write
|
||||
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
# Boston, MA 02110-1301 USA.
|
||||
|
||||
def agent_srm_arguments(params, hostname, ipaddress):
|
||||
args = ''
|
||||
args += "--address=%s " % hostname
|
||||
|
||||
if "cert" in params and params["cert"] == False:
|
||||
args += "--no-cert-check "
|
||||
return args
|
||||
|
||||
special_agent_info['srm'] = agent_srm_arguments
|
||||
|
431
local/share/check_mk/checks/check_nsx
Normal file
431
local/share/check_mk/checks/check_nsx
Normal file
@ -0,0 +1,431 @@
|
||||
#!/usr/bin/python
|
||||
# -*- encoding: utf-8; py-indent-offset: 4 -*-
|
||||
# +------------------------------------------------------------------+
|
||||
# | ____ _ _ __ __ _ __ |
|
||||
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
|
||||
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
|
||||
# | | |___| | | | __/ (__| < | | | | . \ |
|
||||
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
|
||||
# | |
|
||||
# | Copyright Mathias Kettner 2018 mk@mathias-kettner.de |
|
||||
# +------------------------------------------------------------------+
|
||||
#
|
||||
# This file is part of Check_MK.
|
||||
# The official homepage is at http://mathias-kettner.de/check_mk.
|
||||
#
|
||||
# check_mk is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation in version 2. check_mk is distributed
|
||||
# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
|
||||
# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more de-
|
||||
# tails. You should have received a copy of the GNU General Public
|
||||
# License along with GNU Make; see the file COPYING. If not, write
|
||||
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
# Boston, MA 02110-1301 USA.
|
||||
|
||||
import datetime
|
||||
|
||||
def inventory_edges_status(info):
|
||||
for name, edgeid, edgestatus, edgestate, edgetype in info:
|
||||
yield ("Edge %s" % \
|
||||
(edgeid), {})
|
||||
|
||||
|
||||
def check_edges_status(item, params, info):
|
||||
for line in info:
|
||||
edge = "Edge" + " " + line[1]
|
||||
if edge==item:
|
||||
edgename = line[0]
|
||||
edgestatus = line[2]
|
||||
edgestate = line[3]
|
||||
edgetype = line[4]
|
||||
if edgetype == "distributedRouter":
|
||||
if edgestate != "active":
|
||||
return 2, "Edge %s state is %s and status %s" % (edgename, edgestate, edgestatus )
|
||||
elif edgestatus == "GREEN":
|
||||
return 0, "Edge %s state is %s and status %s" % (edgename, edgestate, edgestatus )
|
||||
elif edgestatus == "GREY":
|
||||
return 0, "Edge %s state is %s and status %s" % (edgename, edgestate, edgestatus )
|
||||
elif edgestatus == "YELLOW":
|
||||
return 1, "Edge %s state is %s and status %s" % (edgename, edgestate, edgestatus )
|
||||
elif edgestatus == "RED":
|
||||
return 2, "Edge %s state is %s and status %s" % (edgename, edgestate, edgestatus )
|
||||
return 3, "Edge %s state is %s and status %s" % (edgename, edgestate, edgestatus )
|
||||
else:
|
||||
if edgestatus == "GREEN":
|
||||
return 0, "Edge %s is %s" % (edgename, edgestatus)
|
||||
elif edgestatus == "YELLOW":
|
||||
return 1, "Edge %s is %s" % (edgename, edgestatus)
|
||||
elif edgestatus == "RED":
|
||||
return 2, "Edge %s is %s" % (edgename, edgestatus)
|
||||
return 3, "Edge %s is %s" % (edgename, edgestatus)
|
||||
|
||||
|
||||
check_info['nsx_edges'] = {
|
||||
'inventory_function' : inventory_edges_status,
|
||||
'check_function' : check_edges_status,
|
||||
'service_description' : '%s',
|
||||
'has_perfdata' : False,
|
||||
}
|
||||
|
||||
#.
|
||||
# .--Controller Status---------------------------------------------------.
|
||||
# | ____ _ _ _ |
|
||||
# | / ___|___ _ __ | |_ _ __ ___ | | | ___ _ __ |
|
||||
# | | | / _ \| '_ \| __| '__/ _ \| | |/ _ \ '__| |
|
||||
# | | |__| (_) | | | | |_| | | (_) | | | __/ | |
|
||||
# | \____\___/|_| |_|\__|_| \___/|_|_|\___|_| |
|
||||
# | |
|
||||
# | ____ _ _ |
|
||||
# | / ___|| |_ __ _| |_ _ _ ___ |
|
||||
# | \___ \| __/ _` | __| | | / __| |
|
||||
# | ___) | || (_| | |_| |_| \__ \ |
|
||||
# | |____/ \__\__,_|\__|\__,_|___/ |
|
||||
# | |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | |
|
||||
# '----------------------------------------------------------------------'
|
||||
|
||||
def inventory_controller_status(info):
|
||||
for name, id, status in info:
|
||||
yield ("Controller %s" % \
|
||||
(id), {})
|
||||
|
||||
|
||||
def check_controller_status(item, params, info):
|
||||
for line in info:
|
||||
controller = "Controller" + " " + line[1]
|
||||
if controller==item:
|
||||
controllername = line[0]
|
||||
controllerstatus = line[2]
|
||||
if controllerstatus == "RUNNING":
|
||||
return 0, "Controller %s is %s" % (controllername, controllerstatus)
|
||||
elif controllerstatus == "DEPLOYING":
|
||||
return 1, "Controller %s is %s" % (controllername, controllerstatus)
|
||||
elif controllerstatus == "REMOVING":
|
||||
return 1, "Controller %s is %s" % (controllername, controllerstatus)
|
||||
elif controllerstatus == "UNKNOWN":
|
||||
return 2, "Controller %s is %s" % (controllername, controllerstatus)
|
||||
|
||||
check_info['nsx_controller'] = {
|
||||
'inventory_function' : inventory_controller_status,
|
||||
'check_function' : check_controller_status,
|
||||
'service_description' : '%s',
|
||||
'has_perfdata' : False,
|
||||
}
|
||||
|
||||
|
||||
|
||||
#.
|
||||
# .--NSX Components------------------------------------------------------.
|
||||
# | _ _ ______ __ |
|
||||
# | | \ | / ___\ \/ / |
|
||||
# | | \| \___ \\ / |
|
||||
# | | |\ |___) / \ |
|
||||
# | |_| \_|____/_/\_\ |
|
||||
# | |
|
||||
# | ____ _ |
|
||||
# | / ___|___ _ __ ___ _ __ ___ _ __ ___ _ __ | |_ ___ |
|
||||
# | | | / _ \| '_ ` _ \| '_ \ / _ \| '_ \ / _ \ '_ \| __/ __| |
|
||||
# | | |__| (_) | | | | | | |_) | (_) | | | | __/ | | | |_\__ \ |
|
||||
# | \____\___/|_| |_| |_| .__/ \___/|_| |_|\___|_| |_|\__|___/ |
|
||||
# | |_| |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | |
|
||||
# '----------------------------------------------------------------------'
|
||||
def inventory_nsx_components(info):
|
||||
for name, id, status in info:
|
||||
yield ("Component %s" % \
|
||||
(id), {})
|
||||
|
||||
|
||||
def check_nsx_components(item, params, info):
|
||||
for line in info:
|
||||
component = "Component" + " " + line[1]
|
||||
if component==item:
|
||||
component_name = line[0]
|
||||
component_status = line[2]
|
||||
if component_status == "RUNNING":
|
||||
return 0, "Component %s is %s" % (component_name, component_status)
|
||||
else:
|
||||
return 2, "Component %s is %s" % (component_name, component_status)
|
||||
|
||||
check_info['nsx_components'] = {
|
||||
'inventory_function' : inventory_nsx_components,
|
||||
'check_function' : check_nsx_components,
|
||||
'service_description' : '%s',
|
||||
'has_perfdata' : False,
|
||||
}
|
||||
|
||||
#.
|
||||
# .--NSX Backup----------------------------------------------------------.
|
||||
# | _ _ ______ __ ____ _ |
|
||||
# | | \ | / ___\ \/ / | __ ) __ _ ___| | ___ _ _ __ |
|
||||
# | | \| \___ \\ / | _ \ / _` |/ __| |/ / | | | '_ \ |
|
||||
# | | |\ |___) / \ | |_) | (_| | (__| <| |_| | |_) | |
|
||||
# | |_| \_|____/_/\_\ |____/ \__,_|\___|_|\_\\__,_| .__/ |
|
||||
# | |_| |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | |
|
||||
# '----------------------------------------------------------------------'
|
||||
def inventory_nsx_backups(info):
|
||||
return [(None, {})]
|
||||
|
||||
|
||||
def check_nsx_backup(item, params, info):
|
||||
warn, crit = params
|
||||
if info:
|
||||
last_backup = sorted(info, key=lambda tup: tup[2])[-1]
|
||||
last_backup_size = last_backup[1]
|
||||
last_backup_time = datetime.datetime.fromtimestamp(float(last_backup[2])/1000)
|
||||
elapsed = datetime.datetime.now() - last_backup_time
|
||||
if elapsed >= datetime.timedelta(days=crit):
|
||||
return 2, "Last backup was taken more than %s days ago. Last backup date is %s " \
|
||||
% (crit, last_backup_time)
|
||||
elif elapsed >= datetime.timedelta(days=warn):
|
||||
return 1, "Last backup was taken more than %s days ago. Last backup date is %s " \
|
||||
% (warn, last_backup_time)
|
||||
else:
|
||||
return 0, "Date of last backup is %s" % last_backup_time
|
||||
else:
|
||||
return 3, "Backup not available"
|
||||
|
||||
check_info['nsx_backup'] = {
|
||||
'inventory_function' : inventory_nsx_backups,
|
||||
'check_function' : check_nsx_backup,
|
||||
'service_description' : 'NSX Backups',
|
||||
'has_perfdata' : False,
|
||||
'group' : "backups",
|
||||
}
|
||||
|
||||
#.
|
||||
# .--Memory--------------------------------------------------------------.
|
||||
# | __ __ |
|
||||
# | | \/ | ___ _ __ ___ ___ _ __ _ _ |
|
||||
# | | |\/| |/ _ \ '_ ` _ \ / _ \| '__| | | | |
|
||||
# | | | | | __/ | | | | | (_) | | | |_| | |
|
||||
# | |_| |_|\___|_| |_| |_|\___/|_| \__, | |
|
||||
# | |___/ |
|
||||
# +----------------------------------------------------------------------+
|
||||
nsx_memory_default_levels = ( 80.0, 90.0 )
|
||||
|
||||
def nsx_convert(info):
|
||||
data = {}
|
||||
for line in info:
|
||||
data[line[0]] = line[1:]
|
||||
return data
|
||||
|
||||
def inventory_nsx_mem(info):
|
||||
data = nsx_convert(info)
|
||||
return [(None, 'nsx_mem_default_levels')]
|
||||
|
||||
def check_nsx_mem(item, params, info):
|
||||
data = nsx_convert(info)
|
||||
warn, crit = params
|
||||
memory_usage = savefloat(data['UsedMemory'][0]) * 1024 * 1024
|
||||
memory_size = savefloat(data['TotalMem'][0]) * 1024 * 1024
|
||||
level = savefloat(data['UsedPercentage'][0])
|
||||
state = 0
|
||||
label = ''
|
||||
if level >= crit:
|
||||
state = 2
|
||||
label = " (Levels at %d%%/%d%%)" % (warn, crit)
|
||||
elif level >= warn:
|
||||
state = 1
|
||||
label = " (Levels at %d%%/%d%%)" % (warn, crit)
|
||||
message = "%d%%%s used - %s/%s" % \
|
||||
(level, label, get_bytes_human_readable(memory_usage), get_bytes_human_readable(memory_size))
|
||||
perf = [("mem_used", memory_usage, warn * memory_size / 100, crit * memory_size / 100, 0, memory_size),
|
||||
("mem_total", memory_size)]
|
||||
return(state, message, perf)
|
||||
|
||||
|
||||
check_info['nsx_memory'] = {
|
||||
"inventory_function" : inventory_nsx_mem,
|
||||
"check_function" : check_nsx_mem,
|
||||
"service_description" : "Memory used",
|
||||
"group" : "nsx_memory",
|
||||
"has_perfdata" : True,
|
||||
"default_levels_variable" : "nsx_mem_default_levels"
|
||||
}
|
||||
|
||||
#.
|
||||
# .--CPU-----------------------------------------------------------------.
|
||||
# | ____ ____ _ _ |
|
||||
# | / ___| _ \| | | | |
|
||||
# | | | | |_) | | | | |
|
||||
# | | |___| __/| |_| | |
|
||||
# | \____|_| \___/ |
|
||||
# | |
|
||||
# +----------------------------------------------------------------------+
|
||||
|
||||
nsx_host_cpu_default_levels = {}
|
||||
|
||||
def inventory_nsx_cpu(info):
|
||||
data = nsx_convert(info).keys()
|
||||
if 'usedPercentage' in data \
|
||||
and 'totalNoOfCPUs' in data\
|
||||
and 'capacity' in data:
|
||||
return [(None, {})]
|
||||
|
||||
def check_nsx_cpu(item, params, info):
|
||||
data = nsx_convert(info)
|
||||
|
||||
if "usedPercentage" not in data:
|
||||
return
|
||||
#Asuming that there are 1 thread per core and one core per socket
|
||||
#Asuming that capacity represents total capacity
|
||||
|
||||
num_cpu = int(data['totalNoOfCPUs'][0])
|
||||
total_capacity = int(data['capacity'][0])
|
||||
used_capacity = float(data['usedCapacity'][0])
|
||||
mhz_per_core = float(data['capacity'][0]) / num_cpu
|
||||
|
||||
|
||||
usage = used_capacity / total_capacity * 100
|
||||
per_core = num_cpu / 100.0
|
||||
|
||||
infotext = "%.1f%%" % usage
|
||||
|
||||
# Convert legacy parameters
|
||||
this_time = time.time()
|
||||
state, infotext, perfdata = check_cpu_util(usage, params).next()
|
||||
|
||||
infotext += ", %.2fGHz/%.2fGHz" % (used_capacity / 1000.0, total_capacity / 1000.0)
|
||||
infotext += ", %d sockets, %d cores/socket, %d threads" % (
|
||||
num_cpu, 1 , 1)
|
||||
return (state, infotext, perfdata)
|
||||
|
||||
|
||||
check_info['nsx_cpu'] = {
|
||||
"inventory_function" : inventory_nsx_cpu,
|
||||
"check_function" : check_nsx_cpu,
|
||||
"service_description" : "CPU utilization",
|
||||
"group" : "cpu_utilization_os",
|
||||
"has_perfdata" : True,
|
||||
"default_levels_variable" : "nsx_host_cpu_default_levels",
|
||||
"includes" : [ "cpu_util.include" ],
|
||||
}
|
||||
|
||||
#.
|
||||
# .--NSX vCenter Connection----------------------------------------------.
|
||||
# | _ _ ______ __ ____ _ |
|
||||
# | | \ | / ___\ \/ / __ __/ ___|___ _ __ | |_ ___ _ __ |
|
||||
# | | \| \___ \\ / \ \ / / | / _ \ '_ \| __/ _ \ '__| |
|
||||
# | | |\ |___) / \ \ V /| |__| __/ | | | || __/ | |
|
||||
# | |_| \_|____/_/\_\ \_/ \____\___|_| |_|\__\___|_| |
|
||||
# | |
|
||||
# | ____ _ _ |
|
||||
# | / ___|___ _ __ _ __ ___ ___| |_(_) ___ _ __ |
|
||||
# | | | / _ \| '_ \| '_ \ / _ \/ __| __| |/ _ \| '_ \ |
|
||||
# | | |__| (_) | | | | | | | __/ (__| |_| | (_) | | | | |
|
||||
# | \____\___/|_| |_|_| |_|\___|\___|\__|_|\___/|_| |_| |
|
||||
# | |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | |
|
||||
# '----------------------------------------------------------------------'
|
||||
def inventory_nsx_vcenter_connection(info):
|
||||
return [(None, {})]
|
||||
|
||||
|
||||
def check_nsx_vcenter_connection(item, params, info):
|
||||
if "true" in info[0]:
|
||||
return 0, "vCenterConnection is true"
|
||||
elif "false" in info[0]:
|
||||
return 2, "vCenterConnection is false"
|
||||
|
||||
check_info['nsx_vcenter_connection'] = {
|
||||
'inventory_function' : inventory_nsx_vcenter_connection,
|
||||
'check_function' : check_nsx_vcenter_connection,
|
||||
'service_description' : 'vCenter Connection',
|
||||
'has_perfdata' : False,
|
||||
}
|
||||
|
||||
|
||||
#.
|
||||
# .--NSX Storage Info----------------------------------------------------.
|
||||
# | _ _ ______ __ ____ _ |
|
||||
# | | \ | / ___\ \/ / / ___|| |_ ___ _ __ __ _ __ _ ___ |
|
||||
# | | \| \___ \\ / \___ \| __/ _ \| '__/ _` |/ _` |/ _ \ |
|
||||
# | | |\ |___) / \ ___) | || (_) | | | (_| | (_| | __/ |
|
||||
# | |_| \_|____/_/\_\ |____/ \__\___/|_| \__,_|\__, |\___| |
|
||||
# | |___/ |
|
||||
# | ___ __ |
|
||||
# | |_ _|_ __ / _| ___ |
|
||||
# | | || '_ \| |_ / _ \ |
|
||||
# | | || | | | _| (_) | |
|
||||
# | |___|_| |_|_| \___/ |
|
||||
# | |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | |
|
||||
# '----------------------------------------------------------------------'
|
||||
nsx_storage_default_levels = ( 70.0, 80.0 )
|
||||
|
||||
def inventory_nsx_storage(info):
|
||||
data = nsx_convert(info)
|
||||
return [(None, 'nsx_storage_default_levels')]
|
||||
|
||||
def check_nsx_storage(item, params, info):
|
||||
warn,crit = params
|
||||
data = nsx_convert(info)
|
||||
used_storage = float(re.sub('G','', data['UsedStorage'][0],count =1))
|
||||
total_storage = float(re.sub('G','', data['TotalStorage'][0],count =1))
|
||||
free_storage = float(re.sub('G','', data['FreeStorage'][0],count =1))
|
||||
used_percentage = float(re.sub('G','', data['UsedPercentage'][0],count =1))
|
||||
perf = [("storage_used", used_storage * 1024 * 1024 * 1024, \
|
||||
warn * total_storage * 1024 * 1024 * 1024 / 100 , \
|
||||
crit * total_storage * 1024 * 1024 * 1024 / 100 , 0, total_storage * 1024 * 1024 * 1024)]
|
||||
if used_percentage >= crit:
|
||||
return 2, "Storage used is %sGB out of %sGB" % (used_storage, total_storage) , perf
|
||||
elif used_percentage >= warn:
|
||||
return 1, "Storage used is %sGB out of %sGB" % (used_storage, total_storage) , perf
|
||||
else:
|
||||
return 0, "Storage used is %sGB out of %sGB" % (used_storage, total_storage) , perf
|
||||
|
||||
check_info['nsx_storage_info'] = {
|
||||
"inventory_function" : inventory_nsx_storage,
|
||||
"check_function" : check_nsx_storage,
|
||||
"service_description" : "Storage used",
|
||||
"group" : "nsx_storage",
|
||||
"has_perfdata" : True,
|
||||
"default_levels_variable" : "nsx_storage_default_levels",
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
####NSX_RESOURCES
|
||||
def inventory_nsx_resources(info):
|
||||
for domain_name, component, status in info:
|
||||
component_sn = component.split(".")[-1]
|
||||
yield ("%s %s" % \
|
||||
(domain_name, component_sn), {})
|
||||
|
||||
|
||||
def check_nsx_resources(item, params, info):
|
||||
for line in info:
|
||||
component = line[0] + " " + line[1].split(".")[-1]
|
||||
if component==item:
|
||||
domain_name = line[0]
|
||||
component_name = line[1].split(".")[-1]
|
||||
component_status = line[2]
|
||||
if component_name == "hostRebootRequired":
|
||||
if component_status == "false":
|
||||
return 0, "Host reboot is not required. "
|
||||
else:
|
||||
return 1, "Host needs a reboot"
|
||||
|
||||
if component_status == "GREEN":
|
||||
return 0, "Component %s is %s" % (component_name, component_status)
|
||||
elif component_status =="UNKNOWN":
|
||||
return 3, "Status is unknown"
|
||||
else:
|
||||
return 2, "Component %s is %s" % (component_name, component_status)
|
||||
|
||||
check_info['nsx_resources'] = {
|
||||
'inventory_function' : inventory_nsx_resources,
|
||||
'check_function' : check_nsx_resources,
|
||||
'service_description' : '%s',
|
||||
'has_perfdata' : False,
|
||||
}
|
59
local/share/check_mk/checks/check_srm
Normal file
59
local/share/check_mk/checks/check_srm
Normal file
@ -0,0 +1,59 @@
|
||||
#!/usr/bin/python
|
||||
# -*- encoding: utf-8; py-indent-offset: 4 -*-
|
||||
# +------------------------------------------------------------------+
|
||||
# | ____ _ _ __ __ _ __ |
|
||||
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
|
||||
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
|
||||
# | | |___| | | | __/ (__| < | | | | . \ |
|
||||
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
|
||||
# | |
|
||||
# | Copyright Mathias Kettner 2018 mk@mathias-kettner.de |
|
||||
# +------------------------------------------------------------------+
|
||||
#
|
||||
# This file is part of Check_MK.
|
||||
# The official homepage is at http://mathias-kettner.de/check_mk.
|
||||
#
|
||||
# check_mk is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation in version 2. check_mk is distributed
|
||||
# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
|
||||
# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more de-
|
||||
# tails. You should have received a copy of the GNU General Public
|
||||
# License along with GNU Make; see the file COPYING. If not, write
|
||||
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
# Boston, MA 02110-1301 USA.
|
||||
|
||||
#<<<vcenter_srm>>>
|
||||
#LocalConnection com.vmware.cis.vcenterserver https://buc01m01vc01.test:443/sdk Connected
|
||||
#LocalConnection com.vmware.cis.cs.inventory https://buc01m01vc01.test:443/invsvc/vmomi/sdk Connected
|
||||
#LocalConnection com.vmware.cis.cs.lookup https://buc01psc01.test:443/lookupservice/sdk Connected
|
||||
#LocalConnection com.vmware.cis.cs.identity https://buc01psc01.test/sso-adminserver/sdk/vsphere.local Connected
|
||||
#LocalConnection com.vmware.cis.cs.authorization https://buc01m01vc01.test:443/invsvc/vmomi/sdk Connected
|
||||
#LocalConnection com.vmware.cis.cs.license https://buc01psc01.test:443/ls/sdk Connected
|
||||
#RemoteConnection com.vmware.cis.vcenterserver https://buc01m01vc01.test:443/sdk Connected
|
||||
#RemoteConnection com.vmware.dr.vcDr https://buc01m01vc01.test:443/invsvc/vmomi/sdk Connected
|
||||
#RemoteConnection com.vmware.cis.cs.lookup https://buc01psc01.test:443/lookupservice/sdk Connected
|
||||
#RemoteConnection com.vmware.cis.cs.identity https://buc01psc01.test/sso-adminserver/sdk/vsphere.locaConnected
|
||||
|
||||
import datetime
|
||||
|
||||
def inventory_srm_status(info):
|
||||
for servicename, url, state in info:
|
||||
yield ("%s" % (servicename), {})
|
||||
|
||||
|
||||
def check_srm_status(item, params, info):
|
||||
for line in info:
|
||||
if line[0]==item:
|
||||
if line[2]=="Connected":
|
||||
return 0, "OK, %s is %s; %s" % (item,line[2],line[1])
|
||||
else:
|
||||
return 1, "CRIT, %s is %s; %s" % (item,line[2],line[1])
|
||||
|
||||
check_info['vcenter_srm'] = {
|
||||
'inventory_function' : inventory_srm_status,
|
||||
'check_function' : check_srm_status,
|
||||
'service_description' : '%s',
|
||||
'has_perfdata' : False,
|
||||
}
|
Loading…
Reference in New Issue
Block a user