Module: check_mk
Branch: master
Commit: ab3569bf19533445894ed0ec477dfe683c5da6a6
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ab3569bf195334…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sat Oct 24 15:34:16 2015 +0200
Minor code cleanup: one line for each import
---
modules/check_mk.py | 14 ++++++++++++--
modules/check_mk_base.py | 9 ++++++++-
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 9741829..5e3d0f8 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -31,8 +31,18 @@
# - cluster_name - Name of a cluster (string)
# - realhost_name - Name of a *real* host, not a cluster (string)
-import os, sys, socket, time, getopt, re, stat, py_compile, urllib, inspect
-import subprocess, fcntl
+import os
+import sys
+import time
+import socket
+import getopt
+import re
+import stat
+import urllib
+import subprocess
+import fcntl
+import py_compile
+import inspect
# These variable will be substituted at 'make dist' time
check_mk_version = '(inofficial)'
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index dd6a756..5a8099f 100644
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -42,7 +42,14 @@ import sys
# to python module names like "random"
sys.path.pop(0)
-import socket, os, time, re, signal, math, tempfile, traceback
+import socket
+import os
+import time
+import re
+import signal
+import math
+import tempfile
+import traceback
# PLANNED CLEANUP:
# - central functions for outputting verbose information and bailing
Module: check_mk
Branch: master
Commit: 3164085f39186dda45940f1eea25ac11a6de0d72
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3164085f39186d…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sat Oct 24 15:30:48 2015 +0200
Cleanup in modules: get rid of module glob
---
modules/check_mk.py | 71 +++++++++++++++++++++++++++-----------------------
modules/inventory.py | 10 ++-----
2 files changed, 40 insertions(+), 41 deletions(-)
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 86fb81d..9945810 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -31,7 +31,7 @@
# - cluster_name - Name of a cluster (string)
# - realhost_name - Name of a *real* host, not a cluster (string)
-import os, sys, socket, time, getopt, glob, re, stat, py_compile, urllib, inspect
+import os, sys, socket, time, getopt, re, stat, py_compile, urllib, inspect
import subprocess, fcntl
# These variable will be substituted at 'make dist' time
@@ -338,14 +338,8 @@ special_agent_info = {}
# values user can override those variables in his configuration.
# Do not read in the checks if check_mk is called as module
def load_checks():
- filelist = glob.glob(checks_dir + "/*")
- filelist.sort()
-
- # read local checks *after* shipped ones!
- if local_checks_dir:
- local_files = glob.glob(local_checks_dir + "/*")
- local_files.sort()
- filelist += local_files
+ filelist = plugin_pathnames_in_directory(checks_dir) \
+ + plugin_pathnames_in_directory(local_checks_dir)
# read include files always first, but still in the sorted
# order with local ones last (possibly overriding variables)
@@ -468,6 +462,32 @@ def active_check_service_description(act_info, params):
# | Helper functions for dealing with hosts. |
# '----------------------------------------------------------------------'
+def is_tcp_host(hostname):
+ return in_binary_hostlist(hostname, tcp_hosts)
+
+def is_ping_host(hostname):
+ return not is_snmp_host(hostname) and not is_tcp_host(hostname) and not has_piggyback_info(hostname)
+
+def is_dual_host(hostname):
+ return is_tcp_host(hostname) and is_snmp_host(hostname)
+
+def is_ipv4_host(hostname):
+ # Either explicit IPv4 or implicit (when host is not an IPv6 host)
+ return "ip-v4" in tags_of_host(hostname) or "ip-v6" not in tags_of_host(hostname)
+
+def is_ipv6_host(hostname):
+ return "ip-v6" in tags_of_host(hostname)
+
+def is_ipv6_primary(hostname):
+ dual_stack_host = is_ipv4v6_host(hostname)
+ return (not dual_stack_host and is_ipv6_host(hostname)) \
+ or (dual_stack_host and host_extra_conf(hostname, primary_address_family) == "ipv6")
+
+def is_ipv4v6_host(hostname):
+ tags = tags_of_host(hostname)
+ return "ip-v6" in tags and "ip-v4" in tags
+
+
# Returns a list of all host names, regardless if currently
# disabled or monitored on a remote site. Does not return
# cluster hosts.
@@ -1265,30 +1285,15 @@ def aggregated_service_name(hostname, servicedesc):
# | Misc functions which do not belong to any other topic |
# '----------------------------------------------------------------------'
-def is_tcp_host(hostname):
- return in_binary_hostlist(hostname, tcp_hosts)
-
-def is_ping_host(hostname):
- return not is_snmp_host(hostname) and not is_tcp_host(hostname) and not has_piggyback_info(hostname)
-
-def is_dual_host(hostname):
- return is_tcp_host(hostname) and is_snmp_host(hostname)
-
-def is_ipv4_host(hostname):
- # Either explicit IPv4 or implicit (when host is not an IPv6 host)
- return "ip-v4" in tags_of_host(hostname) or "ip-v6" not in tags_of_host(hostname)
-
-def is_ipv6_host(hostname):
- return "ip-v6" in tags_of_host(hostname)
-
-def is_ipv6_primary(hostname):
- dual_stack_host = is_ipv4v6_host(hostname)
- return (not dual_stack_host and is_ipv6_host(hostname)) \
- or (dual_stack_host and host_extra_conf(hostname, primary_address_family) == "ipv6")
-
-def is_ipv4v6_host(hostname):
- tags = tags_of_host(hostname)
- return "ip-v6" in tags and "ip-v4" in tags
+def plugin_pathnames_in_directory(path):
+ if os.path.exists(path):
+ return sorted([
+ path + "/" + f
+ for f in os.listdir(path)
+ if not f.startswith(".")
+ ])
+ else:
+ return []
def check_period_of(hostname, service):
periods = service_extra_conf(hostname, service, check_periods)
diff --git a/modules/inventory.py b/modules/inventory.py
index 41f2c2a..075d0c5 100644
--- a/modules/inventory.py
+++ b/modules/inventory.py
@@ -47,14 +47,8 @@ inv_info = {} # Inventory plugins
inv_export = {} # Inventory export hooks
# Read all inventory plugins right now
-filelist = glob.glob(inventory_dir + "/*")
-filelist.sort()
-
-# read local checks *after* shipped ones!
-if local_inventory_dir:
- local_files = glob.glob(local_inventory_dir + "/*")
- local_files.sort()
- filelist += local_files
+filelist = plugin_pathnames_in_directory(inventory_dir) \
+ + plugin_pathnames_in_directory(local_inventory_dir)
# read include files always first, but still in the sorted
Module: check_mk
Branch: master
Commit: f1f8c410ba7c1af4c88f68d52faffd0197be630e
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f1f8c410ba7c1a…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Fri Oct 23 16:13:10 2015 +0200
Removed unused file.
---
livestatus/src/strutil.c | 110 ----------------------------------------------
1 file changed, 110 deletions(-)
diff --git a/livestatus/src/strutil.c b/livestatus/src/strutil.c
deleted file mode 100644
index e8473e2..0000000
--- a/livestatus/src/strutil.c
+++ /dev/null
@@ -1,110 +0,0 @@
-// +------------------------------------------------------------------+
-// | ____ _ _ __ __ _ __ |
-// | / ___| |__ ___ ___| | __ | \/ | |/ / |
-// | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
-// | | |___| | | | __/ (__| < | | | | . \ |
-// | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
-// | |
-// | Copyright Mathias Kettner 2014 mk(a)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-
-// ails. 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.
-
-#include <string.h>
-#include <ctype.h>
-
-#include "strutil.h"
-
-char *rstrip(char *c)
-{
- char *w = c + strlen(c) - 1;
- while (w >= c && isspace(*w))
- *w-- = '\0';
- return c;
-}
-
-char *lstrip(char *c)
-{
- while (isspace(*c)) c++;
- return c;
-}
-
-/* *c points to a string containing
- white space separated columns. This method returns
- a pointer to the zero-terminated next field. That
- might be identical with *c itself. The pointer c
- is then moved to the possible beginning of the
- next field. */
-char *next_field(char **c)
-{
- /* *c points to first character of field */
- char *begin = lstrip(*c); // skip leading spaces
- if (!*begin) {
- *c = begin;
- return 0; // found end of string -> no more field
- }
-
- char *end = begin; // copy pointer, search end of field
- while (*end && !isspace(*end)) end++; // search for \0 or white space
- if (*end) { // string continues -> terminate field with '\0'
- *end = '\0';
- *c = end + 1; // skip to character right *after* '\0'
- }
- else
- *c = end; // no more field, point to '\0'
- return begin;
-}
-
-/* similar to next_field() but takes one character as delimiter */
-char *next_token(char **c, char delim)
-{
- char *begin = *c;
- if (!*begin) {
- *c = begin;
- return 0;
- }
-
- char *end = begin;
- while (*end && *end != delim) end++;
- if (*end) {
- *end = 0;
- *c = end + 1;
- }
- else
- *c = end;
- return begin;
-}
-
-/* same as next_token() but returns "" instead of 0 if
- no tokens has been found */
-char *save_next_token(char **c, char delim)
-{
- if (!*c)
- return (char *)"";
-
- char *result = next_token(c, delim);
- if (result == 0)
- return (char *)"";
- else
- return result;
-}
-
-
-int ends_with(const char *a, const char *b)
-{
- return !strcmp(a + strlen(a) - strlen(b), b);
-}
-
-
Module: check_mk
Branch: master
Commit: 87a86227749de285808fd1d17cb515cef66bbc6e
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=87a86227749de2…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Oct 23 15:51:58 2015 +0200
mssql.vbs: removed debug output, fixed missing var declaration
---
agents/windows/plugins/mssql.vbs | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/agents/windows/plugins/mssql.vbs b/agents/windows/plugins/mssql.vbs
index 89baa8e..856d06a 100644
--- a/agents/windows/plugins/mssql.vbs
+++ b/agents/windows/plugins/mssql.vbs
@@ -5,7 +5,7 @@
' on the local system.
'
' The current implementation of the check uses the "trusted authentication"
-' where no user/password needs to be created in the MSSQL server instance by
+' where no user/password needs to be created in the MSSQL server instance by
' default. It is only needed to grant the user as which the Check_MK windows
' agent service is running access to the MSSQL database.
'
@@ -30,7 +30,7 @@
Option Explicit
Dim WMI, FSO, SHO, items, objItem, prop, instId, instIdx, instVersion
-Dim instIds, instName, output, isClustered
+Dim instIds, instName, output, isClustered, instServers
Dim WMIservice, colRunningServices, objService, cfg_dir, cfg_file, hostname
WScript.Timeout = 10
@@ -297,10 +297,9 @@ For Each instId In instIds.Keys
Next
' Loop all databases to get the date of the last backup. Only show databases
- ' which have at least one backup
+ ' which have at least one backup
Dim lastBackupDate
addOutput( "<<<mssql_backup>>>" )
- addOutput( "Blocked _Sessions" )
For Each dbName in dbNames.Keys
RS.open "SELECT CONVERT(VARCHAR, DATEADD(s, DATEDIFF(s, '19700101', MAX(backup_finish_date)), '19700101'), 120) AS last_backup_date " & _
"FROM msdb.dbo.backupset " & _