Skip to content
Permalink
Browse files

Add new sections to special agent, remove duplicate code and move agent

to python 3

Change-Id: I9d632f115d2bc2a99b805534a670bc2b5ce943ed
  • Loading branch information
NikolasHagemann authored and jherbel committed Dec 23, 2019
1 parent 10c1d62 commit 10e8d6ee0c729302eb439182265c8e50bce71955
@@ -1,10 +1,8 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2019 tribe29 GmbH - License: GNU General Public License v2
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
# conditions defined in the file COPYING, which is part of this source code package.
"""Checkmk Special Agent Couchbase
"""

import sys

@@ -24,7 +24,6 @@
special_agents/agent_appdynamics.py
special_agents/agent_azure.py
special_agents/agent_bi.py
special_agents/agent_couchbase.py
special_agents/agent_ddn_s2a.py
special_agents/agent_emcvnx.py
special_agents/agent_fritzbox.py
@@ -62,6 +61,7 @@
utils
ec
special_agents/agent_aws.py
special_agents/agent_couchbase.py
special_agents/agent_elasticsearch.py
special_agents/agent_graylog.py
special_agents/agent_jenkins.py
@@ -1,10 +1,12 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2019 tribe29 GmbH - License: GNU General Public License v2
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
# conditions defined in the file COPYING, which is part of this source code package.
"""Checkmk Special Agent Couchbase
"""
Special agent for monitoring Couchbase servers with Checkmk
"""

import sys
import argparse
import logging
@@ -60,13 +62,40 @@
SECTION_KEYS_B_MEM = (
"mem_total",
"mem_free",
"ep_mem_high_wat",
"ep_mem_low_wat",
)

SECTION_KEYS_B_OPERATIONS = (
"ops",
"cmd_get",
"cmd_set",
"ep_num_ops_del_meta",
"ep_ops_create",
"ep_ops_update",
)

SECTION_KEYS_B_ITEMS = (
"curr_items_tot",
"ep_bg_fetched",
"ep_diskqueue_drain",
"ep_diskqueue_fill",
"disk_write_queue",
)

SECTION_KEYS_B_VBUCKET = (
"vb_active_resident_items_ratio",
"vb_active_eject",
"vb_active_itm_memory",
"vb_active_ops_create",
"vb_pending_num",
"vb_replica_num",
"vb_replica_itm_memory",
)

SECTION_KEYS_B_FRAGMENTATION = (
"couch_docs_fragmentation",
"couch_views_fragmentation",
)

SECTION_KEYS_B_CACHE = ("ep_cache_miss_rate",)
@@ -97,7 +126,11 @@

def parse_arguments(argv):
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("-v", "--verbose", action="count", help="Enable verbose logging.")
parser.add_argument("-v",
"--verbose",
default=0,
action="count",
help="Enable verbose logging.")
parser.add_argument("--debug", action="store_true", help="Raise python exceptions.")
parser.add_argument("--vcrtrace", action=vcrtrace(filter_headers=[('authorization', '****')]))
parser.add_argument("-t",
@@ -219,7 +252,7 @@ def sections_node(client):
}

output = []
for section_name, section_content in sections.iteritems():
for section_name, section_content in sections.items():
output.append('<<<%s>>>' % section_name)
output.extend(section_content)
return output
@@ -254,16 +287,27 @@ def sections_buckets(bucket_list):
"couchbase_buckets_cache:sep(0)": [
_get_dump(name, data, SECTION_KEYS_B_CACHE, _average) for name, data in bucket_list
],
"couchbase_buckets_vbuckets:sep(0)": [
_get_dump(name, data, SECTION_KEYS_B_VBUCKET, _average) for name, data in bucket_list
],
"couchbase_buckets_fragmentation:sep(0)": [
_get_dump(name, data, SECTION_KEYS_B_FRAGMENTATION, _average)
for name, data in bucket_list
],
"couchbase_buckets_items:sep(0)": [
_get_dump(name, data, SECTION_KEYS_B_ITEMS, _average) for name, data in bucket_list
],
}

output = []
for section_name, section_content in sections.iteritems():
for section_name, section_content in sections.items():
output.append('<<<%s>>>' % section_name)
output.extend(section_content)
return output


def main(argv=None):

if argv is None:
cmk.utils.password_store.replace_passwords()
argv = sys.argv[1:]
@@ -280,7 +324,6 @@ def main(argv=None):
raise
return 1

# haha!
bucket_list = list(fetch_bucket_data(client, args.buckets, args.debug))
output += sections_buckets(bucket_list)

@@ -23,6 +23,7 @@
# '--subscription', 'SUBSCRIPTION', '--client', 'CLIENT', '--tenant', 'TENANT', '--secret',
# 'SECRET'
# ],
'agent_couchbase': ['HOSTNAME'],
'agent_elasticsearch': ['HOSTNAME'],
'agent_graylog': ['HOSTNAME'],
'agent_jenkins': ['HOSTNAME'],

0 comments on commit 10e8d6e

Please sign in to comment.
You can’t perform that action at this time.