1 /* 2 * Copyright (c) 2004-2008 Hyperic, Inc. 3 * Copyright (c) 2009 SpringSource, Inc. 4 * Copyright (c) 2009-2010 VMware, Inc. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 #ifndef SIGAR_H 20 #define SIGAR_H 21 22 /* System Information Gatherer And Reporter */ 23 24 #include <limits.h> 25 #include <sigar_visibility.h> 26 #include <stdint.h> 27 #include <inttypes.h> 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 #if defined(_LP64) || \ 34 defined(__LP64__) || \ 35 defined(__64BIT__) || \ 36 defined(__powerpc64__) || \ 37 defined(__osf__) 38 #define SIGAR_64BIT 39 #endif 40 41 #define SIGAR_F_U64 "%"PRIu64 42 43 typedef int32_t sigar_int32_t; 44 typedef int64_t sigar_int64_t; 45 typedef uint32_t sigar_uint32_t; 46 typedef uint64_t sigar_uint64_t; 47 48 #define SIGAR_FIELD_NOTIMPL -1 49 50 #define SIGAR_OK 0 51 #define SIGAR_START_ERROR 20000 52 #define SIGAR_ENOTIMPL (SIGAR_START_ERROR + 1) 53 #define SIGAR_OS_START_ERROR (SIGAR_START_ERROR*2) 54 55 #ifdef WIN32 56 # define SIGAR_ENOENT ERROR_FILE_NOT_FOUND 57 # define SIGAR_EACCES ERROR_ACCESS_DENIED 58 # define SIGAR_ENXIO ERROR_BAD_DRIVER_LEVEL 59 #else 60 # define SIGAR_ENOENT ENOENT 61 # define SIGAR_EACCES EACCES 62 # define SIGAR_ENXIO ENXIO 63 #endif 64 65 #define SIGAR_DECLARE(type) SIGAR_PUBLIC_API type 66 67 #if defined(PATH_MAX) 68 # define SIGAR_PATH_MAX PATH_MAX 69 #elif defined(MAXPATHLEN) 70 # define SIGAR_PATH_MAX MAXPATHLEN 71 #else 72 # define SIGAR_PATH_MAX 4096 73 #endif 74 75 #ifdef WIN32 76 typedef sigar_uint64_t sigar_pid_t; 77 typedef unsigned long sigar_uid_t; 78 typedef unsigned long sigar_gid_t; 79 #else 80 #include <sys/types.h> 81 typedef pid_t sigar_pid_t; 82 typedef uid_t sigar_uid_t; 83 typedef gid_t sigar_gid_t; 84 #endif 85 86 typedef struct sigar_t sigar_t; 87 88 SIGAR_DECLARE(int) sigar_open(sigar_t **sigar); 89 90 SIGAR_DECLARE(int) sigar_close(sigar_t *sigar); 91 92 SIGAR_DECLARE(sigar_pid_t) sigar_pid_get(sigar_t *sigar); 93 94 SIGAR_DECLARE(int) sigar_proc_kill(sigar_pid_t pid, int signum); 95 96 SIGAR_DECLARE(int) sigar_signum_get(char *name); 97 98 SIGAR_DECLARE(char *) sigar_strerror(sigar_t *sigar, int err); 99 100 /* system memory info */ 101 102 typedef struct { 103 sigar_uint64_t 104 ram, 105 total, 106 used, 107 free, 108 actual_used, 109 actual_free; 110 double used_percent; 111 double free_percent; 112 } sigar_mem_t; 113 114 SIGAR_DECLARE(int) sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem); 115 116 typedef struct { 117 sigar_uint64_t 118 total, 119 used, 120 free, 121 page_in, 122 page_out; 123 } sigar_swap_t; 124 125 SIGAR_DECLARE(int) sigar_swap_get(sigar_t *sigar, sigar_swap_t *swap); 126 127 typedef struct { 128 sigar_uint64_t 129 user, 130 sys, 131 nice, 132 idle, 133 wait, 134 irq, 135 soft_irq, 136 stolen, 137 total; 138 } sigar_cpu_t; 139 140 SIGAR_DECLARE(int) sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu); 141 142 typedef struct { 143 unsigned long number; 144 unsigned long size; 145 sigar_cpu_t *data; 146 } sigar_cpu_list_t; 147 148 SIGAR_DECLARE(int) sigar_cpu_list_get(sigar_t *sigar, sigar_cpu_list_t *cpulist); 149 150 SIGAR_DECLARE(int) sigar_cpu_list_destroy(sigar_t *sigar, 151 sigar_cpu_list_t *cpulist); 152 153 typedef struct { 154 char vendor[128]; 155 char model[128]; 156 int mhz; 157 int mhz_max; 158 int mhz_min; 159 sigar_uint64_t cache_size; 160 int total_sockets; 161 int total_cores; 162 int cores_per_socket; 163 } sigar_cpu_info_t; 164 165 typedef struct { 166 unsigned long number; 167 unsigned long size; 168 sigar_cpu_info_t *data; 169 } sigar_cpu_info_list_t; 170 171 SIGAR_DECLARE(int) 172 sigar_cpu_info_list_get(sigar_t *sigar, 173 sigar_cpu_info_list_t *cpu_infos); 174 175 SIGAR_DECLARE(int) 176 sigar_cpu_info_list_destroy(sigar_t *sigar, 177 sigar_cpu_info_list_t *cpu_infos); 178 179 typedef struct { 180 double uptime; 181 } sigar_uptime_t; 182 183 SIGAR_DECLARE(int) sigar_uptime_get(sigar_t *sigar, 184 sigar_uptime_t *uptime); 185 186 typedef struct { 187 double loadavg[3]; 188 } sigar_loadavg_t; 189 190 SIGAR_DECLARE(int) sigar_loadavg_get(sigar_t *sigar, 191 sigar_loadavg_t *loadavg); 192 193 typedef struct { 194 unsigned long number; 195 unsigned long size; 196 sigar_pid_t *data; 197 } sigar_proc_list_t; 198 199 typedef struct { 200 /* RLIMIT_CPU */ 201 sigar_uint64_t cpu_cur, cpu_max; 202 /* RLIMIT_FSIZE */ 203 sigar_uint64_t file_size_cur, file_size_max; 204 /* PIPE_BUF */ 205 sigar_uint64_t pipe_size_cur, pipe_size_max; 206 /* RLIMIT_DATA */ 207 sigar_uint64_t data_cur, data_max; 208 /* RLIMIT_STACK */ 209 sigar_uint64_t stack_cur, stack_max; 210 /* RLIMIT_CORE */ 211 sigar_uint64_t core_cur, core_max; 212 /* RLIMIT_RSS */ 213 sigar_uint64_t memory_cur, memory_max; 214 /* RLIMIT_NPROC */ 215 sigar_uint64_t processes_cur, processes_max; 216 /* RLIMIT_NOFILE */ 217 sigar_uint64_t open_files_cur, open_files_max; 218 /* RLIMIT_AS */ 219 sigar_uint64_t virtual_memory_cur, virtual_memory_max; 220 } sigar_resource_limit_t; 221 222 SIGAR_DECLARE(int) sigar_resource_limit_get(sigar_t *sigar, 223 sigar_resource_limit_t *rlimit); 224 225 SIGAR_DECLARE(int) sigar_proc_list_get(sigar_t *sigar, 226 sigar_proc_list_t *proclist); 227 228 SIGAR_DECLARE(int) sigar_proc_list_destroy(sigar_t *sigar, 229 sigar_proc_list_t *proclist); 230 231 typedef struct { 232 sigar_uint64_t total; 233 sigar_uint64_t sleeping; 234 sigar_uint64_t running; 235 sigar_uint64_t zombie; 236 sigar_uint64_t stopped; 237 sigar_uint64_t idle; 238 sigar_uint64_t threads; 239 } sigar_proc_stat_t; 240 241 SIGAR_DECLARE(int) sigar_proc_stat_get(sigar_t *sigar, 242 sigar_proc_stat_t *procstat); 243 244 typedef struct { 245 sigar_uint64_t 246 size, 247 resident, 248 share, 249 minor_faults, 250 major_faults, 251 page_faults; 252 } sigar_proc_mem_t; 253 254 SIGAR_DECLARE(int) sigar_proc_mem_get(sigar_t *sigar, sigar_pid_t pid, 255 sigar_proc_mem_t *procmem); 256 257 typedef struct { 258 sigar_uid_t uid; 259 sigar_gid_t gid; 260 sigar_uid_t euid; 261 sigar_gid_t egid; 262 } sigar_proc_cred_t; 263 264 SIGAR_DECLARE(int) sigar_proc_cred_get(sigar_t *sigar, sigar_pid_t pid, 265 sigar_proc_cred_t *proccred); 266 267 #define SIGAR_CRED_NAME_MAX 512 268 269 typedef struct { 270 char user[SIGAR_CRED_NAME_MAX]; 271 char group[SIGAR_CRED_NAME_MAX]; 272 } sigar_proc_cred_name_t; 273 274 SIGAR_DECLARE(int) 275 sigar_proc_cred_name_get(sigar_t *sigar, sigar_pid_t pid, 276 sigar_proc_cred_name_t *proccredname); 277 278 typedef struct { 279 sigar_uint64_t 280 start_time, 281 user, 282 sys, 283 total; 284 } sigar_proc_time_t; 285 286 SIGAR_DECLARE(int) sigar_proc_time_get(sigar_t *sigar, sigar_pid_t pid, 287 sigar_proc_time_t *proctime); 288 289 typedef struct { 290 /* must match sigar_proc_time_t fields */ 291 sigar_uint64_t 292 start_time, 293 user, 294 sys, 295 total; 296 sigar_uint64_t last_time; 297 double percent; 298 } sigar_proc_cpu_t; 299 300 SIGAR_DECLARE(int) sigar_proc_cpu_get(sigar_t *sigar, sigar_pid_t pid, 301 sigar_proc_cpu_t *proccpu); 302 303 #define SIGAR_PROC_STATE_SLEEP 'S' 304 #define SIGAR_PROC_STATE_RUN 'R' 305 #define SIGAR_PROC_STATE_STOP 'T' 306 #define SIGAR_PROC_STATE_ZOMBIE 'Z' 307 #define SIGAR_PROC_STATE_IDLE 'D' 308 309 #define SIGAR_PROC_NAME_LEN 128 310 311 typedef struct { 312 char name[SIGAR_PROC_NAME_LEN]; 313 char state; 314 sigar_pid_t ppid; 315 int tty; 316 int priority; 317 int nice; 318 int processor; 319 sigar_uint64_t threads; 320 } sigar_proc_state_t; 321 322 SIGAR_DECLARE(int) sigar_proc_state_get(sigar_t *sigar, sigar_pid_t pid, 323 sigar_proc_state_t *procstate); 324 325 typedef struct { 326 unsigned long number; 327 unsigned long size; 328 char **data; 329 } sigar_proc_args_t; 330 331 SIGAR_DECLARE(int) sigar_proc_args_get(sigar_t *sigar, sigar_pid_t pid, 332 sigar_proc_args_t *procargs); 333 334 SIGAR_DECLARE(int) sigar_proc_args_destroy(sigar_t *sigar, 335 sigar_proc_args_t *procargs); 336 337 typedef struct { 338 void *data; /* user data */ 339 340 enum { 341 SIGAR_PROC_ENV_ALL, 342 SIGAR_PROC_ENV_KEY 343 } type; 344 345 /* used for SIGAR_PROC_ENV_KEY */ 346 const char *key; 347 int klen; 348 349 int (*env_getter)(void *, const char *, int, char *, int); 350 } sigar_proc_env_t; 351 352 SIGAR_DECLARE(int) sigar_proc_env_get(sigar_t *sigar, sigar_pid_t pid, 353 sigar_proc_env_t *procenv); 354 355 typedef struct { 356 sigar_uint64_t total; 357 /* XXX - which are files, sockets, etc. */ 358 } sigar_proc_fd_t; 359 360 SIGAR_DECLARE(int) sigar_proc_fd_get(sigar_t *sigar, sigar_pid_t pid, 361 sigar_proc_fd_t *procfd); 362 363 typedef struct { 364 char name[SIGAR_PATH_MAX+1]; 365 char cwd[SIGAR_PATH_MAX+1]; 366 char root[SIGAR_PATH_MAX+1]; 367 } sigar_proc_exe_t; 368 369 SIGAR_DECLARE(int) sigar_proc_exe_get(sigar_t *sigar, sigar_pid_t pid, 370 sigar_proc_exe_t *procexe); 371 372 typedef struct { 373 void *data; /* user data */ 374 375 int (*module_getter)(void *, char *, int); 376 } sigar_proc_modules_t; 377 378 SIGAR_DECLARE(int) sigar_proc_modules_get(sigar_t *sigar, sigar_pid_t pid, 379 sigar_proc_modules_t *procmods); 380 381 typedef struct { 382 sigar_uint64_t user; 383 sigar_uint64_t sys; 384 sigar_uint64_t total; 385 } sigar_thread_cpu_t; 386 387 SIGAR_DECLARE(int) sigar_thread_cpu_get(sigar_t *sigar, 388 sigar_uint64_t id, 389 sigar_thread_cpu_t *cpu); 390 391 typedef enum { 392 SIGAR_FSTYPE_UNKNOWN, 393 SIGAR_FSTYPE_NONE, 394 SIGAR_FSTYPE_LOCAL_DISK, 395 SIGAR_FSTYPE_NETWORK, 396 SIGAR_FSTYPE_RAM_DISK, 397 SIGAR_FSTYPE_CDROM, 398 SIGAR_FSTYPE_SWAP, 399 SIGAR_FSTYPE_MAX 400 } sigar_file_system_type_e; 401 402 #define SIGAR_FS_NAME_LEN SIGAR_PATH_MAX 403 #define SIGAR_FS_INFO_LEN 256 404 405 typedef struct { 406 char dir_name[SIGAR_FS_NAME_LEN]; 407 char dev_name[SIGAR_FS_NAME_LEN]; 408 char type_name[SIGAR_FS_INFO_LEN]; /* e.g. "local" */ 409 char sys_type_name[SIGAR_FS_INFO_LEN]; /* e.g. "ext3" */ 410 char options[SIGAR_FS_INFO_LEN]; 411 sigar_file_system_type_e type; 412 unsigned long flags; 413 } sigar_file_system_t; 414 415 typedef struct { 416 unsigned long number; 417 unsigned long size; 418 sigar_file_system_t *data; 419 } sigar_file_system_list_t; 420 421 SIGAR_DECLARE(int) 422 sigar_file_system_list_get(sigar_t *sigar, 423 sigar_file_system_list_t *fslist); 424 425 SIGAR_DECLARE(int) 426 sigar_file_system_list_destroy(sigar_t *sigar, 427 sigar_file_system_list_t *fslist); 428 429 typedef struct { 430 sigar_uint64_t reads; 431 sigar_uint64_t writes; 432 sigar_uint64_t write_bytes; 433 sigar_uint64_t read_bytes; 434 sigar_uint64_t rtime; 435 sigar_uint64_t wtime; 436 sigar_uint64_t qtime; 437 sigar_uint64_t time; 438 sigar_uint64_t snaptime; 439 double service_time; 440 double queue; 441 } sigar_disk_usage_t; 442 443 typedef struct { 444 sigar_disk_usage_t disk; 445 double use_percent; 446 sigar_uint64_t total; 447 sigar_uint64_t free; 448 sigar_uint64_t used; 449 sigar_uint64_t avail; 450 sigar_uint64_t files; 451 sigar_uint64_t free_files; 452 } sigar_file_system_usage_t; 453 454 #undef SIGAR_DISK_USAGE_T 455 456 SIGAR_DECLARE(int) 457 sigar_file_system_usage_get(sigar_t *sigar, 458 const char *dirname, 459 sigar_file_system_usage_t *fsusage); 460 461 SIGAR_DECLARE(int) sigar_disk_usage_get(sigar_t *sigar, 462 const char *name, 463 sigar_disk_usage_t *disk); 464 465 SIGAR_DECLARE(int) 466 sigar_file_system_ping(sigar_t *sigar, 467 sigar_file_system_t *fs); 468 469 typedef struct { 470 enum { 471 SIGAR_AF_UNSPEC, 472 SIGAR_AF_INET, 473 SIGAR_AF_INET6, 474 SIGAR_AF_LINK 475 } family; 476 union { 477 sigar_uint32_t in; 478 sigar_uint32_t in6[4]; 479 unsigned char mac[8]; 480 } addr; 481 } sigar_net_address_t; 482 483 #define SIGAR_INET6_ADDRSTRLEN 46 484 485 #define SIGAR_MAXDOMAINNAMELEN 256 486 #define SIGAR_MAXHOSTNAMELEN 256 487 488 typedef struct { 489 char default_gateway[SIGAR_INET6_ADDRSTRLEN]; 490 char default_gateway_interface[16]; 491 char host_name[SIGAR_MAXHOSTNAMELEN]; 492 char domain_name[SIGAR_MAXDOMAINNAMELEN]; 493 char primary_dns[SIGAR_INET6_ADDRSTRLEN]; 494 char secondary_dns[SIGAR_INET6_ADDRSTRLEN]; 495 } sigar_net_info_t; 496 497 SIGAR_DECLARE(int) 498 sigar_net_info_get(sigar_t *sigar, 499 sigar_net_info_t *netinfo); 500 501 #define SIGAR_RTF_UP 0x1 502 #define SIGAR_RTF_GATEWAY 0x2 503 #define SIGAR_RTF_HOST 0x4 504 505 typedef struct { 506 sigar_net_address_t destination; 507 sigar_net_address_t gateway; 508 sigar_net_address_t mask; 509 sigar_uint64_t 510 flags, 511 refcnt, 512 use, 513 metric, 514 mtu, 515 window, 516 irtt; 517 char ifname[16]; 518 } sigar_net_route_t; 519 520 typedef struct { 521 unsigned long number; 522 unsigned long size; 523 sigar_net_route_t *data; 524 } sigar_net_route_list_t; 525 526 SIGAR_DECLARE(int) sigar_net_route_list_get(sigar_t *sigar, 527 sigar_net_route_list_t *routelist); 528 529 SIGAR_DECLARE(int) sigar_net_route_list_destroy(sigar_t *sigar, 530 sigar_net_route_list_t *routelist); 531 532 /* 533 * platforms define most of these "standard" flags, 534 * but of course, with different values in some cases. 535 */ 536 #define SIGAR_IFF_UP 0x1 537 #define SIGAR_IFF_BROADCAST 0x2 538 #define SIGAR_IFF_DEBUG 0x4 539 #define SIGAR_IFF_LOOPBACK 0x8 540 #define SIGAR_IFF_POINTOPOINT 0x10 541 #define SIGAR_IFF_NOTRAILERS 0x20 542 #define SIGAR_IFF_RUNNING 0x40 543 #define SIGAR_IFF_NOARP 0x80 544 #define SIGAR_IFF_PROMISC 0x100 545 #define SIGAR_IFF_ALLMULTI 0x200 546 #define SIGAR_IFF_MULTICAST 0x800 547 #define SIGAR_IFF_SLAVE 0x1000 548 #define SIGAR_IFF_MASTER 0x2000 549 #define SIGAR_IFF_DYNAMIC 0x4000 550 551 #define SIGAR_NULL_HWADDR "00:00:00:00:00:00" 552 553 /* scope values from linux-2.6/include/net/ipv6.h */ 554 #define SIGAR_IPV6_ADDR_ANY 0x0000 555 #define SIGAR_IPV6_ADDR_UNICAST 0x0001 556 #define SIGAR_IPV6_ADDR_MULTICAST 0x0002 557 #define SIGAR_IPV6_ADDR_LOOPBACK 0x0010 558 #define SIGAR_IPV6_ADDR_LINKLOCAL 0x0020 559 #define SIGAR_IPV6_ADDR_SITELOCAL 0x0040 560 #define SIGAR_IPV6_ADDR_COMPATv4 0x0080 561 562 typedef struct { 563 char name[16]; 564 char type[64]; 565 char description[256]; 566 sigar_net_address_t hwaddr; 567 sigar_net_address_t address; 568 sigar_net_address_t destination; 569 sigar_net_address_t broadcast; 570 sigar_net_address_t netmask; 571 sigar_net_address_t address6; 572 int prefix6_length; 573 int scope6; 574 sigar_uint64_t 575 flags, 576 mtu, 577 metric; 578 int tx_queue_len; 579 } sigar_net_interface_config_t; 580 581 SIGAR_DECLARE(int) 582 sigar_net_interface_config_get(sigar_t *sigar, 583 const char *name, 584 sigar_net_interface_config_t *ifconfig); 585 586 SIGAR_DECLARE(int) 587 sigar_net_interface_config_primary_get(sigar_t *sigar, 588 sigar_net_interface_config_t *ifconfig); 589 590 typedef struct { 591 sigar_uint64_t 592 /* received */ 593 rx_packets, 594 rx_bytes, 595 rx_errors, 596 rx_dropped, 597 rx_overruns, 598 rx_frame, 599 /* transmitted */ 600 tx_packets, 601 tx_bytes, 602 tx_errors, 603 tx_dropped, 604 tx_overruns, 605 tx_collisions, 606 tx_carrier, 607 speed; 608 } sigar_net_interface_stat_t; 609 610 SIGAR_DECLARE(int) 611 sigar_net_interface_stat_get(sigar_t *sigar, 612 const char *name, 613 sigar_net_interface_stat_t *ifstat); 614 615 typedef struct { 616 unsigned long number; 617 unsigned long size; 618 char **data; 619 } sigar_net_interface_list_t; 620 621 SIGAR_DECLARE(int) 622 sigar_net_interface_list_get(sigar_t *sigar, 623 sigar_net_interface_list_t *iflist); 624 625 SIGAR_DECLARE(int) 626 sigar_net_interface_list_destroy(sigar_t *sigar, 627 sigar_net_interface_list_t *iflist); 628 629 #define SIGAR_NETCONN_CLIENT 0x01 630 #define SIGAR_NETCONN_SERVER 0x02 631 632 #define SIGAR_NETCONN_TCP 0x10 633 #define SIGAR_NETCONN_UDP 0x20 634 #define SIGAR_NETCONN_RAW 0x40 635 #define SIGAR_NETCONN_UNIX 0x80 636 637 enum { 638 SIGAR_TCP_ESTABLISHED = 1, 639 SIGAR_TCP_SYN_SENT, 640 SIGAR_TCP_SYN_RECV, 641 SIGAR_TCP_FIN_WAIT1, 642 SIGAR_TCP_FIN_WAIT2, 643 SIGAR_TCP_TIME_WAIT, 644 SIGAR_TCP_CLOSE, 645 SIGAR_TCP_CLOSE_WAIT, 646 SIGAR_TCP_LAST_ACK, 647 SIGAR_TCP_LISTEN, 648 SIGAR_TCP_CLOSING, 649 SIGAR_TCP_IDLE, 650 SIGAR_TCP_BOUND, 651 SIGAR_TCP_UNKNOWN 652 }; 653 654 typedef struct { 655 unsigned long local_port; 656 sigar_net_address_t local_address; 657 unsigned long remote_port; 658 sigar_net_address_t remote_address; 659 sigar_uid_t uid; 660 unsigned long inode; 661 int type; 662 int state; 663 unsigned long send_queue; 664 unsigned long receive_queue; 665 } sigar_net_connection_t; 666 667 typedef struct { 668 unsigned long number; 669 unsigned long size; 670 sigar_net_connection_t *data; 671 } sigar_net_connection_list_t; 672 673 SIGAR_DECLARE(int) 674 sigar_net_connection_list_get(sigar_t *sigar, 675 sigar_net_connection_list_t *connlist, 676 int flags); 677 678 SIGAR_DECLARE(int) 679 sigar_net_connection_list_destroy(sigar_t *sigar, 680 sigar_net_connection_list_t *connlist); 681 682 typedef struct sigar_net_connection_walker_t sigar_net_connection_walker_t; 683 684 /* alternative to sigar_net_connection_list_get */ 685 struct sigar_net_connection_walker_t { 686 sigar_t *sigar; 687 int flags; 688 void *data; /* user data */ 689 int (*add_connection)(sigar_net_connection_walker_t *walker, 690 sigar_net_connection_t *connection); 691 }; 692 693 SIGAR_DECLARE(int) 694 sigar_net_connection_walk(sigar_net_connection_walker_t *walker); 695 696 typedef struct { 697 int tcp_states[SIGAR_TCP_UNKNOWN]; 698 sigar_uint32_t tcp_inbound_total; 699 sigar_uint32_t tcp_outbound_total; 700 sigar_uint32_t all_inbound_total; 701 sigar_uint32_t all_outbound_total; 702 } sigar_net_stat_t; 703 704 SIGAR_DECLARE(int) 705 sigar_net_stat_get(sigar_t *sigar, 706 sigar_net_stat_t *netstat, 707 int flags); 708 709 SIGAR_DECLARE(int) 710 sigar_net_stat_port_get(sigar_t *sigar, 711 sigar_net_stat_t *netstat, 712 int flags, 713 sigar_net_address_t *address, 714 unsigned long port); 715 716 /* TCP-MIB */ 717 typedef struct { 718 sigar_uint64_t active_opens; 719 sigar_uint64_t passive_opens; 720 sigar_uint64_t attempt_fails; 721 sigar_uint64_t estab_resets; 722 sigar_uint64_t curr_estab; 723 sigar_uint64_t in_segs; 724 sigar_uint64_t out_segs; 725 sigar_uint64_t retrans_segs; 726 sigar_uint64_t in_errs; 727 sigar_uint64_t out_rsts; 728 } sigar_tcp_t; 729 730 SIGAR_DECLARE(int) 731 sigar_tcp_get(sigar_t *sigar, 732 sigar_tcp_t *tcp); 733 734 typedef struct { 735 sigar_uint64_t null; 736 sigar_uint64_t getattr; 737 sigar_uint64_t setattr; 738 sigar_uint64_t root; 739 sigar_uint64_t lookup; 740 sigar_uint64_t readlink; 741 sigar_uint64_t read; 742 sigar_uint64_t writecache; 743 sigar_uint64_t write; 744 sigar_uint64_t create; 745 sigar_uint64_t remove; 746 sigar_uint64_t rename; 747 sigar_uint64_t link; 748 sigar_uint64_t symlink; 749 sigar_uint64_t mkdir; 750 sigar_uint64_t rmdir; 751 sigar_uint64_t readdir; 752 sigar_uint64_t fsstat; 753 } sigar_nfs_v2_t; 754 755 typedef sigar_nfs_v2_t sigar_nfs_client_v2_t; 756 typedef sigar_nfs_v2_t sigar_nfs_server_v2_t; 757 758 SIGAR_DECLARE(int) 759 sigar_nfs_client_v2_get(sigar_t *sigar, 760 sigar_nfs_client_v2_t *nfs); 761 762 SIGAR_DECLARE(int) 763 sigar_nfs_server_v2_get(sigar_t *sigar, 764 sigar_nfs_server_v2_t *nfs); 765 766 typedef struct { 767 sigar_uint64_t null; 768 sigar_uint64_t getattr; 769 sigar_uint64_t setattr; 770 sigar_uint64_t lookup; 771 sigar_uint64_t access; 772 sigar_uint64_t readlink; 773 sigar_uint64_t read; 774 sigar_uint64_t write; 775 sigar_uint64_t create; 776 sigar_uint64_t mkdir; 777 sigar_uint64_t symlink; 778 sigar_uint64_t mknod; 779 sigar_uint64_t remove; 780 sigar_uint64_t rmdir; 781 sigar_uint64_t rename; 782 sigar_uint64_t link; 783 sigar_uint64_t readdir; 784 sigar_uint64_t readdirplus; 785 sigar_uint64_t fsstat; 786 sigar_uint64_t fsinfo; 787 sigar_uint64_t pathconf; 788 sigar_uint64_t commit; 789 } sigar_nfs_v3_t; 790 791 typedef sigar_nfs_v3_t sigar_nfs_client_v3_t; 792 typedef sigar_nfs_v3_t sigar_nfs_server_v3_t; 793 794 SIGAR_DECLARE(int) 795 sigar_nfs_client_v3_get(sigar_t *sigar, 796 sigar_nfs_client_v3_t *nfs); 797 798 SIGAR_DECLARE(int) 799 sigar_nfs_server_v3_get(sigar_t *sigar, 800 sigar_nfs_server_v3_t *nfs); 801 802 SIGAR_DECLARE(int) 803 sigar_net_listen_address_get(sigar_t *sigar, 804 unsigned long port, 805 sigar_net_address_t *address); 806 807 typedef struct { 808 char ifname[16]; 809 char type[64]; 810 sigar_net_address_t hwaddr; 811 sigar_net_address_t address; 812 sigar_uint64_t flags; 813 } sigar_arp_t; 814 815 typedef struct { 816 unsigned long number; 817 unsigned long size; 818 sigar_arp_t *data; 819 } sigar_arp_list_t; 820 821 SIGAR_DECLARE(int) sigar_arp_list_get(sigar_t *sigar, 822 sigar_arp_list_t *arplist); 823 824 SIGAR_DECLARE(int) sigar_arp_list_destroy(sigar_t *sigar, 825 sigar_arp_list_t *arplist); 826 827 typedef struct { 828 char user[32]; 829 char device[32]; 830 char host[256]; 831 sigar_uint64_t time; 832 } sigar_who_t; 833 834 typedef struct { 835 unsigned long number; 836 unsigned long size; 837 sigar_who_t *data; 838 } sigar_who_list_t; 839 840 SIGAR_DECLARE(int) sigar_who_list_get(sigar_t *sigar, 841 sigar_who_list_t *wholist); 842 843 SIGAR_DECLARE(int) sigar_who_list_destroy(sigar_t *sigar, 844 sigar_who_list_t *wholist); 845 846 SIGAR_DECLARE(int) sigar_proc_port_get(sigar_t *sigar, 847 int protocol, unsigned long port, 848 sigar_pid_t *pid); 849 850 typedef struct { 851 const char *build_date; 852 const char *scm_revision; 853 const char *version; 854 const char *archname; 855 const char *archlib; 856 const char *binname; 857 const char *description; 858 int major, minor, maint, build; 859 } sigar_version_t; 860 861 SIGAR_DECLARE(sigar_version_t *) sigar_version_get(void); 862 863 #define SIGAR_SYS_INFO_LEN SIGAR_MAXHOSTNAMELEN /* more than enough */ 864 865 typedef struct { 866 char name[SIGAR_SYS_INFO_LEN]; /* canonicalized sysname */ 867 char version[SIGAR_SYS_INFO_LEN]; /* utsname.release */ 868 char arch[SIGAR_SYS_INFO_LEN]; 869 char machine[SIGAR_SYS_INFO_LEN]; 870 char description[SIGAR_SYS_INFO_LEN]; 871 char patch_level[SIGAR_SYS_INFO_LEN]; 872 char vendor[SIGAR_SYS_INFO_LEN]; 873 char vendor_version[SIGAR_SYS_INFO_LEN]; 874 char vendor_name[SIGAR_SYS_INFO_LEN]; /* utsname.sysname */ 875 char vendor_code_name[SIGAR_SYS_INFO_LEN]; 876 } sigar_sys_info_t; 877 878 SIGAR_DECLARE(int) sigar_sys_info_get(sigar_t *sigar, sigar_sys_info_t *sysinfo); 879 880 #define SIGAR_FQDN_LEN 512 881 882 SIGAR_DECLARE(int) sigar_fqdn_get(sigar_t *sigar, char *name, int namelen); 883 884 SIGAR_DECLARE(int) sigar_rpc_ping(char *hostname, 885 int protocol, 886 unsigned long program, 887 unsigned long version); 888 889 SIGAR_DECLARE(char *) sigar_rpc_strerror(int err); 890 891 SIGAR_DECLARE(char *) sigar_password_get(const char *prompt); 892 893 #ifdef __cplusplus 894 } 895 #endif 896 897 #endif 898