--- projects/libstatgrab/src/libstatgrab/statgrab.h 2003/11/10 21:07:04 1.16 +++ projects/libstatgrab/src/libstatgrab/statgrab.h 2004/03/28 18:07:30 1.30 @@ -1,30 +1,27 @@ -/* +/* * i-scream central monitoring system * 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.30 2004/03/28 18:07:30 pajs Exp $ */ #include -#ifdef NETBSD -#include -#endif -#ifdef CYGWIN -#include -#endif typedef struct{ long long user; @@ -60,20 +57,6 @@ typedef struct{ double min15; }load_stat_t; -#ifdef SOLARIS -#define MAX_LOGIN_NAME_SIZE 8 -#endif -#if defined(LINUX) || defined(FREEBSD) -#if defined(CYGWIN) -#define MAX_LOGIN_NAME_SIZE _SC_LOGIN_NAME_MAX -#else -#define MAX_LOGIN_NAME_SIZE UT_NAMESIZE -#endif -#endif -#ifdef NETBSD -#define MAX_LOGIN_NAME_SIZE _POSIX_LOGIN_NAME_MAX -#endif - typedef struct{ char *name_list; int num_entries; @@ -125,15 +108,63 @@ 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; +typedef enum{ + FULL_DUPLEX, + HALF_DUPLEX, + UNKNOWN_DUPLEX +}statgrab_duplex; + typedef struct{ + char *interface_name; + int speed; /* In megabits/sec */ + statgrab_duplex dup; + int up; +}network_iface_stat_t; + +typedef struct{ long long pages_pagein; long long pages_pageout; time_t systime; }page_stat_t; +typedef enum{ + RUNNING, + SLEEPING, + STOPPED, + ZOMBIE +}process_status; + +typedef struct{ + char *process_name; + char *proctitle; + + pid_t pid; + pid_t parent; /* Parent pid */ + pid_t pgid; /* process id of process group leader */ + + uid_t uid; + uid_t euid; + gid_t gid; + gid_t egid; + + unsigned long long proc_size; /* in bytes */ + unsigned long long proc_resident; /* in bytes */ + time_t time_spent; + double cpu_percent; + int nice; + process_status state; +}proc_state_t; + +int get_proc_snapshot(proc_state_t **proc_state); + cpu_states_t *get_cpu_totals(); cpu_states_t *get_cpu_diff(); cpu_percent_t *cpu_percent_usage(); @@ -157,7 +188,11 @@ process_stat_t *get_process_stats(); network_stat_t *get_network_stats(int *entries); network_stat_t *get_network_stats_diff(int *entries); +network_iface_stat_t *get_network_iface_stats(int *entries); + page_stat_t *get_page_stats(); page_stat_t *get_page_stats_diff(); int statgrab_init(void); +int statgrab_drop_privileges(void); +