--- projects/libstatgrab/src/libstatgrab/statgrab.h 2003/10/20 15:25:47 1.14 +++ projects/libstatgrab/src/libstatgrab/statgrab.h 2004/04/06 22:09:22 1.37 @@ -1,26 +1,57 @@ -/* - * i-scream central monitoring system +/* + * i-scream libstatgrab * http://www.i-scream.org - * Copyright (C) 2000-2003 i-scream + * Copyright (C) 2000-2004 i-scream * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * This library 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. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser 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. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + * + * $Id: statgrab.h,v 1.37 2004/04/06 22:09:22 ats Exp $ */ #include -typedef struct{ +/* FIXME typedefs for 32/64-bit types */ +/* FIXME maybe tidy up field names? */ +/* FIXME tab/space damage */ +/* FIXME prefixes for util functions too */ +/* FIXME comments for less obvious fields */ + +int sg_init(void); +int sg_drop_privileges(void); + +typedef enum { + SG_ERROR_NONE = 0 +} sg_error; + +void sg_set_error(sg_error code, const char *arg); +sg_error sg_get_error(); +const char *sg_str_error(sg_error code); + +typedef struct { + char *os_name; + char *os_release; + char *os_version; + char *platform; + char *hostname; + time_t uptime; +} sg_host_info; + +sg_host_info *sg_get_host_info(); + +typedef struct { long long user; long long kernel; long long idle; @@ -29,9 +60,12 @@ typedef struct{ long long nice; long long total; time_t systime; -}cpu_states_t; +} sg_cpu_stats; -typedef struct{ +sg_cpu_stats *sg_get_cpu_stats(); +sg_cpu_stats *sg_get_cpu_stats_diff(); + +typedef struct { float user; float kernel; float idle; @@ -39,47 +73,41 @@ typedef struct{ float swap; float nice; time_t time_taken; -}cpu_percent_t; +} sg_cpu_percents; -typedef struct{ +sg_cpu_percents *sg_get_cpu_percents(); + +typedef struct { long long total; long long free; long long used; long long cache; -}mem_stat_t; +} sg_mem_stats; -typedef struct{ +sg_mem_stats *sg_get_mem_stats(); + +typedef struct { double min1; double min5; double min15; -}load_stat_t; +} sg_load_stats; -#ifdef SOLARIS -#define MAX_LOGIN_NAME_SIZE 8 -#endif -#if defined(LINUX) || defined(FREEBSD) -#define MAX_LOGIN_NAME_SIZE UT_NAMESIZE -#endif +sg_load_stats *sg_get_load_stats(); -typedef struct{ +typedef struct { char *name_list; int num_entries; -}user_stat_t; +} sg_user_stats; -typedef struct{ +sg_user_stats *sg_get_user_stats(); + +typedef struct { long long total; long long used; long long free; -}swap_stat_t; +} sg_swap_stats; -typedef struct{ - char *os_name; - char *os_release; - char *os_version; - char *platform; - char *hostname; - time_t uptime; -}general_stat_t; +sg_swap_stats *sg_get_swap_stats(); typedef struct { char *device_name; @@ -91,60 +119,101 @@ typedef struct { long long total_inodes; long long used_inodes; long long free_inodes; -}disk_stat_t; +} sg_fs_stats; -typedef struct{ +sg_fs_stats *sg_get_fs_stats(int *entries); + +typedef struct { char *disk_name; long long read_bytes; long long write_bytes; time_t systime; -}diskio_stat_t; +} sg_disk_io_stats; -typedef struct{ - int total; - int running; - int sleeping; - int stopped; - int zombie; -}process_stat_t; +sg_disk_io_stats *sg_get_disk_io_stats(int *entries); +sg_disk_io_stats *sg_get_disk_io_stats_diff(int *entries); -typedef struct{ +typedef struct { char *interface_name; long long tx; long long rx; + long long ipackets; + long long opackets; + long long ierrors; + long long oerrors; + long long collisions; time_t systime; -}network_stat_t; +} sg_network_io_stats; -typedef struct{ +sg_network_io_stats *sg_get_network_io_stats(int *entries); +sg_network_io_stats *sg_get_network_io_stats_diff(int *entries); + +typedef enum { + SG_IFACE_DUPLEX_FULL, + SG_IFACE_DUPLEX_HALF, + SG_IFACE_DUPLEX_UNKNOWN +} sg_iface_duplex; + +typedef struct { + char *interface_name; + int speed; /* In megabits/sec */ + sg_iface_duplex dup; + int up; +} sg_network_iface_stats; + +sg_network_iface_stats *sg_get_network_iface_stats(int *entries); + +typedef struct { long long pages_pagein; long long pages_pageout; time_t systime; -}page_stat_t; +} sg_page_stats; -cpu_states_t *get_cpu_totals(); -cpu_states_t *get_cpu_diff(); -cpu_percent_t *cpu_percent_usage(); +sg_page_stats *sg_get_page_stats(); +sg_page_stats *sg_get_page_stats_diff(); -mem_stat_t *get_memory_stats(); +typedef enum { + SG_PROCESS_STATE_RUNNING, + SG_PROCESS_STATE_SLEEPING, + SG_PROCESS_STATE_STOPPED, + SG_PROCESS_STATE_ZOMBIE, + SG_PROCESS_STATE_UNKNOWN +} sg_process_state; -load_stat_t *get_load_stats(); +typedef struct { + char *process_name; + char *proctitle; -user_stat_t *get_user_stats(); + pid_t pid; + pid_t parent; /* Parent pid */ + pid_t pgid; /* process id of process group leader */ -swap_stat_t *get_swap_stats(); + uid_t uid; + uid_t euid; + gid_t gid; + gid_t egid; -general_stat_t *get_general_stats(); + unsigned long long proc_size; /* in bytes */ + unsigned long long proc_resident; /* in bytes */ + time_t time_spent; /* time running in seconds */ + double cpu_percent; + int nice; + sg_process_state state; +} sg_process_stats; -disk_stat_t *get_disk_stats(int *entries); -diskio_stat_t *get_diskio_stats(int *entries); -diskio_stat_t *get_diskio_stats_diff(int *entries); +sg_process_stats *sg_get_process_stats(int *entries); -process_stat_t *get_process_stats(); +typedef struct { + int total; + int running; + int sleeping; + int stopped; + int zombie; +} sg_process_count; -network_stat_t *get_network_stats(int *entries); -network_stat_t *get_network_stats_diff(int *entries); +sg_process_count *sg_get_process_count(); -page_stat_t *get_page_stats(); -page_stat_t *get_page_stats_diff(); +#ifdef SG_ENABLE_DEPRECATED +#include +#endif -int statgrab_init(void);