Module: check_mk
Branch: master
Commit: ae3f4495d7ffcc1458918603db8202bed5df51b1
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ae3f4495d7ffcc…
Author: Goetz Golla <gg(a)mathias-kettner.de>
Date: Wed Dec 3 18:20:13 2014 +0100
#1451 users: new check to monitor number of users logged in on a linux system
This check currently needs the mk_users agent plugin installed in the monitoring client.
The agent section may at some later point be moved into check_mk_agent.linux
---
.werks/1451 | 11 +++++++
ChangeLog | 3 +-
agents/plugins/mk_users | 29 +++++++++++++++++
checkman/users | 24 ++++++++++++++
checks/users | 59 ++++++++++++++++++++++++++++++++++
web/plugins/wato/check_parameters.py | 12 +++++++
6 files changed, 137 insertions(+), 1 deletion(-)
diff --git a/.werks/1451 b/.werks/1451
new file mode 100644
index 0000000..08f7427
--- /dev/null
+++ b/.werks/1451
@@ -0,0 +1,11 @@
+Title: users: new check to monitor number of users logged in on a linux system
+Level: 2
+Component: checks
+Compatible: compat
+Version: 1.2.5i7
+Date: 1417627059
+Class: feature
+
+This check currently needs the mk_users agent plugin installed in the monitoring client.
+The agent section may at some later point be moved into check_mk_agent.linux
+
diff --git a/ChangeLog b/ChangeLog
index 17f057c..b03f1b0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -35,9 +35,10 @@
* 1565 mem.win: set default levels for page file to 80%/90%
* 1608 zpool_status: Add an overall state check (thx to Craig Cook)...
* 1567 postfix_mailq: speedup in Linux agent for large mail queues...
- * 1450 checkpoint_connections, checkpoint_packets: new checks to monitor Checkpoint firewalls
* 1611 mssql.vbs: Supporting SQL-Server 2014 now
* 1568 f5_bigip_cluster_v11: new check for F5 cluster status for firmware version 11
+ * 1450 checkpoint_connections, checkpoint_packets: new checks to monitor Checkpoint firewalls
+ * 1451 users: new check to monitor number of users logged in on a linux system...
* 1478 FIX: kernel.util, statgrab_cpu: fix computation of utilization...
* 1480 FIX: brocade_vdx_status: disable check on some devices that do not support it...
* 1485 FIX: dell_om_disks, dell_om_esmlog, dell_om_mem, dell_om_processors, dell_om_sensors: detect more devices...
diff --git a/agents/plugins/mk_users b/agents/plugins/mk_users
new file mode 100755
index 0000000..7058b96
--- /dev/null
+++ b/agents/plugins/mk_users
@@ -0,0 +1,29 @@
+#!/bin/bash
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | 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.
+
+if type who >/dev/null; then
+ echo "<<<users>>>"
+ who | wc -l
+fi
diff --git a/checkman/users b/checkman/users
new file mode 100644
index 0000000..c3ebbce
--- /dev/null
+++ b/checkman/users
@@ -0,0 +1,24 @@
+title: Number of Users Currently Logged In
+agents: linux
+catalog: os/misc
+license: GPL
+distribution: check_mk
+description:
+ Monitor the number of users currently logged in.
+ The default levels are set to {20} and {30}.
+
+inventory:
+ A check of this type is created automatically on each Linux host as soon
+ as the mk_users plugin is installed on the host.
+
+perfdata:
+ On variable: the current number of users logged in
+
+[parameters]
+warn (int): Number of users logged in at which a warning level
+ is triggered
+crit (int): Number for a critical state
+
+[configuration]
+users_default_levels (int, int): Levels used for all checks found
+ by inventory. This variable is preset to {(20, 30)}.
diff --git a/checks/users b/checks/users
new file mode 100644
index 0000000..71287de
--- /dev/null
+++ b/checks/users
@@ -0,0 +1,59 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | 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.
+
+
+# Example output from agent:
+# <<<user>>>
+# 3
+
+users_default_levels = (20,30)
+
+def inventory_users(info):
+ if info:
+ return [ (None, "users_default_levels") ]
+
+def check_users(_no_item, params, info):
+ if info:
+ users = int(info[0][0])
+ warn, crit = params
+ state = 0
+ if users >= crit:
+ state = 2
+ elif users >= warn:
+ state = 1
+
+ infotext = "%d users logged in, levels at %d/%d" % ( users, warn, crit )
+ perfdata = [ ( "users", users, warn, crit, 0 ) ]
+ yield state, infotext, perfdata
+
+
+check_info["users"] = {
+ 'check_function' : check_users,
+ 'inventory_function' : inventory_users,
+ 'service_description' : 'Users',
+ 'has_perfdata' : True,
+ 'group' : 'users',
+}
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 781df59..45be91a 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -4238,6 +4238,18 @@ register_check_parameters(
)
register_check_parameters(
+ subgroup_os,
+ "users",
+ _("Number of Users Logged In"),
+ Tuple(
+ help = _("This rule defines levels for the number of users logged in on a system."),
+ elements = [
+ Integer(title = _("Warning if above"), unit = _("users"), default_value = 20),
+ Integer(title = _("Critical if above"), unit = _("users"), default_value = 30)]),
+ None, None
+)
+
+register_check_parameters(
subgroup_applications,
"vms_procs",
_("Number of processes on OpenVMS"),
Module: check_mk
Branch: master
Commit: 867742b2f3feff096906f653226cf5bbc6f7428d
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=867742b2f3feff…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Dec 3 17:35:14 2014 +0100
Change detection of postfix in Linux agent
---
agents/check_mk_agent.linux | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index 51b425b..48d6847 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -501,7 +501,7 @@ fi
# Only handle the last 6 lines (includes the summary line at the bottom and
# the last message in the queue. The last message is not used at the moment
# but it could be used to get the timestamp of the last message.
-if type mailq >/dev/null 2>&1 && [ -x /usr/sbin/postfix ] && getent passwd postfix >/dev/null 2>&1; then
+if type postconf ; then
echo '<<<postfix_mailq>>>'
echo -- \
$(du -kd0 $(postconf -h queue_directory)/deferred | awk '{print $1 }') Kbytes in \
Module: check_mk
Branch: master
Commit: bbb866fabde1c05110e42472e41054693a6d9fc8
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bbb866fabde1c0…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Dec 3 17:10:55 2014 +0100
#1612 FIX job: Fixed wrong reported start time for running jobs
---
.werks/1612 | 9 +++++++++
ChangeLog | 1 +
checks/job | 35 +++++++++++++++--------------------
3 files changed, 25 insertions(+), 20 deletions(-)
diff --git a/.werks/1612 b/.werks/1612
new file mode 100644
index 0000000..8c6446c
--- /dev/null
+++ b/.werks/1612
@@ -0,0 +1,9 @@
+Title: job: Fixed wrong reported start time for running jobs
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.5i7
+Date: 1417623022
+Class: fix
+
+
diff --git a/ChangeLog b/ChangeLog
index 7ba5338..d1193f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -69,6 +69,7 @@
* 1564 FIX: check_mk_agent.linux: fix situation where async plugin is not executed after crash...
* 1609 FIX: zpool_status: fix problem when the zpool has a separate log or cache device...
* 1566 FIX: 3ware_disks: consider VERIFYING state as OK now...
+ * 1612 FIX: job: Fixed wrong reported start time for running jobs
Multisite:
* 1508 Allow input of plugin output and perfdata when faking check results...
diff --git a/checks/job b/checks/job
index 83f3ba6..f8c895f 100644
--- a/checks/job
+++ b/checks/job
@@ -71,31 +71,27 @@ def job_parse_real_time(s):
return float(parts[-1]) + min_sec + hour_sec
def job_parse(item, info):
- found = False
- found_running = False
data = {}
+ prefix = None
for line in info:
- if ' '.join(line[1:-1]) == item:
- found = True
+ if line[0] == '==>':
- elif ' '.join(line[1:-1]) == item + '.running':
- # There might be a second section per job, the contents of the
- # <ident>.running file which exists during execution of the job.
- # We use the start_time from this file.
- found_running = True
+ if ' '.join(line[1:-1]) == item:
+ prefix = ''
- elif found_running and line[0] == '==>':
- continue # simply skip over this line
+ elif ' '.join(line[1:-1]) == item + '.running':
+ # There might be a second section per job, the contents of the
+ # <ident>.running file which exists during execution of the job.
+ # We use the start_time from this file.
+ prefix = 'running_'
- elif found_running and len(line) == 2:
- key, val = line
- if key == 'start_time':
- data['running_start_time'] = int(val)
+ elif 'start_time' in data.keys() and 'running_start_time' in data.keys():
+ break # both sections completed => we are done here
- elif found and line[0] == '==>':
- break # Stop at next section
+ else:
+ prefix = None
- elif found and len(line) == 2:
+ elif len(line) == 2 and prefix is not None:
key, val = line
# Convert several keys/values
if key == 'real_time':
@@ -107,7 +103,7 @@ def job_parse(item, info):
elif key in [ 'max_res_kbytes', 'avg_mem_kbytes' ]:
key = key.replace('kbytes', 'bytes')
val = int(val) * 1000
- data[key] = val
+ data[prefix+key] = val
return data
@@ -138,7 +134,6 @@ def check_job(item, params, info):
output.append('(Started: %s)' % display_value)
return state, ' '.join(output)
-
txt = 'Exit-Code: %d' % job['exit_code']
if job['exit_code'] != 0:
state = max(state, 2)