diff options
Diffstat (limited to 'plugins/t')
0 files changed, 0 insertions, 0 deletions
diff --git a/plugins/Makefile.am b/plugins/Makefile.am index ab59eb7..49086b7 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am | |||
@@ -112,7 +112,7 @@ check_tcp_LDADD = $(SSLOBJS) | |||
112 | check_time_LDADD = $(NETLIBS) | 112 | check_time_LDADD = $(NETLIBS) |
113 | check_ntp_time_LDADD = $(NETLIBS) $(MATHLIBS) | 113 | check_ntp_time_LDADD = $(NETLIBS) $(MATHLIBS) |
114 | check_ups_LDADD = $(NETLIBS) | 114 | check_ups_LDADD = $(NETLIBS) |
115 | check_users_LDADD = $(BASEOBJS) $(WTSAPI32LIBS) | 115 | check_users_LDADD = $(BASEOBJS) $(WTSAPI32LIBS) $(SYSTEMDLIBS) |
116 | check_by_ssh_LDADD = $(NETLIBS) | 116 | check_by_ssh_LDADD = $(NETLIBS) |
117 | check_ide_smart_LDADD = $(BASEOBJS) | 117 | check_ide_smart_LDADD = $(BASEOBJS) |
118 | negate_LDADD = $(BASEOBJS) | 118 | negate_LDADD = $(BASEOBJS) |
diff --git a/plugins/check_users.c b/plugins/check_users.c index f6f4b36..2a9ee98 100644 --- a/plugins/check_users.c +++ b/plugins/check_users.c | |||
@@ -1,33 +1,33 @@ | |||
1 | /***************************************************************************** | 1 | /***************************************************************************** |
2 | * | 2 | * |
3 | * Monitoring check_users plugin | 3 | * Monitoring check_users plugin |
4 | * | 4 | * |
5 | * License: GPL | 5 | * License: GPL |
6 | * Copyright (c) 2000-2012 Monitoring Plugins Development Team | 6 | * Copyright (c) 2000-2012 Monitoring Plugins Development Team |
7 | * | 7 | * |
8 | * Description: | 8 | * Description: |
9 | * | 9 | * |
10 | * This file contains the check_users plugin | 10 | * This file contains the check_users plugin |
11 | * | 11 | * |
12 | * This plugin checks the number of users currently logged in on the local | 12 | * This plugin checks the number of users currently logged in on the local |
13 | * system and generates an error if the number exceeds the thresholds | 13 | * system and generates an error if the number exceeds the thresholds |
14 | * specified. | 14 | * specified. |
15 | * | 15 | * |
16 | * | 16 | * |
17 | * This program is free software: you can redistribute it and/or modify | 17 | * This program is free software: you can redistribute it and/or modify |
18 | * it under the terms of the GNU General Public License as published by | 18 | * it under the terms of the GNU General Public License as published by |
19 | * the Free Software Foundation, either version 3 of the License, or | 19 | * the Free Software Foundation, either version 3 of the License, or |
20 | * (at your option) any later version. | 20 | * (at your option) any later version. |
21 | * | 21 | * |
22 | * This program is distributed in the hope that it will be useful, | 22 | * This program is distributed in the hope that it will be useful, |
23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
25 | * GNU General Public License for more details. | 25 | * GNU General Public License for more details. |
26 | * | 26 | * |
27 | * You should have received a copy of the GNU General Public License | 27 | * You should have received a copy of the GNU General Public License |
28 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 28 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
29 | * | 29 | * |
30 | * | 30 | * |
31 | *****************************************************************************/ | 31 | *****************************************************************************/ |
32 | 32 | ||
33 | const char *progname = "check_users"; | 33 | const char *progname = "check_users"; |
@@ -48,6 +48,11 @@ const char *email = "devel@monitoring-plugins.org"; | |||
48 | # include "popen.h" | 48 | # include "popen.h" |
49 | #endif | 49 | #endif |
50 | 50 | ||
51 | #ifdef HAVE_LIBSYSTEMD | ||
52 | #include <systemd/sd-daemon.h> | ||
53 | #include <systemd/sd-login.h> | ||
54 | #endif | ||
55 | |||
51 | #define possibly_set(a,b) ((a) == 0 ? (b) : 0) | 56 | #define possibly_set(a,b) ((a) == 0 ? (b) : 0) |
52 | 57 | ||
53 | int process_arguments (int, char **); | 58 | int process_arguments (int, char **); |
@@ -85,6 +90,11 @@ main (int argc, char **argv) | |||
85 | 90 | ||
86 | users = 0; | 91 | users = 0; |
87 | 92 | ||
93 | #ifdef HAVE_LIBSYSTEMD | ||
94 | if (sd_booted () > 0) | ||
95 | users = sd_get_sessions (NULL); | ||
96 | else { | ||
97 | #endif | ||
88 | #if HAVE_WTSAPI32_H | 98 | #if HAVE_WTSAPI32_H |
89 | if (!WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE, | 99 | if (!WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE, |
90 | 0, 1, &wtsinfo, &wtscount)) { | 100 | 0, 1, &wtsinfo, &wtscount)) { |
@@ -156,6 +166,9 @@ main (int argc, char **argv) | |||
156 | if (spclose (child_process)) | 166 | if (spclose (child_process)) |
157 | result = possibly_set (result, STATE_UNKNOWN); | 167 | result = possibly_set (result, STATE_UNKNOWN); |
158 | #endif | 168 | #endif |
169 | #ifdef HAVE_LIBSYSTEMD | ||
170 | } | ||
171 | #endif | ||
159 | 172 | ||
160 | /* check the user count against warning and critical thresholds */ | 173 | /* check the user count against warning and critical thresholds */ |
161 | result = get_status((double)users, thlds); | 174 | result = get_status((double)users, thlds); |
@@ -163,7 +176,7 @@ main (int argc, char **argv) | |||
163 | if (result == STATE_UNKNOWN) | 176 | if (result == STATE_UNKNOWN) |
164 | printf ("%s\n", _("Unable to read output")); | 177 | printf ("%s\n", _("Unable to read output")); |
165 | else { | 178 | else { |
166 | printf (_("USERS %s - %d users currently logged in |%s\n"), | 179 | printf (_("USERS %s - %d users currently logged in |%s\n"), |
167 | state_text(result), users, | 180 | state_text(result), users, |
168 | sperfdata_int("users", users, "", warning_range, | 181 | sperfdata_int("users", users, "", warning_range, |
169 | critical_range, TRUE, 0, FALSE, 0)); | 182 | critical_range, TRUE, 0, FALSE, 0)); |