sigar/src/os/stub/stub_sigar.c

298 lines
6.4 KiB
C
Raw Normal View History

2004-06-22 06:37:04 +08:00
#include "sigar.h"
#include "sigar_private.h"
#include "sigar_os.h"
2004-09-06 10:50:41 +08:00
#include "sigar_util.h"
2004-06-22 06:37:04 +08:00
int sigar_os_open(sigar_t **sigar)
{
*sigar = malloc(sizeof(**sigar));
return SIGAR_OK;
}
int sigar_os_close(sigar_t *sigar)
{
free(sigar);
return SIGAR_OK;
}
2005-03-12 14:19:34 +08:00
char *sigar_os_error_string(sigar_t *sigar, int err)
2004-06-22 06:37:04 +08:00
{
return NULL;
}
int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
{
mem->total = -1;
mem->ram = -1;
mem->used = -1;
mem->free = -1;
mem->actual_free = mem->free;
mem->actual_used = mem->used;
2004-06-22 06:37:04 +08:00
return SIGAR_OK;
}
int sigar_swap_get(sigar_t *sigar, sigar_swap_t *swap)
{
swap->total = -1;
swap->used = -1;
swap->free = -1;
2007-07-21 02:02:21 +08:00
swap->page_in = -1;
swap->page_out = -1;
2004-06-22 06:37:04 +08:00
return SIGAR_OK;
}
int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu)
{
cpu->user = -1;
cpu->nice = -1;
cpu->sys = -1;
cpu->idle = -1;
2004-11-22 09:51:34 +08:00
cpu->wait = -1;
2004-06-22 06:37:04 +08:00
cpu->total = cpu->user + cpu->nice + cpu->sys + cpu->idle;
return SIGAR_OK;
}
int sigar_cpu_list_get(sigar_t *sigar, sigar_cpu_list_t *cpulist)
{
return SIGAR_ENOTIMPL;
}
int sigar_uptime_get(sigar_t *sigar,
sigar_uptime_t *uptime)
{
uptime->uptime = -1;
return SIGAR_OK;
}
int sigar_loadavg_get(sigar_t *sigar,
sigar_loadavg_t *loadavg)
{
loadavg->loadavg[0] = -1;
loadavg->loadavg[1] = -1;
loadavg->loadavg[2] = -1;
return SIGAR_OK;
}
int sigar_proc_list_get(sigar_t *sigar,
sigar_proc_list_t *proclist)
{
return SIGAR_ENOTIMPL;
}
int sigar_proc_mem_get(sigar_t *sigar, sigar_pid_t pid,
sigar_proc_mem_t *procmem)
{
procmem->size = -1;
procmem->share = -1;
procmem->resident = -1;
2005-11-24 02:00:02 +08:00
procmem->page_faults = -1;
procmem->minor_faults = -1;
procmem->major_faults = -1;
2004-06-22 06:37:04 +08:00
return SIGAR_OK;
}
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;
return SIGAR_OK;
}
int sigar_proc_time_get(sigar_t *sigar, sigar_pid_t pid,
sigar_proc_time_t *proctime)
{
proctime->start_time = -1;
proctime->user = -1;
proctime->sys = -1;
proctime->total = proctime->user + proctime->sys;
2004-06-22 06:37:04 +08:00
return SIGAR_OK;
}
int sigar_proc_state_get(sigar_t *sigar, sigar_pid_t pid,
sigar_proc_state_t *procstate)
{
SIGAR_SSTRCPY(procstate->name, "java");
procstate->ppid = -1;
procstate->priority = -1;
procstate->nice = -1;
procstate->tty = -1;
procstate->state = 'R';
2005-11-23 08:39:37 +08:00
procstate->threads = -1;
2005-11-23 09:28:51 +08:00
procstate->processor = -1;
2004-06-22 06:37:04 +08:00
return SIGAR_OK;
}
int sigar_proc_args_get(sigar_t *sigar, sigar_pid_t pid,
sigar_proc_args_t *procargs)
{
return SIGAR_ENOTIMPL;
}
int sigar_proc_env_get(sigar_t *sigar, sigar_pid_t pid,
sigar_proc_env_t *procenv)
{
return SIGAR_ENOTIMPL;
}
int sigar_proc_fd_get(sigar_t *sigar, sigar_pid_t pid,
sigar_proc_fd_t *procfd)
{
procfd->total = -1;
return SIGAR_OK;
}
int sigar_proc_exe_get(sigar_t *sigar, sigar_pid_t pid,
sigar_proc_exe_t *procexe)
{
return SIGAR_ENOTIMPL;
}
2004-06-23 03:40:37 +08:00
int sigar_proc_modules_get(sigar_t *sigar, sigar_pid_t pid,
sigar_proc_modules_t *procmods)
{
return SIGAR_ENOTIMPL;
}
2004-11-17 13:35:17 +08:00
int sigar_thread_cpu_get(sigar_t *sigar,
sigar_uint64_t id,
sigar_thread_cpu_t *cpu)
{
return SIGAR_ENOTIMPL;
}
2004-06-22 06:37:04 +08:00
int sigar_os_fs_type_get(sigar_file_system_t *fsp)
{
fsp->type = SIGAR_FSTYPE_UNKNOWN;
return SIGAR_OK;
}
int sigar_file_system_list_get(sigar_t *sigar,
sigar_file_system_list_t *fslist)
{
sigar_file_system_list_create(fslist);
return SIGAR_OK;
}
int sigar_file_system_usage_get(sigar_t *sigar,
const char *dirname,
sigar_file_system_usage_t *fsusage)
{
fsusage->total = -1;
fsusage->free = -1;
fsusage->avail = -1;
2005-04-27 03:55:21 +08:00
fsusage->used = -1;
2004-06-22 06:37:04 +08:00
fsusage->files = -1;
fsusage->free_files = -1;
SIGAR_DISK_STATS_NOTIMPL(fsusage);
2004-06-22 06:37:04 +08:00
return SIGAR_OK;
}
int sigar_cpu_info_list_get(sigar_t *sigar,
sigar_cpu_info_list_t *cpu_infos)
2004-06-22 06:37:04 +08:00
{
sigar_cpu_info_t *info;
sigar_cpu_info_list_create(cpu_infos);
2004-06-22 06:37:04 +08:00
info = &cpu_infos->data[cpu_infos->number++];
SIGAR_SSTRCPY(info->vendor, "vendor");
SIGAR_SSTRCPY(info->model, "model");
info->mhz = -1;
info->cache_size = -1;
return SIGAR_OK;
}
int sigar_net_route_list_get(sigar_t *sigar,
sigar_net_route_list_t *routelist)
{
2004-09-06 10:50:41 +08:00
return SIGAR_ENOTIMPL;
2004-06-22 06:37:04 +08:00
}
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->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;
2006-03-07 09:08:23 +08:00
ifstat->speed = -1;
2004-06-22 06:37:04 +08:00
return SIGAR_OK;
}
int sigar_net_connection_walk(sigar_net_connection_walker_t *walker)
2004-06-22 06:37:04 +08:00
{
return SIGAR_ENOTIMPL;
}
2005-03-16 10:47:57 +08:00
2007-07-15 00:01:58 +08:00
SIGAR_DECLARE(int)
2007-08-08 13:34:21 +08:00
sigar_tcp_get(sigar_t *sigar,
sigar_tcp_t *tcp)
2007-07-15 00:01:58 +08:00
{
return SIGAR_ENOTIMPL;
}
2007-07-26 14:30:29 +08:00
int sigar_nfs_client_v2_get(sigar_t *sigar,
2007-08-08 13:40:58 +08:00
sigar_nfs_client_v2_t *nfs)
2007-07-26 14:30:29 +08:00
{
return SIGAR_ENOTIMPL;
}
int sigar_nfs_server_v2_get(sigar_t *sigar,
2007-08-08 13:40:58 +08:00
sigar_nfs_server_v2_t *nfs)
2007-07-26 14:30:29 +08:00
{
return SIGAR_ENOTIMPL;
}
int sigar_nfs_client_v3_get(sigar_t *sigar,
2007-08-08 13:40:58 +08:00
sigar_nfs_client_v3_t *nfs)
2007-07-26 14:30:29 +08:00
{
return SIGAR_ENOTIMPL;
}
int sigar_nfs_server_v3_get(sigar_t *sigar,
2007-08-08 13:40:58 +08:00
sigar_nfs_server_v3_t *nfs)
2007-07-26 14:30:29 +08:00
{
return SIGAR_ENOTIMPL;
}
2005-03-16 10:47:57 +08:00
int sigar_proc_port_get(sigar_t *sigar, int protocol,
unsigned long port, sigar_pid_t *pid)
{
return SIGAR_ENOTIMPL;
}
int sigar_os_sys_info_get(sigar_t *sigar,
sigar_sys_info_t *sysinfo)
{
return SIGAR_OK;
}