Source
if (1 == invalid_user) /* handle 0 for non-existent user after all parameters have been parsed and validated */
/*
** Zabbix
** Copyright (C) 2001-2023 Zabbix SIA
**
** This program 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; either version 2 of the License, or
** (at your option) any later version.
**
** 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
int proc_mem(AGENT_REQUEST *request, AGENT_RESULT *result)
{
DIR *dir;
int proc;
struct dirent *entries;
zbx_stat_t buf;
struct passwd *usrinfo;
struct prpsinfo psinfo;
char filename[MAX_STRING_LEN];
char *procname, *proccomm, *param;
double memsize = -1;
int pgsize = getpagesize();
int proccount = 0, invalid_user = 0, do_task;
pid_t curr_pid = getpid();
if (4 < request->nparam)
{
SET_MSG_RESULT(result, zbx_strdup(NULL, "Too many parameters."));
return SYSINFO_RET_FAIL;
}
procname = get_rparam(request, 0);
param = get_rparam(request, 1);
if (NULL != param && '\0' != *param)
{
if (NULL == (usrinfo = getpwnam(param)))
invalid_user = 1;
}
else
usrinfo = NULL;
param = get_rparam(request, 2);
if (NULL == param || '\0' == *param || 0 == strcmp(param, "sum")) /* default parameter */