Module: check_mk
Branch: master
Commit: 113435629904a491a02ef0c4a26f418a41fadb67
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=113435629904a4…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Feb 4 14:18:07 2014 +0100
Internal code cleanup for inventory function
---
modules/check_mk.py | 144 ++++++++++++++++++++++++++-------------------------
1 file changed, 73 insertions(+), 71 deletions(-)
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 2d64184..6ea87b1 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -2633,6 +2633,70 @@ def quote_nagios_string(s):
# | Automatic service detection |
# '----------------------------------------------------------------------'
+def do_inventory(hostnames, checknames, only_new):
+
+ # For clusters add their nodes to the list
+ nodes = []
+ for h in hostnames:
+ nodes = nodes_of(h)
+ if nodes:
+ hostnames += nodes
+
+ # Then remove clusters and make list unique
+ hostnames = list(set([ h for h in hostnames if not is_cluster(h) ]))
+ hostnames.sort()
+
+ if opt_verbose:
+ if len(hostnames) > 0:
+ sys.stdout.write("Inventorizing %s.\n" % ", ".join(hostnames))
+ else:
+ sys.stdout.write("Inventorizing all hosts.\n")
+
+ if inventory_checks:
+ checknames = inventory_checks.split(",")
+
+ # remove existing checks, if option -I is used twice
+ if seen_I > 1:
+ if inventory_checks == None:
+ checknames = inventorable_checktypes("all")
+ if len(hostnames) > 0:
+ # Entries in hostnames that are either prefixed with @
+ # or are no valid hostnames are considered to be tags.
+ for host in hostnames:
+ remove_autochecks_of(host, checknames)
+ # If all nodes of a cluster are contained in the list, then
+ # also remove the autochecks of that cluster. Beware: a host
+ # can be part more multiple clusters
+ for clust in clusters_of(host):
+ missing = [] # collect nodes missing on the command line
+ for node in nodes_of(clust):
+ if node not in hostnames:
+ missing.append(node)
+
+ if len(missing) == 0:
+ if opt_verbose:
+ sys.stdout.write("All nodes of %s specified, dropping checks of %s, too.\n" % (clust, node))
+ remove_autochecks_of(clust, checknames)
+
+ else:
+ sys.stdout.write("Warning: %s is part of cluster %s, but you didn't specify %s as well.\nChecks on %s will be kept.\n" %
+ (host, clust, ",".join(missing), clust))
+
+ else:
+ for host in all_active_hosts() + all_active_clusters():
+ remove_autochecks_of(host, checknames)
+ reread_autochecks()
+
+ if inventory_checks == None:
+ do_snmp_scan(hostnames)
+ checknames = inventorable_checktypes("tcp")
+
+ for checkname in checknames:
+ make_inventory(checkname, hostnames, False)
+
+ do_cleanup_autochecks()
+
+
def inventorable_checktypes(what): # snmp, tcp, all
checknames = [ k for k in check_info.keys()
@@ -5689,7 +5753,7 @@ if __name__ == "__main__":
done = False
seen_I = 0
- inventory_checks = None
+ check_types = None
# Scan modifying options first (makes use independent of option order)
for o,a in opts:
if o in [ '-v', '--verbose' ]:
@@ -5725,7 +5789,7 @@ if __name__ == "__main__":
elif o == '-I':
seen_I += 1
elif o == "--checks":
- inventory_checks = a
+ check_types = a.split(",")
elif o == "--cmc-file":
opt_cmc_relfilename = a
@@ -5859,70 +5923,11 @@ if __name__ == "__main__":
raise
sys.exit(3)
+ # handle -I / -II
if not done and seen_I > 0:
-
hostnames = parse_hostname_list(args)
- # For clusters add their nodes to the list
- nodes = []
- for h in hostnames:
- nodes = nodes_of(h)
- if nodes:
- hostnames += nodes
-
- # Then remove clusters and make list unique
- hostnames = list(set([ h for h in hostnames if not is_cluster(h) ]))
- hostnames.sort()
-
- if opt_verbose:
- if len(hostnames) > 0:
- sys.stdout.write("Inventorizing %s.\n" % ", ".join(hostnames))
- else:
- sys.stdout.write("Inventorizing all hosts.\n")
-
- if inventory_checks:
- checknames = inventory_checks.split(",")
-
- # remove existing checks, if option -I is used twice
- if seen_I > 1:
- if inventory_checks == None:
- checknames = inventorable_checktypes("all")
- if len(hostnames) > 0:
- # Entries in hostnames that are either prefixed with @
- # or are no valid hostnames are considered to be tags.
- for host in hostnames:
- remove_autochecks_of(host, checknames)
- # If all nodes of a cluster are contained in the list, then
- # also remove the autochecks of that cluster. Beware: a host
- # can be part more multiple clusters
- for clust in clusters_of(host):
- missing = [] # collect nodes missing on the command line
- for node in nodes_of(clust):
- if node not in hostnames:
- missing.append(node)
-
- if len(missing) == 0:
- if opt_verbose:
- sys.stdout.write("All nodes of %s specified, dropping checks of %s, too.\n" % (clust, node))
- remove_autochecks_of(clust, checknames)
-
- else:
- sys.stdout.write("Warning: %s is part of cluster %s, but you didn't specify %s as well.\nChecks on %s will be kept.\n" %
- (host, clust, ",".join(missing), clust))
-
- else:
- for host in all_active_hosts() + all_active_clusters():
- remove_autochecks_of(host, checknames)
- reread_autochecks()
-
- if inventory_checks == None:
- do_snmp_scan(hostnames)
- checknames = inventorable_checktypes("tcp")
-
- for checkname in checknames:
- make_inventory(checkname, hostnames, False)
-
- do_cleanup_autochecks()
-
+ do_inventory(hostnames, check_types, seen_I == 1)
+ done = True
if done:
output_profile()
@@ -5930,10 +5935,13 @@ if __name__ == "__main__":
elif (len(args) == 0 and not opt_keepalive) or len(args) > 2:
usage()
sys.exit(1)
+
+ # handle --keepalive
elif opt_keepalive:
do_check_keepalive()
- else:
+ # handle adhoc-check
+ else:
hostname = args[0]
if len(args) == 2:
ipaddress = args[1]
@@ -5947,11 +5955,5 @@ if __name__ == "__main__":
print "Cannot resolve hostname '%s'." % hostname
sys.exit(2)
- # honor --checks= also when checking (makes testing easier)
- if inventory_checks:
- check_types = inventory_checks.split(",")
- else:
- check_types = None
-
do_check(hostname, ipaddress, check_types)
Module: check_mk
Branch: master
Commit: 25a3ca9632feced097917c3632ccd32fcc493582
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=25a3ca9632fece…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Feb 4 14:06:26 2014 +0100
FIX postgres_sessions: fix empty agent section in case of 0 sessions
This fixes the problem that in some case when 0 sessions are active
the agent section is empty and the inventory will find the check
nomore.
---
.werks/689 | 11 +++++++++++
ChangeLog | 3 ++-
agents/plugins/mk_postgres | 3 +++
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/.werks/689 b/.werks/689
new file mode 100644
index 0000000..8d40dd2
--- /dev/null
+++ b/.werks/689
@@ -0,0 +1,11 @@
+Title: postgres_sessions: fix empty agent section in case of 0 sessions
+Level: 1
+Component: checks
+Class: fix
+State: unknown
+Version: 1.2.5i1
+Date: 1391505669
+
+This fixes the problem that in some case when 0 sessions are active
+the agent section is empty and the inventory will find the check
+nomore.
diff --git a/ChangeLog b/ChangeLog
index dff5b97..6345c5f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -153,8 +153,9 @@
* 0575 FIX: cmciii_lcp_airin, cmciii_lcp_airout, cmciii_lcp_waterin, cmciii_lcp_waterout: improved handling of warning state...
* 0272 FIX: if checks: port type 56 (fibrechannel) is no longer inventorized per default...
* 0577 FIX: fileinfo.groups: new date pattern is now available for inventory check as well
- * 0578 FIX: zypper: check is always registered as soon as mk_zypper plugin detects zypper tool...
* 0688 FIX: winperf_msx_queues: Support output of Exchange 2013...
+ * 0578 FIX: zypper: check is always registered as soon as mk_zypper plugin detects zypper tool...
+ * 0689 FIX: postgres_sessions: fix empty agent section in case of 0 sessions...
Multisite:
* 0371 Added log class filter to hostsvcevents view
diff --git a/agents/plugins/mk_postgres b/agents/plugins/mk_postgres
index 3d928db..dc92a20 100755
--- a/agents/plugins/mk_postgres
+++ b/agents/plugins/mk_postgres
@@ -17,6 +17,9 @@ do
su - $USER -c "psql --variable ON_ERROR_STOP=1 -d postgres -A -t -F' '" 2>/dev/null)" && break
done
echo "$OUTPUT"
+# line with number of idle sessions is sometimes missing on Postgre 8.x. This can lead
+# to an altogether empty section and thus the check disappearing.
+echo "$OUTPUT" | grep -q '^t ' || echo "t 0"
echo '<<<postgres_stat_database:sep(59)>>>'
echo 'select datid, datname, numbackends, xact_commit, xact_rollback, blks_read, blks_hit, tup_returned, tup_fetched, tup_inserted, tup_updated, tup_deleted, pg_database_size(datname) "datsize" from pg_stat_database;' \
Module: check_mk
Branch: master
Commit: 97f3ea3acca6c09831fe6e1e64a2e3351621449d
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=97f3ea3acca6c0…
Author: Bernd Stroessenreuther <bs(a)mathias-kettner.de>
Date: Mon Feb 3 14:59:25 2014 +0100
emcvnx_info: now reports information about Model an Revision correctly. It retrieves this information by an additional call of naviseccli with getagent option
---
agents/special/agent_emcvnx | 29 +++++++++++++++++++++++------
checkman/emcvnx_info | 8 ++++++++
web/plugins/wato/datasource_programs.py | 1 +
3 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/agents/special/agent_emcvnx b/agents/special/agent_emcvnx
index 887ba29..35e5e89 100755
--- a/agents/special/agent_emcvnx
+++ b/agents/special/agent_emcvnx
@@ -65,9 +65,9 @@ OPTIONS:
-i MODULES, --modules MODULES Modules to query. This is a comma separated list of
which may contain the keywords "disks", "hba", "hwstatus",
- "raidgroups" or "all" to define which information should
- be queried from the SP. You can define to use only view of
- them to optimize performance. The default is "all".
+ "raidgroups", "agent" or "all" to define which information
+ should be queried from the SP. You can define to use only
+ view of them to optimize performance. The default is "all".
""")
@@ -93,6 +93,7 @@ host_address = None
user = None
password = None
mortypes = [ 'all' ]
+fetch_agent_info = False
naviseccli_options = {
"disks" : {"cmd_option" : "-disk", "active" : False},
@@ -135,6 +136,7 @@ for module in naviseccli_options.keys():
try:
if mortypes.index("all") >= 0:
naviseccli_options[module]["active"] = True
+ fetch_agent_info = True
except ValueError:
pass
@@ -144,19 +146,24 @@ for module in naviseccli_options.keys():
except ValueError:
pass
+try:
+ if mortypes.index("agent") >= 0:
+ fetch_agent_info = True
+except ValueError:
+ pass
#############################################################################
# fetch information by calling naviseccli
#############################################################################
-basecmd="naviseccli -h %s -User %s -Password '%s' -Scope 0 getall " % (host_address, user, password)
+basecmd="naviseccli -h %s -User %s -Password '%s' -Scope 0 " % (host_address, user, password)
#
# check_mk section of agent output
#
print "<<<check_mk>>>"
-cmd=basecmd + "-sp"
+cmd=basecmd + "getall -sp"
if opt_debug:
sys.stderr.write("executing external command: %s\n" % cmd)
@@ -179,13 +186,23 @@ print "<<<emcvnx_info>>>"
for line in cmdout:
print line
+# if module "agent" was requested, fetch additional information about the
+# agent, e. g. Model and Revision
+if fetch_agent_info:
+ cmd=basecmd + "getagent"
+ if opt_debug:
+ sys.stderr.write("executing external command: %s\n" % cmd)
+
+ for line in os.popen(cmd).readlines():
+ print line,
+
#
# all other sections of agent output
#
for module in naviseccli_options.keys():
if naviseccli_options[module]["active"] == True:
print "<<<emcvnx_%s>>>" % module
- cmd=basecmd + naviseccli_options[module]["cmd_option"]
+ cmd=basecmd + "getall " + naviseccli_options[module]["cmd_option"]
if opt_debug:
sys.stderr.write("executing external command: %s\n" % cmd)
for line in os.popen(cmd).readlines():
diff --git a/checkman/emcvnx_info b/checkman/emcvnx_info
index d37855e..a85329c 100644
--- a/checkman/emcvnx_info
+++ b/checkman/emcvnx_info
@@ -12,5 +12,13 @@ description:
The information is retriefed by the special agent agent_emcvnx which uses
EMC's command line tool naviseccli.
+ The full information is only available if you did switch on the "Model and
+ Revsion" switch in the WATO rule "Check state of EMC VNX storage systems" or
+ did call the special agent (as datasource program) with --modules option
+ including "agent" module. If you are not interested in Model and Revision of
+ your Storage device you can switch this off and save one call of naviseccli in
+ every check interval. In this case the Check reports only the serial number
+ of the SP.
+
inventory:
Finds exactly one check on every EMC VNX storage system called EMC VNX Info
diff --git a/web/plugins/wato/datasource_programs.py b/web/plugins/wato/datasource_programs.py
index 60f39f5..9989cbc 100644
--- a/web/plugins/wato/datasource_programs.py
+++ b/web/plugins/wato/datasource_programs.py
@@ -193,6 +193,7 @@ register_rule(group,
( "hba", _("iSCSI HBAs") ),
( "hwstatus", _("Hardware Status") ),
( "raidgroups", _("RAID Groups") ),
+ ( "agent", _("Model and Revsion") ),
],
default_value = [ "disks", "hba", "hwstatus", ],
allow_empty = False,
Module: check_mk
Branch: master
Commit: 91fb977c212575e3e65b9a8108b1a1ad83855528
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=91fb977c212575…
Author: Bernd Stroessenreuther <bs(a)mathias-kettner.de>
Date: Mon Feb 3 13:51:01 2014 +0100
emcvnx_raidgroups: did fail on very first check with an index out of range exception
---
checks/emcvnx_raidgroups | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/checks/emcvnx_raidgroups b/checks/emcvnx_raidgroups
index dffb854..6b559a9 100644
--- a/checks/emcvnx_raidgroups
+++ b/checks/emcvnx_raidgroups
@@ -201,7 +201,9 @@ def check_emcvnx_raidgroups_capacity(item, params, info):
# variable name in perfdata is not allowed to be just a number
# especially 0 does not work, so prefix it generally with "rg"
rc, message, perfdata = df_check_filesystem_list(item, params, fslist)
- perfdata[0] = ("rg" + perfdata[0][0], perfdata[0][1], perfdata[0][2], perfdata[0][3], perfdata[0][4], perfdata[0][5])
+ # note: on very first run perfdata is empty
+ if len(perfdata) > 0:
+ perfdata[0] = ("rg" + perfdata[0][0], perfdata[0][1], perfdata[0][2], perfdata[0][3], perfdata[0][4], perfdata[0][5])
return rc, message, perfdata