Checks for Solr status added
This commit is contained in:
@@ -217,6 +217,23 @@ def getMailcowInfo(headers, verify, base_url):
|
||||
sys.stderr.write(f"Request response code is {response.status_code} with URL {url}\n")
|
||||
sys.exit(1)
|
||||
|
||||
def getSolrInfo(headers, verify, base_url):
|
||||
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.exit(1)
|
||||
|
||||
|
||||
'''
|
||||
Output is as follows:
|
||||
0 mailbox name email address used for login
|
||||
@@ -257,11 +274,11 @@ def doCmkOutputMailboxes():
|
||||
print(f"{mb};{active};{created};{modified};{name};{num_messages};{percent_in_use};{quota};{quota_used};{last_imap_login};{last_pop3_login};{last_smtp_login}")
|
||||
|
||||
|
||||
def doCmkOutputMailcow(version, num_domains, num_mailboxes, num_global_messages):
|
||||
def doCmkOutputMailcow(version, num_domains, num_mailboxes, num_global_messages, solr_enabled, solr_size, solr_documents):
|
||||
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}")
|
||||
print(f"{version};{num_domains};{num_mailboxes};{num_global_messages};{solr_enabled};{solr_size};{solr_documents}")
|
||||
|
||||
|
||||
'''
|
||||
@@ -355,11 +372,12 @@ def main():
|
||||
# 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_version = getMailcowInfo(headers, verify, base_url)
|
||||
# create agent output
|
||||
doCmkOutputDomains()
|
||||
doCmkOutputMailboxes()
|
||||
doCmkOutputMailcow(mailcow_version, num_domains, num_mailboxes, num_global_messages)
|
||||
doCmkOutputMailcow(mailcow_version, num_domains, num_mailboxes, num_global_messages, solr_enabled, solr_size, solr_documents)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -12,6 +12,8 @@ description:
|
||||
Shows several information about a Mailcow instance, e.g. number of domains/mailboxes/messages.
|
||||
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 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)
|
||||
@@ -69,4 +69,16 @@ metric_info["mailcow_mailboxes_messages"] = {
|
||||
"title": _("Number of 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",
|
||||
}
|
||||
@@ -56,6 +56,34 @@ def _parameter_spec_mailcow_info():
|
||||
)
|
||||
],
|
||||
)),
|
||||
("levels_solr_size", Tuple(
|
||||
title=_("Solr size"),
|
||||
elements=[
|
||||
Float(
|
||||
title=_("Warning at"),
|
||||
default_value=4096.0,
|
||||
unit="KBytes",
|
||||
),
|
||||
Float(
|
||||
title=_("Critical at"),
|
||||
default_value=8192.0,
|
||||
unit="KBytes",
|
||||
)
|
||||
],
|
||||
)),
|
||||
("levels_solr_documents", Tuple(
|
||||
title=_("Number of Solr documents"),
|
||||
elements=[
|
||||
Integer(
|
||||
title=_("Warning at"),
|
||||
default_value=2000,
|
||||
),
|
||||
Integer(
|
||||
title=_("Critical at"),
|
||||
default_value=4000,
|
||||
)
|
||||
],
|
||||
)),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -65,6 +93,6 @@ rulespec_registry.register(
|
||||
group=RulespecGroupCheckParametersApplications,
|
||||
match_type="dict",
|
||||
parameter_valuespec=_parameter_spec_mailcow_info,
|
||||
title=lambda: _("Mailcow Info"),
|
||||
title=lambda: _("Levels for Mailcow info"),
|
||||
)
|
||||
)
|
||||
Reference in New Issue
Block a user