1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984
|
/*
* Copyright (c) 2004-2008 Hyperic, Inc.
* Copyright (c) 2009 SpringSource, Inc.
* Copyright (c) 2009-2010 VMware, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SIGAR_H
#define SIGAR_H
/* System Information Gatherer And Reporter */
#include <limits.h>
#ifndef MAX_INTERFACE_NAME_LEN
#define MAX_INTERFACE_NAME_LEN 256
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if defined(_LP64) || \
defined(__LP64__) || \
defined(__64BIT__) || \
defined(__powerpc64__) || \
defined(__osf__)
#define SIGAR_64BIT
#endif
/* for printf sigar_uint64_t */
#ifdef SIGAR_64BIT
# define SIGAR_F_U64 "%lu"
#else
# define SIGAR_F_U64 "%Lu"
#endif
#if defined(WIN32)
typedef unsigned __int32 sigar_uint32_t;
typedef unsigned __int64 sigar_uint64_t;
typedef __int32 sigar_int32_t;
typedef __int64 sigar_int64_t;
#elif ULONG_MAX > 4294967295UL
typedef unsigned int sigar_uint32_t;
typedef unsigned long sigar_uint64_t;
typedef int sigar_int32_t;
typedef long sigar_int64_t;
#else
typedef unsigned int sigar_uint32_t;
typedef unsigned long long sigar_uint64_t;
typedef int sigar_int32_t;
typedef long long sigar_int64_t;
#endif
#define SIGAR_FIELD_NOTIMPL -1
#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)
#ifdef WIN32
# define SIGAR_ENOENT ERROR_FILE_NOT_FOUND
# define SIGAR_EACCES ERROR_ACCESS_DENIED
# define SIGAR_ENXIO ERROR_BAD_DRIVER_LEVEL
#else
# define SIGAR_ENOENT ENOENT
# define SIGAR_EACCES EACCES
# define SIGAR_ENXIO ENXIO
#endif
#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 4096
#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);
SIGAR_DECLARE(int) sigar_signum_get(char *name);
SIGAR_DECLARE(char *) sigar_strerror(sigar_t *sigar, int err);
/* system memory info */
typedef struct {
sigar_uint64_t
ram,
total,
used,
free,
actual_used,
actual_free;
double used_percent;
double free_percent;
} sigar_mem_t;
SIGAR_DECLARE(int) sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem);
typedef struct {
sigar_uint64_t
total,
used,
free,
page_in,
page_out;
} 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,
wait,
irq,
soft_irq,
stolen,
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;
int mhz_max;
int mhz_min;
sigar_uint64_t cache_size;
int total_sockets;
int total_cores;
int cores_per_socket;
} sigar_cpu_info_t;
typedef struct {
unsigned long number;
unsigned long size;
sigar_cpu_info_t *data;
} sigar_cpu_info_list_t;
SIGAR_DECLARE(int)
sigar_cpu_info_list_get(sigar_t *sigar,
sigar_cpu_info_list_t *cpu_infos);
SIGAR_DECLARE(int)
sigar_cpu_info_list_destroy(sigar_t *sigar,
sigar_cpu_info_list_t *cpu_infos);
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;
typedef struct {
/* RLIMIT_CPU */
sigar_uint64_t cpu_cur, cpu_max;
/* RLIMIT_FSIZE */
sigar_uint64_t file_size_cur, file_size_max;
/* PIPE_BUF */
sigar_uint64_t pipe_size_cur, pipe_size_max;
/* 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 */
sigar_uint64_t memory_cur, memory_max;
/* RLIMIT_NPROC */
sigar_uint64_t processes_cur, processes_max;
/* RLIMIT_NOFILE */
sigar_uint64_t open_files_cur, open_files_max;
/* RLIMIT_AS */
sigar_uint64_t virtual_memory_cur, virtual_memory_max;
} sigar_resource_limit_t;
SIGAR_DECLARE(int) sigar_resource_limit_get(sigar_t *sigar,
sigar_resource_limit_t *rlimit);
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;
sigar_uint64_t sleeping;
sigar_uint64_t running;
sigar_uint64_t zombie;
sigar_uint64_t stopped;
sigar_uint64_t idle;
sigar_uint64_t threads;
} 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,
minor_faults,
major_faults,
page_faults;
} 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_uint64_t
bytes_read,
bytes_written,
bytes_total;
} sigar_proc_disk_io_t;
SIGAR_DECLARE(int) sigar_proc_disk_io_get(sigar_t *sigar, sigar_pid_t pid,
sigar_proc_disk_io_t *proc_disk_io);
typedef struct {
sigar_uint64_t
bytes_read,
bytes_written,
bytes_total;
sigar_uint64_t last_time;
sigar_uint64_t
bytes_read_diff,
bytes_written_diff,
bytes_total_diff;
} sigar_cached_proc_disk_io_t;
typedef struct {
sigar_uint64_t
bytes_read,
bytes_written,
bytes_total;
} sigar_proc_cumulative_disk_io_t;
SIGAR_DECLARE(int) sigar_proc_cumulative_disk_io_get(sigar_t *sigar, sigar_pid_t pid,
sigar_proc_cumulative_disk_io_t *proc_cumulative_disk_io);
typedef struct {
sigar_uint64_t dummy;
}sigar_dump_pid_cache_t;
SIGAR_DECLARE(int) sigar_dump_pid_cache_get(sigar_t *sigar, sigar_dump_pid_cache_t *info);
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,
user,
sys,
total;
} sigar_proc_time_t;
SIGAR_DECLARE(int) sigar_proc_time_get(sigar_t *sigar, sigar_pid_t pid,
sigar_proc_time_t *proctime);
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);
#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'
#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;
int processor;
sigar_uint64_t threads;
} 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);
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);
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);
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 SIGAR_PATH_MAX
#define SIGAR_FS_INFO_LEN 256
typedef struct {
char dir_name[SIGAR_FS_NAME_LEN];
char dev_name[SIGAR_FS_NAME_LEN];
char type_name[SIGAR_FS_INFO_LEN]; /* e.g. "local" */
char sys_type_name[SIGAR_FS_INFO_LEN]; /* e.g. "ext3" */
char options[SIGAR_FS_INFO_LEN];
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 reads;
sigar_uint64_t writes;
sigar_uint64_t write_bytes;
sigar_uint64_t read_bytes;
sigar_uint64_t rtime;
sigar_uint64_t wtime;
sigar_uint64_t qtime;
sigar_uint64_t time;
sigar_uint64_t snaptime;
double service_time;
double queue;
} sigar_disk_usage_t;
/* XXX for sigar_file_system_usage_t compat */
#define disk_reads disk.reads
#define disk_writes disk.writes
#define disk_write_bytes disk.write_bytes
#define disk_read_bytes disk.read_bytes
#define disk_queue disk.queue
#define disk_service_time disk.service_time
typedef struct {
sigar_disk_usage_t disk;
double use_percent;
sigar_uint64_t total;
sigar_uint64_t free;
sigar_uint64_t used;
sigar_uint64_t avail;
sigar_uint64_t files;
sigar_uint64_t free_files;
} sigar_file_system_usage_t;
#undef SIGAR_DISK_USAGE_T
SIGAR_DECLARE(int)
sigar_file_system_usage_get(sigar_t *sigar,
const char *dirname,
sigar_file_system_usage_t *fsusage);
SIGAR_DECLARE(int) sigar_disk_usage_get(sigar_t *sigar,
const char *name,
sigar_disk_usage_t *disk);
SIGAR_DECLARE(int)
sigar_file_system_ping(sigar_t *sigar,
sigar_file_system_t *fs);
typedef struct {
enum {
SIGAR_AF_UNSPEC,
SIGAR_AF_INET,
SIGAR_AF_INET6,
SIGAR_AF_LINK
} family;
union {
sigar_uint32_t in;
sigar_uint32_t in6[4];
unsigned char mac[8];
} addr;
} sigar_net_address_t;
#define SIGAR_INET6_ADDRSTRLEN 46
#define SIGAR_MAXDOMAINNAMELEN 256
#define SIGAR_MAXHOSTNAMELEN 256
typedef struct {
char default_gateway[SIGAR_INET6_ADDRSTRLEN];
char default_gateway_interface[MAX_INTERFACE_NAME_LEN];
char host_name[SIGAR_MAXHOSTNAMELEN];
char domain_name[SIGAR_MAXDOMAINNAMELEN];
char primary_dns[SIGAR_INET6_ADDRSTRLEN];
char secondary_dns[SIGAR_INET6_ADDRSTRLEN];
} sigar_net_info_t;
SIGAR_DECLARE(int)
sigar_net_info_get(sigar_t *sigar,
sigar_net_info_t *netinfo);
#define SIGAR_RTF_UP 0x1
#define SIGAR_RTF_GATEWAY 0x2
#define SIGAR_RTF_HOST 0x4
typedef struct {
sigar_net_address_t destination;
sigar_net_address_t gateway;
sigar_net_address_t mask;
sigar_uint64_t
flags,
refcnt,
use,
metric,
mtu,
window,
irtt;
char ifname[MAX_INTERFACE_NAME_LEN];
} 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
#define SIGAR_IFF_SLAVE 0x1000
#define SIGAR_IFF_MASTER 0x2000
#define SIGAR_IFF_DYNAMIC 0x4000
#define SIGAR_NULL_HWADDR "00:00:00:00:00:00"
/* scope values from linux-2.6/include/net/ipv6.h */
#define SIGAR_IPV6_ADDR_ANY 0x0000
#define SIGAR_IPV6_ADDR_UNICAST 0x0001
#define SIGAR_IPV6_ADDR_MULTICAST 0x0002
#define SIGAR_IPV6_ADDR_LOOPBACK 0x0010
#define SIGAR_IPV6_ADDR_LINKLOCAL 0x0020
#define SIGAR_IPV6_ADDR_SITELOCAL 0x0040
#define SIGAR_IPV6_ADDR_COMPATv4 0x0080
typedef struct {
char name[MAX_INTERFACE_NAME_LEN];
char type[64];
char description[256];
sigar_net_address_t hwaddr;
sigar_net_address_t address;
sigar_net_address_t destination;
sigar_net_address_t broadcast;
sigar_net_address_t netmask;
sigar_net_address_t address6;
int prefix6_length;
int scope6;
sigar_uint64_t
flags,
mtu,
metric;
int tx_queue_len;
} 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);
SIGAR_DECLARE(int)
sigar_net_interface_config_primary_get(sigar_t *sigar,
sigar_net_interface_config_t *ifconfig);
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,
tx_carrier,
speed;
} 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
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,
SIGAR_TCP_CLOSING,
SIGAR_TCP_IDLE,
SIGAR_TCP_BOUND,
SIGAR_TCP_UNKNOWN
};
typedef struct {
unsigned long local_port;
sigar_net_address_t local_address;
unsigned long remote_port;
sigar_net_address_t remote_address;
sigar_uid_t uid;
unsigned long inode;
int type;
int state;
unsigned long send_queue;
unsigned long receive_queue;
} 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);
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);
};
SIGAR_DECLARE(int)
sigar_net_connection_walk(sigar_net_connection_walker_t *walker);
typedef struct {
int tcp_states[SIGAR_TCP_UNKNOWN];
sigar_uint32_t tcp_inbound_total;
sigar_uint32_t tcp_outbound_total;
sigar_uint32_t all_inbound_total;
sigar_uint32_t all_outbound_total;
} sigar_net_stat_t;
SIGAR_DECLARE(int)
sigar_net_stat_get(sigar_t *sigar,
sigar_net_stat_t *netstat,
int flags);
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);
/* TCP-MIB */
typedef struct {
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 in_errs;
sigar_uint64_t out_rsts;
} sigar_tcp_t;
SIGAR_DECLARE(int)
sigar_tcp_get(sigar_t *sigar,
sigar_tcp_t *tcp);
typedef struct {
sigar_uint64_t null;
sigar_uint64_t getattr;
sigar_uint64_t setattr;
sigar_uint64_t root;
sigar_uint64_t lookup;
sigar_uint64_t readlink;
sigar_uint64_t read;
sigar_uint64_t writecache;
sigar_uint64_t write;
sigar_uint64_t create;
sigar_uint64_t remove;
sigar_uint64_t rename;
sigar_uint64_t link;
sigar_uint64_t symlink;
sigar_uint64_t mkdir;
sigar_uint64_t rmdir;
sigar_uint64_t readdir;
sigar_uint64_t fsstat;
} sigar_nfs_v2_t;
typedef sigar_nfs_v2_t sigar_nfs_client_v2_t;
typedef sigar_nfs_v2_t sigar_nfs_server_v2_t;
SIGAR_DECLARE(int)
sigar_nfs_client_v2_get(sigar_t *sigar,
sigar_nfs_client_v2_t *nfs);
SIGAR_DECLARE(int)
sigar_nfs_server_v2_get(sigar_t *sigar,
sigar_nfs_server_v2_t *nfs);
typedef struct {
sigar_uint64_t null;
sigar_uint64_t getattr;
sigar_uint64_t setattr;
sigar_uint64_t lookup;
sigar_uint64_t access;
sigar_uint64_t readlink;
sigar_uint64_t read;
sigar_uint64_t write;
sigar_uint64_t create;
sigar_uint64_t mkdir;
sigar_uint64_t symlink;
sigar_uint64_t mknod;
sigar_uint64_t remove;
sigar_uint64_t rmdir;
sigar_uint64_t rename;
sigar_uint64_t link;
sigar_uint64_t readdir;
sigar_uint64_t readdirplus;
sigar_uint64_t fsstat;
sigar_uint64_t fsinfo;
sigar_uint64_t pathconf;
sigar_uint64_t commit;
} sigar_nfs_v3_t;
typedef sigar_nfs_v3_t sigar_nfs_client_v3_t;
typedef sigar_nfs_v3_t sigar_nfs_server_v3_t;
SIGAR_DECLARE(int)
sigar_nfs_client_v3_get(sigar_t *sigar,
sigar_nfs_client_v3_t *nfs);
SIGAR_DECLARE(int)
sigar_nfs_server_v3_get(sigar_t *sigar,
sigar_nfs_server_v3_t *nfs);
SIGAR_DECLARE(int)
sigar_net_listen_address_get(sigar_t *sigar,
unsigned long port,
sigar_net_address_t *address);
typedef struct {
char ifname[MAX_INTERFACE_NAME_LEN];
char type[64];
sigar_net_address_t hwaddr;
sigar_net_address_t address;
sigar_uint64_t flags;
} sigar_arp_t;
typedef struct {
unsigned long number;
unsigned long size;
sigar_arp_t *data;
} sigar_arp_list_t;
SIGAR_DECLARE(int) sigar_arp_list_get(sigar_t *sigar,
sigar_arp_list_t *arplist);
SIGAR_DECLARE(int) sigar_arp_list_destroy(sigar_t *sigar,
sigar_arp_list_t *arplist);
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);
SIGAR_DECLARE(int) sigar_proc_port_get(sigar_t *sigar,
int protocol, unsigned long port,
sigar_pid_t *pid);
typedef struct {
const char *build_date;
const char *scm_revision;
const char *version;
const char *archname;
const char *archlib;
const char *binname;
const char *description;
int major, minor, maint, build;
} sigar_version_t;
SIGAR_DECLARE(sigar_version_t *) sigar_version_get(void);
#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];
char machine[SIGAR_SYS_INFO_LEN];
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);
#define SIGAR_FQDN_LEN 512
SIGAR_DECLARE(int) sigar_fqdn_get(sigar_t *sigar, char *name, int namelen);
SIGAR_DECLARE(int) sigar_rpc_ping(char *hostname,
int protocol,
unsigned long program,
unsigned long version);
SIGAR_DECLARE(char *) sigar_rpc_strerror(int err);
SIGAR_DECLARE(char *) sigar_password_get(const char *prompt);
#ifdef __cplusplus
}
#endif
#endif
|