Imported Upstream version 2.0
This commit is contained in:
parent
c89ccc3c74
commit
0841b5c7c7
165 changed files with 25440 additions and 4442 deletions
|
@ -1,9 +1,9 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* Nagios check_users plugin
|
||||
* Monitoring check_users plugin
|
||||
*
|
||||
* License: GPL
|
||||
* Copyright (c) 2000-2012 Nagios Plugins Development Team
|
||||
* Copyright (c) 2000-2012 Monitoring Plugins Development Team
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
|
@ -32,12 +32,17 @@
|
|||
|
||||
const char *progname = "check_users";
|
||||
const char *copyright = "2000-2007";
|
||||
const char *email = "nagiosplug-devel@lists.sourceforge.net";
|
||||
const char *email = "devel@monitoring-plugins.org";
|
||||
|
||||
#include "common.h"
|
||||
#include "utils.h"
|
||||
|
||||
#if HAVE_UTMPX_H
|
||||
#if HAVE_WTSAPI32_H
|
||||
# include <windows.h>
|
||||
# include <wtsapi32.h>
|
||||
# undef ERROR
|
||||
# define ERROR -1
|
||||
#elif HAVE_UTMPX_H
|
||||
# include <utmpx.h>
|
||||
#else
|
||||
# include "popen.h"
|
||||
|
@ -58,7 +63,11 @@ main (int argc, char **argv)
|
|||
int users = -1;
|
||||
int result = STATE_UNKNOWN;
|
||||
char *perf;
|
||||
#if HAVE_UTMPX_H
|
||||
#if HAVE_WTSAPI32_H
|
||||
WTS_SESSION_INFO *wtsinfo;
|
||||
DWORD wtscount;
|
||||
DWORD index;
|
||||
#elif HAVE_UTMPX_H
|
||||
struct utmpx *putmpx;
|
||||
#else
|
||||
char input_buffer[MAX_INPUT_BUFFER];
|
||||
|
@ -78,7 +87,36 @@ main (int argc, char **argv)
|
|||
|
||||
users = 0;
|
||||
|
||||
#if HAVE_UTMPX_H
|
||||
#if HAVE_WTSAPI32_H
|
||||
if (!WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE,
|
||||
0, 1, &wtsinfo, &wtscount)) {
|
||||
printf(_("Could not enumerate RD sessions: %d\n"), GetLastError());
|
||||
return STATE_UNKNOWN;
|
||||
}
|
||||
|
||||
for (index = 0; index < wtscount; index++) {
|
||||
LPTSTR username;
|
||||
DWORD size;
|
||||
int len;
|
||||
|
||||
if (!WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE,
|
||||
wtsinfo[index].SessionId, WTSUserName, &username, &size))
|
||||
continue;
|
||||
|
||||
len = lstrlen(username);
|
||||
|
||||
WTSFreeMemory(username);
|
||||
|
||||
if (len == 0)
|
||||
continue;
|
||||
|
||||
if (wtsinfo[index].State == WTSActive ||
|
||||
wtsinfo[index].State == WTSDisconnected)
|
||||
users++;
|
||||
}
|
||||
|
||||
WTSFreeMemory(wtsinfo);
|
||||
#elif HAVE_UTMPX_H
|
||||
/* get currently logged users from utmpx */
|
||||
setutxent ();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue