removed all Solr modules
This commit is contained in:
parent
3ae427459a
commit
358f84307c
@ -32,13 +32,6 @@ def check_mailcow_info(params, section):
|
||||
levels_num_domains = params["levels_num_domains"]
|
||||
levels_num_mailboxes = params["levels_num_mailboxes"]
|
||||
levels_num_global_messages = params["levels_num_global_messages"]
|
||||
levels_solr_size_kb = params["levels_solr_size"]
|
||||
# Levels for Solr size are given in MBytes, so convert it to bytes
|
||||
levels_solr_size_warn = levels_solr_size_kb[0] * 1024 * 1024
|
||||
levels_solr_size_crit = levels_solr_size_kb[1] * 1024 * 1024
|
||||
levels_solr_size = (levels_solr_size_warn, levels_solr_size_crit)
|
||||
levels_solr_documents = params["levels_solr_documents"]
|
||||
|
||||
version = section[key]["version"]
|
||||
git_version = section[key]["git_version"]
|
||||
check_version_enabled = section[key]["check_version_enabled"]
|
||||
@ -46,19 +39,19 @@ def check_mailcow_info(params, section):
|
||||
num_domains = section[key]["num_domains"]
|
||||
num_mailboxes = section[key]["num_mailboxes"]
|
||||
num_global_messages = section[key]["num_global_messages"]
|
||||
solr_enabled = section[key]["solr_enabled"]
|
||||
solr_size = section[key]["solr_size"]
|
||||
solr_documents = section[key]["solr_documents"]
|
||||
|
||||
# create graphs for number of domains, mailboxes and messages
|
||||
yield (Metric("mc_num_domains", num_domains, levels=levels_num_domains))
|
||||
yield(Metric("mc_num_mailboxes", num_mailboxes, levels=levels_num_mailboxes))
|
||||
yield(Metric("mc_num_global_messages", num_global_messages, levels=levels_num_global_messages))
|
||||
|
||||
# create graphs for solr size and number of solr documents
|
||||
if solr_enabled:
|
||||
yield(Metric("mc_solr_size", solr_size, levels=levels_solr_size))
|
||||
yield(Metric("mc_solr_documents", solr_documents, levels=levels_solr_documents))
|
||||
yield (
|
||||
Metric("mc_num_mailboxes", num_mailboxes, levels=levels_num_mailboxes)
|
||||
)
|
||||
yield (
|
||||
Metric(
|
||||
"mc_num_global_messages",
|
||||
num_global_messages,
|
||||
levels=levels_num_global_messages,
|
||||
)
|
||||
)
|
||||
|
||||
# create overall result
|
||||
if check_version_enabled:
|
||||
@ -71,7 +64,7 @@ def check_mailcow_info(params, section):
|
||||
else:
|
||||
summary = f"Version is {version}, Update check is disabled"
|
||||
state = State.OK
|
||||
details = f"Mailcow version: {version}\nNumber of domains: {num_domains}\nNumber of mailboxes: {num_mailboxes}\nNumber of messages: {num_global_messages}\n\nSolr size: {render.bytes(solr_size)}\nNumber of Solr documents: {solr_documents}"
|
||||
details = f"Mailcow version: {version}\nNumber of domains: {num_domains}\nNumber of mailboxes: {num_mailboxes}\nNumber of messages: {num_global_messages}"
|
||||
yield Result(state=state, summary=summary, details=details)
|
||||
|
||||
# Create result for number of domains
|
||||
@ -95,24 +88,6 @@ def check_mailcow_info(params, section):
|
||||
if state != State.OK:
|
||||
yield (Result(state=state, notice=notice))
|
||||
|
||||
# Create result for solr size and solr number of documents
|
||||
if solr_enabled:
|
||||
warn, crit = levels_solr_size
|
||||
state = getStateUpper((warn, crit), solr_size)
|
||||
notice = f"Solr size: {render.bytes(solr_size)}"
|
||||
if state != State.OK:
|
||||
yield(Result(state=state, notice=notice))
|
||||
|
||||
warn, crit = levels_solr_documents
|
||||
state = getStateUpper((warn, crit), solr_documents)
|
||||
notice = f"Number of Solr documents: {solr_documents}"
|
||||
if state != State.OK:
|
||||
yield(Result(state=state, notice=notice))
|
||||
else:
|
||||
state = State.WARN
|
||||
notice = f"Solr is disabled"
|
||||
yield(Result(state=state, notice=notice))
|
||||
|
||||
|
||||
def parse_mailcow_info_section(string_table):
|
||||
# pprint(string_table)
|
||||
@ -125,26 +100,13 @@ def parse_mailcow_info_section(string_table):
|
||||
num_domains = int(line[1])
|
||||
num_mailboxes = int(line[2])
|
||||
num_global_messages = int(line[3])
|
||||
solr_enabled = bool(line[4])
|
||||
# solr size comes with value and unit, unfortunately
|
||||
solr_size_str = line[5]
|
||||
solr_size_list = solr_size_str.split()
|
||||
solr_size_unit = solr_size_list[1]
|
||||
solr_size = float(solr_size_list[0])
|
||||
if solr_size_unit == "KB":
|
||||
solr_size = solr_size * 1024.0
|
||||
elif solr_size_unit == "MB":
|
||||
solr_size = solr_size * 1024.0 * 1024.0
|
||||
elif solr_size_unit == "GB":
|
||||
solr_size = solr_size * 1024.0 * 1024.0 * 1024.0
|
||||
solr_documents = int(line[6])
|
||||
git_version = line[7]
|
||||
update_available = line[8]
|
||||
git_version = line[4]
|
||||
update_available = line[5]
|
||||
if update_available == "True":
|
||||
update_available = True
|
||||
else:
|
||||
update_available = False
|
||||
check_version_enabled = line[9]
|
||||
check_version_enabled = line[6]
|
||||
if check_version_enabled == "True":
|
||||
check_version_enabled = True
|
||||
else:
|
||||
@ -153,9 +115,6 @@ def parse_mailcow_info_section(string_table):
|
||||
parsed_data["mailcow"]["num_domains"] = num_domains
|
||||
parsed_data["mailcow"]["num_mailboxes"] = num_mailboxes
|
||||
parsed_data["mailcow"]["num_global_messages"] = num_global_messages
|
||||
parsed_data["mailcow"]["solr_enabled"] = solr_enabled
|
||||
parsed_data["mailcow"]["solr_size"] = solr_size
|
||||
parsed_data["mailcow"]["solr_documents"] = solr_documents
|
||||
parsed_data["mailcow"]["git_version"] = git_version
|
||||
parsed_data["mailcow"]["update_available"] = update_available
|
||||
parsed_data["mailcow"]["check_version_enabled"] = check_version_enabled
|
||||
@ -178,8 +137,6 @@ register.check_plugin(
|
||||
"levels_num_domains": (100, 200),
|
||||
"levels_num_mailboxes": (500, 1000),
|
||||
"levels_num_global_messages": (100000, 250000),
|
||||
"levels_solr_size": (4096.0, 8192.0),
|
||||
"levels_solr_documents": (20000, 40000)
|
||||
},
|
||||
check_ruleset_name="mailcow_info",
|
||||
)
|
@ -11,11 +11,15 @@ from pprint import pprint
|
||||
from requests.structures import CaseInsensitiveDict
|
||||
from requests.auth import HTTPBasicAuth
|
||||
from time import (
|
||||
time, localtime, strftime,
|
||||
time,
|
||||
localtime,
|
||||
strftime,
|
||||
)
|
||||
|
||||
|
||||
def showUsage() -> None:
|
||||
sys.stderr.write("""CheckMK Mailcow Special Agent
|
||||
sys.stderr.write(
|
||||
"""CheckMK Mailcow Special Agent
|
||||
|
||||
USAGE: agent_nextcloud -H [hostname] -k [apikey]
|
||||
agent_nextcloud -h
|
||||
@ -28,7 +32,9 @@ OPTIONS:
|
||||
--no-https True|False If "True": Disable HTTPS, use HTTP (not recommended!)
|
||||
--no-cert-check True|False If "True": Disable TLS certificate check (not recommended!)
|
||||
-h, --help Show this help message and exit
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
# set this to True to produce debug output (this clutters the agent output)
|
||||
# be aware: activating this logs very sensitive information to debug files in ~/tmp
|
||||
@ -45,9 +51,15 @@ opt_check_version = False
|
||||
opt_no_https = False
|
||||
opt_no_cert_check = False
|
||||
|
||||
short_options = 'hH:k:P:'
|
||||
short_options = "hH:k:P:"
|
||||
long_options = [
|
||||
'hostname=', 'apikey=', 'port=', 'check-version=', 'no-https=', 'no-cert-check=', 'help'
|
||||
"hostname=",
|
||||
"apikey=",
|
||||
"port=",
|
||||
"check-version=",
|
||||
"no-https=",
|
||||
"no-cert-check=",
|
||||
"help",
|
||||
]
|
||||
|
||||
domain_data = {}
|
||||
@ -59,7 +71,7 @@ SEP = "|"
|
||||
TIMEFMT = "%Y-%m-%d %H:%M:%S"
|
||||
FLOATFMT = "{:.4f}"
|
||||
|
||||
'''
|
||||
"""
|
||||
Decorator function for debugging purposes
|
||||
creates a file with many information regarding the function call, like:
|
||||
timestamp
|
||||
@ -70,7 +82,9 @@ Decorator function for debugging purposes
|
||||
return value of function call
|
||||
type of return value
|
||||
all parameters given to function
|
||||
'''
|
||||
"""
|
||||
|
||||
|
||||
def debugLog(function):
|
||||
def wrapper(*args, **kwargs):
|
||||
# execute function and measure runtime
|
||||
@ -103,12 +117,15 @@ def debugLog(function):
|
||||
with open(debugLogFilename, "a+") as f:
|
||||
f.write(f"{out1}{out2}{out3}\n")
|
||||
except:
|
||||
sys.stderr.write(f"Something went wrong when writing to file {debugLogFilename}\n")
|
||||
sys.stderr.write(
|
||||
f"Something went wrong when writing to file {debugLogFilename}\n"
|
||||
)
|
||||
sys.exit(1)
|
||||
else:
|
||||
sys.stderr.write(f"Debug activated, but no debug filename given.\n")
|
||||
sys.exit(1)
|
||||
return value
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
@ -129,28 +146,28 @@ def getOptions() -> None:
|
||||
|
||||
opts, args = getopt.getopt(sys.argv[1:], short_options, long_options)
|
||||
for opt, arg in opts:
|
||||
if opt in ['-H', '--hostname']:
|
||||
if opt in ["-H", "--hostname"]:
|
||||
opt_hostname = arg
|
||||
elif opt in ['-k', '--apikey']:
|
||||
elif opt in ["-k", "--apikey"]:
|
||||
opt_apikey = arg
|
||||
elif opt in ['-P', '--port']:
|
||||
elif opt in ["-P", "--port"]:
|
||||
opt_port = arg
|
||||
elif opt in ['--check-version']:
|
||||
if arg == 'True':
|
||||
elif opt in ["--check-version"]:
|
||||
if arg == "True":
|
||||
opt_check_version = True
|
||||
else:
|
||||
opt_check_version = False
|
||||
elif opt in ['--no-https']:
|
||||
if arg == 'True':
|
||||
elif opt in ["--no-https"]:
|
||||
if arg == "True":
|
||||
opt_no_https = True
|
||||
else:
|
||||
opt_no_https = False
|
||||
elif opt in ['--no-cert-check']:
|
||||
if arg == 'True':
|
||||
elif opt in ["--no-cert-check"]:
|
||||
if arg == "True":
|
||||
opt_no_cert_check = True
|
||||
else:
|
||||
opt_no_cert_check = False
|
||||
elif opt in ['-h', '--help']:
|
||||
elif opt in ["-h", "--help"]:
|
||||
showUsage()
|
||||
sys.exit(0)
|
||||
if DEBUG:
|
||||
@ -158,7 +175,9 @@ def getOptions() -> None:
|
||||
tmp_path = f"{home_path}/tmp"
|
||||
help_file = f"{tmp_path}/mailcow_{opt_hostname}_debug.txt"
|
||||
with open(help_file, "a") as file:
|
||||
file.write(f"Number of Arguments: {len(sys.argv)}, Argument List: {str(sys.argv)}\n")
|
||||
file.write(
|
||||
f"Number of Arguments: {len(sys.argv)}, Argument List: {str(sys.argv)}\n"
|
||||
)
|
||||
|
||||
|
||||
# @debugLog
|
||||
@ -173,13 +192,16 @@ def showOptions() -> None:
|
||||
tmp_path = f"{home_path}/tmp"
|
||||
help_file = f"{tmp_path}/mailcow_{opt_hostname}_debug.txt"
|
||||
with open(help_file, "a") as file:
|
||||
file.write(f"Hostname: {opt_hostname}, Port: {opt_port}, No HTTPS: {opt_no_https}, No Cert Check: {opt_no_cert_check}\n")
|
||||
file.write(
|
||||
f"Hostname: {opt_hostname}, Port: {opt_port}, No HTTPS: {opt_no_https}, No Cert Check: {opt_no_cert_check}\n"
|
||||
)
|
||||
|
||||
|
||||
# @debugLog
|
||||
def getDomainInfo(headers: str, verify: bool, base_url: str) -> int:
|
||||
url = f"{base_url}/domain/all"
|
||||
response = requests.get(url, headers=headers, verify=verify)
|
||||
if (response.status_code == 200):
|
||||
if response.status_code == 200:
|
||||
jsdata = response.text
|
||||
data = json.loads(jsdata) # returns a list of dictionaries
|
||||
i = 0
|
||||
@ -214,7 +236,7 @@ def getDomainInfo(headers: str, verify: bool, base_url: str) -> int:
|
||||
"aliases_in_domain": aliases_in_domain,
|
||||
"msgs_total": msgs_total,
|
||||
"bytes_total": bytes_total,
|
||||
"max_quota_for_domain": max_quota_for_domain
|
||||
"max_quota_for_domain": max_quota_for_domain,
|
||||
}
|
||||
domain_data[domain_name] = {}
|
||||
domain_data[domain_name] = dom
|
||||
@ -222,14 +244,17 @@ def getDomainInfo(headers: str, verify: bool, base_url: str) -> int:
|
||||
# return number of email domains
|
||||
return i
|
||||
else:
|
||||
sys.stderr.write(f"Request response code is {response.status_code} with URL {url}\n")
|
||||
sys.stderr.write(
|
||||
f"Request response code is {response.status_code} with URL {url}\n"
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
# @debugLog
|
||||
def getMailboxInfo(headers: str, verify: bool, base_url: str) -> tuple:
|
||||
url = f"{base_url}/mailbox/all"
|
||||
response = requests.get(url, headers=headers, verify=verify)
|
||||
if (response.status_code == 200):
|
||||
if response.status_code == 200:
|
||||
jsdata = response.text
|
||||
data = json.loads(jsdata) # returns a list of dictionaries
|
||||
i = 0
|
||||
@ -269,7 +294,7 @@ def getMailboxInfo(headers: str, verify: bool, base_url: str) -> tuple:
|
||||
"messages": messages,
|
||||
"last_imap_login": last_imap_login,
|
||||
"last_pop3_login": last_pop3_login,
|
||||
"last_smtp_login": last_smtp_login
|
||||
"last_smtp_login": last_smtp_login,
|
||||
}
|
||||
mailbox_data[username] = {}
|
||||
mailbox_data[username] = mb
|
||||
@ -278,23 +303,29 @@ def getMailboxInfo(headers: str, verify: bool, base_url: str) -> tuple:
|
||||
# return number of mailboxes and global number of messages
|
||||
return i, global_num_messages
|
||||
else:
|
||||
sys.stderr.write(f"Request response code is {response.status_code} with URL {url}\n")
|
||||
sys.stderr.write(
|
||||
f"Request response code is {response.status_code} with URL {url}\n"
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def getGitVersion() -> str:
|
||||
url = "https://api.github.com/repos/mailcow/mailcow-dockerized/releases/latest"
|
||||
git_version = ""
|
||||
response = requests.get(url)
|
||||
if (response.status_code == 200):
|
||||
if response.status_code == 200:
|
||||
jsdata = response.text
|
||||
data = json.loads(jsdata) # returns a dictionary
|
||||
git_version = data["tag_name"]
|
||||
# print(git_version)
|
||||
else:
|
||||
sys.stderr.write(f"Request response code is {response.status_code} with URL {url}\n")
|
||||
sys.stderr.write(
|
||||
f"Request response code is {response.status_code} with URL {url}\n"
|
||||
)
|
||||
sys.exit(1)
|
||||
return git_version
|
||||
|
||||
|
||||
def compareVersions(mc_ver: str, git_ver: str) -> bool:
|
||||
update_available = False
|
||||
try:
|
||||
@ -332,12 +363,13 @@ def compareVersions(mc_ver: str, git_ver: str) -> bool:
|
||||
pass
|
||||
return update_available
|
||||
|
||||
|
||||
# @debugLog
|
||||
def getMailcowInfo(headers: str, verify: bool, base_url: str) -> dict:
|
||||
info_data = {}
|
||||
url = f"{base_url}/status/version"
|
||||
response = requests.get(url, headers=headers, verify=verify)
|
||||
if (response.status_code == 200):
|
||||
if response.status_code == 200:
|
||||
jsdata = response.text
|
||||
data = json.loads(jsdata) # returns a dictionary
|
||||
# pprint(data)
|
||||
@ -358,28 +390,13 @@ def getMailcowInfo(headers: str, verify: bool, base_url: str) -> dict:
|
||||
info_data["check_version_enabled"] = opt_check_version
|
||||
return info_data
|
||||
else:
|
||||
sys.stderr.write(f"Request response code is {response.status_code} with URL {url}\n")
|
||||
sys.exit(1)
|
||||
|
||||
#@debugLog
|
||||
def getSolrInfo(headers: str, verify: bool, base_url: str) -> tuple:
|
||||
url = f"{base_url}/status/solr"
|
||||
response = requests.get(url, headers=headers, verify=verify)
|
||||
if (response.status_code == 200):
|
||||
jsdata = response.text
|
||||
data = json.loads(jsdata) # returns a dictionary
|
||||
#pprint(data)
|
||||
# get Solr infos
|
||||
solr_enabled = data["solr_enabled"]
|
||||
solr_size = data["solr_size"]
|
||||
solr_documents = data["solr_documents"]
|
||||
return solr_enabled, solr_size, solr_documents
|
||||
else:
|
||||
sys.stderr.write(f"Request response code is {response.status_code} with URL {url}\n")
|
||||
sys.stderr.write(
|
||||
f"Request response code is {response.status_code} with URL {url}\n"
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
'''
|
||||
"""
|
||||
Output is as follows:
|
||||
0 mailbox name email address used for login
|
||||
1 active 1 --> active, 0 --> not active
|
||||
@ -398,7 +415,8 @@ Example:
|
||||
user1@dom1.de;1;2022-04-29 14:29:34;2022-04-29 14:29:34;Sarah;2433;2;21474836480;495481374;1692520168;0;1692281537
|
||||
user2@dom1.de;1;2022-04-29 14:38:33;2022-04-29 14:38:33;Tom;271;0;21474836480;25895752;1657394782;1692519758;1681065713
|
||||
user1@dom2.de;1;2022-04-30 09:55:37;2022-04-30 09:55:37;Melissa;53460;33;19964887040;6677677548;1692520066;0;1692510822
|
||||
'''
|
||||
"""
|
||||
|
||||
|
||||
# @debugLog
|
||||
def doCmkOutputMailboxes() -> None:
|
||||
@ -417,21 +435,30 @@ def doCmkOutputMailboxes() -> None:
|
||||
last_imap_login = mailbox_data[mb]["last_imap_login"]
|
||||
last_pop3_login = mailbox_data[mb]["last_pop3_login"]
|
||||
last_smtp_login = mailbox_data[mb]["last_smtp_login"]
|
||||
print(f"{mb};{active};{created};{modified};{name};{num_messages};{percent_in_use};{quota};{quota_used};{last_imap_login};{last_pop3_login};{last_smtp_login}")
|
||||
print(
|
||||
f"{mb};{active};{created};{modified};{name};{num_messages};{percent_in_use};{quota};{quota_used};{last_imap_login};{last_pop3_login};{last_smtp_login}"
|
||||
)
|
||||
|
||||
|
||||
# @debugLog
|
||||
def doCmkOutputMailcow(version: str,
|
||||
num_domains: int, num_mailboxes: int, num_global_messages: int,
|
||||
solr_enabled: bool, solr_size: float, solr_documents: int,
|
||||
git_version: str, update_available: bool, check_version_enabled: bool
|
||||
def doCmkOutputMailcow(
|
||||
version: str,
|
||||
num_domains: int,
|
||||
num_mailboxes: int,
|
||||
num_global_messages: int,
|
||||
git_version: str,
|
||||
update_available: bool,
|
||||
check_version_enabled: bool,
|
||||
) -> None:
|
||||
print("<<<mailcow_info:sep(59)>>>")
|
||||
# strip semicolons, if present, since we use it as delimiter
|
||||
version = version.replace(";", "")
|
||||
print(f"{version};{num_domains};{num_mailboxes};{num_global_messages};{solr_enabled};{solr_size};{solr_documents};{git_version};{update_available};{check_version_enabled}")
|
||||
print(
|
||||
f"{version};{num_domains};{num_mailboxes};{num_global_messages};{git_version};{update_available};{check_version_enabled}"
|
||||
)
|
||||
|
||||
|
||||
'''
|
||||
"""
|
||||
Output is as follows:
|
||||
0 domain_name
|
||||
1 active 1 --> active, 0 --> not active
|
||||
@ -449,7 +476,8 @@ Example:
|
||||
dom1.de;1;2022-04-23 22:54:57;None;10;0;400;6;0;0;10737418240
|
||||
dom2.de;1;2022-04-29 13:38:42;2023-08-19 17:21:04;10;0;400;2;0;0;10737418240
|
||||
dom3.de;1;2022-04-29 13:36:08;2022-04-29 21:26:19;10;1;100;3;28132;12852485367;21474836480
|
||||
'''
|
||||
"""
|
||||
|
||||
|
||||
# @debugLog
|
||||
def doCmkOutputDomains() -> None:
|
||||
@ -465,7 +493,9 @@ def doCmkOutputDomains() -> None:
|
||||
msgs_total = domain_data[dom]["msgs_total"]
|
||||
bytes_total = domain_data[dom]["bytes_total"]
|
||||
max_quota_for_domain = domain_data[dom]["max_quota_for_domain"]
|
||||
print(f"{dom};{active};{created};{modified};{max_num_mboxes_for_domain};{mboxes_in_domain};{max_num_aliases_for_domain};{aliases_in_domain};{msgs_total};{bytes_total};{max_quota_for_domain}")
|
||||
print(
|
||||
f"{dom};{active};{created};{modified};{max_num_mboxes_for_domain};{mboxes_in_domain};{max_num_aliases_for_domain};{aliases_in_domain};{msgs_total};{bytes_total};{max_quota_for_domain}"
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
@ -473,39 +503,39 @@ def main():
|
||||
cmk.utils.password_store.replace_passwords()
|
||||
getOptions()
|
||||
# do some parameter checks
|
||||
if (opt_hostname == ""):
|
||||
if opt_hostname == "":
|
||||
sys.stderr.write(f"No hostname given.\n")
|
||||
showUsage()
|
||||
sys.exit(1)
|
||||
else:
|
||||
hostname = opt_hostname
|
||||
if (opt_apikey == ""):
|
||||
if opt_apikey == "":
|
||||
sys.stderr.write(f"No API key given.\n")
|
||||
showUsage()
|
||||
sys.exit(1)
|
||||
if (opt_no_cert_check):
|
||||
if opt_no_cert_check:
|
||||
# disable certificate warnings
|
||||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||
verify = False
|
||||
else:
|
||||
verify = True
|
||||
if (opt_port == ""):
|
||||
if (opt_no_https):
|
||||
if opt_port == "":
|
||||
if opt_no_https:
|
||||
protocol = "http"
|
||||
port = "80"
|
||||
else:
|
||||
protocol = "https"
|
||||
port = "443"
|
||||
else:
|
||||
if (opt_no_https):
|
||||
if opt_no_https:
|
||||
protocol = "http"
|
||||
else:
|
||||
protocol = "https"
|
||||
port = opt_port
|
||||
if (protocol == "http" and port == "443"):
|
||||
if protocol == "http" and port == "443":
|
||||
sys.stderr.write(f"Combining HTTP with port 443 is not supported.\n")
|
||||
sys.exit(1)
|
||||
if (protocol == "https" and port == "80"):
|
||||
if protocol == "https" and port == "80":
|
||||
sys.stderr.write(f"Combining HTTPS with port 80 is not supported.\n")
|
||||
sys.exit(1)
|
||||
headers = CaseInsensitiveDict()
|
||||
@ -519,14 +549,15 @@ def main():
|
||||
debugLogFilename = getDebugFilename(hostname)
|
||||
if DEBUG:
|
||||
showOptions()
|
||||
print(f"hostname: {hostname}, protocol: {protocol}, port: {port}, verify: {verify}")
|
||||
print(
|
||||
f"hostname: {hostname}, protocol: {protocol}, port: {port}, verify: {verify}"
|
||||
)
|
||||
base_url = f"{protocol}://{hostname}:{port}/{mc_api_base}"
|
||||
# get domain data
|
||||
num_domains = getDomainInfo(headers, verify, base_url)
|
||||
# get mailbox data
|
||||
num_mailboxes, num_global_messages = getMailboxInfo(headers, verify, base_url)
|
||||
# get global Mailcow info
|
||||
solr_enabled, solr_size, solr_documents = getSolrInfo(headers, verify, base_url)
|
||||
mailcow_info = getMailcowInfo(headers, verify, base_url)
|
||||
mailcow_version = mailcow_info["mc_version"]
|
||||
github_version = mailcow_info["git_version"]
|
||||
@ -535,10 +566,14 @@ def main():
|
||||
# create agent output
|
||||
doCmkOutputDomains()
|
||||
doCmkOutputMailboxes()
|
||||
doCmkOutputMailcow(mailcow_version,
|
||||
num_domains, num_mailboxes, num_global_messages,
|
||||
solr_enabled, solr_size, solr_documents,
|
||||
github_version, update_available, check_version_enabled
|
||||
doCmkOutputMailcow(
|
||||
mailcow_version,
|
||||
num_domains,
|
||||
num_mailboxes,
|
||||
num_global_messages,
|
||||
github_version,
|
||||
update_available,
|
||||
check_version_enabled,
|
||||
)
|
||||
|
||||
|
||||
|
@ -14,7 +14,5 @@ description:
|
||||
The check will raise WARN/CRIT if the number of domains is above the configurable levels.
|
||||
The check will raise WARN/CRIT if the number of mailboxes is above the configurable levels.
|
||||
The check will raise WARN/CRIT if the number of messages is above the configurable levels.
|
||||
The check will raise WARN/CRIT if the solr size is above the configurable levels.
|
||||
The check will raise WARN/CRIT if the number of solr documents is above the configurable levels.
|
||||
inventory:
|
||||
one service is created (with several details)
|
@ -1,12 +1,19 @@
|
||||
def agent_mailcow_arguments(params, hostname, ipaddress):
|
||||
return [
|
||||
"--hostname", params["hostname"],
|
||||
"--apikey", passwordstore_get_cmdline("%s", params["apikey"]),
|
||||
"--port", params["port"],
|
||||
"--check-version", params["check_version"],
|
||||
"--no-https", params["no_https"],
|
||||
"--no-cert-check", params["no_cert_check"],
|
||||
"--hostname",
|
||||
params["hostname"],
|
||||
"--apikey",
|
||||
passwordstore_get_cmdline("%s", params["apikey"]),
|
||||
"--port",
|
||||
params["port"],
|
||||
"--check-version",
|
||||
params["check_version"],
|
||||
"--no-https",
|
||||
params["no_https"],
|
||||
"--no-cert-check",
|
||||
params["no_cert_check"],
|
||||
ipaddress,
|
||||
]
|
||||
|
||||
special_agent_info['mailcow'] = agent_mailcow_arguments
|
||||
|
||||
special_agent_info["mailcow"] = agent_mailcow_arguments
|
||||
|
@ -70,15 +70,3 @@ metric_info["mailcow_mailboxes_messages"] = {
|
||||
"unit": "count",
|
||||
"color": "24/b",
|
||||
}
|
||||
|
||||
metric_info["mc_solr_size"] = {
|
||||
"title": _("Solr Size"),
|
||||
"unit": "bytes",
|
||||
"color": "24/b",
|
||||
}
|
||||
|
||||
metric_info["mc_solr_documents"] = {
|
||||
"title": _("Number of Solr Documents"),
|
||||
"unit": "count",
|
||||
"color": "24/a",
|
||||
}
|
@ -1,17 +1,24 @@
|
||||
#!/usr/bin/env python3
|
||||
from cmk.gui.plugins.metrics import perfometer_info
|
||||
|
||||
perfometer_info.append({
|
||||
perfometer_info.append(
|
||||
{
|
||||
"type": "stacked",
|
||||
"perfometers": [
|
||||
{
|
||||
"type": "linear",
|
||||
"segments": ["mc_num_domains","mc_num_mailboxes","mc_num_global_messages"],
|
||||
"segments": [
|
||||
"mc_num_domains",
|
||||
"mc_num_mailboxes",
|
||||
"mc_num_global_messages",
|
||||
],
|
||||
},
|
||||
],
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
perfometer_info.append({
|
||||
perfometer_info.append(
|
||||
{
|
||||
"type": "stacked",
|
||||
"perfometers": [
|
||||
{
|
||||
@ -20,9 +27,11 @@ perfometer_info.append({
|
||||
"total": 100.0,
|
||||
},
|
||||
],
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
perfometer_info.append({
|
||||
perfometer_info.append(
|
||||
{
|
||||
"type": "stacked",
|
||||
"perfometers": [
|
||||
{
|
||||
@ -31,24 +40,5 @@ perfometer_info.append({
|
||||
"total": 100.0,
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
#perfometer_info.append({
|
||||
# "type": "stacked",
|
||||
# "perfometers": [
|
||||
# {
|
||||
# "type": "linear",
|
||||
# "segments": ["mc_num_mailboxes"],
|
||||
# },
|
||||
# ],
|
||||
#})
|
||||
|
||||
#perfometer_info.append({
|
||||
# "type": "stacked",
|
||||
# "perfometers": [
|
||||
# {
|
||||
# "type": "linear",
|
||||
# "segments": ["mc_num_global_messages"],
|
||||
# },
|
||||
# ],
|
||||
#})
|
||||
}
|
||||
)
|
||||
|
@ -2,7 +2,7 @@ from cmk.gui.i18n import _
|
||||
from cmk.gui.plugins.wato import (
|
||||
CheckParameterRulespecWithoutItem,
|
||||
rulespec_registry,
|
||||
RulespecGroupCheckParametersApplications
|
||||
RulespecGroupCheckParametersApplications,
|
||||
)
|
||||
|
||||
from cmk.gui.valuespec import (
|
||||
@ -14,10 +14,13 @@ from cmk.gui.valuespec import (
|
||||
Float,
|
||||
)
|
||||
|
||||
|
||||
def _parameter_spec_mailcow_info():
|
||||
return Dictionary(
|
||||
elements=[
|
||||
("levels_num_domains", Tuple(
|
||||
(
|
||||
"levels_num_domains",
|
||||
Tuple(
|
||||
title=_("Number of email domains"),
|
||||
elements=[
|
||||
Integer(
|
||||
@ -29,10 +32,13 @@ def _parameter_spec_mailcow_info():
|
||||
title=_("Critical at"),
|
||||
size=32,
|
||||
default_value=200,
|
||||
)
|
||||
),
|
||||
],
|
||||
)),
|
||||
("levels_num_mailboxes", Tuple(
|
||||
),
|
||||
),
|
||||
(
|
||||
"levels_num_mailboxes",
|
||||
Tuple(
|
||||
title=_("Number of mailboxes"),
|
||||
elements=[
|
||||
Integer(
|
||||
@ -44,10 +50,13 @@ def _parameter_spec_mailcow_info():
|
||||
title=_("Critical at"),
|
||||
size=32,
|
||||
default_value=1000,
|
||||
)
|
||||
),
|
||||
],
|
||||
)),
|
||||
("levels_num_global_messages", Tuple(
|
||||
),
|
||||
),
|
||||
(
|
||||
"levels_num_global_messages",
|
||||
Tuple(
|
||||
title=_("Number of messages"),
|
||||
elements=[
|
||||
Integer(
|
||||
@ -59,44 +68,14 @@ def _parameter_spec_mailcow_info():
|
||||
title=_("Critical at"),
|
||||
size=32,
|
||||
default_value=250000,
|
||||
)
|
||||
],
|
||||
)),
|
||||
("levels_solr_size", Tuple(
|
||||
title=_("Solr size"),
|
||||
elements=[
|
||||
Float(
|
||||
title=_("Warning at"),
|
||||
size=32,
|
||||
default_value=4096.0,
|
||||
unit="MBytes",
|
||||
),
|
||||
Float(
|
||||
title=_("Critical at"),
|
||||
size=32,
|
||||
default_value=8192.0,
|
||||
unit="MBytes",
|
||||
)
|
||||
],
|
||||
)),
|
||||
("levels_solr_documents", Tuple(
|
||||
title=_("Number of Solr documents"),
|
||||
elements=[
|
||||
Integer(
|
||||
title=_("Warning at"),
|
||||
size=32,
|
||||
default_value=20000,
|
||||
),
|
||||
Integer(
|
||||
title=_("Critical at"),
|
||||
size=32,
|
||||
default_value=40000,
|
||||
)
|
||||
],
|
||||
)),
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
rulespec_registry.register(
|
||||
CheckParameterRulespecWithoutItem(
|
||||
check_group_name="mailcow_info",
|
||||
|
@ -27,32 +27,68 @@ from cmk.gui.valuespec import (
|
||||
Integer,
|
||||
)
|
||||
|
||||
|
||||
def _valuespec_special_agent_mailcow():
|
||||
return Dictionary(
|
||||
title=_("Mailcow Server Information"),
|
||||
help=_("Checking Mailcow instances via API"),
|
||||
elements=[
|
||||
("hostname", TextAscii(title=_("Hostname"),
|
||||
(
|
||||
"hostname",
|
||||
TextAscii(
|
||||
title=_("Hostname"),
|
||||
size=32,
|
||||
allow_empty=False,
|
||||
help=_("Hostname of Mailcow server (bare FQDN or IP), mandatory"))),
|
||||
("apikey", IndividualOrStoredPassword(title=_("API Key"),
|
||||
help=_("Hostname of Mailcow server (bare FQDN or IP), mandatory"),
|
||||
),
|
||||
),
|
||||
(
|
||||
"apikey",
|
||||
IndividualOrStoredPassword(
|
||||
title=_("API Key"),
|
||||
size=32,
|
||||
allow_empty=False,
|
||||
help=_("API Key, mandatory"))),
|
||||
("port", TextAscii(title=_("Port"),
|
||||
help=_("API Key, mandatory"),
|
||||
),
|
||||
),
|
||||
(
|
||||
"port",
|
||||
TextAscii(
|
||||
title=_("Port"),
|
||||
allow_empty=True,
|
||||
help=_("Specify port if not listening to HTTPS/HTTP, optional"))),
|
||||
("check_version", Checkbox(title=_("Check version"),
|
||||
help=_("Checks the running version against the public Github repo"))),
|
||||
("no_https", Checkbox(title=_("Disable HTTPS"),
|
||||
help=_("Activate to disable TLS encryption (not recommended), optional"))),
|
||||
("no_cert_check", Checkbox(title=_("Disable certificate validation"),
|
||||
help=_("Activate to disable certificate validation (not recommended), optional"))),
|
||||
help=_("Specify port if not listening to HTTPS/HTTP, optional"),
|
||||
),
|
||||
),
|
||||
(
|
||||
"check_version",
|
||||
Checkbox(
|
||||
title=_("Check version"),
|
||||
help=_("Checks the running version against the public Github repo"),
|
||||
),
|
||||
),
|
||||
(
|
||||
"no_https",
|
||||
Checkbox(
|
||||
title=_("Disable HTTPS"),
|
||||
help=_(
|
||||
"Activate to disable TLS encryption (not recommended), optional"
|
||||
),
|
||||
),
|
||||
),
|
||||
(
|
||||
"no_cert_check",
|
||||
Checkbox(
|
||||
title=_("Disable certificate validation"),
|
||||
help=_(
|
||||
"Activate to disable certificate validation (not recommended), optional"
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
optional_keys=[],
|
||||
)
|
||||
|
||||
|
||||
rulespec_registry.register(
|
||||
HostRulespec(
|
||||
group=RulespecGroupDatasourceProgramsApps,
|
||||
|
BIN
mkp/Mailcow-1.3.0.mkp
Normal file
BIN
mkp/Mailcow-1.3.0.mkp
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user