Source
xxxxxxxxxx
for (attr_id = 0; NULL != attrList[attr_id] && 0 != strcmp(attrList[attr_id], "vmsize"); attr_id++)
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
/* ConvertSidToStringSid */
typedef struct
{
unsigned int pid;
unsigned int ppid;
unsigned int tid;
char *name;
zbx_uint64_t processes;
zbx_uint64_t threads;
zbx_int64_t handles;
char *user;
char *sid;
double cputime_user;
double cputime_system;
double page_faults;
double io_read_b;
double io_write_b;
double io_other_b;
double io_read_op;
double io_write_op;
double io_other_op;
double vmsize;
double wkset;
}
proc_data_t;
ZBX_PTR_VECTOR_DECL(proc_data_ptr, proc_data_t *)
ZBX_PTR_VECTOR_IMPL(proc_data_ptr, proc_data_t *)
/* function 'zbx_get_process_username' require 'userName' with size 'MAX_NAME' */
static int zbx_get_process_username(HANDLE hProcess, char *userName, char *sid)
{
HANDLE tok;
TOKEN_USER *ptu = NULL;
DWORD sz = 0, nlen, dlen;
wchar_t name[MAX_NAME], dom[MAX_NAME], *sid_string;
int iUse, res = FAIL;
/* clean result; */
*userName = '\0';
if (NULL != sid)
*sid = '\0';
/* open the processes token */
if (0 == OpenProcessToken(hProcess, TOKEN_QUERY, &tok))
return res;
/* Get required buffer size and allocate the TOKEN_USER buffer */
if (0 == GetTokenInformation(tok, (TOKEN_INFORMATION_CLASS)1, (LPVOID)ptu, 0, &sz))
{
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
goto lbl_err;
ptu = (PTOKEN_USER)zbx_malloc(ptu, sz);
}
/* Get the token user information from the access token. */
if (0 == GetTokenInformation(tok, (TOKEN_INFORMATION_CLASS)1, (LPVOID)ptu, sz, &sz))
goto lbl_err;
/* get the account/domain name of the SID */