2006-07-16 01:46:36 +08:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2004-06-22 06:37:04 +08:00
|
|
|
#ifndef SIGAR_H
|
|
|
|
#define SIGAR_H
|
|
|
|
|
|
|
|
/* System Information Gatherer And Reporter */
|
|
|
|
|
|
|
|
#include <limits.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(WIN32)
|
|
|
|
|
2006-07-04 05:38:43 +08:00
|
|
|
typedef unsigned __int32 sigar_uint32_t;
|
|
|
|
|
2004-06-22 06:37:04 +08:00
|
|
|
typedef unsigned __int64 sigar_uint64_t;
|
|
|
|
|
2007-03-12 05:46:41 +08:00
|
|
|
typedef __int32 sigar_int32_t;
|
|
|
|
|
|
|
|
typedef __int64 sigar_int64_t;
|
|
|
|
|
2004-06-22 06:37:04 +08:00
|
|
|
#elif ULONG_MAX > 4294967295UL
|
|
|
|
|
2006-07-04 05:38:43 +08:00
|
|
|
typedef unsigned int sigar_uint32_t;
|
|
|
|
|
2004-06-22 06:37:04 +08:00
|
|
|
typedef unsigned long sigar_uint64_t;
|
|
|
|
|
2007-03-12 05:46:41 +08:00
|
|
|
typedef int sigar_int32_t;
|
|
|
|
|
|
|
|
typedef long sigar_int64_t;
|
|
|
|
|
2004-06-22 06:37:04 +08:00
|
|
|
#else
|
|
|
|
|
2006-07-04 05:38:43 +08:00
|
|
|
typedef unsigned int sigar_uint32_t;
|
|
|
|
|
2004-06-22 06:37:04 +08:00
|
|
|
typedef unsigned long long sigar_uint64_t;
|
|
|
|
|
2007-03-12 05:46:41 +08:00
|
|
|
typedef int sigar_int32_t;
|
|
|
|
|
|
|
|
typedef long long sigar_int64_t;
|
|
|
|
|
2004-06-22 06:37:04 +08:00
|
|
|
#endif
|
|
|
|
|
2004-12-06 07:36:48 +08:00
|
|
|
#define SIGAR_FIELD_NOTIMPL -1
|
|
|
|
|
2004-06-22 06:37:04 +08:00
|
|
|
#define SIGAR_OK 0
|
|
|
|
#define SIGAR_START_ERROR 20000
|
|
|
|
#define SIGAR_ENOTIMPL (SIGAR_START_ERROR + 1)
|
|
|
|
#define SIGAR_OS_START_ERROR (SIGAR_START_ERROR*2)
|
|
|
|
|
2007-04-05 23:49:17 +08:00
|
|
|
#ifdef WIN32
|
|
|
|
# define SIGAR_ENOENT ERROR_FILE_NOT_FOUND
|
|
|
|
# define SIGAR_EACCES ERROR_ACCESS_DENIED
|
2007-04-06 00:20:35 +08:00
|
|
|
# define SIGAR_ENXIO ERROR_BAD_DRIVER_LEVEL
|
2007-04-05 23:49:17 +08:00
|
|
|
#else
|
|
|
|
# define SIGAR_ENOENT ENOENT
|
|
|
|
# define SIGAR_EACCES EACCES
|
2007-04-05 23:55:42 +08:00
|
|
|
# define SIGAR_ENXIO ENXIO
|
2007-04-05 23:49:17 +08:00
|
|
|
#endif
|
|
|
|
|
2004-06-22 06:37:04 +08:00
|
|
|
#ifdef WIN32
|
|
|
|
# define SIGAR_DECLARE(type) \
|
|
|
|
__declspec(dllexport) type __stdcall
|
|
|
|
#else
|
|
|
|
# define SIGAR_DECLARE(type) type
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(PATH_MAX)
|
|
|
|
# define SIGAR_PATH_MAX PATH_MAX
|
|
|
|
#elif defined(MAXPATHLEN)
|
|
|
|
# define SIGAR_PATH_MAX MAXPATHLEN
|
|
|
|
#else
|
|
|
|
# define SIGAR_PATH_MAX 8192
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
typedef sigar_uint64_t sigar_pid_t;
|
|
|
|
typedef unsigned long sigar_uid_t;
|
|
|
|
typedef unsigned long sigar_gid_t;
|
|
|
|
#else
|
|
|
|
#include <sys/types.h>
|
|
|
|
typedef pid_t sigar_pid_t;
|
|
|
|
typedef uid_t sigar_uid_t;
|
|
|
|
typedef gid_t sigar_gid_t;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct sigar_t sigar_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_open(sigar_t **sigar);
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_close(sigar_t *sigar);
|
|
|
|
|
|
|
|
SIGAR_DECLARE(sigar_pid_t) sigar_pid_get(sigar_t *sigar);
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_proc_kill(sigar_pid_t pid, int signum);
|
|
|
|
|
2007-03-01 14:15:23 +08:00
|
|
|
SIGAR_DECLARE(int) sigar_signum_get(char *name);
|
|
|
|
|
2004-06-22 06:37:04 +08:00
|
|
|
SIGAR_DECLARE(char *) sigar_strerror(sigar_t *sigar, int err);
|
|
|
|
|
|
|
|
/* system memory info */
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
sigar_uint64_t
|
|
|
|
ram,
|
|
|
|
total,
|
|
|
|
used,
|
|
|
|
free,
|
2004-11-20 10:08:16 +08:00
|
|
|
actual_used,
|
|
|
|
actual_free;
|
2004-06-22 06:37:04 +08:00
|
|
|
} sigar_mem_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
sigar_uint64_t
|
|
|
|
total,
|
|
|
|
used,
|
2007-07-21 02:02:21 +08:00
|
|
|
free,
|
|
|
|
page_in,
|
|
|
|
page_out;
|
2004-06-22 06:37:04 +08:00
|
|
|
} sigar_swap_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_swap_get(sigar_t *sigar, sigar_swap_t *swap);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
sigar_uint64_t
|
|
|
|
user,
|
|
|
|
sys,
|
|
|
|
nice,
|
|
|
|
idle,
|
2004-11-22 09:51:34 +08:00
|
|
|
wait,
|
2004-06-22 06:37:04 +08:00
|
|
|
total;
|
|
|
|
} sigar_cpu_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned long number;
|
|
|
|
unsigned long size;
|
|
|
|
sigar_cpu_t *data;
|
|
|
|
} sigar_cpu_list_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_cpu_list_get(sigar_t *sigar, sigar_cpu_list_t *cpulist);
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_cpu_list_destroy(sigar_t *sigar,
|
|
|
|
sigar_cpu_list_t *cpulist);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char vendor[128];
|
|
|
|
char model[128];
|
|
|
|
int mhz;
|
|
|
|
sigar_uint64_t cache_size;
|
|
|
|
} sigar_cpu_info_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned long number;
|
|
|
|
unsigned long size;
|
|
|
|
sigar_cpu_info_t *data;
|
2004-07-10 12:44:45 +08:00
|
|
|
} sigar_cpu_info_list_t;
|
2004-06-22 06:37:04 +08:00
|
|
|
|
2004-07-10 12:44:45 +08:00
|
|
|
SIGAR_DECLARE(int)
|
|
|
|
sigar_cpu_info_list_get(sigar_t *sigar,
|
|
|
|
sigar_cpu_info_list_t *cpu_infos);
|
2004-06-22 06:37:04 +08:00
|
|
|
|
2004-07-10 12:44:45 +08:00
|
|
|
SIGAR_DECLARE(int)
|
|
|
|
sigar_cpu_info_list_destroy(sigar_t *sigar,
|
|
|
|
sigar_cpu_info_list_t *cpu_infos);
|
2004-06-22 06:37:04 +08:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
double uptime;
|
|
|
|
} sigar_uptime_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_uptime_get(sigar_t *sigar,
|
|
|
|
sigar_uptime_t *uptime);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
double loadavg[3];
|
|
|
|
} sigar_loadavg_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_loadavg_get(sigar_t *sigar,
|
|
|
|
sigar_loadavg_t *loadavg);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned long number;
|
|
|
|
unsigned long size;
|
|
|
|
sigar_pid_t *data;
|
|
|
|
} sigar_proc_list_t;
|
|
|
|
|
2005-07-08 09:03:15 +08:00
|
|
|
typedef struct {
|
|
|
|
/* RLIMIT_CPU */
|
|
|
|
sigar_uint64_t cpu_cur, cpu_max;
|
|
|
|
/* RLIMIT_FSIZE */
|
|
|
|
sigar_uint64_t file_size_cur, file_size_max;
|
2005-07-22 10:26:48 +08:00
|
|
|
/* PIPE_BUF */
|
|
|
|
sigar_uint64_t pipe_size_cur, pipe_size_max;
|
2005-07-08 09:03:15 +08:00
|
|
|
/* RLIMIT_DATA */
|
|
|
|
sigar_uint64_t data_cur, data_max;
|
|
|
|
/* RLIMIT_STACK */
|
|
|
|
sigar_uint64_t stack_cur, stack_max;
|
|
|
|
/* RLIMIT_CORE */
|
|
|
|
sigar_uint64_t core_cur, core_max;
|
|
|
|
/* RLIMIT_RSS */
|
2005-07-08 09:11:03 +08:00
|
|
|
sigar_uint64_t memory_cur, memory_max;
|
2005-07-08 09:03:15 +08:00
|
|
|
/* RLIMIT_NPROC */
|
|
|
|
sigar_uint64_t processes_cur, processes_max;
|
|
|
|
/* RLIMIT_NOFILE */
|
|
|
|
sigar_uint64_t open_files_cur, open_files_max;
|
|
|
|
/* RLIMIT_AS */
|
2005-07-08 09:11:03 +08:00
|
|
|
sigar_uint64_t virtual_memory_cur, virtual_memory_max;
|
2005-07-08 09:03:15 +08:00
|
|
|
} sigar_resource_limit_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_resource_limit_get(sigar_t *sigar,
|
|
|
|
sigar_resource_limit_t *rlimit);
|
|
|
|
|
2004-06-22 06:37:04 +08:00
|
|
|
SIGAR_DECLARE(int) sigar_proc_list_get(sigar_t *sigar,
|
|
|
|
sigar_proc_list_t *proclist);
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_proc_list_destroy(sigar_t *sigar,
|
|
|
|
sigar_proc_list_t *proclist);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
sigar_uint64_t total;
|
2007-04-15 06:28:25 +08:00
|
|
|
sigar_uint64_t sleeping;
|
|
|
|
sigar_uint64_t running;
|
|
|
|
sigar_uint64_t zombie;
|
|
|
|
sigar_uint64_t stopped;
|
|
|
|
sigar_uint64_t idle;
|
2004-06-22 06:37:04 +08:00
|
|
|
} sigar_proc_stat_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_proc_stat_get(sigar_t *sigar,
|
|
|
|
sigar_proc_stat_t *procstat);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
sigar_uint64_t
|
|
|
|
size,
|
|
|
|
resident,
|
|
|
|
share,
|
2005-11-24 01:39:28 +08:00
|
|
|
minor_faults,
|
|
|
|
major_faults,
|
|
|
|
page_faults;
|
2004-06-22 06:37:04 +08:00
|
|
|
} sigar_proc_mem_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_proc_mem_get(sigar_t *sigar, sigar_pid_t pid,
|
|
|
|
sigar_proc_mem_t *procmem);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
sigar_uid_t uid;
|
|
|
|
sigar_gid_t gid;
|
|
|
|
sigar_uid_t euid;
|
|
|
|
sigar_gid_t egid;
|
|
|
|
} sigar_proc_cred_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_proc_cred_get(sigar_t *sigar, sigar_pid_t pid,
|
|
|
|
sigar_proc_cred_t *proccred);
|
|
|
|
|
|
|
|
#define SIGAR_CRED_NAME_MAX 512
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char user[SIGAR_CRED_NAME_MAX];
|
|
|
|
char group[SIGAR_CRED_NAME_MAX];
|
|
|
|
} sigar_proc_cred_name_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int)
|
|
|
|
sigar_proc_cred_name_get(sigar_t *sigar, sigar_pid_t pid,
|
|
|
|
sigar_proc_cred_name_t *proccredname);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
sigar_uint64_t
|
|
|
|
start_time,
|
2004-08-21 08:13:13 +08:00
|
|
|
user,
|
2004-08-21 08:25:07 +08:00
|
|
|
sys,
|
|
|
|
total;
|
2004-06-22 06:37:04 +08:00
|
|
|
} sigar_proc_time_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_proc_time_get(sigar_t *sigar, sigar_pid_t pid,
|
|
|
|
sigar_proc_time_t *proctime);
|
|
|
|
|
2007-03-12 05:46:41 +08:00
|
|
|
typedef struct {
|
|
|
|
/* must match sigar_proc_time_t fields */
|
|
|
|
sigar_uint64_t
|
|
|
|
start_time,
|
|
|
|
user,
|
|
|
|
sys,
|
|
|
|
total;
|
|
|
|
sigar_uint64_t last_time;
|
|
|
|
double percent;
|
|
|
|
} sigar_proc_cpu_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_proc_cpu_get(sigar_t *sigar, sigar_pid_t pid,
|
|
|
|
sigar_proc_cpu_t *proccpu);
|
|
|
|
|
2007-04-15 06:28:25 +08:00
|
|
|
#define SIGAR_PROC_STATE_SLEEP 'S'
|
|
|
|
#define SIGAR_PROC_STATE_RUN 'R'
|
|
|
|
#define SIGAR_PROC_STATE_STOP 'T'
|
|
|
|
#define SIGAR_PROC_STATE_ZOMBIE 'Z'
|
|
|
|
#define SIGAR_PROC_STATE_IDLE 'D'
|
|
|
|
|
2004-06-22 06:37:04 +08:00
|
|
|
#define SIGAR_PROC_NAME_LEN 128
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char name[SIGAR_PROC_NAME_LEN];
|
|
|
|
char state;
|
|
|
|
sigar_pid_t ppid;
|
|
|
|
int tty;
|
|
|
|
int priority;
|
|
|
|
int nice;
|
2005-11-23 09:16:52 +08:00
|
|
|
int processor;
|
2005-11-23 08:43:29 +08:00
|
|
|
sigar_uint64_t threads;
|
2004-06-22 06:37:04 +08:00
|
|
|
} sigar_proc_state_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_proc_state_get(sigar_t *sigar, sigar_pid_t pid,
|
|
|
|
sigar_proc_state_t *procstate);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned long number;
|
|
|
|
unsigned long size;
|
|
|
|
char **data;
|
|
|
|
} sigar_proc_args_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_proc_args_get(sigar_t *sigar, sigar_pid_t pid,
|
|
|
|
sigar_proc_args_t *procargs);
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_proc_args_destroy(sigar_t *sigar,
|
|
|
|
sigar_proc_args_t *procargs);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
void *data; /* user data */
|
|
|
|
|
|
|
|
enum {
|
|
|
|
SIGAR_PROC_ENV_ALL,
|
|
|
|
SIGAR_PROC_ENV_KEY
|
|
|
|
} type;
|
|
|
|
|
|
|
|
/* used for SIGAR_PROC_ENV_KEY */
|
|
|
|
const char *key;
|
|
|
|
int klen;
|
|
|
|
|
|
|
|
int (*env_getter)(void *, const char *, int, char *, int);
|
|
|
|
} sigar_proc_env_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_proc_env_get(sigar_t *sigar, sigar_pid_t pid,
|
|
|
|
sigar_proc_env_t *procenv);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
sigar_uint64_t total;
|
|
|
|
/* XXX - which are files, sockets, etc. */
|
|
|
|
} sigar_proc_fd_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_proc_fd_get(sigar_t *sigar, sigar_pid_t pid,
|
|
|
|
sigar_proc_fd_t *procfd);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char name[SIGAR_PATH_MAX+1];
|
|
|
|
char cwd[SIGAR_PATH_MAX+1];
|
|
|
|
char root[SIGAR_PATH_MAX+1];
|
|
|
|
} sigar_proc_exe_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_proc_exe_get(sigar_t *sigar, sigar_pid_t pid,
|
|
|
|
sigar_proc_exe_t *procexe);
|
|
|
|
|
2004-06-22 14:11:38 +08:00
|
|
|
typedef struct {
|
|
|
|
void *data; /* user data */
|
|
|
|
|
|
|
|
int (*module_getter)(void *, char *, int);
|
|
|
|
} sigar_proc_modules_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_proc_modules_get(sigar_t *sigar, sigar_pid_t pid,
|
|
|
|
sigar_proc_modules_t *procmods);
|
|
|
|
|
2004-11-17 12:55:31 +08:00
|
|
|
typedef struct {
|
|
|
|
sigar_uint64_t user;
|
|
|
|
sigar_uint64_t sys;
|
|
|
|
sigar_uint64_t total;
|
|
|
|
} sigar_thread_cpu_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_thread_cpu_get(sigar_t *sigar,
|
|
|
|
sigar_uint64_t id,
|
|
|
|
sigar_thread_cpu_t *cpu);
|
|
|
|
|
2004-06-22 06:37:04 +08:00
|
|
|
typedef enum {
|
|
|
|
SIGAR_FSTYPE_UNKNOWN,
|
|
|
|
SIGAR_FSTYPE_NONE,
|
|
|
|
SIGAR_FSTYPE_LOCAL_DISK,
|
|
|
|
SIGAR_FSTYPE_NETWORK,
|
|
|
|
SIGAR_FSTYPE_RAM_DISK,
|
|
|
|
SIGAR_FSTYPE_CDROM,
|
|
|
|
SIGAR_FSTYPE_SWAP,
|
|
|
|
SIGAR_FSTYPE_MAX
|
|
|
|
} sigar_file_system_type_e;
|
|
|
|
|
|
|
|
#define SIGAR_FS_NAME_LEN 64
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char dir_name[SIGAR_FS_NAME_LEN];
|
|
|
|
char dev_name[SIGAR_FS_NAME_LEN];
|
|
|
|
char type_name[SIGAR_FS_NAME_LEN]; /* e.g. "local" */
|
|
|
|
char sys_type_name[SIGAR_FS_NAME_LEN]; /* e.g. "ext3" */
|
|
|
|
sigar_file_system_type_e type;
|
|
|
|
unsigned long flags;
|
|
|
|
} sigar_file_system_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned long number;
|
|
|
|
unsigned long size;
|
|
|
|
sigar_file_system_t *data;
|
|
|
|
} sigar_file_system_list_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int)
|
|
|
|
sigar_file_system_list_get(sigar_t *sigar,
|
|
|
|
sigar_file_system_list_t *fslist);
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int)
|
|
|
|
sigar_file_system_list_destroy(sigar_t *sigar,
|
|
|
|
sigar_file_system_list_t *fslist);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
sigar_uint64_t
|
|
|
|
total,
|
|
|
|
free,
|
2005-04-27 03:55:21 +08:00
|
|
|
used,
|
2004-06-22 06:37:04 +08:00
|
|
|
avail,
|
|
|
|
files,
|
2004-12-05 09:18:57 +08:00
|
|
|
free_files,
|
|
|
|
disk_reads,
|
2005-04-07 09:23:17 +08:00
|
|
|
disk_writes,
|
|
|
|
disk_write_bytes,
|
|
|
|
disk_read_bytes,
|
|
|
|
disk_queue;
|
2004-06-22 06:37:04 +08:00
|
|
|
double use_percent;
|
|
|
|
} sigar_file_system_usage_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int)
|
|
|
|
sigar_file_system_usage_get(sigar_t *sigar,
|
|
|
|
const char *dirname,
|
|
|
|
sigar_file_system_usage_t *fsusage);
|
|
|
|
|
2007-05-17 14:12:54 +08:00
|
|
|
SIGAR_DECLARE(int)
|
|
|
|
sigar_file_system_ping(sigar_t *sigar,
|
|
|
|
sigar_file_system_t *fs);
|
|
|
|
|
2006-07-05 00:35:27 +08:00
|
|
|
typedef struct {
|
|
|
|
enum {
|
|
|
|
SIGAR_AF_UNSPEC,
|
|
|
|
SIGAR_AF_INET,
|
2006-07-06 05:12:10 +08:00
|
|
|
SIGAR_AF_INET6,
|
|
|
|
SIGAR_AF_LINK
|
2006-07-05 00:35:27 +08:00
|
|
|
} family;
|
|
|
|
union {
|
|
|
|
sigar_uint32_t in;
|
|
|
|
sigar_uint32_t in6[4];
|
2006-07-06 05:12:10 +08:00
|
|
|
unsigned char mac[8];
|
2006-07-05 00:35:27 +08:00
|
|
|
} addr;
|
|
|
|
} sigar_net_address_t;
|
|
|
|
|
2006-10-20 04:10:13 +08:00
|
|
|
#define SIGAR_INET6_ADDRSTRLEN 46
|
2005-07-12 04:20:56 +08:00
|
|
|
|
|
|
|
#define SIGAR_MAXDOMAINNAMELEN 256
|
2005-07-12 06:43:56 +08:00
|
|
|
#define SIGAR_MAXHOSTNAMELEN 256
|
2005-07-12 04:20:56 +08:00
|
|
|
|
|
|
|
typedef struct {
|
2006-10-20 04:10:13 +08:00
|
|
|
char default_gateway[SIGAR_INET6_ADDRSTRLEN];
|
2005-07-12 06:43:56 +08:00
|
|
|
char host_name[SIGAR_MAXHOSTNAMELEN];
|
2005-07-12 04:41:57 +08:00
|
|
|
char domain_name[SIGAR_MAXDOMAINNAMELEN];
|
2006-10-20 04:10:13 +08:00
|
|
|
char primary_dns[SIGAR_INET6_ADDRSTRLEN];
|
|
|
|
char secondary_dns[SIGAR_INET6_ADDRSTRLEN];
|
2005-07-12 04:20:56 +08:00
|
|
|
} sigar_net_info_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int)
|
|
|
|
sigar_net_info_get(sigar_t *sigar,
|
|
|
|
sigar_net_info_t *netinfo);
|
|
|
|
|
2005-07-13 02:40:38 +08:00
|
|
|
#define SIGAR_RTF_UP 0x1
|
|
|
|
#define SIGAR_RTF_GATEWAY 0x2
|
|
|
|
#define SIGAR_RTF_HOST 0x4
|
|
|
|
|
2004-06-22 06:37:04 +08:00
|
|
|
typedef struct {
|
2006-07-05 03:22:05 +08:00
|
|
|
sigar_net_address_t destination;
|
|
|
|
sigar_net_address_t gateway;
|
|
|
|
sigar_net_address_t mask;
|
2004-06-22 06:37:04 +08:00
|
|
|
sigar_uint64_t
|
|
|
|
flags,
|
|
|
|
refcnt,
|
|
|
|
use,
|
|
|
|
metric,
|
|
|
|
mtu,
|
|
|
|
window,
|
|
|
|
irtt;
|
|
|
|
char ifname[16];
|
|
|
|
} sigar_net_route_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned long number;
|
|
|
|
unsigned long size;
|
|
|
|
sigar_net_route_t *data;
|
|
|
|
} sigar_net_route_list_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_net_route_list_get(sigar_t *sigar,
|
|
|
|
sigar_net_route_list_t *routelist);
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_net_route_list_destroy(sigar_t *sigar,
|
|
|
|
sigar_net_route_list_t *routelist);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* platforms define most of these "standard" flags,
|
|
|
|
* but of course, with different values in some cases.
|
|
|
|
*/
|
|
|
|
#define SIGAR_IFF_UP 0x1
|
|
|
|
#define SIGAR_IFF_BROADCAST 0x2
|
|
|
|
#define SIGAR_IFF_DEBUG 0x4
|
|
|
|
#define SIGAR_IFF_LOOPBACK 0x8
|
|
|
|
#define SIGAR_IFF_POINTOPOINT 0x10
|
|
|
|
#define SIGAR_IFF_NOTRAILERS 0x20
|
|
|
|
#define SIGAR_IFF_RUNNING 0x40
|
|
|
|
#define SIGAR_IFF_NOARP 0x80
|
|
|
|
#define SIGAR_IFF_PROMISC 0x100
|
|
|
|
#define SIGAR_IFF_ALLMULTI 0x200
|
|
|
|
#define SIGAR_IFF_MULTICAST 0x800
|
2005-11-19 02:26:52 +08:00
|
|
|
#define SIGAR_IFF_SLAVE 0x1000
|
2004-06-22 06:37:04 +08:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char name[16];
|
2005-11-19 02:07:35 +08:00
|
|
|
char type[64];
|
2006-03-05 06:28:09 +08:00
|
|
|
char description[256];
|
2006-07-06 05:12:10 +08:00
|
|
|
sigar_net_address_t hwaddr;
|
2006-07-05 01:32:08 +08:00
|
|
|
sigar_net_address_t address;
|
|
|
|
sigar_net_address_t destination;
|
|
|
|
sigar_net_address_t broadcast;
|
|
|
|
sigar_net_address_t netmask;
|
2004-06-22 06:37:04 +08:00
|
|
|
sigar_uint64_t
|
|
|
|
flags,
|
|
|
|
mtu,
|
2006-03-07 08:59:03 +08:00
|
|
|
metric;
|
2004-06-22 06:37:04 +08:00
|
|
|
} sigar_net_interface_config_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int)
|
|
|
|
sigar_net_interface_config_get(sigar_t *sigar,
|
|
|
|
const char *name,
|
|
|
|
sigar_net_interface_config_t *ifconfig);
|
|
|
|
|
2007-03-13 11:49:08 +08:00
|
|
|
SIGAR_DECLARE(int)
|
|
|
|
sigar_net_interface_config_primary_get(sigar_t *sigar,
|
|
|
|
sigar_net_interface_config_t *ifconfig);
|
|
|
|
|
2004-06-22 06:37:04 +08:00
|
|
|
typedef struct {
|
|
|
|
sigar_uint64_t
|
|
|
|
/* received */
|
|
|
|
rx_packets,
|
|
|
|
rx_bytes,
|
|
|
|
rx_errors,
|
|
|
|
rx_dropped,
|
|
|
|
rx_overruns,
|
|
|
|
rx_frame,
|
|
|
|
/* transmitted */
|
|
|
|
tx_packets,
|
|
|
|
tx_bytes,
|
|
|
|
tx_errors,
|
|
|
|
tx_dropped,
|
|
|
|
tx_overruns,
|
|
|
|
tx_collisions,
|
2006-03-07 09:08:23 +08:00
|
|
|
tx_carrier,
|
|
|
|
speed;
|
2004-06-22 06:37:04 +08:00
|
|
|
} sigar_net_interface_stat_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int)
|
|
|
|
sigar_net_interface_stat_get(sigar_t *sigar,
|
|
|
|
const char *name,
|
|
|
|
sigar_net_interface_stat_t *ifstat);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned long number;
|
|
|
|
unsigned long size;
|
|
|
|
char **data;
|
|
|
|
} sigar_net_interface_list_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int)
|
|
|
|
sigar_net_interface_list_get(sigar_t *sigar,
|
|
|
|
sigar_net_interface_list_t *iflist);
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int)
|
|
|
|
sigar_net_interface_list_destroy(sigar_t *sigar,
|
|
|
|
sigar_net_interface_list_t *iflist);
|
|
|
|
|
|
|
|
#define SIGAR_NETCONN_CLIENT 0x01
|
|
|
|
#define SIGAR_NETCONN_SERVER 0x02
|
|
|
|
|
|
|
|
#define SIGAR_NETCONN_TCP 0x10
|
|
|
|
#define SIGAR_NETCONN_UDP 0x20
|
|
|
|
#define SIGAR_NETCONN_RAW 0x40
|
|
|
|
#define SIGAR_NETCONN_UNIX 0x80
|
|
|
|
|
2005-03-11 12:44:26 +08:00
|
|
|
enum {
|
|
|
|
SIGAR_TCP_ESTABLISHED = 1,
|
|
|
|
SIGAR_TCP_SYN_SENT,
|
|
|
|
SIGAR_TCP_SYN_RECV,
|
|
|
|
SIGAR_TCP_FIN_WAIT1,
|
|
|
|
SIGAR_TCP_FIN_WAIT2,
|
|
|
|
SIGAR_TCP_TIME_WAIT,
|
|
|
|
SIGAR_TCP_CLOSE,
|
|
|
|
SIGAR_TCP_CLOSE_WAIT,
|
|
|
|
SIGAR_TCP_LAST_ACK,
|
|
|
|
SIGAR_TCP_LISTEN,
|
2005-03-12 01:11:07 +08:00
|
|
|
SIGAR_TCP_CLOSING,
|
2005-03-12 10:17:20 +08:00
|
|
|
SIGAR_TCP_IDLE,
|
|
|
|
SIGAR_TCP_BOUND,
|
2005-03-12 01:11:07 +08:00
|
|
|
SIGAR_TCP_UNKNOWN
|
2005-03-11 12:44:26 +08:00
|
|
|
};
|
|
|
|
|
2004-06-22 06:37:04 +08:00
|
|
|
typedef struct {
|
|
|
|
unsigned long local_port;
|
2006-07-05 00:35:27 +08:00
|
|
|
sigar_net_address_t local_address;
|
2004-06-22 06:37:04 +08:00
|
|
|
unsigned long remote_port;
|
2006-07-05 00:35:27 +08:00
|
|
|
sigar_net_address_t remote_address;
|
2004-06-22 06:37:04 +08:00
|
|
|
sigar_uid_t uid;
|
|
|
|
unsigned long inode;
|
|
|
|
int type;
|
2005-03-12 00:59:43 +08:00
|
|
|
int state;
|
2005-03-12 12:12:15 +08:00
|
|
|
unsigned long send_queue;
|
|
|
|
unsigned long receive_queue;
|
2004-06-22 06:37:04 +08:00
|
|
|
} sigar_net_connection_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned long number;
|
|
|
|
unsigned long size;
|
|
|
|
sigar_net_connection_t *data;
|
|
|
|
} sigar_net_connection_list_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int)
|
|
|
|
sigar_net_connection_list_get(sigar_t *sigar,
|
|
|
|
sigar_net_connection_list_t *connlist,
|
|
|
|
int flags);
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int)
|
|
|
|
sigar_net_connection_list_destroy(sigar_t *sigar,
|
|
|
|
sigar_net_connection_list_t *connlist);
|
|
|
|
|
2006-06-16 04:50:00 +08:00
|
|
|
typedef struct sigar_net_connection_walker_t sigar_net_connection_walker_t;
|
|
|
|
|
|
|
|
/* alternative to sigar_net_connection_list_get */
|
|
|
|
struct sigar_net_connection_walker_t {
|
|
|
|
sigar_t *sigar;
|
|
|
|
int flags;
|
|
|
|
void *data; /* user data */
|
|
|
|
int (*add_connection)(sigar_net_connection_walker_t *walker,
|
|
|
|
sigar_net_connection_t *connection);
|
|
|
|
};
|
|
|
|
|
2006-06-20 08:27:58 +08:00
|
|
|
SIGAR_DECLARE(int)
|
|
|
|
sigar_net_connection_walk(sigar_net_connection_walker_t *walker);
|
|
|
|
|
2006-06-20 08:17:59 +08:00
|
|
|
typedef struct {
|
|
|
|
int tcp_states[SIGAR_TCP_UNKNOWN];
|
2006-07-11 04:04:41 +08:00
|
|
|
sigar_uint32_t tcp_inbound_total;
|
|
|
|
sigar_uint32_t tcp_outbound_total;
|
2007-04-06 13:05:37 +08:00
|
|
|
sigar_uint32_t all_inbound_total;
|
|
|
|
sigar_uint32_t all_outbound_total;
|
2006-06-20 08:17:59 +08:00
|
|
|
} sigar_net_stat_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int)
|
|
|
|
sigar_net_stat_get(sigar_t *sigar,
|
|
|
|
sigar_net_stat_t *netstat,
|
|
|
|
int flags);
|
2007-04-06 13:05:37 +08:00
|
|
|
|
|
|
|
SIGAR_DECLARE(int)
|
|
|
|
sigar_net_stat_port_get(sigar_t *sigar,
|
|
|
|
sigar_net_stat_t *netstat,
|
|
|
|
int flags,
|
|
|
|
sigar_net_address_t *address,
|
|
|
|
unsigned long port);
|
|
|
|
|
2007-07-15 00:01:58 +08:00
|
|
|
/* TCP-MIB */
|
|
|
|
typedef struct {
|
|
|
|
sigar_uint32_t max_conn;
|
|
|
|
sigar_uint64_t active_opens;
|
|
|
|
sigar_uint64_t passive_opens;
|
|
|
|
sigar_uint64_t attempt_fails;
|
|
|
|
sigar_uint64_t estab_resets;
|
|
|
|
sigar_uint64_t curr_estab;
|
|
|
|
sigar_uint64_t in_segs;
|
|
|
|
sigar_uint64_t out_segs;
|
|
|
|
sigar_uint64_t retrans_segs;
|
|
|
|
sigar_uint64_t out_rsts;
|
|
|
|
} sigar_tcp_stat_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int)
|
|
|
|
sigar_tcp_stat_get(sigar_t *sigar,
|
|
|
|
sigar_tcp_stat_t *tcpstat);
|
|
|
|
|
2007-04-06 21:39:25 +08:00
|
|
|
SIGAR_DECLARE(int)
|
|
|
|
sigar_net_listen_address_get(sigar_t *sigar,
|
|
|
|
unsigned long port,
|
|
|
|
sigar_net_address_t *address);
|
2007-04-06 20:50:05 +08:00
|
|
|
|
2005-02-22 09:50:16 +08:00
|
|
|
typedef struct {
|
|
|
|
char user[32];
|
|
|
|
char device[32];
|
|
|
|
char host[256];
|
|
|
|
sigar_uint64_t time;
|
|
|
|
} sigar_who_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned long number;
|
|
|
|
unsigned long size;
|
|
|
|
sigar_who_t *data;
|
|
|
|
} sigar_who_list_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_who_list_get(sigar_t *sigar,
|
|
|
|
sigar_who_list_t *wholist);
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_who_list_destroy(sigar_t *sigar,
|
|
|
|
sigar_who_list_t *wholist);
|
|
|
|
|
2005-03-16 10:44:52 +08:00
|
|
|
SIGAR_DECLARE(int) sigar_proc_port_get(sigar_t *sigar,
|
|
|
|
int protocol, unsigned long port,
|
2004-06-22 06:37:04 +08:00
|
|
|
sigar_pid_t *pid);
|
|
|
|
|
2005-12-15 07:41:01 +08:00
|
|
|
typedef struct {
|
|
|
|
const char *build_date;
|
|
|
|
const char *version;
|
|
|
|
const char *archname;
|
2005-12-15 07:48:28 +08:00
|
|
|
const char *archlib;
|
|
|
|
const char *binname;
|
2006-07-14 05:56:06 +08:00
|
|
|
int major, minor, maint, build;
|
2005-12-15 07:41:01 +08:00
|
|
|
} sigar_version_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(sigar_version_t *) sigar_version_get(void);
|
|
|
|
|
2006-09-25 02:23:04 +08:00
|
|
|
#define SIGAR_SYS_INFO_LEN SIGAR_MAXHOSTNAMELEN /* more than enough */
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char name[SIGAR_SYS_INFO_LEN]; /* canonicalized sysname */
|
|
|
|
char version[SIGAR_SYS_INFO_LEN]; /* utsname.release */
|
|
|
|
char arch[SIGAR_SYS_INFO_LEN];
|
2006-09-25 09:47:33 +08:00
|
|
|
char machine[SIGAR_SYS_INFO_LEN];
|
2006-09-25 02:23:04 +08:00
|
|
|
char description[SIGAR_SYS_INFO_LEN];
|
|
|
|
char patch_level[SIGAR_SYS_INFO_LEN];
|
|
|
|
char vendor[SIGAR_SYS_INFO_LEN];
|
|
|
|
char vendor_version[SIGAR_SYS_INFO_LEN];
|
|
|
|
char vendor_name[SIGAR_SYS_INFO_LEN]; /* utsname.sysname */
|
|
|
|
char vendor_code_name[SIGAR_SYS_INFO_LEN];
|
|
|
|
} sigar_sys_info_t;
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_sys_info_get(sigar_t *sigar, sigar_sys_info_t *sysinfo);
|
|
|
|
|
2004-06-22 06:37:04 +08:00
|
|
|
#define SIGAR_FQDN_LEN 512
|
|
|
|
|
|
|
|
SIGAR_DECLARE(int) sigar_fqdn_get(sigar_t *sigar, char *name, int namelen);
|
|
|
|
|
2006-02-27 07:31:07 +08:00
|
|
|
SIGAR_DECLARE(int) sigar_rpc_ping(char *hostname,
|
|
|
|
int protocol,
|
|
|
|
unsigned long program,
|
|
|
|
unsigned long version);
|
2005-02-21 09:50:34 +08:00
|
|
|
|
2006-02-27 09:47:41 +08:00
|
|
|
SIGAR_DECLARE(char *) sigar_rpc_strerror(int err);
|
|
|
|
|
2004-06-22 06:37:04 +08:00
|
|
|
SIGAR_DECLARE(char *) sigar_password_get(const char *prompt);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|