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"),