diff --git a/bindings/java/src/net/hyperic/sigar/Sigar.java b/bindings/java/src/net/hyperic/sigar/Sigar.java index 1c89c4cd..8bb435a7 100644 --- a/bindings/java/src/net/hyperic/sigar/Sigar.java +++ b/bindings/java/src/net/hyperic/sigar/Sigar.java @@ -19,6 +19,8 @@ import net.hyperic.jni.ArchNotSupportedException; */ public class Sigar implements SigarProxy { + public static final long FIELD_NOTIMPL = -1; + /** * The Sigar version in String form. */ diff --git a/include/sigar.h b/include/sigar.h index fccd929f..45b27cda 100644 --- a/include/sigar.h +++ b/include/sigar.h @@ -23,6 +23,8 @@ typedef unsigned long long sigar_uint64_t; #endif +#define SIGAR_FIELD_NOTIMPL -1 + #define SIGAR_OK 0 #define SIGAR_START_ERROR 20000 #define SIGAR_ENOTIMPL (SIGAR_START_ERROR + 1) diff --git a/src/os/aix/aix_sigar.c b/src/os/aix/aix_sigar.c index cb4e4fb6..c34c3967 100644 --- a/src/os/aix/aix_sigar.c +++ b/src/os/aix/aix_sigar.c @@ -357,7 +357,7 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem) mem->actual_used = mem->used; mem->actual_free = mem->free; - mem->shared = -1; + mem->shared = SIGAR_FIELD_NOTIMPL; sigar_mem_calc_ram(sigar, mem); @@ -576,7 +576,7 @@ int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu) if (sigar->perfstat.cpu_total(&cpu_data, sizeof(cpu_data)) == 1) { cpu->user = cpu_data.user; - cpu->nice = -1; /* N/A */ + cpu->nice = SIGAR_FIELD_NOTIMPL; /* N/A */ cpu->sys = cpu_data.sys; cpu->idle = cpu_data.idle; cpu->wait = cpu_data.wait; @@ -595,7 +595,7 @@ int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu) } cpu->user = data.cpu[CPU_USER]; - cpu->nice = -1; /* N/A */ + cpu->nice = SIGAR_FIELD_NOTIMPL; /* N/A */ cpu->sys = data.cpu[CPU_KERNEL]; cpu->idle = data.cpu[CPU_IDLE]; cpu->total = 0; @@ -700,7 +700,7 @@ static int sigar_cpu_list_get_pstat(sigar_t *sigar, sigar_cpu_list_t *cpulist) if (sigar->perfstat.cpu(&id, &data, sizeof(data), 1) == 1) { cpu->user = data.user; - cpu->nice = -1; /* N/A */ + cpu->nice = SIGAR_FIELD_NOTIMPL; /* N/A */ cpu->sys = data.sys; cpu->idle = data.idle; cpu->wait = data.wait; @@ -925,7 +925,7 @@ int sigar_proc_mem_get(sigar_t *sigar, sigar_pid_t pid, procmem->vsize = PAGESHIFT(pinfo->pi_dvm); procmem->share = PAGESHIFT(pinfo->pi_sdsize); procmem->rss = PAGESHIFT(pinfo->pi_drss + pinfo->pi_trss); - procmem->resident = -1; /* N/A */ + procmem->resident = SIGAR_FIELD_NOTIMPL; /* N/A */ return SIGAR_OK; } @@ -988,7 +988,7 @@ int sigar_proc_state_get(sigar_t *sigar, sigar_pid_t pid, procstate->ppid = pinfo->pi_ppid; procstate->nice = pinfo->pi_nice; procstate->tty = pinfo->pi_ttyd; - procstate->priority = -1; /* XXX getthrds() */ + procstate->priority = SIGAR_FIELD_NOTIMPL; /* XXX getthrds() */ switch (pinfo->pi_state) { case SACTIVE: @@ -1440,7 +1440,7 @@ static int sigar_get_cpu_mhz_perfstat(sigar_t *sigar) static int sigar_get_cpu_mhz(sigar_t *sigar) { - if (sigar->cpu_mhz == -1) { + if (sigar->cpu_mhz == SIGAR_FIELD_NOTIMPL) { if (sigar_get_cpu_mhz_perfstat(sigar) != SIGAR_OK) { sigar_uint64_t cache_size = SIGAR_CPU_CACHE_SIZE; @@ -1455,7 +1455,7 @@ static int sigar_get_cpu_mhz(sigar_t *sigar) sigar->cpu_mhz = 450; break; default: - sigar->cpu_mhz = -1; + sigar->cpu_mhz = SIGAR_FIELD_NOTIMPL; break; } } @@ -1629,16 +1629,16 @@ int sigar_net_interface_stat_get(sigar_t *sigar, const char *name, ifstat->rx_packets = data.if_ipackets; ifstat->rx_errors = data.if_ierrors; ifstat->rx_dropped = data.if_iqdrops; - ifstat->rx_overruns = -1; - ifstat->rx_frame = -1; + ifstat->rx_overruns = SIGAR_FIELD_NOTIMPL; + ifstat->rx_frame = SIGAR_FIELD_NOTIMPL; ifstat->tx_bytes = data.if_obytes; ifstat->tx_packets = data.if_opackets; ifstat->tx_errors = data.if_oerrors; - ifstat->tx_dropped = -1; - ifstat->tx_overruns = -1; + ifstat->tx_dropped = SIGAR_FIELD_NOTIMPL; + ifstat->tx_overruns = SIGAR_FIELD_NOTIMPL; ifstat->tx_collisions = data.if_collisions; - ifstat->tx_carrier = -1; + ifstat->tx_carrier = SIGAR_FIELD_NOTIMPL; return SIGAR_OK; } diff --git a/src/os/darwin/darwin_sigar.c b/src/os/darwin/darwin_sigar.c index 9e6b7663..005600ec 100644 --- a/src/os/darwin/darwin_sigar.c +++ b/src/os/darwin/darwin_sigar.c @@ -123,7 +123,7 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem) #endif mem->used = mem->total - mem->free; - mem->shared = -1; /*XXX*/ + mem->shared = SIGAR_FIELD_NOTIMPL; /*XXX*/ mem->actual_free = mem->free; mem->actual_used = mem->used; @@ -363,8 +363,8 @@ int sigar_proc_mem_get(sigar_t *sigar, sigar_pid_t pid, /*XXX*/ procmem->size = 1; /* 1 == let ant test pass for now */ - procmem->rss = -1; - procmem->share = -1; + procmem->rss = SIGAR_FIELD_NOTIMPL; + procmem->share = SIGAR_FIELD_NOTIMPL; return SIGAR_OK; } @@ -470,7 +470,7 @@ int sigar_proc_state_get(sigar_t *sigar, sigar_pid_t pid, procstate->ppid = pinfo->kp_eproc.e_ppid; procstate->priority = pinfo->kp_proc.p_priority; procstate->nice = pinfo->kp_proc.p_nice; - procstate->tty = -1; /*XXX*/ + procstate->tty = SIGAR_FIELD_NOTIMPL; /*XXX*/ switch (pinfo->kp_proc.p_stat) { case SIDL: @@ -624,8 +624,8 @@ int sigar_cpu_info_list_get(sigar_t *sigar, SIGAR_SSTRCPY(info->vendor, "Apple"); SIGAR_SSTRCPY(info->model, "powerpc"); - info->mhz = -1; /*XXX*/ - info->cache_size = -1; + info->mhz = SIGAR_FIELD_NOTIMPL; /*XXX*/ + info->cache_size = SIGAR_FIELD_NOTIMPL; } return SIGAR_OK; @@ -850,16 +850,16 @@ int sigar_net_interface_stat_get(sigar_t *sigar, const char *name, ifstat->rx_packets = ifm->ifm_data.ifi_ipackets; ifstat->rx_errors = ifm->ifm_data.ifi_ierrors; ifstat->rx_dropped = ifm->ifm_data.ifi_iqdrops; - ifstat->rx_overruns = -1; - ifstat->rx_frame = -1; + ifstat->rx_overruns = SIGAR_FIELD_NOTIMPL; + ifstat->rx_frame = SIGAR_FIELD_NOTIMPL; ifstat->tx_bytes = ifm->ifm_data.ifi_obytes; ifstat->tx_packets = ifm->ifm_data.ifi_opackets; ifstat->tx_errors = ifm->ifm_data.ifi_oerrors; ifstat->tx_collisions = ifm->ifm_data.ifi_collisions; - ifstat->tx_dropped = -1; - ifstat->tx_overruns = -1; - ifstat->tx_carrier = -1; + ifstat->tx_dropped = SIGAR_FIELD_NOTIMPL; + ifstat->tx_overruns = SIGAR_FIELD_NOTIMPL; + ifstat->tx_carrier = SIGAR_FIELD_NOTIMPL; return SIGAR_OK; } diff --git a/src/os/hpux/hpux_sigar.c b/src/os/hpux/hpux_sigar.c index 5dbeecf3..a6a8e5aa 100644 --- a/src/os/hpux/hpux_sigar.c +++ b/src/os/hpux/hpux_sigar.c @@ -55,7 +55,7 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem) mem->used = mem->total - mem->free; /*XXX*/ - mem->shared = 0; + mem->shared = SIGAR_FIELD_NOTIMPL; mem->actual_free = mem->free; mem->actual_used = mem->used; @@ -589,7 +589,7 @@ int sigar_cpu_info_list_get(sigar_t *sigar, SIGAR_SSTRCPY(info->vendor, "HP"); /*XXX*/ SIGAR_SSTRCPY(info->model, "PA RISC"); /*XXX*/ info->mhz = sigar->ticks * proc.psp_iticksperclktick / 1000000; - info->cache_size = -1; /*XXX*/ + info->cache_size = SIGAR_FIELD_NOTIMPL; /*XXX*/ } return SIGAR_OK; @@ -717,16 +717,16 @@ int sigar_net_interface_stat_get(sigar_t *sigar, const char *name, ifstat->rx_packets = mib.ifInUcastPkts + mib.ifInNUcastPkts; ifstat->rx_errors = mib.ifInErrors; ifstat->rx_dropped = mib.ifInDiscards; - ifstat->rx_overruns = 0; /*XXX*/ - ifstat->rx_frame = 0; /*XXX*/ + ifstat->rx_overruns = SIGAR_FIELD_NOTIMPL; + ifstat->rx_frame = SIGAR_FIELD_NOTIMPL; ifstat->tx_bytes = mib.ifOutOctets; ifstat->tx_packets = mib.ifOutUcastPkts + mib.ifOutNUcastPkts; ifstat->tx_errors = mib.ifOutErrors; ifstat->tx_dropped = mib.ifOutDiscards; - ifstat->tx_overruns = 0; /*XXX*/ - ifstat->tx_collisions = 0; /*XXX*/ - ifstat->tx_carrier = 0; /*XXX*/ + ifstat->tx_overruns = SIGAR_FIELD_NOTIMPL; + ifstat->tx_collisions = SIGAR_FIELD_NOTIMPL; + ifstat->tx_carrier = SIGAR_FIELD_NOTIMPL; return SIGAR_OK; } diff --git a/src/os/linux/linux_sigar.c b/src/os/linux/linux_sigar.c index bb3659d0..ef10bd38 100644 --- a/src/os/linux/linux_sigar.c +++ b/src/os/linux/linux_sigar.c @@ -274,7 +274,7 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem) mem->actual_free = mem->free + kern; mem->actual_used = mem->used - kern; - mem->shared = 0; /* XXX where did this go in 2.6?? */ + mem->shared = SIGAR_FIELD_NOTIMPL; /* XXX where did this go in 2.6?? */ if (get_ram(sigar, mem) != SIGAR_OK) { /* XXX other options on failure? */ @@ -1229,7 +1229,8 @@ int sigar_file_system_usage_get(sigar_t *sigar, break; } - fsusage->disk_reads = fsusage->disk_writes = 0; + fsusage->disk_reads = fsusage->disk_writes = + SIGAR_FIELD_NOTIMPL; return SIGAR_OK; } diff --git a/src/os/osf1/osf1_sigar.c b/src/os/osf1/osf1_sigar.c index c15409b1..b051c9a9 100644 --- a/src/os/osf1/osf1_sigar.c +++ b/src/os/osf1/osf1_sigar.c @@ -49,7 +49,7 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem) sigar_mem_calc_ram(sigar, mem); - mem->shared = -1; + mem->shared = SIGAR_FIELD_NOTIMPL; mem->actual_free = mem->free; mem->actual_used = mem->used; @@ -220,7 +220,7 @@ int sigar_proc_mem_get(sigar_t *sigar, sigar_pid_t pid, status = table(TBL_UAREA, pid, &s_user, 1, sizeof(s_user)); if (status != 1) { - procmem->share = -1; + procmem->share = SIGAR_FIELD_NOTIMPL; return SIGAR_OK; } @@ -234,10 +234,10 @@ int sigar_proc_mem_get(sigar_t *sigar, sigar_pid_t pid, int sigar_proc_cred_get(sigar_t *sigar, sigar_pid_t pid, sigar_proc_cred_t *proccred) { - proccred->uid = -1; - proccred->gid = -1; - proccred->euid = -1; - proccred->egid = -1; + proccred->uid = SIGAR_FIELD_NOTIMPL; + proccred->gid = SIGAR_FIELD_NOTIMPL; + proccred->euid = SIGAR_FIELD_NOTIMPL; + proccred->egid = SIGAR_FIELD_NOTIMPL; return SIGAR_OK; } @@ -276,8 +276,8 @@ int sigar_proc_state_get(sigar_t *sigar, sigar_pid_t pid, SIGAR_SSTRCPY(procstate->name, info.pi_comm); procstate->ppid = info.pi_ppid; - procstate->priority = -1; - procstate->nice = -1; + procstate->priority = SIGAR_FIELD_NOTIMPL; + procstate->nice = SIGAR_FIELD_NOTIMPL; procstate->tty = info.pi_ttyd; switch (info.pi_status) { @@ -310,7 +310,7 @@ int sigar_proc_env_get(sigar_t *sigar, sigar_pid_t pid, int sigar_proc_fd_get(sigar_t *sigar, sigar_pid_t pid, sigar_proc_fd_t *procfd) { - procfd->total = -1; + procfd->total = SIGAR_FIELD_NOTIMPL; return SIGAR_OK; } @@ -487,7 +487,7 @@ int sigar_cpu_info_list_get(sigar_t *sigar, SIGAR_SSTRCPY(info->vendor, "DEC"); SIGAR_SSTRCPY(info->model, "alpha"); info->mhz = sigar->mhz; - info->cache_size = -1; + info->cache_size = SIGAR_FIELD_NOTIMPL; return SIGAR_OK; } @@ -501,20 +501,20 @@ int sigar_net_route_list_get(sigar_t *sigar, int sigar_net_interface_stat_get(sigar_t *sigar, const char *name, sigar_net_interface_stat_t *ifstat) { - ifstat->rx_bytes = -1; - ifstat->rx_packets = -1; - ifstat->rx_errors = -1; - ifstat->rx_dropped = -1; - ifstat->rx_overruns = -1; - ifstat->rx_frame = -1; + ifstat->rx_bytes = SIGAR_FIELD_NOTIMPL; + ifstat->rx_packets = SIGAR_FIELD_NOTIMPL; + ifstat->rx_errors = SIGAR_FIELD_NOTIMPL; + ifstat->rx_dropped = SIGAR_FIELD_NOTIMPL; + ifstat->rx_overruns = SIGAR_FIELD_NOTIMPL; + ifstat->rx_frame = SIGAR_FIELD_NOTIMPL; - ifstat->tx_bytes = -1; - ifstat->tx_packets = -1; - ifstat->tx_errors = -1; - ifstat->tx_dropped = -1; - ifstat->tx_overruns = -1; - ifstat->tx_collisions = -1; - ifstat->tx_carrier = -1; + ifstat->tx_bytes = SIGAR_FIELD_NOTIMPL; + ifstat->tx_packets = SIGAR_FIELD_NOTIMPL; + ifstat->tx_errors = SIGAR_FIELD_NOTIMPL; + ifstat->tx_dropped = SIGAR_FIELD_NOTIMPL; + ifstat->tx_overruns = SIGAR_FIELD_NOTIMPL; + ifstat->tx_collisions = SIGAR_FIELD_NOTIMPL; + ifstat->tx_carrier = SIGAR_FIELD_NOTIMPL; return SIGAR_OK; } diff --git a/src/os/solaris/solaris_sigar.c b/src/os/solaris/solaris_sigar.c index 4b2dbca4..42709f2f 100644 --- a/src/os/solaris/solaris_sigar.c +++ b/src/os/solaris/solaris_sigar.c @@ -568,9 +568,9 @@ int sigar_proc_mem_get(sigar_t *sigar, sigar_pid_t pid, procmem->size = pinfo->pr_size << 10; procmem->rss = pinfo->pr_rssize << 10; - procmem->resident = procmem->rss; /*XXX*/ - procmem->vsize = procmem->size; /*XXX*/ - procmem->share = 0; /*XXX*/ + procmem->resident = SIGAR_FIELD_NOTIMPL; + procmem->vsize = SIGAR_FIELD_NOTIMPL; + procmem->share = SIGAR_FIELD_NOTIMPL; return SIGAR_OK; } @@ -1191,7 +1191,7 @@ int sigar_cpu_info_list_get(sigar_t *sigar, } info->mhz = stats.pi_clock; - info->cache_size = -1; /*XXX*/ + info->cache_size = SIGAR_FIELD_NOTIMPL; /*XXX*/ } return SIGAR_OK; @@ -1379,19 +1379,19 @@ static int sigar_net_ifstat_get_lo(sigar_t *sigar, const char *name, sigar_koffsets_init_lo(sigar, ksp); ifstat->rx_packets = kLO(KSTAT_LO_RX_PACKETS); - ifstat->rx_bytes = -1; - ifstat->rx_errors = -1; - ifstat->rx_dropped = -1; - ifstat->rx_overruns = -1; - ifstat->rx_frame = -1; + ifstat->rx_bytes = SIGAR_FIELD_NOTIMPL; + ifstat->rx_errors = SIGAR_FIELD_NOTIMPL; + ifstat->rx_dropped = SIGAR_FIELD_NOTIMPL; + ifstat->rx_overruns = SIGAR_FIELD_NOTIMPL; + ifstat->rx_frame = SIGAR_FIELD_NOTIMPL; ifstat->tx_packets = kLO(KSTAT_LO_TX_PACKETS); - ifstat->tx_bytes = -1; - ifstat->tx_errors = -1; - ifstat->tx_dropped = -1; - ifstat->tx_overruns = -1; - ifstat->tx_collisions = -1; - ifstat->tx_carrier = -1; + ifstat->tx_bytes = SIGAR_FIELD_NOTIMPL; + ifstat->tx_errors = SIGAR_FIELD_NOTIMPL; + ifstat->tx_dropped = SIGAR_FIELD_NOTIMPL; + ifstat->tx_overruns = SIGAR_FIELD_NOTIMPL; + ifstat->tx_collisions = SIGAR_FIELD_NOTIMPL; + ifstat->tx_carrier = SIGAR_FIELD_NOTIMPL; return SIGAR_OK; } diff --git a/src/os/win32/win32_sigar.c b/src/os/win32/win32_sigar.c index 4eb7703e..9e13e80c 100644 --- a/src/os/win32/win32_sigar.c +++ b/src/os/win32/win32_sigar.c @@ -613,9 +613,9 @@ SIGAR_DECLARE(int) sigar_proc_mem_get(sigar_t *sigar, sigar_pid_t pid, procmem->vsize = pinfo->vsize; procmem->size = pinfo->size; - procmem->resident = -1; - procmem->share = -1; - procmem->rss = -1; + procmem->resident = SIGAR_FIELD_NOTIMPL; + procmem->share = SIGAR_FIELD_NOTIMPL; + procmem->rss = SIGAR_FIELD_NOTIMPL; return SIGAR_OK; } @@ -754,8 +754,8 @@ SIGAR_DECLARE(int) sigar_proc_state_get(sigar_t *sigar, sigar_pid_t pid, procstate->state = pinfo->state; procstate->ppid = pinfo->ppid; procstate->priority = pinfo->priority; - procstate->nice = -1; - procstate->tty = -1; + procstate->nice = SIGAR_FIELD_NOTIMPL; + procstate->tty = SIGAR_FIELD_NOTIMPL; return SIGAR_OK; } @@ -1451,13 +1451,14 @@ sigar_file_system_usage_get(sigar_t *sigar, fsusage->use_percent = sigar_file_system_usage_calc_used(sigar, fsusage); - /* XXX */ - fsusage->files = 0; - fsusage->free_files = 0; + /* N/A */ + fsusage->files = SIGAR_FIELD_NOTIMPL; + fsusage->free_files = SIGAR_FIELD_NOTIMPL; status = get_disk_metrics(sigar, dirname, fsusage); if (status != SIGAR_OK) { - fsusage->disk_reads = fsusage->disk_writes = 0; + fsusage->disk_reads = fsusage->disk_writes = + SIGAR_FIELD_NOTIMPL; } return SIGAR_OK; @@ -1634,16 +1635,16 @@ sigar_net_interface_stat_get(sigar_t *sigar, const char *name, ifstat->rx_packets = ifr->dwInUcastPkts + ifr->dwInNUcastPkts; ifstat->rx_errors = ifr->dwInErrors; ifstat->rx_dropped = ifr->dwInDiscards; - ifstat->rx_overruns = 0; /*XXX*/ - ifstat->rx_frame = 0; /*XXX*/ + ifstat->rx_overruns = SIGAR_FIELD_NOTIMPL; + ifstat->rx_frame = ifstat->tx_bytes = ifr->dwOutOctets; ifstat->tx_packets = ifr->dwOutUcastPkts + ifr->dwOutNUcastPkts; ifstat->tx_errors = ifr->dwOutErrors; ifstat->tx_dropped = ifr->dwOutDiscards; - ifstat->tx_overruns = 0; /*XXX*/ - ifstat->tx_collisions = 0; /*XXX*/ - ifstat->tx_carrier = 0; /*XXX*/ + ifstat->tx_overruns = SIGAR_FIELD_NOTIMPL; + ifstat->tx_collisions = SIGAR_FIELD_NOTIMPL; + ifstat->tx_carrier = SIGAR_FIELD_NOTIMPL; free(buffer);