Module: check_mk
Branch: master
Commit: eac59aa0c978f8e539d6c3945841fdd2d94f3243
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=eac59aa0c978f8…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Jul 12 14:40:11 2018 +0200
Fixed a few simplifiable-if-statement warnings.
Change-Id: I379e8eba59be0d0a4195846b456decce3bf21150
---
active_checks/check_sftp | 5 +----
agents/plugins/mk_logwatch | 5 +----
agents/plugins/mtr | 14 +++-----------
checks/cisco_mem.include | 5 +----
checks/if.include | 5 +----
checks/ipmi | 5 -----
6 files changed, 7 insertions(+), 32 deletions(-)
diff --git a/active_checks/check_sftp b/active_checks/check_sftp
index 14093e7..7d6c4d3 100755
--- a/active_checks/check_sftp
+++ b/active_checks/check_sftp
@@ -148,10 +148,7 @@ def get_paths(omd_root, working_dir):
def file_available(working_dir):
filename = opt_put_local.split("/")[-1]
- if filename in sftp.listdir("%s/%s" % (working_dir, opt_put_remote)):
- return True
- else:
- return False
+ return filename in sftp.listdir("%s/%s" % (working_dir, opt_put_remote))
def create_testfile(paths):
diff --git a/agents/plugins/mk_logwatch b/agents/plugins/mk_logwatch
index db6a606..8b2bad9 100755
--- a/agents/plugins/mk_logwatch
+++ b/agents/plugins/mk_logwatch
@@ -305,10 +305,7 @@ def is_inode_cabable(path):
import win32api # pylint: disable=import-error
volume_info = win32api.GetVolumeInformation(volume_name)
volume_type = volume_info[-1]
- if "ntfs" in volume_type.lower():
- return True
- else:
- return False
+ return "ntfs" in volume_type.lower()
else:
return False
diff --git a/agents/plugins/mtr b/agents/plugins/mtr
index 08ed178..3ffe9e3 100755
--- a/agents/plugins/mtr
+++ b/agents/plugins/mtr
@@ -47,10 +47,7 @@ config_dir = mk_confdir + "/mtr.d/*.cfg"
status_filename = mk_vardir + "/mtr.state"
report_filepre = mk_vardir + "/mtr.report."
-if '-d' in sys.argv[2:] or '--debug' in sys.argv[1:]:
- debug = True
-else:
- debug = False
+debug = '-d' in sys.argv[2:] or '--debug' in sys.argv[1:]
def which(program):
@@ -179,13 +176,8 @@ def check_mtr_pid(pid):
else:
pid_cmdline = "/proc/%d/cmdline" % pid
try:
- if os.path.exists(pid_cmdline):
- if
file(pid_cmdline).read().startswith("mtr\x00--report\x00--report-wide"):
- return True
- else:
- return False # different process than mtr
- else:
- return False # cmdline no longer exists, race condition..
+ return os.path.exists(pid_cmdline) and \
+
file(pid_cmdline).read().startswith("mtr\x00--report\x00--report-wide")
except:
return False # any error
diff --git a/checks/cisco_mem.include b/checks/cisco_mem.include
index e75351a..2b30eb2 100644
--- a/checks/cisco_mem.include
+++ b/checks/cisco_mem.include
@@ -32,10 +32,7 @@ factory_settings["cisco_mem_default_levels"] = {
def scan_cisco_mem_asa64(oid):
version =
int((oid(".1.3.6.1.2.1.1.1.0").split("Version")[-1]).split(".")[0])
- if version >= 9:
- return True
- else:
- return False
+ return version >= 9
def inventory_cisco_mem(info):
diff --git a/checks/if.include b/checks/if.include
index 3def51a..ce1c525 100644
--- a/checks/if.include
+++ b/checks/if.include
@@ -649,10 +649,7 @@ def check_if_common(item, params, info, has_nodeinfo = False,
group_name = "Grou
group_operStatus = "2" # down
alias_info = []
- if len(params["aggregate"].get("group_patterns", {})) >=
2:
- add_node_info = True
- else:
- add_node_info = False
+ add_node_info = len(params["aggregate"].get("group_patterns",
{})) >= 2
for node_name, attrs in
params["aggregate"].get("group_patterns", {}).items():
if attrs.get("iftype"):
diff --git a/checks/ipmi b/checks/ipmi
index 4af9f28..23a2d3b 100644
--- a/checks/ipmi
+++ b/checks/ipmi
@@ -204,11 +204,6 @@ def inventory_ipmi(info):
rules = host_extra_conf(host_name(), inventory_ipmi_rules)
if rules and type(rules[0]) == dict:
if rules[0].get("summarize", True):
- summarize = True
- else:
- summarize = False
-
- if summarize:
rules = [ 'summarize' ]
else:
if rules[0].get('ignored_sensors', []):