hyperic-sigar 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/COPYING +339 -0
- data/EXCEPTIONS +104 -0
- data/README +2 -0
- data/Rakefile +87 -0
- data/bindings/SigarWrapper.pm +2934 -0
- data/bindings/ruby/examples/cpu_info.rb +16 -0
- data/bindings/ruby/examples/df.rb +32 -0
- data/bindings/ruby/examples/free.rb +19 -0
- data/bindings/ruby/examples/ifconfig.rb +67 -0
- data/bindings/ruby/examples/netstat.rb +54 -0
- data/bindings/ruby/examples/pargs.rb +18 -0
- data/bindings/ruby/examples/penv.rb +14 -0
- data/bindings/ruby/examples/route.rb +31 -0
- data/bindings/ruby/examples/who.rb +13 -0
- data/bindings/ruby/extconf.rb +110 -0
- data/bindings/ruby/rbsigar.c +628 -0
- data/include/sigar.h +901 -0
- data/include/sigar_fileinfo.h +141 -0
- data/include/sigar_format.h +65 -0
- data/include/sigar_getline.h +18 -0
- data/include/sigar_log.h +82 -0
- data/include/sigar_private.h +365 -0
- data/include/sigar_ptql.h +55 -0
- data/include/sigar_util.h +192 -0
- data/src/os/aix/aix_sigar.c +1927 -0
- data/src/os/aix/sigar_os.h +71 -0
- data/src/os/darwin/darwin_sigar.c +3450 -0
- data/src/os/darwin/sigar_os.h +82 -0
- data/src/os/hpux/dlpi.c +284 -0
- data/src/os/hpux/hpux_sigar.c +1205 -0
- data/src/os/hpux/sigar_os.h +51 -0
- data/src/os/linux/linux_sigar.c +2595 -0
- data/src/os/linux/sigar_os.h +84 -0
- data/src/os/netware/netware_sigar.c +719 -0
- data/src/os/netware/sigar_os.h +26 -0
- data/src/os/osf1/osf1_sigar.c +593 -0
- data/src/os/osf1/sigar_os.h +42 -0
- data/src/os/solaris/get_mib2.c +321 -0
- data/src/os/solaris/get_mib2.h +127 -0
- data/src/os/solaris/hmekstat.h +77 -0
- data/src/os/solaris/kstats.c +182 -0
- data/src/os/solaris/procfs.c +99 -0
- data/src/os/solaris/sigar_os.h +225 -0
- data/src/os/solaris/solaris_sigar.c +2561 -0
- data/src/os/stub/sigar_os.h +8 -0
- data/src/os/stub/stub_sigar.c +303 -0
- data/src/os/win32/peb.c +213 -0
- data/src/os/win32/sigar_os.h +623 -0
- data/src/os/win32/sigar_pdh.h +49 -0
- data/src/os/win32/win32_sigar.c +3718 -0
- data/src/sigar.c +2292 -0
- data/src/sigar_cache.c +181 -0
- data/src/sigar_fileinfo.c +792 -0
- data/src/sigar_format.c +649 -0
- data/src/sigar_getline.c +1849 -0
- data/src/sigar_ptql.c +1966 -0
- data/src/sigar_signal.c +218 -0
- data/src/sigar_util.c +1061 -0
- data/version.properties +11 -0
- metadata +112 -0
@@ -0,0 +1,141 @@
|
|
1
|
+
/* ====================================================================
|
2
|
+
* The Apache Software License, Version 1.1
|
3
|
+
*
|
4
|
+
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
|
5
|
+
* reserved.
|
6
|
+
*
|
7
|
+
* Redistribution and use in source and binary forms, with or without
|
8
|
+
* modification, are permitted provided that the following conditions
|
9
|
+
* are met:
|
10
|
+
*
|
11
|
+
* 1. Redistributions of source code must retain the above copyright
|
12
|
+
* notice, this list of conditions and the following disclaimer.
|
13
|
+
*
|
14
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
15
|
+
* notice, this list of conditions and the following disclaimer in
|
16
|
+
* the documentation and/or other materials provided with the
|
17
|
+
* distribution.
|
18
|
+
*
|
19
|
+
* 3. The end-user documentation included with the redistribution,
|
20
|
+
* if any, must include the following acknowledgment:
|
21
|
+
* "This product includes software developed by the
|
22
|
+
* Apache Software Foundation (http://www.apache.org/)."
|
23
|
+
* Alternately, this acknowledgment may appear in the software itself,
|
24
|
+
* if and wherever such third-party acknowledgments normally appear.
|
25
|
+
*
|
26
|
+
* 4. The names "Apache" and "Apache Software Foundation" must
|
27
|
+
* not be used to endorse or promote products derived from this
|
28
|
+
* software without prior written permission. For written
|
29
|
+
* permission, please contact apache@apache.org.
|
30
|
+
*
|
31
|
+
* 5. Products derived from this software may not be called "Apache",
|
32
|
+
* nor may "Apache" appear in their name, without prior written
|
33
|
+
* permission of the Apache Software Foundation.
|
34
|
+
*
|
35
|
+
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
36
|
+
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
37
|
+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
38
|
+
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
39
|
+
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
40
|
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
41
|
+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
42
|
+
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
43
|
+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
44
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
45
|
+
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
46
|
+
* SUCH DAMAGE.
|
47
|
+
* ====================================================================
|
48
|
+
*
|
49
|
+
* This software consists of voluntary contributions made by many
|
50
|
+
* individuals on behalf of the Apache Software Foundation. For more
|
51
|
+
* information on the Apache Software Foundation, please see
|
52
|
+
* <http://www.apache.org/>.
|
53
|
+
*/
|
54
|
+
|
55
|
+
#include "sigar.h"
|
56
|
+
|
57
|
+
typedef enum {
|
58
|
+
SIGAR_FILETYPE_NOFILE = 0, /**< no file type determined */
|
59
|
+
SIGAR_FILETYPE_REG, /**< a regular file */
|
60
|
+
SIGAR_FILETYPE_DIR, /**< a directory */
|
61
|
+
SIGAR_FILETYPE_CHR, /**< a character device */
|
62
|
+
SIGAR_FILETYPE_BLK, /**< a block device */
|
63
|
+
SIGAR_FILETYPE_PIPE, /**< a FIFO / pipe */
|
64
|
+
SIGAR_FILETYPE_LNK, /**< a symbolic link */
|
65
|
+
SIGAR_FILETYPE_SOCK, /**< a [unix domain] socket */
|
66
|
+
SIGAR_FILETYPE_UNKFILE /**< a file of some other unknown type */
|
67
|
+
} sigar_file_type_e;
|
68
|
+
|
69
|
+
#define SIGAR_UREAD 0x0400 /**< Read by user */
|
70
|
+
#define SIGAR_UWRITE 0x0200 /**< Write by user */
|
71
|
+
#define SIGAR_UEXECUTE 0x0100 /**< Execute by user */
|
72
|
+
|
73
|
+
#define SIGAR_GREAD 0x0040 /**< Read by group */
|
74
|
+
#define SIGAR_GWRITE 0x0020 /**< Write by group */
|
75
|
+
#define SIGAR_GEXECUTE 0x0010 /**< Execute by group */
|
76
|
+
|
77
|
+
#define SIGAR_WREAD 0x0004 /**< Read by others */
|
78
|
+
#define SIGAR_WWRITE 0x0002 /**< Write by others */
|
79
|
+
#define SIGAR_WEXECUTE 0x0001 /**< Execute by others */
|
80
|
+
|
81
|
+
typedef struct {
|
82
|
+
/** The access permissions of the file. Mimics Unix access rights. */
|
83
|
+
sigar_uint64_t permissions;
|
84
|
+
sigar_file_type_e type;
|
85
|
+
/** The user id that owns the file */
|
86
|
+
sigar_uid_t uid;
|
87
|
+
/** The group id that owns the file */
|
88
|
+
sigar_gid_t gid;
|
89
|
+
/** The inode of the file. */
|
90
|
+
sigar_uint64_t inode;
|
91
|
+
/** The id of the device the file is on. */
|
92
|
+
sigar_uint64_t device;
|
93
|
+
/** The number of hard links to the file. */
|
94
|
+
sigar_uint64_t nlink;
|
95
|
+
/** The size of the file */
|
96
|
+
sigar_uint64_t size;
|
97
|
+
/** The time the file was last accessed */
|
98
|
+
sigar_uint64_t atime;
|
99
|
+
/** The time the file was last modified */
|
100
|
+
sigar_uint64_t mtime;
|
101
|
+
/** The time the file was last changed */
|
102
|
+
sigar_uint64_t ctime;
|
103
|
+
} sigar_file_attrs_t;
|
104
|
+
|
105
|
+
typedef struct {
|
106
|
+
sigar_uint64_t total;
|
107
|
+
sigar_uint64_t files;
|
108
|
+
sigar_uint64_t subdirs;
|
109
|
+
sigar_uint64_t symlinks;
|
110
|
+
sigar_uint64_t chrdevs;
|
111
|
+
sigar_uint64_t blkdevs;
|
112
|
+
sigar_uint64_t sockets;
|
113
|
+
sigar_uint64_t disk_usage;
|
114
|
+
} sigar_dir_stat_t;
|
115
|
+
|
116
|
+
typedef sigar_dir_stat_t sigar_dir_usage_t;
|
117
|
+
|
118
|
+
SIGAR_DECLARE(const char *)
|
119
|
+
sigar_file_attrs_type_string_get(sigar_file_type_e type);
|
120
|
+
|
121
|
+
SIGAR_DECLARE(int) sigar_file_attrs_get(sigar_t *sigar,
|
122
|
+
const char *file,
|
123
|
+
sigar_file_attrs_t *fileattrs);
|
124
|
+
|
125
|
+
SIGAR_DECLARE(int) sigar_link_attrs_get(sigar_t *sigar,
|
126
|
+
const char *file,
|
127
|
+
sigar_file_attrs_t *fileattrs);
|
128
|
+
|
129
|
+
SIGAR_DECLARE(int)sigar_file_attrs_mode_get(sigar_uint64_t permissions);
|
130
|
+
|
131
|
+
SIGAR_DECLARE(char *)
|
132
|
+
sigar_file_attrs_permissions_string_get(sigar_uint64_t permissions,
|
133
|
+
char *str);
|
134
|
+
|
135
|
+
SIGAR_DECLARE(int) sigar_dir_stat_get(sigar_t *sigar,
|
136
|
+
const char *dir,
|
137
|
+
sigar_dir_stat_t *dirstats);
|
138
|
+
|
139
|
+
SIGAR_DECLARE(int) sigar_dir_usage_get(sigar_t *sigar,
|
140
|
+
const char *dir,
|
141
|
+
sigar_dir_usage_t *dirusage);
|
@@ -0,0 +1,65 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) [2004, 2005, 2006], Hyperic, Inc.
|
3
|
+
* This file is part of SIGAR.
|
4
|
+
*
|
5
|
+
* SIGAR is free software; you can redistribute it and/or modify
|
6
|
+
* it under the terms version 2 of the GNU General Public License as
|
7
|
+
* published by the Free Software Foundation. This program is distributed
|
8
|
+
* in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
9
|
+
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
10
|
+
* PARTICULAR PURPOSE. See the GNU General Public License for more
|
11
|
+
* details.
|
12
|
+
*
|
13
|
+
* You should have received a copy of the GNU General Public License
|
14
|
+
* along with this program; if not, write to the Free Software
|
15
|
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
16
|
+
* USA.
|
17
|
+
*/
|
18
|
+
|
19
|
+
#ifndef SIGAR_FORMAT_H
|
20
|
+
#define SIGAR_FORMAT_H
|
21
|
+
|
22
|
+
typedef struct {
|
23
|
+
double user;
|
24
|
+
double sys;
|
25
|
+
double nice;
|
26
|
+
double idle;
|
27
|
+
double wait;
|
28
|
+
double irq;
|
29
|
+
double soft_irq;
|
30
|
+
double stolen;
|
31
|
+
double combined;
|
32
|
+
} sigar_cpu_perc_t;
|
33
|
+
|
34
|
+
SIGAR_DECLARE(int) sigar_cpu_perc_calculate(sigar_cpu_t *prev,
|
35
|
+
sigar_cpu_t *curr,
|
36
|
+
sigar_cpu_perc_t *perc);
|
37
|
+
|
38
|
+
SIGAR_DECLARE(int) sigar_uptime_string(sigar_t *sigar,
|
39
|
+
sigar_uptime_t *uptime,
|
40
|
+
char *buffer,
|
41
|
+
int buflen);
|
42
|
+
|
43
|
+
SIGAR_DECLARE(char *) sigar_format_size(sigar_uint64_t size, char *buf);
|
44
|
+
|
45
|
+
SIGAR_DECLARE(int) sigar_net_address_equals(sigar_net_address_t *addr1,
|
46
|
+
sigar_net_address_t *addr2);
|
47
|
+
|
48
|
+
SIGAR_DECLARE(int) sigar_net_address_to_string(sigar_t *sigar,
|
49
|
+
sigar_net_address_t *address,
|
50
|
+
char *addr_str);
|
51
|
+
|
52
|
+
SIGAR_DECLARE(sigar_uint32_t) sigar_net_address_hash(sigar_net_address_t *address);
|
53
|
+
|
54
|
+
|
55
|
+
SIGAR_DECLARE(const char *)sigar_net_connection_type_get(int type);
|
56
|
+
|
57
|
+
SIGAR_DECLARE(const char *)sigar_net_connection_state_get(int state);
|
58
|
+
|
59
|
+
SIGAR_DECLARE(char *) sigar_net_interface_flags_to_string(sigar_uint64_t flags, char *buf);
|
60
|
+
|
61
|
+
SIGAR_DECLARE(char *)sigar_net_services_name_get(sigar_t *sigar,
|
62
|
+
int protocol, unsigned long port);
|
63
|
+
|
64
|
+
#endif
|
65
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#ifndef SIGAR_GETLINE_H
|
2
|
+
#define SIGAR_GETLINE_H
|
3
|
+
|
4
|
+
#include "sigar.h"
|
5
|
+
|
6
|
+
typedef int (*sigar_getline_completer_t)(char *, int, int *);
|
7
|
+
|
8
|
+
SIGAR_DECLARE(char *) sigar_getline(char *prompt);
|
9
|
+
SIGAR_DECLARE(void) sigar_getline_setwidth(int width);
|
10
|
+
SIGAR_DECLARE(void) sigar_getline_redraw(void);
|
11
|
+
SIGAR_DECLARE(void) sigar_getline_reset(void);
|
12
|
+
SIGAR_DECLARE(void) sigar_getline_windowchanged();
|
13
|
+
SIGAR_DECLARE(void) sigar_getline_histinit(char *file);
|
14
|
+
SIGAR_DECLARE(void) sigar_getline_histadd(char *buf);
|
15
|
+
SIGAR_DECLARE(int) sigar_getline_eof();
|
16
|
+
SIGAR_DECLARE(void) sigar_getline_completer_set(sigar_getline_completer_t func);
|
17
|
+
|
18
|
+
#endif /* SIGAR_GETLINE_H */
|
data/include/sigar_log.h
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) [2004, 2005, 2006], Hyperic, Inc.
|
3
|
+
* This file is part of SIGAR.
|
4
|
+
*
|
5
|
+
* SIGAR is free software; you can redistribute it and/or modify
|
6
|
+
* it under the terms version 2 of the GNU General Public License as
|
7
|
+
* published by the Free Software Foundation. This program is distributed
|
8
|
+
* in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
9
|
+
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
10
|
+
* PARTICULAR PURPOSE. See the GNU General Public License for more
|
11
|
+
* details.
|
12
|
+
*
|
13
|
+
* You should have received a copy of the GNU General Public License
|
14
|
+
* along with this program; if not, write to the Free Software
|
15
|
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
16
|
+
* USA.
|
17
|
+
*/
|
18
|
+
|
19
|
+
#ifndef SIGAR_LOG_H
|
20
|
+
#define SIGAR_LOG_H
|
21
|
+
|
22
|
+
#include <stdarg.h>
|
23
|
+
|
24
|
+
#define SIGAR_LOG_FATAL 0
|
25
|
+
#define SIGAR_LOG_ERROR 1
|
26
|
+
#define SIGAR_LOG_WARN 2
|
27
|
+
#define SIGAR_LOG_INFO 3
|
28
|
+
#define SIGAR_LOG_DEBUG 4
|
29
|
+
#define SIGAR_LOG_TRACE 5
|
30
|
+
|
31
|
+
#define SIGAR_LOG_IS_FATAL(sigar) \
|
32
|
+
(sigar->log_level >= SIGAR_LOG_FATAL)
|
33
|
+
|
34
|
+
#define SIGAR_LOG_IS_ERROR(sigar) \
|
35
|
+
(sigar->log_level >= SIGAR_LOG_ERROR)
|
36
|
+
|
37
|
+
#define SIGAR_LOG_IS_WARN(sigar) \
|
38
|
+
(sigar->log_level >= SIGAR_LOG_WARN)
|
39
|
+
|
40
|
+
#define SIGAR_LOG_IS_INFO(sigar) \
|
41
|
+
(sigar->log_level >= SIGAR_LOG_INFO)
|
42
|
+
|
43
|
+
#define SIGAR_LOG_IS_DEBUG(sigar) \
|
44
|
+
(sigar->log_level >= SIGAR_LOG_DEBUG)
|
45
|
+
|
46
|
+
#define SIGAR_LOG_IS_TRACE(sigar) \
|
47
|
+
(sigar->log_level >= SIGAR_LOG_TRACE)
|
48
|
+
|
49
|
+
#define SIGAR_STRINGIFY(n) #n
|
50
|
+
|
51
|
+
#define SIGAR_LOG_FILELINE \
|
52
|
+
__FILE__ ":" SIGAR_STRINGIFY(__LINE__)
|
53
|
+
|
54
|
+
#if defined(__GNUC__)
|
55
|
+
# if (__GNUC__ > 2)
|
56
|
+
# define SIGAR_FUNC __func__
|
57
|
+
# else
|
58
|
+
# define SIGAR_FUNC __FUNCTION__
|
59
|
+
# endif
|
60
|
+
#else
|
61
|
+
# define SIGAR_FUNC SIGAR_LOG_FILELINE
|
62
|
+
#endif
|
63
|
+
|
64
|
+
typedef void (*sigar_log_impl_t)(sigar_t *, void *, int, char *);
|
65
|
+
|
66
|
+
SIGAR_DECLARE(void) sigar_log_printf(sigar_t *sigar, int level,
|
67
|
+
const char *format, ...);
|
68
|
+
|
69
|
+
SIGAR_DECLARE(void) sigar_log(sigar_t *sigar, int level, char *message);
|
70
|
+
|
71
|
+
SIGAR_DECLARE(void) sigar_log_impl_set(sigar_t *sigar, void *data,
|
72
|
+
sigar_log_impl_t impl);
|
73
|
+
|
74
|
+
SIGAR_DECLARE(void) sigar_log_impl_file(sigar_t *sigar, void *data,
|
75
|
+
int level, char *message);
|
76
|
+
|
77
|
+
SIGAR_DECLARE(int) sigar_log_level_get(sigar_t *sigar);
|
78
|
+
|
79
|
+
SIGAR_DECLARE(void) sigar_log_level_set(sigar_t *sigar, int level);
|
80
|
+
|
81
|
+
|
82
|
+
#endif /* SIGAR_LOG_H */
|
@@ -0,0 +1,365 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) [2004, 2005, 2006], Hyperic, Inc.
|
3
|
+
* This file is part of SIGAR.
|
4
|
+
*
|
5
|
+
* SIGAR is free software; you can redistribute it and/or modify
|
6
|
+
* it under the terms version 2 of the GNU General Public License as
|
7
|
+
* published by the Free Software Foundation. This program is distributed
|
8
|
+
* in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
9
|
+
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
10
|
+
* PARTICULAR PURPOSE. See the GNU General Public License for more
|
11
|
+
* details.
|
12
|
+
*
|
13
|
+
* You should have received a copy of the GNU General Public License
|
14
|
+
* along with this program; if not, write to the Free Software
|
15
|
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
16
|
+
* USA.
|
17
|
+
*/
|
18
|
+
|
19
|
+
#ifndef SIGAR_PRIVATE_DOT_H
|
20
|
+
#define SIGAR_PRIVATE_DOT_H
|
21
|
+
|
22
|
+
#include "sigar_log.h"
|
23
|
+
#include "sigar_ptql.h"
|
24
|
+
|
25
|
+
#include <stdlib.h>
|
26
|
+
#include <string.h>
|
27
|
+
#include <ctype.h>
|
28
|
+
|
29
|
+
#ifndef WIN32
|
30
|
+
#include <unistd.h>
|
31
|
+
#include <stddef.h>
|
32
|
+
#ifndef DARWIN
|
33
|
+
#include <strings.h>
|
34
|
+
#endif
|
35
|
+
#endif
|
36
|
+
|
37
|
+
#ifdef DMALLOC
|
38
|
+
#define _MEMORY_H /* exclude memory.h on solaris */
|
39
|
+
#define DMALLOC_FUNC_CHECK
|
40
|
+
#include <dmalloc.h>
|
41
|
+
#endif
|
42
|
+
|
43
|
+
/* common to all os sigar_t's */
|
44
|
+
/* XXX: this is ugly; but don't want the same stuffs
|
45
|
+
* duplicated on 4 platforms and am too lazy to change
|
46
|
+
* sigar_t to the way it was originally where sigar_t was
|
47
|
+
* common and contained a sigar_os_t.
|
48
|
+
* feel free trav ;-)
|
49
|
+
*/
|
50
|
+
#define SIGAR_T_BASE \
|
51
|
+
int cpu_list_cores; \
|
52
|
+
int log_level; \
|
53
|
+
void *log_data; \
|
54
|
+
sigar_log_impl_t log_impl; \
|
55
|
+
void *ptql_re_data; \
|
56
|
+
sigar_ptql_re_impl_t ptql_re_impl; \
|
57
|
+
unsigned int ncpu; \
|
58
|
+
unsigned long version; \
|
59
|
+
unsigned long boot_time; \
|
60
|
+
int ticks; \
|
61
|
+
sigar_pid_t pid; \
|
62
|
+
char errbuf[256]; \
|
63
|
+
char *ifconf_buf; \
|
64
|
+
int ifconf_len; \
|
65
|
+
char *self_path; \
|
66
|
+
sigar_proc_list_t *pids; \
|
67
|
+
sigar_cache_t *fsdev; \
|
68
|
+
sigar_cache_t *proc_cpu; \
|
69
|
+
sigar_cache_t *net_listen; \
|
70
|
+
sigar_cache_t *net_services_tcp; \
|
71
|
+
sigar_cache_t *net_services_udp
|
72
|
+
|
73
|
+
#if defined(WIN32)
|
74
|
+
# define SIGAR_INLINE __inline
|
75
|
+
#elif defined(__GNUC__)
|
76
|
+
# define SIGAR_INLINE inline
|
77
|
+
#else
|
78
|
+
# define SIGAR_INLINE
|
79
|
+
#endif
|
80
|
+
|
81
|
+
#ifdef DMALLOC
|
82
|
+
/* linux has its own strdup macro, make sure we use dmalloc's */
|
83
|
+
#define sigar_strdup(s) \
|
84
|
+
dmalloc_strndup(__FILE__, __LINE__, (s), -1, 0)
|
85
|
+
#else
|
86
|
+
# ifdef WIN32
|
87
|
+
# define sigar_strdup(s) _strdup(s)
|
88
|
+
# else
|
89
|
+
# define sigar_strdup(s) strdup(s)
|
90
|
+
# endif
|
91
|
+
#endif
|
92
|
+
|
93
|
+
#define SIGAR_ZERO(s) \
|
94
|
+
memset(s, '\0', sizeof(*(s)))
|
95
|
+
|
96
|
+
#define SIGAR_STRNCPY(dest, src, len) \
|
97
|
+
strncpy(dest, src, len); \
|
98
|
+
dest[len-1] = '\0'
|
99
|
+
|
100
|
+
/* we use fixed size buffers pretty much everywhere */
|
101
|
+
/* this is strncpy + ensured \0 terminator */
|
102
|
+
#define SIGAR_SSTRCPY(dest, src) \
|
103
|
+
SIGAR_STRNCPY(dest, src, sizeof(dest))
|
104
|
+
|
105
|
+
#ifndef strEQ
|
106
|
+
#define strEQ(s1, s2) (strcmp(s1, s2) == 0)
|
107
|
+
#endif
|
108
|
+
|
109
|
+
#ifndef strnEQ
|
110
|
+
#define strnEQ(s1, s2, n) (strncmp(s1, s2, n) == 0)
|
111
|
+
#endif
|
112
|
+
|
113
|
+
#ifdef WIN32
|
114
|
+
#define strcasecmp stricmp
|
115
|
+
#define strncasecmp strnicmp
|
116
|
+
#endif
|
117
|
+
|
118
|
+
#ifndef strcaseEQ
|
119
|
+
#define strcaseEQ(s1, s2) (strcasecmp(s1, s2) == 0)
|
120
|
+
#endif
|
121
|
+
|
122
|
+
#ifndef strncaseEQ
|
123
|
+
#define strncaseEQ(s1, s2, n) (strncasecmp(s1, s2, n) == 0)
|
124
|
+
#endif
|
125
|
+
|
126
|
+
#ifdef offsetof
|
127
|
+
#define sigar_offsetof offsetof
|
128
|
+
#else
|
129
|
+
#define sigar_offsetof(type, field) ((size_t)(&((type *)0)->field))
|
130
|
+
#endif
|
131
|
+
|
132
|
+
#define SIGAR_MSEC 1000L
|
133
|
+
#define SIGAR_USEC 1000000L
|
134
|
+
#define SIGAR_NSEC 1000000000L
|
135
|
+
|
136
|
+
#define SIGAR_SEC2NANO(s) \
|
137
|
+
((sigar_uint64_t)(s) * (sigar_uint64_t)SIGAR_NSEC)
|
138
|
+
|
139
|
+
/* cpu ticks to milliseconds */
|
140
|
+
#define SIGAR_TICK2MSEC(s) \
|
141
|
+
((sigar_uint64_t)(s) * ((sigar_uint64_t)SIGAR_MSEC / (double)sigar->ticks))
|
142
|
+
|
143
|
+
#define SIGAR_TICK2NSEC(s) \
|
144
|
+
((sigar_uint64_t)(s) * ((sigar_uint64_t)SIGAR_NSEC / (double)sigar->ticks))
|
145
|
+
|
146
|
+
/* nanoseconds to milliseconds */
|
147
|
+
#define SIGAR_NSEC2MSEC(s) \
|
148
|
+
((sigar_uint64_t)(s) / ((sigar_uint64_t)1000000L))
|
149
|
+
|
150
|
+
#define IFTYPE_LO 2
|
151
|
+
#define IFTYPE_ETH 3
|
152
|
+
|
153
|
+
#define SIGAR_LAST_PROC_EXPIRE 2
|
154
|
+
|
155
|
+
#define SIGAR_FS_MAX 10
|
156
|
+
|
157
|
+
#define SIGAR_CPU_INFO_MAX 4
|
158
|
+
|
159
|
+
#define SIGAR_CPU_LIST_MAX 4
|
160
|
+
|
161
|
+
#define SIGAR_PROC_LIST_MAX 256
|
162
|
+
|
163
|
+
#define SIGAR_PROC_ARGS_MAX 12
|
164
|
+
|
165
|
+
#define SIGAR_NET_ROUTE_LIST_MAX 6
|
166
|
+
|
167
|
+
#define SIGAR_NET_IFLIST_MAX 20
|
168
|
+
|
169
|
+
#define SIGAR_NET_CONNLIST_MAX 20
|
170
|
+
|
171
|
+
#define SIGAR_WHO_LIST_MAX 12
|
172
|
+
|
173
|
+
int sigar_os_open(sigar_t **sigar);
|
174
|
+
|
175
|
+
int sigar_os_close(sigar_t *sigar);
|
176
|
+
|
177
|
+
char *sigar_os_error_string(sigar_t *sigar, int err);
|
178
|
+
|
179
|
+
char *sigar_strerror_get(int err, char *errbuf, int buflen);
|
180
|
+
|
181
|
+
void sigar_strerror_set(sigar_t *sigar, char *msg);
|
182
|
+
|
183
|
+
void sigar_strerror_printf(sigar_t *sigar, const char *format, ...);
|
184
|
+
|
185
|
+
int sigar_sys_info_get_uname(sigar_sys_info_t *sysinfo);
|
186
|
+
|
187
|
+
int sigar_os_sys_info_get(sigar_t *sigar, sigar_sys_info_t *sysinfo);
|
188
|
+
|
189
|
+
int sigar_os_proc_list_get(sigar_t *sigar,
|
190
|
+
sigar_proc_list_t *proclist);
|
191
|
+
|
192
|
+
int sigar_proc_list_create(sigar_proc_list_t *proclist);
|
193
|
+
|
194
|
+
int sigar_proc_list_grow(sigar_proc_list_t *proclist);
|
195
|
+
|
196
|
+
#define SIGAR_PROC_LIST_GROW(proclist) \
|
197
|
+
if (proclist->number >= proclist->size) { \
|
198
|
+
sigar_proc_list_grow(proclist); \
|
199
|
+
}
|
200
|
+
|
201
|
+
int sigar_proc_args_create(sigar_proc_args_t *proclist);
|
202
|
+
|
203
|
+
int sigar_proc_args_grow(sigar_proc_args_t *procargs);
|
204
|
+
|
205
|
+
#define SIGAR_PROC_ARGS_GROW(procargs) \
|
206
|
+
if (procargs->number >= procargs->size) { \
|
207
|
+
sigar_proc_args_grow(procargs); \
|
208
|
+
}
|
209
|
+
|
210
|
+
int sigar_os_proc_args_get(sigar_t *sigar, sigar_pid_t pid,
|
211
|
+
sigar_proc_args_t *procargs);
|
212
|
+
|
213
|
+
int sigar_file_system_list_create(sigar_file_system_list_t *fslist);
|
214
|
+
|
215
|
+
int sigar_file_system_list_grow(sigar_file_system_list_t *fslist);
|
216
|
+
|
217
|
+
#define SIGAR_FILE_SYSTEM_LIST_GROW(fslist) \
|
218
|
+
if (fslist->number >= fslist->size) { \
|
219
|
+
sigar_file_system_list_grow(fslist); \
|
220
|
+
}
|
221
|
+
|
222
|
+
int sigar_os_fs_type_get(sigar_file_system_t *fsp);
|
223
|
+
|
224
|
+
/* os plugins that set fsp->type call fs_type_get directly */
|
225
|
+
#define sigar_fs_type_init(fsp) \
|
226
|
+
fsp->type = SIGAR_FSTYPE_UNKNOWN; \
|
227
|
+
sigar_fs_type_get(fsp)
|
228
|
+
|
229
|
+
void sigar_fs_type_get(sigar_file_system_t *fsp);
|
230
|
+
|
231
|
+
int sigar_cpu_info_list_create(sigar_cpu_info_list_t *cpu_infos);
|
232
|
+
|
233
|
+
int sigar_cpu_info_list_grow(sigar_cpu_info_list_t *cpu_infos);
|
234
|
+
|
235
|
+
#define SIGAR_CPU_INFO_LIST_GROW(cpu_infos) \
|
236
|
+
if (cpu_infos->number >= cpu_infos->size) { \
|
237
|
+
sigar_cpu_info_list_grow(cpu_infos); \
|
238
|
+
}
|
239
|
+
|
240
|
+
int sigar_cpu_list_create(sigar_cpu_list_t *cpulist);
|
241
|
+
|
242
|
+
int sigar_cpu_list_grow(sigar_cpu_list_t *cpulist);
|
243
|
+
|
244
|
+
#define SIGAR_CPU_LIST_GROW(cpulist) \
|
245
|
+
if (cpulist->number >= cpulist->size) { \
|
246
|
+
sigar_cpu_list_grow(cpulist); \
|
247
|
+
}
|
248
|
+
|
249
|
+
int sigar_net_route_list_create(sigar_net_route_list_t *routelist);
|
250
|
+
|
251
|
+
int sigar_net_route_list_grow(sigar_net_route_list_t *net_routelist);
|
252
|
+
|
253
|
+
#define SIGAR_NET_ROUTE_LIST_GROW(routelist) \
|
254
|
+
if (routelist->number >= routelist->size) { \
|
255
|
+
sigar_net_route_list_grow(routelist); \
|
256
|
+
}
|
257
|
+
|
258
|
+
int sigar_net_interface_list_create(sigar_net_interface_list_t *iflist);
|
259
|
+
|
260
|
+
int sigar_net_interface_list_grow(sigar_net_interface_list_t *iflist);
|
261
|
+
|
262
|
+
#define SIGAR_NET_IFLIST_GROW(iflist) \
|
263
|
+
if (iflist->number >= iflist->size) { \
|
264
|
+
sigar_net_interface_list_grow(iflist); \
|
265
|
+
}
|
266
|
+
|
267
|
+
int sigar_net_connection_list_create(sigar_net_connection_list_t *connlist);
|
268
|
+
|
269
|
+
int sigar_net_connection_list_grow(sigar_net_connection_list_t *connlist);
|
270
|
+
|
271
|
+
#define SIGAR_NET_CONNLIST_GROW(connlist) \
|
272
|
+
if (connlist->number >= connlist->size) { \
|
273
|
+
sigar_net_connection_list_grow(connlist); \
|
274
|
+
}
|
275
|
+
|
276
|
+
#define sigar_net_address_set(a, val) \
|
277
|
+
(a).addr.in = val; \
|
278
|
+
(a).family = SIGAR_AF_INET
|
279
|
+
|
280
|
+
#define sigar_net_address6_set(a, val) \
|
281
|
+
memcpy(&((a).addr.in6), val, sizeof((a).addr.in6)); \
|
282
|
+
(a).family = SIGAR_AF_INET6
|
283
|
+
|
284
|
+
#define SIGAR_IFHWADDRLEN 6
|
285
|
+
|
286
|
+
#define sigar_net_address_mac_set(a, val, len) \
|
287
|
+
memcpy(&((a).addr.mac), val, len); \
|
288
|
+
(a).family = SIGAR_AF_LINK
|
289
|
+
|
290
|
+
#define sigar_hwaddr_set_null(ifconfig) \
|
291
|
+
SIGAR_ZERO(&ifconfig->hwaddr.addr.mac); \
|
292
|
+
ifconfig->hwaddr.family = SIGAR_AF_LINK
|
293
|
+
|
294
|
+
int sigar_tcp_curr_estab(sigar_t *sigar, sigar_tcp_t *tcp);
|
295
|
+
|
296
|
+
int sigar_who_list_create(sigar_who_list_t *wholist);
|
297
|
+
|
298
|
+
int sigar_who_list_grow(sigar_who_list_t *wholist);
|
299
|
+
|
300
|
+
#define SIGAR_WHO_LIST_GROW(wholist) \
|
301
|
+
if (wholist->number >= wholist->size) { \
|
302
|
+
sigar_who_list_grow(wholist); \
|
303
|
+
}
|
304
|
+
|
305
|
+
int sigar_user_id_get(sigar_t *sigar, const char *name, int *uid);
|
306
|
+
|
307
|
+
int sigar_user_name_get(sigar_t *sigar, int uid, char *buf, int buflen);
|
308
|
+
|
309
|
+
int sigar_group_name_get(sigar_t *sigar, int gid, char *buf, int buflen);
|
310
|
+
|
311
|
+
#define SIGAR_PROC_ENV_KEY_LOOKUP() \
|
312
|
+
if ((procenv->type == SIGAR_PROC_ENV_KEY) && \
|
313
|
+
(pid == sigar->pid)) \
|
314
|
+
{ \
|
315
|
+
char *value = getenv(procenv->key); \
|
316
|
+
if (value != NULL) { \
|
317
|
+
procenv->env_getter(procenv->data, \
|
318
|
+
procenv->key, \
|
319
|
+
procenv->klen, \
|
320
|
+
value, strlen(value)); \
|
321
|
+
} \
|
322
|
+
return SIGAR_OK; \
|
323
|
+
}
|
324
|
+
|
325
|
+
#define SIGAR_DISK_STATS_INIT(disk) \
|
326
|
+
(disk)->reads = (disk)->writes = \
|
327
|
+
(disk)->read_bytes = (disk)->write_bytes = \
|
328
|
+
(disk)->rtime = (disk)->wtime = (disk)->qtime = (disk)->time = \
|
329
|
+
(disk)->queue = (disk)->service_time = SIGAR_FIELD_NOTIMPL; \
|
330
|
+
(disk)->snaptime = 0
|
331
|
+
|
332
|
+
/* key used for filesystem (/) -> device (/dev/hda1) mapping */
|
333
|
+
/* and disk_usage cache for service_time */
|
334
|
+
#define SIGAR_FSDEV_ID(sb) \
|
335
|
+
(S_ISBLK((sb).st_mode) ? (sb).st_rdev : ((sb).st_ino + (sb).st_dev))
|
336
|
+
|
337
|
+
#if defined(WIN32) || defined(NETWARE)
|
338
|
+
int sigar_get_iftype(const char *name, int *type, int *inst);
|
339
|
+
#endif
|
340
|
+
|
341
|
+
#define SIGAR_NIC_LOOPBACK "Local Loopback"
|
342
|
+
#define SIGAR_NIC_ETHERNET "Ethernet"
|
343
|
+
#define SIGAR_NIC_NETROM "AMPR NET/ROM"
|
344
|
+
|
345
|
+
#ifndef WIN32
|
346
|
+
#include <netdb.h>
|
347
|
+
#endif
|
348
|
+
|
349
|
+
#define SIGAR_HOSTENT_LEN 512
|
350
|
+
#if defined(_AIX)
|
351
|
+
#define SIGAR_HAS_HOSTENT_DATA
|
352
|
+
#endif
|
353
|
+
|
354
|
+
typedef struct {
|
355
|
+
char buffer[SIGAR_HOSTENT_LEN];
|
356
|
+
int error;
|
357
|
+
#ifndef WIN32
|
358
|
+
struct hostent hs;
|
359
|
+
#endif
|
360
|
+
#ifdef SIGAR_HAS_HOSTENT_DATA
|
361
|
+
struct hostent_data hd;
|
362
|
+
#endif
|
363
|
+
} sigar_hostent_t;
|
364
|
+
|
365
|
+
#endif
|