From 9a04924df3319c23718107b259e25f6af9a12694 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Sat, 14 Apr 2007 22:28:25 +0000 Subject: [PATCH] fold java CurrentProcessSummary metric into sigar_proc_stat_t --- bindings/java/src/jni/generate.pl | 25 +++++ .../hyperic/sigar/CurrentProcessSummary.java | 95 ------------------- .../java/src/org/hyperic/sigar/cmd/Top.java | 13 ++- include/sigar.h | 11 +++ src/sigar.c | 33 ++++++- 5 files changed, 79 insertions(+), 98 deletions(-) delete mode 100644 bindings/java/src/org/hyperic/sigar/CurrentProcessSummary.java diff --git a/bindings/java/src/jni/generate.pl b/bindings/java/src/jni/generate.pl index 70f75bb4..a7b46fb0 100644 --- a/bindings/java/src/jni/generate.pl +++ b/bindings/java/src/jni/generate.pl @@ -381,6 +381,31 @@ my %classes = ( desc => 'Total number of processes', plat => '*' }, + { + name => 'idle', type => 'Long', + desc => 'Total number of processes in idle state', + plat => '*' + }, + { + name => 'running', type => 'Long', + desc => 'Total number of processes in run state', + plat => '*' + }, + { + name => 'sleeping', type => 'Long', + desc => 'Total number of processes in sleep state', + plat => '*' + }, + { + name => 'stopped', type => 'Long', + desc => 'Total number of processes in stop state', + plat => '*' + }, + { + name => 'zombie', type => 'Long', + desc => 'Total number of processes in zombie state', + plat => '*' + }, ], ProcExe => [ { diff --git a/bindings/java/src/org/hyperic/sigar/CurrentProcessSummary.java b/bindings/java/src/org/hyperic/sigar/CurrentProcessSummary.java deleted file mode 100644 index fce5b162..00000000 --- a/bindings/java/src/org/hyperic/sigar/CurrentProcessSummary.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) [2004, 2005, 2006], Hyperic, Inc. - * This file is part of SIGAR. - * - * SIGAR is free software; you can redistribute it and/or modify - * it under the terms version 2 of the GNU General Public License as - * published by the Free Software Foundation. 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - */ - -package org.hyperic.sigar; - -/** - * This class provides a summary of current process states. - * @see org.hyperic.sigar.cmd.Top - */ -public class CurrentProcessSummary { - private int total=0, sleeping=0, running=0, zombie=0, stopped=0; - - private CurrentProcessSummary() { } - - public static CurrentProcessSummary get(SigarProxy sigar) - throws SigarException { - - long[] pids = sigar.getProcList(); - CurrentProcessSummary summary = - new CurrentProcessSummary(); - - for (int i=0; itotal = proclist.number; + for (i=0; iidle++; + break; + case SIGAR_PROC_STATE_RUN: + procstat->running++; + break; + case SIGAR_PROC_STATE_SLEEP: + procstat->sleeping++; + break; + case SIGAR_PROC_STATE_STOP: + procstat->stopped++; + break; + case SIGAR_PROC_STATE_ZOMBIE: + procstat->zombie++; + break; + default: + break; + } + } + sigar_proc_list_destroy(sigar, &proclist); return SIGAR_OK;