summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-08-06 13:29:56 +0000
committersasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-08-06 13:29:56 +0000
commit5132f1679c3106da0ce8bda401ecdec3af45bd55 (patch)
tree02afb5777d2723c11b9eeaa7873222fce4cedb41
parent1adf64e6bba5741b531d27b550f0dffa8db5f5f3 (diff)
downloadzabbix-5132f1679c3106da0ce8bda401ecdec3af45bd55.tar.gz
zabbix-5132f1679c3106da0ce8bda401ecdec3af45bd55.tar.xz
zabbix-5132f1679c3106da0ce8bda401ecdec3af45bd55.zip
- [DEV-168] More supported items
git-svn-id: svn://svn.zabbix.com/trunk@5882 97f52cf1-0a1b-0410-bd0e-c28be96e8082
-rw-r--r--src/libs/zbxsysinfo/freebsd/proc.c68
-rw-r--r--src/zabbix_agent/active.c8
2 files changed, 24 insertions, 52 deletions
diff --git a/src/libs/zbxsysinfo/freebsd/proc.c b/src/libs/zbxsysinfo/freebsd/proc.c
index 93f2cdc4..3115ca4c 100644
--- a/src/libs/zbxsysinfo/freebsd/proc.c
+++ b/src/libs/zbxsysinfo/freebsd/proc.c
@@ -19,6 +19,7 @@
#include "common.h"
#include "sysinfo.h"
+#include "log.h"
#include <sys/sysctl.h>
@@ -31,62 +32,43 @@
#define ZBX_PROC_STAT_RUN 1
#define ZBX_PROC_STAT_SLEEP 2
#define ZBX_PROC_STAT_ZOMB 3
-
-static kvm_t *kd = NULL;
static char *get_commandline(struct kinfo_proc *proc)
{
- struct pargs pa;
+ int mib[4], i;
size_t sz;
- char *p;
static char *args = NULL;
static int args_alloc = 128;
- if (NULL == kd)
- return NULL;
-
- sz = sizeof(pa);
-
- if (kvm_read(kd, (unsigned long)proc->ki_args, &pa, sz) != sz)
- return NULL;
-
if (NULL == args)
args = zbx_malloc(args, args_alloc);
- if (args_alloc < pa.ar_length)
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_PROC;
+ mib[2] = KERN_PROC_ARGS;
+ mib[3] = proc->ki_pid;
+retry:
+ sz = (size_t)args_alloc;
+ if (-1 == sysctl(mib, 4, args, &sz, NULL, 0))
{
- args_alloc = pa.ar_length;
- args = zbx_realloc(args, args_alloc);
- }
-
- if (pa.ar_length != kvm_read(kd, (unsigned long)proc->ki_args
- + sizeof(pa.ar_ref) + sizeof(pa.ar_length), args, pa.ar_length))
+ if (errno == ENOMEM) {
+ args_alloc *= 2;
+ args = zbx_realloc(args, args_alloc);
+ goto retry;
+ }
return NULL;
+ }
- p = args;
- sz = 1; /* do not change last '\0' */
+ for (i = 0; i < (int)(sz - 1); i++)
+ if (args[i] == '\0')
+ args[i] = ' ';
- do {
- if (*p == '\0')
- *p = ' ';
- p++;
- } while (++sz < pa.ar_length);
+ if (sz == 0)
+ zbx_strlcpy(args, proc->ki_comm, args_alloc);
return args;
}
-static void init_kernel_access()
-{
- static int already = 0;
-
- if (1 == already)
- return;
-
- kd = kvm_open(NULL, NULL, NULL, O_RDONLY, NULL);
-
- already = 1;
-}
-
/*
* proc.mem[<process_name><,user_name><,mode><,command_line>]
* <mode> : *sum, avg, max, min
@@ -116,8 +98,6 @@ int PROC_MEMORY(const char *cmd, const char *param, unsigned flags, AGENT_RE
init_result(result);
- init_kernel_access();
-
if (num_param(param) > 4)
return SYSINFO_RET_FAIL;
@@ -156,9 +136,6 @@ int PROC_MEMORY(const char *cmd, const char *param, unsigned flags, AGENT_RE
if (0 != get_param(param, 4, proccomm, sizeof(proccomm)))
*proccomm = '\0';
- if (*proccomm != '\0' && kd == NULL)
- return SYSINFO_RET_FAIL;
-
pagesize = getpagesize();
mib[0] = CTL_KERN;
@@ -254,8 +231,6 @@ int PROC_NUM(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *r
init_result(result);
- init_kernel_access();
-
if (num_param(param) > 4)
return SYSINFO_RET_FAIL;
@@ -294,9 +269,6 @@ int PROC_NUM(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *r
if (0 != get_param(param, 4, proccomm, sizeof(proccomm)))
*proccomm = '\0';
- if (*proccomm != '\0' && kd == NULL)
- return SYSINFO_RET_FAIL;
-
mib[0] = CTL_KERN;
mib[1] = KERN_PROC;
if (NULL != usrinfo) {
diff --git a/src/zabbix_agent/active.c b/src/zabbix_agent/active.c
index 20d4cb60..840a1ee4 100644
--- a/src/zabbix_agent/active.c
+++ b/src/zabbix_agent/active.c
@@ -857,14 +857,10 @@ ZBX_THREAD_ENTRY(active_checks_thread, args)
zabbix_log( LOG_LEVEL_INFORMATION, "zabbix_agentd active check started [%s:%u]", activechk_args.host, activechk_args.port);
- zbx_setproctitle("getting list of active checks");
-
init_active_metrics();
while(ZBX_IS_RUNNING)
{
- zbx_setproctitle("processing active checks");
-
if(time(NULL) >= nextsend)
{
send_buffer(activechk_args.host, activechk_args.port);
@@ -873,6 +869,8 @@ ZBX_THREAD_ENTRY(active_checks_thread, args)
if(time(NULL) >= nextrefresh)
{
+ zbx_setproctitle("poller [getting list of active checks]");
+
if(FAIL == refresh_active_checks(activechk_args.host, activechk_args.port))
{
nextrefresh = (int)time(NULL) + 60;
@@ -885,6 +883,8 @@ ZBX_THREAD_ENTRY(active_checks_thread, args)
if(time(NULL) >= nextcheck)
{
+ zbx_setproctitle("poller [processing active checks]");
+
process_active_checks(activechk_args.host, activechk_args.port);
nextcheck = get_min_nextcheck();
if(FAIL == nextcheck) nextcheck = (int)time(NULL) + 60;