ifstat-1.1/0040755000031000000620000000000007775071166011450 5ustar gaelstaffifstat-1.1/debian/0040755000031000000620000000000007775071162012666 5ustar gaelstaffifstat-1.1/debian/changelog0100644000031000000620000000335307775071054014541 0ustar gaelstaffifstat (1.1-1) unstable; urgency=low * Upstream release. -- Gaël Roualland Thu, 1 Jan 2004 20:14:35 +0100 ifstat (1.0-1) unstable; urgency=low * Upstream release. * Support for building with net-snmp 5.0 and > -- Gaël Roualland Mon, 21 Apr 2003 23:22:17 +0200 ifstat (1.0rc3-1) unstable; urgency=low * Upstream release candidate. -- Gaël Roualland Sat, 19 Apr 2003 02:50:02 +0200 ifstat (1.0rc2-1) unstable; urgency=low * Upstream release candidate. -- Gaël Roualland Sun, 2 Feb 2003 19:15:53 +0100 ifstat (1.0rc1-1) unstable; urgency=low * Do not create /usr/doc link as per policy. * Link libifstat-config.1 to undocumented. * Add GPL location in copyright file. -- Gaël Roualland Sun, 2 Feb 2003 04:22:09 +0100 ifstat (1.0pre-1) unstable; urgency=low * Temporary upstream release. * Created new libifstat-dev package * Updated build dependency on libsnmp-dev for future libsnmp packages. -- Gaël Roualland Fri, 20 Sep 2002 00:41:24 +0200 ifstat (0.5-2) unstable; urgency=low * Interim release for debian packaging (Closes: #148218) * Sponsored by Igor Genibel -- Gaël Roualland Mon, 8 Jul 2002 00:30:44 +0200 ifstat (0.5-1) unstable; urgency=low * Upstream release -- Gaël Roualland Thu, 17 Jan 2002 00:07:12 +0100 ifstat (0.4-1) unstable; urgency=low * Initial Release. -- Gaël Roualland Sun, 6 Jan 2002 01:39:24 +0100 Local variables: mode: debian-changelog End: ifstat-1.1/debian/control0100644000031000000620000000135407651054755014273 0ustar gaelstaffSource: ifstat Priority: optional Maintainer: Gaël Roualland Build-Depends: debhelper (>> 3.0.0), libsnmp-dev | libsnmp5-dev, libssl-dev Standards-Version: 3.5.2 Package: ifstat Section: net Architecture: any Depends: ${shlibs:Depends} Description: InterFace STATistics Monitoring ifstat is a tool to report network interfaces bandwith just like vmstat/iostat do for other system counters. It can monitor local interfaces by polling the kernel counters, or remote hosts interfaces using SNMP. Package: libifstat-dev Section: devel Architecture: any Depends: libsnmp-dev Description: Ifstat Development Files Static library, header and config file to include ifstat functionality in other applications. ifstat-1.1/debian/copyright0100644000031000000620000000044407617107541014614 0ustar gaelstaffThis package was debianized by Gaël Roualland on Sun, 6 Jan 2002 01:39:24 +0100. Copyright: GNU General Public License (GPL) On Debian GNU/Linux systems, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/GPL'. ifstat-1.1/debian/docs0100644000031000000620000000002407415740475013533 0ustar gaelstaffREADME TODO HISTORY ifstat-1.1/debian/ifstat.dirs0100644000031000000620000000001007542453323015022 0ustar gaelstaffusr/bin ifstat-1.1/debian/ifstat.files0100644000031000000620000000004407542453323015172 0ustar gaelstaffusr/bin/ifstat usr/share/man/man1/* ifstat-1.1/debian/libifstat-dev.dirs0100644000031000000620000000003407542453323016273 0ustar gaelstaffusr/bin usr/lib usr/include ifstat-1.1/debian/libifstat-dev.files0100644000031000000620000000007307542453323016437 0ustar gaelstaffusr/bin/libifstat* usr/include/ifstat.h usr/lib/libifstat* ifstat-1.1/debian/libifstat-dev.undocumented0100644000031000000620000000002307617107612020022 0ustar gaelstafflibifstat-config.1 ifstat-1.1/debian/rules0100744000031000000620000000276607651055166013753 0ustar gaelstaff#!/usr/bin/make -f # Sample debian/rules that uses debhelper. # GNU copyright 1997 to 1999 by Joey Hess. # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 # This is the debhelper compatability version to use. export DH_COMPAT=4 configure: configure-stamp configure-stamp: dh_testdir # Add here commands to configure the package. CPPFLAGS="-D_REENTRANT" ./configure --prefix=/usr --mandir="\$${prefix}/share/man" --infodir="\$${prefix}/share/info" --enable-optim --enable-library --with-libcrypto touch configure-stamp build: configure-stamp build-stamp build-stamp: dh_testdir # Add here commands to compile the package. $(MAKE) touch build-stamp clean: dh_testdir dh_testroot rm -f build-stamp configure-stamp # Add here commands to clean up after the build process. -$(MAKE) distclean dh_clean install: build dh_testdir dh_testroot dh_clean -k dh_installdirs # Add here commands to install the package into debian/tmp $(MAKE) install prefix=$(CURDIR)/debian/tmp/usr # Build architecture-independent files here. binary-indep: build install # We have nothing to do by default. # Build architecture-dependent files here. binary-arch: build install dh_testdir dh_testroot dh_movefiles dh_installdocs -n dh_installman dh_installchangelogs dh_undocumented dh_link dh_strip dh_compress dh_fixperms dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary install configure ifstat-1.1/COPYING0100644000031000000620000004307607402774450012503 0ustar gaelstaff GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy 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 program 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. 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., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. ifstat-1.1/HISTORY0100644000031000000620000000651207775025654012536 0ustar gaelstaffInterFace STATistics Gaël Roualland =============================================== Releases History: * v1.1 - 01/01/2004 "The Happy New Year Release" - Digital Unix (OSF/1) and Tru64 support. - AIX support (tested on AIX v4.3). - HP-UX support with DLPI streams interface. (sample code contributed by Jean-Marc Saffroy ) - Win32 support (native or with cygwin) with GetIfTable interface. (sample code contributed by Alexandre Raclot ) - Use net-snmp-config if present to find out SNMP flags. * v1.0 - 21/04/2003 "The Easter Release" - SIOCGIFDATA ioctl(2) support for IRIX and OpenBSD. (allows stats for non root users on OpenBSD). - Improved kvm(3) support. - Route sysctl support for BSD based systems. (allows stats for non root users on NetBSD/MacOS X). - Handle OpenBSD pflog interfaces as loopbacks. (suggested by Nick Nauwelaerts ) - Can report total bandwith on monitored interfaces. (suggested by Nick Nauwelaerts ) - Dynamic column width to cope with long interfaces names (can be disabled). - Can report bandwith in kbits/sec instead of kbytes/sec. - Fix handling of bandwith larger than display width. - Adjust to height of term when resized. - Can wrap long stats lines when polling lots of interfaces. - Can disable scrolling for one line updated display. (inspired from patch by Joe Laffey ) - Reprint headers on SIGCONT for use with shell job control. (suggested by Joe Laffey ) - Index based polling for ifmib and snmp. - Max number of requests per snmp packet can be set and is automatically lowered on "too big" errors. Poll interfaces independently on error. Walk indexes to discover available interfaces. - Generated interface names for snmp are really their index. (when using #host). - Ignore interfaces for which statistics are not available. - Can ignore "null" interfaces (0 bytes ever sent/received) - Can build as a static library for use in other software. - Can disable warnings. - Misc cleanups and improvements. * v0.5 - 17/01/2002 - Cleaner driver interface, no more static stuff. - Multiple driver support with individual options. - Timestamping support. - Do not include loopback interfaces by default. - "All" and "Loopback" options for interfaces selection. - Display format fixup for rates >= 10000 KB/s - Fast start support with different first delay. - libcrypto workaround for SNMP (needed on OpenBSD/Sparc at least) - Debian (deb) packaging support. - Redhat (rpm) packaging support. (contributed by Werner Bosse ) * v0.4 - 24/12/2001 "The Christmas Release" - SNMP support through ucd-snmp if available. - Removed syntax restrictions on interfaces names. - Commas in interfaces names can be escaped. * v0.3 - 07/12/2001 - BSD-like kvm support. - if_nameindex support. - Smarter header reprinting (use terminal line number). - Shorter delays available. - No statistics information. * v0.2 - 04/12/2001 - FreeBSD ifmib, Solaris kstat support. - Ioctl support to find interfaces. - More precise measuring. - autoconf, man pages, etc... * v0.1 - 02/12/2001 - Initial implementation. - Linux 2.2 > (/proc) support. ifstat-1.1/INSTALL0100644000031000000620000001723007402774450012472 0ustar gaelstaffBasic Installation ================== These are generic installation instructions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, a file `config.cache' that saves the results of its tests to speed up reconfiguring, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.in' is used to create `configure' by a program called `autoconf'. You only need `configure.in' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. If you're using `csh' on an old version of System V, you might need to type `sh ./configure' instead to prevent `csh' from trying to execute `configure' itself. Running `configure' takes awhile. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. You can give `configure' initial values for variables by setting them in the environment. Using a Bourne-compatible shell, you can do that on the command line like this: CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure Or on systems that have the `env' program, you can do it like this: env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you must use a version of `make' that supports the `VPATH' variable, such as GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. If you have to use a `make' that does not supports the `VPATH' variable, you have to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. Installation Names ================== By default, `make install' will install the package's files in `/usr/local/bin', `/usr/local/man', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PATH'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you give `configure' the option `--exec-prefix=PATH', the package will use PATH as the prefix for installing programs and libraries. Documentation and other data files will still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=PATH' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Specifying the System Type ========================== There may be some features `configure' can not figure out automatically, but needs to determine by the type of host the package will run on. Usually `configure' can figure that out, but if it prints a message saying it can not guess the host type, give it the `--host=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name with three fields: CPU-COMPANY-SYSTEM See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the host type. If you are building compiler tools for cross-compiling, you can also use the `--target=TYPE' option to select the type of system they will produce code for and the `--build=TYPE' option to select the type of system on which you are compiling the package. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Operation Controls ================== `configure' recognizes the following options to control how it operates. `--cache-file=FILE' Use and save the results of the tests in FILE instead of `./config.cache'. Set FILE to `/dev/null' to disable caching, for debugging `configure'. `--help' Print a summary of the options to `configure', and exit. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--version' Print the version of Autoconf used to generate the `configure' script, and exit. `configure' also accepts some other, not widely useful, options. ifstat-1.1/Makefile.in0100644000031000000620000000432407542211650013477 0ustar gaelstaffsrcdir = @srcdir@ prefix = @prefix@ libdir = @libdir@ exec_prefix = @exec_prefix@ datadir = @datadir@ bindir = @bindir@ mandir = @mandir@ etcdir = @sysconfdir@ includedir = @includedir@ SHELL = /bin/sh CC = @CC@ RM = rm -f INSTALL = @INSTALL@ RANLIB = @RANLIB@ CFLAGS = -I. @CFLAGS@ @DEFS@ @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ LIBSRCS = drivers.c data.c @SNMPSRC@ SRCS = ifstat.c $(LIBSRCS) OBJS = ${SRCS:.c=.o} LIBOBJS = ${LIBSRCS:.c=.o} TARGET = ifstat LIBTARGET = libifstat.a TARGETS = $(TARGET) @LIBTARGET@ .SUFFIXES: .c .o .c.o: $(CC) $(CFLAGS) -c $< -o $@ all: $(TARGETS) Makefile $(TARGET): $(OBJS) $(CC) $(OBJS) $(LDFLAGS) $(LIBS) -o $(TARGET) $(LIBTARGET): $(LIBOBJS) ar rv $(LIBTARGET) $(LIBOBJS) $(RANLIB) $(LIBTARGET) clean: $(RM) *.o *~ .*~ core \#*\# gmon.out *.bak $(TARGETS) distclean: clean $(RM) config.h config.cache config.log config.status Makefile libifstat-config maintainer-clean: distclean $(RM) configure config.h.in ifstat.1 ${srcdir}/configure: configure.in cd ${srcdir} && autoconf ${srcdir}/config.h.in: configure.in acconfig.h cd ${srcdir} && autoheader Makefile: Makefile.in config.status CONFIG_FILES=Makefile CONFIG_HEADERS= ./config.status config.status: configure ./config.status --recheck libifstat-config: libifstat-config.in CONFIG_FILES=libifstat-config CONFIG_HEADERS= ./config.status install: install-$(TARGET) install-@LIBTARGET@ install-$(TARGET): $(TARGET) $(INSTALL) -d -m 755 $(bindir) $(INSTALL) -s -m 755 $(TARGET) $(bindir)/$(TARGET) $(INSTALL) -d -m 755 $(mandir)/man1 $(INSTALL) -m 644 ifstat.1 $(mandir)/man1/ifstat.1 install-$(LIBTARGET): $(LIBTARGET) libifstat-config $(INSTALL) -d -m 755 $(bindir) $(INSTALL) -m 755 libifstat-config $(bindir)/libifstat-config $(INSTALL) -d -m 755 $(includedir) $(INSTALL) -m 644 ifstat.h $(includedir)/ifstat.h $(INSTALL) -d -m 755 $(libdir) $(INSTALL) -m 644 $(LIBTARGET) $(libdir)/$(LIBTARGET) install-: # dependency when not building library realclean: maintainer-clean # deps ifstat.o: ifstat.c ifstat.h config.h drivers.o: drivers.c ifstat.h config.h snmp.h snmp.o: snmp.c ifstat.h config.h snmp.h ifstat-1.1/README0100644000031000000620000000726007757535627012341 0ustar gaelstaffInterFace STATistics Gaël Roualland =============================================== * Introduction Ifstat is a little tool to report interface activity like vmstat/iostat do. Since gathering these statistics is highly system dependant, only a few operating systems are supported right now: Linux with /proc/net/dev interface (Linux >= 2.2.x) Solaris with kstat(3K) interface (Solaris >= 2.6.x) FreeBSD with ifmib(4) interface (FreeBSD > 2.2) IRIX and OpenBSD with SIOCGIFDATA ioctl(2). BSD like systems with route sysctl(3) interface (NetBSD, Darwin). BSD like systems with kvm(3) interface. Digital Unix (OSF/1), AIX with "legacy" kmem interface. HP-UX with DLPI streams interface. Win32 (native or with cygwin) with GetIfTable interface. Others might be easy to add, or might simply work out-of-the-box if some compatibility layer is there. As usual your mileage may vary. In addition, ifstat can poll remote hosts through SNMP if you have the ucd-snmp library. It will also be used for localhost if no other known method works (You need to have snmpd running for this though). * Compilation To compile, just run the configure script as follows: (Refer to the INSTALL file for generic configure instructions) ./configure You might need to set several variables for the configure script on some systems: - On HP-UX, if using the HP C Compiler, add CC="cc -Ae" so that ANSI C syntax is accepted. - On Windows, you might want to add CC="gcc -mno-cygwin" under Cygwin to build a native win32 binary. You might also need to pass several options to the configure script. This package accepts the following extra-options: --enable-debug This turns debugging on in the library. --enable-optim This turns on some gcc optimization flags. --enable-library Enable build and installation of libifstat. By default, all the statistics gathering drivers are checked for availibility until a working one is found, but several can be included. If you wish to force inclusion of an alternate driver (if available) or disable one, you can use one of the following options: --with-proc Force support of /proc if available. --without-proc Do not include support for /proc. --with-kstat Force support of kstat if available. --without-kstat Do not include support for kstat. --with-ifmib Force support of ifmib if available. --without-ifmib Do not include support for ifmib. --with-ifdata Force support of ifdata if available. --without-ifata Do not include support for ifdata. --with-route Force support of route if available. --without-route Do not include support for route. --with-kvm Force support of kvm if available. --without-kvm Do not include support for kvm. --with-dlpi Force support of dlpi if available. --without-dlpi Do not include support for dlpi. --with-win32 Force support of wiN32 if available. --without-win32 Do not include support for win32. --with-snmp=prefix Specify where the snmp library is installed --without-snmp Do not include support for SNMP. --with-libcrypto Force use of libcrypto with UCD-SNMP. This is needed on at least OpenBSD, since the snmp library links but doesn't run without it. Then, run the make command: make and finally, to install it run: make install * Usage Simply run ifstat and see stats rolling ;) * Homepage http://gael.roualland.free.fr/ifstat/ * Feedback If you're happy with ifstat, I'd be glad to hear from you and know what you use it for and on which systems. Bugs reports are welcomed too! Thanks. ifstat-1.1/TODO0100644000031000000620000000027307617072431012126 0ustar gaelstaffInterFace STATistics Gaël Roualland =============================================== To do: - add support for other systems; contributions appreciated :) ifstat-1.1/VERSION0100644000031000000620000000000407775071052012501 0ustar gaelstaff1.1 ifstat-1.1/autogen.sh0100755000031000000620000000343507541206137013440 0ustar gaelstaff#!/bin/sh # Run this to generate all the initial makefiles, etc. srcdir=`dirname $0` # name of the current package PKG_NAME=`basename \`(cd $srcdir; pwd)\`` # default configure options conf_flags="--enable-debug --with-debug" DIE=0 libtool=0 gettext=0 missing() { echo echo "**Error**: You must have \`$1' installed to compile $PKG_NAME." echo "Download the appropriate package for your distribution," echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" DIE=1 } (autoconf --version) < /dev/null > /dev/null 2>&1 || missing autoconf grep "^AM_GNU_GETTEXT" $srcdir/configure.in >/dev/null && gettext=1 grep "^AC_PROG_LIBTOOL" $srcdir/configure.in >/dev/null && libtool=1 if test "$gettext" -eq 1; then grep "sed.*POTFILES" $srcdir/configure.in >/dev/null || \ (gettextize --version) < /dev/null > /dev/null 2>&1 || missing gettext fi if test "$libtool" -eq 1; then (libtoolize --version) < /dev/null > /dev/null 2>&1 || missing libtool fi if test "$DIE" -eq 1; then exit 1 fi if test -z "$*"; then echo "**Warning**: I am going to run \`configure' with default arguments." echo "If you wish to pass any others to it, please specify them on the" echo \`$0\'" command line." echo else unset conf_flags fi if test "$gettext" -eq 1; then echo "Running gettextize... Ignore non-fatal messages." echo "no" | gettextize --force --copy fi if test "$libtool" -eq 1; then echo "Running libtoolize..." libtoolize --force --copy fi echo "Running autoheader..." autoheader echo "Running autoconf ..." autoconf echo "Creating man page ..." sh ifstat.pod if test x$NOCONFIGURE = x; then echo Running $srcdir/configure $conf_flags "$@" ... $srcdir/configure $conf_flags "$@" \ && echo Now type \`make\' to compile $PKG_NAME else echo Skipping configure process. fi ifstat-1.1/configure.in0100644000031000000620000004173107757535627013773 0ustar gaelstaffdnl configure.in for ifstat dnl Process this file with autoconf to create configure dnl $Id: configure.in,v 1.51 2003/11/22 01:27:51 gael Exp $ AC_INIT(ifstat.c) AC_ARG_ENABLE(debug, [ --enable-debug setup flags (gcc) for debugging (default=no)], CFLAGS="$CFLAGS -O2 -Wall -g" CPPFLAGS="$CPPFLAGS -DDEBUG" LDFLAGS="$LDFLAGS",) AC_ARG_ENABLE(optim, [ --enable-optim setup flags (gcc) for optimizations (default=no)], if test "x$enable_debug" != "xyes" ; then CFLAGS="$CFLAGS -O3 -fomit-frame-pointer -g0" LDFLAGS="$LDFLAGS -s" else AC_MSG_WARN([enable-optim and enable-debug are incompatible -- disabling optimizations]) fi,) AC_CONFIG_HEADER(config.h) dnl Programs AC_PROG_INSTALL AC_PROG_CC AC_PROG_RANLIB AC_HEADER_STDC AC_CHECK_HEADERS(sys/time.h) AC_HEADER_TIME AC_CHECK_HEADERS(unistd.h ctype.h sys/types.h sys/param.h sys/mbuf.h net/route.h net/if.h net/if_var.h net/if_types.h sys/socket.h sys/ioctl.h sys/sockio.h net/soioctl.h sys/termios.h errno.h signal.h stdarg.h limits.h fcntl.h) AC_TYPE_SIGNAL AC_CHECK_FUNCS(sigaction snprintf) # Options for various drivers # auto means try if no other found, no disables, and anything else is try. AC_ARG_WITH(proc, [ --with-proc[=FILE] include /proc/net/dev support (default=auto)], [], [with_proc=auto]) AC_ARG_WITH(kstat, [ --with-kstat include kstat(3K) support (default=auto)], [], [with_kstat=auto]) AC_ARG_WITH(ifmib, [ --with-ifmib include ifmib(4) support (default=auto)], [], [with_ifmib=auto]) AC_ARG_WITH(ifdata, [ --with-ifdata include ifdata ioctl support (default=auto)], [], [with_ifdata=auto]) AC_ARG_WITH(route, [ --with-route include route(4) sysctl support (default=auto)], [], [with_route=auto]) AC_ARG_WITH(kvm, [ --with-kvm include kvm(3) support (default=auto)], [], [with_kvm=auto]) AC_ARG_WITH(dlpi, [ --with-dlpi include HP DLPI support (default=auto)], [], [with_dlpi=auto]) AC_ARG_WITH(win32, [ --with-win32 include Win32 support (default=auto)], [], [with_win32=auto]) AC_ARG_WITH(snmp, [ --with-snmp[=PREFIX] include UCD-SNMP support (default=yes)], [], [with_snmp=yes]) with_ioctl=no # only enabled if needed by other drivers local=no # yes if one driver is local # checking for proc (Linux) if test "x$with_proc" != "xno"; then case "$with_proc" in /*) file=$with_proc ;; *) file=/proc/net/dev ;; esac AC_MSG_CHECKING([for proc interface in $file]) if grep -q Inter- $file 2>/dev/null; then AC_DEFINE([USE_PROC], 1, [Define if you want to use /proc to get stats]) AC_DEFINE_UNQUOTED([PROC_FILE], ["$file"], [Proc file to poll for stats]) with_proc=yes with_ioctl=yes local=yes else with_proc=no fi AC_MSG_RESULT([$with_proc]) fi # checking for kstat (Solaris) test "x$with_kstat" = "xauto" -a "x$local" = "xyes" && with_kstat=no if test "x$with_kstat" != "xno"; then AC_CHECK_FUNC(kstat_open, with_kstat=yes, with_kstat=no) if test "x$with_kstat" != "xyes" ; then case "x$LIBS" in *-lkstat*) ;; *) AC_CHECK_LIB(kstat, kstat_open, [LIBS="$LIBS -lkstat"; with_kstat=yes]) ;; esac fi if test "x$with_kstat" = "xyes" ; then AC_CHECK_HEADERS(kstat.h) AC_DEFINE([USE_KSTAT], 1, [Define if you want to use kstat to get stats]) with_ioctl=yes local=yes fi fi # checking for ifmib (FreeBSD) test "x$with_ifmib" = "xauto" -a "x$local" = "xyes" && with_ifmib=no if test "x$with_ifmib" != "xno"; then AC_CHECK_HEADER(net/if_mib.h, [AC_CHECK_FUNC(sysctl, with_ifmib=yes, with_ifmib=no)], with_ifmib=no) if test "x$with_ifmib" = "xyes"; then AC_CHECK_HEADERS(sys/sysctl.h net/if_mib.h) AC_MSG_CHECKING([for working ifmib sysctl]) # try run since interface is available on darwin but doesn't work AC_TRY_RUN([#include #include #ifdef HAVE_SYS_PARAM_H #include #endif #ifdef HAVE_SYS_SYSCTL_H #include #endif #ifdef HAVE_NET_IF_H #include #endif #ifdef HAVE_NET_IF_MIB_H #include #endif int ifcount[] = {CTL_NET, PF_LINK, NETLINK_GENERIC, IFMIB_SYSTEM, IFMIB_IFCOUNT}; int size; int main() { return sysctl(ifcount, 5, NULL, &size, NULL, NULL); }], [with_ifmib=yes], [with_ifmib=no], [with_ifmib=maybe]) AC_MSG_RESULT([$with_ifmib]) if test "x$with_ifmib" != "xno" ; then AC_DEFINE([USE_IFMIB], 1, [Define if you want to use if_mib to get stats]) local=yes fi fi fi # checking for ioctl ifdata (Irix, ...) test "x$with_ifdata" = "xauto" -a "x$local" = "xyes" && with_ifdata=no if test "x$with_ifdata" != "xno"; then AC_MSG_CHECKING([for SIOCGIFDATA and ifdatareq]) AC_TRY_COMPILE([#include #include #include #ifdef HAVE_SYS_SOCKIO_H #include #endif #ifdef HAVE_NET_SOIOCTL_H #include #endif #include ], [struct ifdatareq ifd; ioctl(0, SIOCGIFDATA, (char *) &ifd); ifd.ifd_ifd.ifi_ibytes = ifd.ifd_ifd.ifi_obytes;], with_ifdata=yes, with_ifdata=no) AC_MSG_RESULT([$with_ifdata]) test "x$with_ifdata" = "xno" && with_ifdata=checkifr fi if test "x$with_ifdata" = "xcheckifr"; then AC_MSG_CHECKING([for SIOCGIFDATA and ifreq.ifr_data]) AC_TRY_COMPILE([#include #include #include #ifdef HAVE_SYS_SOCKIO_H #include #endif #ifdef HAVE_NET_SOIOCTL_H #include #endif #include ], [struct ifreq ifr; struct if_data ifd; ifr.ifr_data = &ifd; ioctl(0, SIOCGIFDATA, (char *) &ifr); ifd.ifi_ibytes = ifd.ifi_obytes;], [with_ifdata=yes AC_DEFINE([HAVE_IFREQ_IFR_DATA], 1, [Define if you have a ifr_data member in struct ifreq])], with_ifdata=no) AC_MSG_RESULT([$with_ifdata]) fi if test "x$with_ifdata" = "xyes"; then AC_DEFINE([USE_IFDATA], 1, [Define if you want to use ifdata to get stats]) local=yes with_ioctl=yes fi # checking for route sysctl (*BSDs) test "x$with_route" = "xauto" -a "x$local" = "xyes" && with_route=no if test "x$with_route" != "xno"; then AC_CHECK_HEADERS(sys/sysctl.h net/if_dl.h) AC_CHECK_FUNC(sysctl, with_route=yes, with_route=no) if test "x$with_route" = "xyes"; then AC_MSG_CHECKING([for route info sysctl]) AC_TRY_COMPILE([#include #include #ifdef HAVE_SYS_PARAM_H #include #endif #ifdef HAVE_SYS_SYSCTL_H #include #endif #ifdef HAVE_NET_IF_H #include #endif #ifdef HAVE_NET_IF_DL_H #include #endif], [struct sockaddr_dl dl; struct if_msghdr ifm; int iflist[] = {CTL_NET, PF_ROUTE, 0, AF_LINK, NET_RT_IFLIST}; ifm.ifm_type = dl.sdl_nlen; dl.sdl_data + ifm.ifm_msglen; ifm.ifm_data.ifi_ibytes;], with_route=yes, with_route=no) AC_MSG_RESULT([$with_route]) if test "x$with_route" != "xno"; then AC_DEFINE([USE_ROUTE], 1, [Define this if you want to use roue(4) sysctl to get stats]) local=yes fi fi fi # checking for kvm (*BSDs) test "x$with_kvm" = "xauto" -a "x$local" = "xyes" && with_kvm=no if test "x$with_kvm" != "xno"; then AC_CHECK_FUNC(kvm_openfiles, with_kvm=yes, with_kvm=no) if test "x$with_kvm" != "xyes" ; then case "x$LIBS" in *-lkvm*) ;; *) AC_CHECK_LIB(kvm, kvm_openfiles, [LIBS="$LIBS -lkvm"; with_kvm=yes]) ;; esac fi if test "x$with_kvm" != "xyes"; then # see if emulation is possible AC_CHECK_HEADERS(nlist.h, [ AC_CHECK_FUNCS(knlist, [ with_kvm=yes AC_MSG_CHECKING([whether knlist takes 3 arguments]) AC_TRY_COMPILE([#include ],[knlist((struct nlist *) 0, 0, 10);], knlist3=yes, knlist3=no) AC_MSG_RESULT([$knlist3]) if test "x$knlist3" = "xyes"; then AC_DEFINE([HAVE_KNLIST_ARGS3], 1, [Define if knlist needs 3 arguments]) fi ], [AC_CHECK_FUNC(nlist, [with_kvm=yes])]) ]) if test "x$with_kvm" = "xyes"; then AC_CHECK_FUNCS(readx) AC_CHECK_HEADERS(paths.h) fi else AC_CHECK_HEADERS(kvm.h) AC_DEFINE([HAVE_KVM], 1, [Define if you have the kvm(3) interface]) fi if test "x$with_kvm" = "xyes"; then AC_MSG_CHECKING([whether struct ifnet has needed interface data]) AC_TRY_COMPILE([#include #include #include #ifdef HAVE_NET_IF_VAR_H #include #endif],[struct ifnet in; in.if_ibytes = in.if_obytes; in.if_type = in.if_flags], with_kvm=yes, with_kvm=no) AC_MSG_RESULT([$with_kvm]) fi if test "x$with_kvm" = "xyes"; then AC_MSG_CHECKING([for struct ifnet if_xname member]) AC_TRY_COMPILE([#include #include #include #ifdef HAVE_NET_IF_VAR_H #include #endif],[struct ifnet in; in.if_xname[0] = 'a';], ifxname=yes, ifxname=no) test "x$ifxname" = "xyes" && AC_DEFINE([HAVE_IFNET_IF_XNAME], 1, [Define if you have a if_xname member in struct ifnet]) AC_MSG_RESULT([$ifxname]) AC_MSG_CHECKING([for struct ifnet if_next member]) AC_TRY_COMPILE([#include #include #include #ifdef HAVE_NET_IF_VAR_H #include #endif],[struct ifnet in; in.if_next;], ifnext=yes, ifnext=no) AC_MSG_RESULT([$ifnext]) if test "x$ifnext" = "xyes"; then AC_DEFINE([HAVE_IFNET_IF_NEXT], 1, [Define if you have a if_next member in struct ifnet]) else AC_MSG_CHECKING([for struct ifnet if_link member]) AC_TRY_COMPILE([#include #include #include #ifdef HAVE_NET_IF_VAR_H #include #endif],[struct ifnet in; in.if_link;], iflink=yes, iflink=no) test "x$iflink" = "xyes" && AC_DEFINE([HAVE_IFNET_IF_LINK], 1, [Define if you have a if_link member in struct ifnet]) AC_MSG_RESULT([$iflink]) fi AC_DEFINE([USE_KVM], 1, [Define if you want to use kvm to get stats]) AC_MSG_WARN([you might need to make ifstat SGID kmem to run as simple user]) local=yes fi fi # checking for hp dlpi interface test "x$with_dlpi" = "xauto" -a "x$local" = "xyes" && with_dlpi=no if test "x$with_dlpi" != "xno"; then AC_CHECK_HEADERS(sys/dlpi.h sys/dlpi_ext.h stropts.h sys/mib.h) AC_MSG_CHECKING([for dlpi streams interface]) AC_TRY_COMPILE([#ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_SYS_DLPI_H #include #endif #ifdef HAVE_SYS_DLPI_EXT_H #include #endif #ifdef HAVE_STROPTS_H #include #endif #ifdef HAVE_SYS_MIB_H #include #endif], [mib_ifEntry mib; dl_hp_ppa_req_t req; struct strbuf ctlptr; putmsg(0, &ctlptr, NULL, 0);], with_dlpi=yes, with_dlpi=no) AC_MSG_RESULT([$with_dlpi]) if test "x$with_dlpi" = "xyes"; then AC_DEFINE([USE_DLPI], 1, [Define if you want to use dlpi to get stats]) local=yes fi fi test "x$with_win32" = "xauto" -a "x$local" = "xyes" && with_win32=no if test "x$with_win32" != "xno"; then AC_MSG_CHECKING([for win32 GetIfTable interface]) OLIBS="$LIBS" LIBS="$LIBS -liphlpapi" AC_TRY_LINK([#include #include ], [GetIfTable(NULL, NULL, 0);], [with_win32=yes], [with_win32=no; LIBS="$OLIBS"]) AC_MSG_RESULT([$with_win32]) if test "x$with_win32" = "xyes"; then AC_DEFINE([USE_WIN32], 1, [Define if you want to use win32 to get stats]) local=yes fi fi # checking for ioctl (siocgifconf) to get interfaces test "x$with_ioctl" = "xauto" -a "x$local" = "xyes" && with_ioctl=no if test "x$with_ioctl" != "xno"; then AC_DEFINE([USE_IOCTL], 1, [Define if you want to use ioctls to get if list]) AC_CHECK_FUNC(socket, checksocket=no, checksocket=yes) if test "x$checksocket" = "xyes"; then case "x$LIBS" in *-lsocket*);; *) AC_CHECK_LIB(socket, socket) ;; esac fi AC_CHECK_FUNC(if_nameindex, ifnameindex=yes, ifnameindex=no) if test "x$ifnameindex" != "xyes"; then case "x$LIBS" in *-lnsl*);; *) AC_CHECK_LIB(nsl, if_nameindex, [ifnameindex=yes; LIBS="$LIBS -lnsl"]) ;; esac fi if test "x$ifnameindex" != "xyes"; then AC_MSG_CHECKING([for sockaddr sa_len member]) AC_TRY_COMPILE([ #include #include ],[struct sockaddr sa; sa.sa_len = 1;], salen=yes, salen=no) test "x$salen" = "xyes" && AC_DEFINE([HAVE_SOCKADDR_SA_LEN], 1, [Define if you have a sa_len member in struct sockaddr]) AC_MSG_RESULT([$salen]) else AC_DEFINE([USE_IFNAMEINDEX], 1, [Define if you want ot use if_nameindex to find interfaces]) fi fi # checking for snmp (NET-SNMP/UCD-SNMP) if test "x$with_snmp" != "xno" ; then OCPPFLAGS="$CPPFLAGS" OLDFLAGS="$LDFLAGS" snmp_ok=no AC_PATH_PROG(netsnmpconfig, [net-snmp-config], [no], $PATH:$with_snmp) if test "x$netsnmpconfig" != "xno"; then CPPFLAGS="$CPPFLAGS `$netsnmpconfig --base-cflags 2>/dev/null`" LDFLAGS="$LDFLAGS `$netsnmpconfig --libs 2>/dev/null`" AC_MSG_CHECKING([whether net-snmp-config hints compiles and links fine]) AC_TRY_LINK([#include], [snmp_sess_init((void *) 0);], [snmp_ok=yes], [snmp_ok=no]) AC_MSG_RESULT([$snmp_ok]) if test "x$snmp_ok" = "xyes"; then with_snmp=yes snmp_type=net else CPPFLAGS="$OCPPFLAGS" LDFLAGS="$OLDFLAGS" fi fi if test "x$snmp_ok" != "xyes"; then if test "x$with_snmp" != "xyes" ; then CPPFLAGS="$CPPFLAGS -I$with_snmp/include" LDFLAGS="$LDFLAGS -L$with_snmp/lib" fi AC_CHECK_HEADER(net-snmp/net-snmp-config.h, snmp_type=net, [AC_CHECK_HEADER(ucd-snmp/ucd-snmp-config.h, snmp_type=ucd, with_snmp=no)]) if test "x$with_snmp" != "xno"; then if test "x$snmp_type" = "xnet"; then libsnmp="-lnetsnmp" else libsnmp="-lsnmp" fi with_snmp=no SNMPLIBALONE="$libsnmp" # Setting to be able to force linking with -lcrypto.... # This is needed on OpenBSD (at least) where the snmplib port links without -lcrypto, # but fails to run. AC_ARG_WITH(libcrypto, [ --with-libcrypto force link with -lcrypto for UCD-SNMP (default=no)], [], [with_libcrypto=no]) if test "x$with_libcrypto" = "xyes" ; then SNMPLIBALONE="" fi for lib in $SNMPLIBALONE "$libsnmp -lcrypto" ; do if test "x$with_snmp" != "xyes" ; then AC_MSG_CHECKING([for snmp support in $lib]) OLIBS="$LIBS" LIBS="$LIBS $lib" AC_TRY_LINK([], [snmp_sess_init();], [with_snmp=yes], [LIBS="$OLIBS"]) AC_MSG_RESULT([$with_snmp]) fi done fi fi if test "x$with_snmp" = "xyes" ; then AC_DEFINE([USE_SNMP], 1, [Define if you have SNMP support]) if test "x$snmp_type" = "xnet"; then AC_DEFINE([HAVE_NET_SNMP], 1, [Define if your SNMP implementation is net-snmp v5.0 or greater]) fi SNMPSRC=snmp.c AC_SUBST(SNMPSRC) # hint users about the possible needed option case `uname -s` in *OpenBSD*) case "$LIBS" in *-lcrypto*) ;; *) AC_MSG_WARN([SNMP test linked fine, but you might need to use --with-libcrypto for SNMP to work on this OS.]);; esac ;; esac else CPPFLAGS="$OCPPFLAGS" LDFLAGS="$OLDFLAGS" fi fi # checking that we do have at least one driver if test "x$local" != "xyes"; then if test "x$with_snmp" = "xyes"; then AC_MSG_WARN([no native stats gathering mechanism found; will use SNMP.]) else AC_MSG_ERROR([no statistics gathering methods found, porting needed.]) fi fi # check for library AC_ARG_ENABLE(library, [ --enable-library enable build and installation of libifstat (default=no)], LIBTARGET=libifstat.a, ) dnl Version VERSION="`cat VERSION`" test -z $VERSION && VERSION="0.0" # perl -MPOSIX -e 'print strftime("%Y%m%d", localtime((stat("CVS"))[9]));' test -d CVS && VERSION="$VERSION-cvs"`date +%Y%m%d` AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version]) dnl Output AC_SUBST(VERSION) AC_SUBST(CFLAGS) AC_SUBST(CPPFLAGS) AC_SUBST(LDFLAGS) AC_SUBST(LIBTARGET) AC_OUTPUT(Makefile) ifstat-1.1/data.c0100644000031000000620000000770307620574575012532 0ustar gaelstaff/* * ifstat - InterFace STATistics * Copyright (c) 2001, Gaël Roualland * * 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 program 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. * * 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., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id: data.c,v 1.7 2003/02/07 00:10:37 gael Exp $ */ #ifdef HAVE_CONFIG_H #include #endif #if STDC_HEADERS #include #else # ifndef HAVE_STRCHR # define strchr index # define strrchr rindex # endif char *strchr (), *strrchr (); # ifndef HAVE_MEMCPY # define memcpy(d, s, n) bcopy ((s), (d), (n)) # define memmove(d, s, n) bcopy ((s), (d), (n)) # endif #endif #ifdef HAVE_STDARG_H #include #endif #ifdef HAVE_ERRNO_H #include #endif #include #include #include "ifstat.h" const char *ifstat_version = VERSION; int ifstat_quiet = 0; char *ifstat_progname = "libifstat"; void _ifstat_error(char *format, ...) { va_list ap; fprintf(stderr, "%s: ", ifstat_progname); va_start(ap, format); vfprintf(stderr, format, ap); va_end(ap); putc('\n', stderr); } void (*ifstat_error) (char *format, ...) = &_ifstat_error; void ifstat_perror(char *func) { ifstat_error("%s: %s", func, strerror(errno)); } void ifstat_add_interface(struct ifstat_list *ifs, char *ifname, int flags) { struct ifstat_data *cur, *last; int len; /* check interface name */ if (*ifname == '\0') return; len = strlen(ifname); last = NULL; for (cur = ifs->first; cur != NULL; cur = cur->next) { if (len == cur->namelen && cur->name[0] == ifname[0] && !strncmp(cur->name + 1, ifname + 1, len - 1) && !(flags & IFSTAT_TOTAL) && !(cur->flags & IFSTAT_TOTAL)) return; last = cur; } if ((cur = calloc(1, sizeof(struct ifstat_data))) == NULL) { ifstat_perror("malloc"); exit(EXIT_FAILURE); } cur->name = strdup(ifname); cur->namelen = len; cur->flags = flags; if (last != NULL) last->next = cur; if (ifs->first == NULL) ifs->first = cur; } void ifstat_free_interface(struct ifstat_data *data) { free(data->name); free(data); } void ifstat_set_interface_stats(struct ifstat_data *data, unsigned long bytesin, unsigned long bytesout) { if (data->bout > bytesout || data->bin > bytesin) { if (!ifstat_quiet) ifstat_error("warning: rollover for interface %s, reinitialising.", data->name); data->obout = bytesout; data->obin = bytesin; } else { data->obout = data->bout; data->obin = data->bin; } data->bout = bytesout; data->bin = bytesin; data->flags |= IFSTAT_HASSTATS; } void ifstat_set_interface_index(struct ifstat_data *data, int index) { data->index = index; data->flags |= IFSTAT_HASINDEX; } struct ifstat_data *ifstat_get_interface(struct ifstat_list *ifs, char *ifname) { struct ifstat_data *ptr; int len = strlen(ifname); for (ptr = ifs->first; ptr != NULL; ptr = ptr->next) if (len == ptr->namelen && ptr->name[0] == ifname[0] && !strncmp(ptr->name + 1, ifname + 1, len - 1) && !(ptr->flags & IFSTAT_TOTAL)) return ptr; return NULL; } void ifstat_reset_interfaces(struct ifstat_list *ifs) { struct ifstat_data *ptr; int hasindex = 1; for (ptr = ifs->first; ptr != NULL; ptr = ptr->next) { if (!(ptr->flags & IFSTAT_HASINDEX)) hasindex = 0; ptr->flags &= ~(IFSTAT_HASSTATS|IFSTAT_HASINDEX); } if (hasindex) ifs->flags |= IFSTAT_HASINDEX; else ifs->flags &= ~IFSTAT_HASINDEX; } ifstat-1.1/drivers.c0100644000031000000620000010275507757535627013310 0ustar gaelstaff/* * ifstat - InterFace STATistics * Copyright (c) 2001, Gaël Roualland * * 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 program 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. * * 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., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id: drivers.c,v 1.45 2003/11/22 01:27:51 gael Exp $ */ #ifdef HAVE_CONFIG_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_PARAM_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #if STDC_HEADERS #include #else # ifndef HAVE_STRCHR # define strchr index # define strrchr rindex # endif char *strchr (), *strrchr (); # ifndef HAVE_MEMCPY # define memcpy(d, s, n) bcopy ((s), (d), (n)) # define memmove(d, s, n) bcopy ((s), (d), (n)) # endif #endif #ifdef HAVE_CTYPE_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_SYS_SOCKIO_H #include #endif #ifdef HAVE_SYS_IOCTL_H #include #endif #ifdef HAVE_NET_SOIOCTL_H #include #endif #ifdef HAVE_SYS_MBUF_H #include #endif #ifdef HAVE_NET_ROUTE_H #include #endif #ifdef HAVE_NET_IF_H #include #endif #ifdef HAVE_SYS_SYSCTL_H #include #endif #ifdef HAVE_NET_IF_MIB_H #include #endif #ifdef HAVE_NET_IF_VAR_H #include #endif #ifdef HAVE_NET_IF_TYPES_H #include #endif #ifdef HAVE_NET_IF_DL_H #include #endif #ifdef HAVE_SYS_DLPI_H #include #endif #ifdef HAVE_SYS_DLPI_EXT_H #include #endif #ifdef HAVE_STROPTS_H #include #endif #ifdef HAVE_SYS_MIB_H #include #endif #ifdef HAVE_KSTAT_H #include #endif #ifdef HAVE_FCNTL_H #include #endif #ifdef HAVE_KVM_H #include #endif #ifdef HAVE_ERRNO_H #include #endif #ifdef HAVE_LIMITS_H #include #endif #ifdef HAVE_NLIST_H #include #endif #ifdef HAVE_PATHS_H #include #endif #include #include #include "ifstat.h" #ifdef USE_SNMP #include "snmp.h" #endif #ifndef IFNAMSIZ #define IFNAMSIZ 16 #endif #ifdef USE_WIN32 #include #include #ifndef IFF_UP #define IFF_UP 1 #endif #ifndef IFF_LOOPBACK #define IFF_LOOPBACK 2 #endif #endif static void examine_interface(struct ifstat_list *ifs, char *name, int ifflags, int iftype) { #ifdef IFF_LOOPBACK if ((ifflags & IFF_LOOPBACK) && !(ifs->flags & IFSTAT_LOOPBACK)) return; #endif #ifdef IFF_UP if (!(ifflags & IFF_UP) && !(ifs->flags & IFSTAT_DOWN)) return; #endif #ifdef IFT_PFLOG /* assume PFLOG interfaces are loopbacks (on OpenBSD) */ if (iftype == IFT_PFLOG && !(ifs->flags & IFSTAT_LOOPBACK)) return; #endif ifstat_add_interface(ifs, name, 0); } #ifdef USE_IOCTL #ifdef USE_IFNAMEINDEX static int ioctl_map_ifs(int sd, int (*mapf)(int sd, struct ifreq *ifr, void *data), void *mdata) { struct if_nameindex *iflist, *cur; struct ifreq ifr; if ((iflist = if_nameindex()) == NULL) { ifstat_perror("if_nameindex"); return 0; } for(cur = iflist; cur->if_index != 0 && cur->if_name != NULL; cur++) { memcpy(ifr.ifr_name, cur->if_name, sizeof(ifr.ifr_name)); ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0'; if (!mapf(sd, &ifr, mdata)) return 0; } if_freenameindex(iflist); return 1; } #else static int ioctl_map_ifs(int sd, int (*mapf)(int sd, struct ifreq *ifr, void *data), void *mdata) { struct ifconf ifc; struct ifreq *ifr; int len, n, res = 0; char *buf; #ifdef SIOCGIFNUM if (ioctl(sd, SIOCGIFNUM, &n) < 0) { ifstat_perror("ioctl(SIOCGIFNUM):"); goto end; } n += 2; #else n = 256; /* bad bad bad... */ #endif len = n * sizeof(struct ifreq); if ((buf = malloc(len)) == NULL) { ifstat_perror("malloc"); return 0; } ifc.ifc_buf = buf; ifc.ifc_len = len; if (ioctl(sd, SIOCGIFCONF, (char *)&ifc) < 0) { ifstat_perror("ioctl(SIOCGIFCONF):"); goto end; } n = 0; while (n < ifc.ifc_len) { ifr = (struct ifreq *) (buf + n); #ifdef HAVE_SOCKADDR_SA_LEN n += sizeof(ifr->ifr_name) + ifr->ifr_addr.sa_len; #else n += sizeof(struct ifreq); #endif if (!mapf(sd, ifr, mdata)) goto end; } res = 1; end: free(buf); return res; } #endif static int ioctl_map_scan(int sd, struct ifreq *ifr, void *data) { if (ioctl(sd, SIOCGIFFLAGS, (char *)ifr) != 0) return 1; examine_interface((struct ifstat_list *) data, ifr->ifr_name, ifr->ifr_flags, 0); return 1; } static int ioctl_scan_interfaces(struct ifstat_driver *driver, struct ifstat_list *ifs) { int sd; if ((sd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { ifstat_perror("socket"); return 0; } ioctl_map_ifs(sd, &ioctl_map_scan, (void *) ifs); close(sd); return 1; } #endif #ifdef USE_KSTAT static int get_kstat_long(kstat_t *ksp, char *name, unsigned long *value) { kstat_named_t *data; if ((data = kstat_data_lookup(ksp, name)) == NULL) return 0; switch (data->data_type) { #ifdef KSTAT_DATA_INT32 /* solaris 2.6 and over */ case KSTAT_DATA_INT32: *value = data->value.i32; break; case KSTAT_DATA_INT64: *value = data->value.i64; break; case KSTAT_DATA_UINT32: *value = data->value.ui32; break; case KSTAT_DATA_UINT64: *value = data->value.ui64; break; #else case KSTAT_DATA_LONGLONG: *value = data->value.ll; break; case KSTAT_DATA_ULONGLONG: *value = data->value.ull; break; case KSTAT_DATA_LONG: *value = data->value.l; break; case KSTAT_DATA_ULONG: *value = data->value.ul; break; #endif default: return 0; } return 1; } static int kstat_open_driver(struct ifstat_driver *driver, char *options) { kstat_ctl_t *kc; if ((kc = kstat_open()) == NULL) { ifstat_perror("kstat_open"); return 0; } driver->data = (void *) kc; return 1; } static int kstat_get_stats(struct ifstat_driver *driver, struct ifstat_list *ifs) { unsigned long bytesin, bytesout; struct ifstat_data *cur; kstat_ctl_t *kc = driver->data; kstat_t *ksp; for (cur = ifs->first; cur != NULL; cur = cur->next) { if (cur->flags & IFSTAT_TOTAL) continue; if ((ksp = kstat_lookup(kc, NULL, -1, cur->name)) == NULL || ksp->ks_type != KSTAT_TYPE_NAMED) continue; if (kstat_read(kc, ksp, 0) >= 0 && get_kstat_long(ksp, "obytes", &bytesout) && get_kstat_long(ksp, "rbytes", &bytesin)) ifstat_set_interface_stats(cur, bytesin, bytesout); } return 1; } static void kstat_close_driver(struct ifstat_driver *driver) { kstat_close(((kstat_ctl_t *) driver->data)); } #endif #ifdef USE_KVM #ifndef HAVE_KVM /* use internal emulation using open/read/nlist */ #ifndef _POSIX2_LINE_MAX #define _POSIX2_LINE_MAX 2048 #endif #ifndef _PATH_KMEM #define _PATH_KMEM "/dev/kmem" #endif #ifndef _PATH_UNIX #define _PATH_UNIX "/vmunix" #endif typedef struct _kvm_t { int fd; char *errbuf; char *execfile; } kvm_t; static void _kvm_error(char *errbuf, char *message) { strncpy(errbuf, message ? message : strerror(errno), _POSIX2_LINE_MAX - 1); errbuf[_POSIX2_LINE_MAX - 1] = '\0'; } static kvm_t *kvm_openfiles(const char *execfile, const char *corefile, const char *swapfile, int flags, char *errbuf) { kvm_t *kd; if (swapfile != NULL) { _kvm_error(errbuf, "swap file option not supported"); return NULL; } if ((kd = malloc(sizeof(kvm_t))) == NULL) { _kvm_error(errbuf, NULL); return NULL; } if ((kd->fd = open(corefile ? corefile : _PATH_KMEM, flags)) < 0) { _kvm_error(errbuf, NULL); free(kd); return NULL; } kd->execfile = execfile ? strdup(execfile) : NULL; kd->errbuf = errbuf; return kd; } static int kvm_nlist (kvm_t *kd, struct nlist *nl) { int count; #ifdef HAVE_KNLIST if (kd->execfile == NULL) { #ifdef HAVE_KNLIST_ARGS3 for(count = 0; nl[count].n_name != NULL; count++); count = knlist(nl, count, sizeof(struct nlist)); #else count = knlist(nl); #endif if (count < 0) _kvm_error(kd->errbuf, "error looking up symbol in live kernel"); return count; } #endif if ((count = nlist(kd->execfile ? kd->execfile : _PATH_UNIX, nl)) < 0) _kvm_error(kd->errbuf, "error looking up symbol in kernel file"); return count; } #ifdef HAVE_READX #define KOFFSET(x) ((x) & 0x7FFFFFFF) #define KREAD(fd, buf, size, addr) readx((fd), (buf), (size), ((off_t) (addr)) < 0 ? 1 : 0) #else #define KOFFSET(x) (x) #define KREAD(fd, buf, size, addr) read((fd), (buf), (size)) #endif static ssize_t kvm_read(kvm_t *kd, unsigned long addr, void *buf, size_t nbytes) { ssize_t len; if (lseek(kd->fd, KOFFSET(addr), SEEK_SET) == -1) { _kvm_error(kd->errbuf, NULL); return -1; } if ((len = KREAD(kd->fd, buf, nbytes, addr)) < 0) { _kvm_error(kd->errbuf, NULL); return -1; } return len; } static int kvm_close(kvm_t *kd) { close(kd->fd); free(kd->execfile); free(kd); return 0; } #endif struct kvm_driver_data { kvm_t *kvmfd; unsigned long ifnetaddr; char errbuf[_POSIX2_LINE_MAX + 1]; }; static int kvm_open_driver(struct ifstat_driver *driver, char *options) { struct kvm_driver_data *data; struct nlist kvm_syms[2]; unsigned long ifnetaddr; char *files[3] = { NULL /* execfile */, NULL /* corefile */, NULL /* swapfile */ }; int i; if ((data = malloc(sizeof(struct kvm_driver_data))) == NULL) { ifstat_perror("malloc"); return 0; } data->errbuf[0] = '\0'; /* cut options : [execfile][,[corefile][,[swapfile]]] */ i = 0; while (options != NULL && i < 3) { char *v = strchr(options, ','); if (v != NULL) *v++ = '\0'; if (*options != '\0') files[i] = options; i++; options = v; } if ((data->kvmfd = kvm_openfiles(files[0], files[1], files[2], O_RDONLY, data->errbuf)) == NULL) { ifstat_error("kvm_openfiles: %s", data->errbuf); return 0; } memset(&kvm_syms, 0, sizeof(kvm_syms)); kvm_syms[0].n_name = "_ifnet"; if (kvm_nlist(data->kvmfd, kvm_syms) < 0 || kvm_syms[0].n_value == 0) { kvm_syms[0].n_name = "ifnet"; if (kvm_nlist(data->kvmfd, kvm_syms) < 0) { ifstat_error("kvm_nlist: %s", data->errbuf); return 0; } } if (kvm_syms[0].n_value == 0) { ifstat_error("kvm: no _ifnet or ifnet symbol found"); return 0; } if (kvm_read(data->kvmfd, (unsigned long) kvm_syms[0].n_value, &ifnetaddr, sizeof(ifnetaddr)) < 0) { ifstat_error("kvm_read(ifnetaddr): %s", data->errbuf); return 0; } if (ifnetaddr == 0) { ifstat_error("kvm: ifnetaddr has null address."); return 0; } data->ifnetaddr = ifnetaddr; driver->data = (void *) data; return 1; } #ifdef HAVE_IFNET_IF_NEXT #define IFNET_NEXT(ifnet) (ifnet).if_next #else #ifdef HAVE_IFNET_IF_LINK #define if_list if_link #endif #ifndef TAILQ_NEXT #define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) #endif #define IFNET_NEXT(ifnet) TAILQ_NEXT((&ifnet), if_list) #endif static int kvm_map_ifs(struct ifstat_driver *driver, int (*mapf)(char *name, struct ifnet *ifnet, void *data), void *mdata) { struct kvm_driver_data *data = driver->data; unsigned long ifaddr; struct ifnet ifnet; #ifndef HAVE_IFNET_IF_XNAME char ifname[IFNAMSIZ + 1]; #endif char interface[IFNAMSIZ + 10]; for (ifaddr = data->ifnetaddr; ifaddr != 0; ifaddr = (unsigned long) IFNET_NEXT(ifnet)) { if (kvm_read(data->kvmfd, ifaddr, &ifnet, sizeof(ifnet)) < 0) { ifstat_error("kvm_read: %s", data->errbuf); return 0; } #ifdef HAVE_IFNET_IF_XNAME memcpy(interface, ifnet.if_xname, sizeof(interface)); interface[sizeof(interface) - 1] = '\0'; #else if (kvm_read(data->kvmfd, (unsigned long) ifnet.if_name, &ifname, sizeof(ifname)) < 0) { ifstat_error("kvm_read: %s", data->errbuf); return 0; } ifname[sizeof(ifname) - 1] = '\0'; sprintf(interface, "%s%d", ifname, ifnet.if_unit); #endif if (!mapf(interface, &ifnet, mdata)) return 0; } return 1; } static int kvm_map_stats(char *name, struct ifnet *ifnet, void *data) { struct ifstat_data *cur; if ((cur = ifstat_get_interface((struct ifstat_list *) data, name)) == NULL) return 1; ifstat_set_interface_stats(cur, ifnet->if_ibytes, ifnet->if_obytes); return 1; } static int kvm_get_stats(struct ifstat_driver *driver, struct ifstat_list *ifs) { return kvm_map_ifs(driver, &kvm_map_stats, (void *) ifs); } static int kvm_map_scan(char *name, struct ifnet *ifnet, void *data) { examine_interface((struct ifstat_list *) data, name, ifnet->if_flags, ifnet->if_type); return 1; } static int kvm_scan_interfaces(struct ifstat_driver *driver, struct ifstat_list *ifs) { return kvm_map_ifs(driver, &kvm_map_scan, (void *) ifs); } static void kvm_close_driver(struct ifstat_driver *driver) { kvm_close(((struct kvm_driver_data *) driver->data)->kvmfd); } #endif #ifdef USE_IFMIB static int get_ifcount() { int ifcount[] = { CTL_NET, PF_LINK, NETLINK_GENERIC, IFMIB_SYSTEM, IFMIB_IFCOUNT }; int count, size; size = sizeof(count); if (sysctl(ifcount, sizeof(ifcount) / sizeof(int), &count, &size, NULL, 0) < 0) { ifstat_perror("sysctl(net.link.generic.ifmib.ifcount)"); return -1; } return count; } static int get_ifdata(int index, struct ifmibdata * ifmd) { int ifinfo[] = { CTL_NET, PF_LINK, NETLINK_GENERIC, IFMIB_IFDATA, index, IFDATA_GENERAL }; int size = sizeof(*ifmd); if (sysctl(ifinfo, sizeof(ifinfo) / sizeof(int), ifmd, &size, NULL, 0) < 0) return 0; return 1; } static int ifmib_scan_interfaces(struct ifstat_driver *driver, struct ifstat_list *ifs) { int count, i; struct ifmibdata ifmd; if ((count = get_ifcount()) <= 0) return 0; for (i = 1; i <= count; i++) { if (!get_ifdata(i, &ifmd)) continue; examine_interface(ifs, ifmd.ifmd_name, ifmd.ifmd_flags, ifmd.ifmd_data.ifi_type); } return 1; } static int ifmib_get_stats(struct ifstat_driver *driver, struct ifstat_list *ifs) { int count, i; struct ifmibdata ifmd; struct ifstat_data *cur; if (ifs->flags & IFSTAT_HASINDEX) { /* poll by index */ for (cur = ifs->first; cur != NULL; cur = cur->next) { i = ifstat_get_interface_index(cur); if (i < 0 || !get_ifdata(i, &ifmd)) continue; if (strcmp(ifstat_get_interface_name(cur), ifmd.ifmd_name)) continue; ifstat_set_interface_stats(cur, ifmd.ifmd_data.ifi_ibytes, ifmd.ifmd_data.ifi_obytes); ifstat_set_interface_index(cur, i); } return 1; } if ((count = get_ifcount()) <= 0) return 0; for (i = 1; i <= count; i++) { if (!get_ifdata(i, &ifmd)) continue; if ((cur = ifstat_get_interface(ifs, ifmd.ifmd_name)) == NULL) continue; ifstat_set_interface_stats(cur, ifmd.ifmd_data.ifi_ibytes, ifmd.ifmd_data.ifi_obytes); ifstat_set_interface_index(cur, i); } return 1; } #endif #ifdef USE_IFDATA struct ifdata_driver_data { int sd; #ifdef HAVE_IFREQ_IFR_DATA struct if_data ifd; #else struct ifdatareq ifd; #endif }; static int ifdata_open_driver(struct ifstat_driver *driver, char *options) { struct ifdata_driver_data *data; if ((data = malloc(sizeof(struct ifdata_driver_data))) == NULL) { ifstat_perror("malloc"); return 0; } if ((data->sd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { ifstat_perror("socket"); free(data); return 0; } driver->data = (void *) data; return 1; } static struct if_data *ifdata_get_data(struct ifdata_driver_data *data, char *name) { #ifdef HAVE_IFREQ_IFR_DATA struct ifreq ifr; strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); ifr.ifr_data = (caddr_t) &(data->ifd); if (ioctl(data->sd, SIOCGIFDATA, (char *) &ifr) < 0) return NULL; return &(data->ifd); #else strncpy(data->ifd.ifd_name, name, sizeof(data->ifd.ifd_name)); if (ioctl(data->sd, SIOCGIFDATA, (char *) &(data->ifd)) < 0) return NULL; return &(data->ifd.ifd_ifd); #endif } struct ifdata_scan_data { struct ifstat_list *ifs; struct ifdata_driver_data *data; }; static int ifdata_map_scan(int sd, struct ifreq *ifr, void *pdata) { struct ifdata_scan_data *sdata = pdata; struct if_data *ifd; if (ioctl(sd, SIOCGIFFLAGS, (char *)ifr) != 0) return 1; if ((ifd = ifdata_get_data(sdata->data, ifr->ifr_name)) == NULL) return 1; examine_interface(sdata->ifs, ifr->ifr_name, ifr->ifr_flags, ifd->ifi_type); return 1; } static int ifdata_scan_interfaces(struct ifstat_driver *driver, struct ifstat_list *ifs) { struct ifdata_driver_data *data = driver->data; struct ifdata_scan_data sdata = { ifs, data }; return ioctl_map_ifs(data->sd, &ifdata_map_scan, &sdata); } static int ifdata_get_stats(struct ifstat_driver *driver, struct ifstat_list *ifs) { struct ifdata_driver_data *data = driver->data; struct if_data *ifd; struct ifstat_data *cur; for (cur = ifs->first; cur != NULL; cur = cur->next) { if (cur->flags & IFSTAT_TOTAL) continue; if ((ifd = ifdata_get_data(data, cur->name)) != NULL) ifstat_set_interface_stats(cur, ifd->ifi_ibytes, ifd->ifi_obytes); } return 1; } static void ifdata_close_driver(struct ifstat_driver *driver) { struct ifdata_driver_data *data = driver->data; if (data->sd >= 0) close(data->sd); free(data); } #endif #ifdef USE_PROC struct proc_driver_data { char *file; int checked; }; static int proc_open_driver(struct ifstat_driver *driver, char *options) { struct proc_driver_data *data; if ((data = malloc(sizeof(struct proc_driver_data))) == NULL) { ifstat_perror("malloc"); return 0; } data->file = (options != NULL) ? strdup(options) : NULL; data->checked = 0; driver->data = (void *) data; return 1; } static void proc_close_driver(struct ifstat_driver *driver) { struct proc_driver_data *data = driver->data; if (data->file != NULL) free(data->file); free(data); } static int proc_get_stats(struct ifstat_driver *driver, struct ifstat_list *ifs) { char buf[1024]; FILE *f; char *iface, *stats; unsigned long bytesin, bytesout; struct ifstat_data *cur; struct proc_driver_data *data = driver->data; char *file; if (data->file != NULL) file = data->file; else file = PROC_FILE; if ((f = fopen(file, "r")) == NULL) { ifstat_error("can't open %s: %s", file, strerror(errno)); return 0; } /* check first lines */ if (fgets(buf, sizeof(buf), f) == NULL) goto badproc; if (!data->checked && strncmp(buf, "Inter-|", 7)) goto badproc; if (fgets(buf, sizeof(buf), f) == NULL) goto badproc; if (!data->checked) { if (strncmp(buf, " face |by", 9)) goto badproc; data->checked = 1; } while (fgets(buf, sizeof(buf), f) != NULL) { if ((stats = strchr(buf, ':')) == NULL) continue; *stats++ = '\0'; iface = buf; while (*iface == ' ') iface++; if (*iface == '\0') continue; if (sscanf(stats, "%lu %*u %*u %*u %*u %*u %*u %*u %lu %*u", &bytesin, &bytesout) != 2) continue; if ((cur = ifstat_get_interface(ifs, iface)) != NULL) ifstat_set_interface_stats(cur, bytesin, bytesout); } fclose(f); return 1; badproc: fclose(f); ifstat_error("%s: unsupported format.", file); return 0; } #endif #ifdef USE_ROUTE struct route_driver_data { char *buf; size_t size; }; #define DEFAULT_SIZE 16384 static int route_open_driver(struct ifstat_driver *driver, char *options) { struct route_driver_data *data; if ((data = malloc(sizeof(struct route_driver_data))) == NULL) { ifstat_perror("malloc"); return 0; } if ((data->buf = malloc(DEFAULT_SIZE)) < 0) { ifstat_perror("malloc"); free(data); return 0; } data->size = DEFAULT_SIZE; driver->data = (void *) data; return 1; } static int route_map_ifs(struct ifstat_driver *driver, int (*mapf)(char *name, struct if_msghdr *ifmsg, void *data), void *mdata) { struct route_driver_data *data = driver->data; int iflist[] = { CTL_NET, PF_ROUTE, 0, AF_LINK, NET_RT_IFLIST, 0 }; struct if_msghdr *ifm; struct sockaddr_dl *dl; char *ptr; char ifname[IFNAMSIZ + 1]; size_t len; if (data->size != 0) { /* try with current buf size */ len = data->size; if (sysctl(iflist, sizeof(iflist) / sizeof(int), data->buf, &len, NULL, 0) < 0) { if (errno != ENOMEM) { ifstat_perror("sysctl"); return 0; } /* buffer too small */ free (data->buf); data->size = 0; } } if (data->size == 0) { /* ask for size */ if (sysctl(iflist, sizeof(iflist) / sizeof(int), NULL, &len, NULL, 0) < 0) { ifstat_perror("sysctl"); return 0; } if ((data->buf = malloc(len)) < 0) { ifstat_perror("malloc"); return 0; } if (sysctl(iflist, sizeof(iflist) / sizeof(int), data->buf, &len, NULL, 0) < 0) { ifstat_perror("sysctl"); return 0; } } /* browse interfaes */ for (ptr = data->buf; ptr < data->buf + len; ptr += ifm->ifm_msglen) { ifm = (struct if_msghdr *) ptr; if (ifm->ifm_type != RTM_IFINFO) continue; if (ifm->ifm_msglen <= sizeof(struct if_msghdr)) /* no address */ continue; dl = (struct sockaddr_dl *) (ptr + sizeof(struct if_msghdr)); if (dl->sdl_family != AF_LINK) continue; if (dl->sdl_nlen > (sizeof(ifname) - 1)) dl->sdl_nlen = sizeof(ifname) - 1; memcpy(ifname, dl->sdl_data, dl->sdl_nlen); ifname[dl->sdl_nlen] = '\0'; if (!mapf(ifname, ifm, mdata)) return 0; } return 1; } static int route_map_stats(char *name, struct if_msghdr *ifmsg, void *data) { struct ifstat_data *cur; if ((cur = ifstat_get_interface((struct ifstat_list *) data, name)) == NULL) return 1; ifstat_set_interface_stats(cur, ifmsg->ifm_data.ifi_ibytes, ifmsg->ifm_data.ifi_obytes); return 1; } static int route_get_stats(struct ifstat_driver *driver, struct ifstat_list *ifs) { return route_map_ifs(driver, &route_map_stats, ifs); } static int route_map_scan(char *name, struct if_msghdr *ifmsg, void *data) { examine_interface((struct ifstat_list *) data, name, ifmsg->ifm_flags, ifmsg->ifm_data.ifi_type); return 1; } static int route_scan_interfaces(struct ifstat_driver *driver, struct ifstat_list *ifs) { return route_map_ifs(driver, &route_map_scan, (void *) ifs); } static void route_close_driver(struct ifstat_driver *driver) { struct route_driver_data *data = driver->data; if (data->buf != NULL) free(data->buf); free(data); } #endif #ifdef USE_DLPI #define DLPI_DEFBUF_LEN 1024 #define DLPI_NO_PPA -1 #define DLPI_DEVICE "/dev/dlpi" struct dlpi_driver_data { int fd; unsigned int *buf; int maxlen; int ppa; }; static int dlpi_open_driver(struct ifstat_driver *driver, char *options) { struct dlpi_driver_data *dlpi; if ((dlpi = malloc(sizeof(struct dlpi_driver_data))) == NULL) { ifstat_perror("malloc"); return 0; } if ((dlpi->fd = open(options != NULL ? options : DLPI_DEVICE, O_RDWR)) < 0) { ifstat_perror("open"); free(dlpi); return 0; } dlpi->maxlen = DLPI_DEFBUF_LEN; if ((dlpi->buf = malloc(dlpi->maxlen)) == NULL) { ifstat_perror("malloc"); free(dlpi); return 0; } dlpi->ppa = DLPI_NO_PPA; driver->data = (void *) dlpi; return 1; } static int dlpi_req (struct dlpi_driver_data *dlpi, void *req, int reqlen, int ackprim, void **ack, int *acklen) { struct strbuf ctlptr; int len, ret, flags; dl_error_ack_t *err_ack; ctlptr.maxlen = 0; ctlptr.len = reqlen; ctlptr.buf = req; if (putmsg(dlpi->fd, &ctlptr, NULL, 0) < 0) { ifstat_perror("putmsg"); return 0; } ctlptr.maxlen = dlpi->maxlen; ctlptr.buf = (char *) dlpi->buf; ctlptr.len = 0; len = 0; flags = 0; while ((ret = getmsg(dlpi->fd, &ctlptr, NULL, &flags)) == MORECTL) { /* duplicate size of buf */ dlpi->maxlen *= 2; if ((dlpi->buf = realloc(dlpi->buf, dlpi->maxlen)) == NULL) { ifstat_perror("malloc"); return 0; } len += ctlptr.len; ctlptr.buf = (char *) dlpi->buf + len; ctlptr.maxlen = dlpi->maxlen - len; ctlptr.len = 0; } if (ret < 0) { ifstat_perror("getmsg"); return 0; } len += ctlptr.len; err_ack = (dl_error_ack_t *) dlpi->buf; if (err_ack->dl_primitive != ackprim) { if (err_ack->dl_primitive == DL_ERROR_ACK) { errno = err_ack->dl_errno; ifstat_perror("dlpi"); } else { ifstat_error("dlpi: unexpected ack type returned"); } return 0; } if (ack != NULL) *ack = dlpi->buf; if (acklen != NULL) *acklen = len; return 1; } static int dlpi_attach(struct dlpi_driver_data *dlpi, int ppa) { dl_attach_req_t attach_req; dl_detach_req_t dettach_req; /* check if already attached */ if (dlpi->ppa == ppa) return 1; /* else detach */ if (dlpi->ppa != DLPI_NO_PPA) { dettach_req.dl_primitive = DL_DETACH_REQ; if (!dlpi_req(dlpi, &dettach_req, sizeof(dl_detach_req_t), DL_OK_ACK, NULL, NULL)) return 0; dlpi->ppa = DLPI_NO_PPA; if (ppa == DLPI_NO_PPA) return 1; /* we're done */ } /* attach */ attach_req.dl_primitive = DL_ATTACH_REQ; attach_req.dl_ppa = ppa; if (!dlpi_req(dlpi, &attach_req, sizeof(dl_attach_req_t), DL_OK_ACK, NULL, NULL)) return 0; dlpi->ppa = ppa; return 1; } static int dlpi_get_ifmib(struct dlpi_driver_data *dlpi, int ppa, mib_ifEntry *mib) { dl_get_statistics_req_t stats_req; dl_get_statistics_ack_t *stats_ack; int len; /* first attach to PPA */ if (!dlpi_attach(dlpi, ppa)) return 0; /* grab stats */ stats_req.dl_primitive = DL_GET_STATISTICS_REQ; if (!dlpi_req(dlpi, &stats_req, sizeof(dl_get_statistics_req_t), DL_GET_STATISTICS_ACK, (void **) &stats_ack, &len)) return 0; if (len < sizeof(dl_get_statistics_ack_t) || stats_ack->dl_stat_offset < 0 || stats_ack->dl_stat_offset + sizeof(mib_ifEntry) > len) { ifstat_error("dlpi: invalid data returned by stats ack"); } memcpy(mib, (char *) stats_ack + stats_ack->dl_stat_offset, sizeof(mib_ifEntry)); return 1; } static int dlpi_map_ifs(struct dlpi_driver_data *dlpi, int (*mapf)(mib_ifEntry *mib, int ppa, char *name, void *mdata), void *mdata) { dl_hp_ppa_req_t ppa_req; dl_hp_ppa_ack_t *ppa_ack; dl_hp_ppa_info_t *ppa_info; mib_ifEntry mib; void *buf; int len, i, ofs; char ifname[sizeof(ppa_info->dl_module_id_1) + 12]; if (!dlpi_attach(dlpi, DLPI_NO_PPA)) return 0; ppa_req.dl_primitive = DL_HP_PPA_REQ; if (!dlpi_req(dlpi, &ppa_req, sizeof(ppa_req), DL_HP_PPA_ACK, (void **) &ppa_ack, &len)) return 0; if (len < sizeof(dl_hp_ppa_ack_t)) { ifstat_error("dlpi: short read for ppa ack"); return 0; } /* copy buffer since used by later calls */ if ((buf = malloc(len)) == NULL) { perror("malloc"); return 0; } memcpy(buf, (void *) ppa_ack, len); ppa_ack = buf; /* browse interface list */ ofs = ppa_ack->dl_offset; for(i = 0; i < ppa_ack->dl_count; i++) { if (ofs < 0 || ofs + sizeof(dl_hp_ppa_info_t) > len) { ifstat_error("dlpi: data returned by ppa ack exceeds data buffer"); free(buf); return 0; } ppa_info = (dl_hp_ppa_info_t *) ((char *) ppa_ack + ofs); if (dlpi_get_ifmib(dlpi, ppa_info->dl_ppa, &mib)) { sprintf(ifname, "%s%d", ppa_info->dl_module_id_1, ppa_info->dl_instance_num); if (!mapf(&mib, ppa_info->dl_ppa, ifname, mdata)) { free(buf); return 0; } } ofs = ppa_ack->dl_offset + ppa_info->dl_next_offset; } free(buf); return 1; } static int dlpi_map_scan(mib_ifEntry *mib, int ppa, char *name, void *mdata) { examine_interface((struct ifstat_list *) mdata, name, (mib->ifOper == 1 ? IFF_UP : 0) | (mib->ifType == 24 ? IFF_LOOPBACK : 0), 0); return 1; } static int dlpi_scan_interfaces(struct ifstat_driver *driver, struct ifstat_list *ifs) { return dlpi_map_ifs(driver->data, &dlpi_map_scan, (void *) ifs); } static int dlpi_map_stats(mib_ifEntry *mib, int ppa, char *name, void *mdata) { struct ifstat_data *cur; if ((cur = ifstat_get_interface((struct ifstat_list *) mdata, name)) == NULL) return 1; ifstat_set_interface_stats(cur, mib->ifInOctets, mib->ifOutOctets); ifstat_set_interface_index(cur, ppa); return 1; } static int dlpi_get_stats(struct ifstat_driver *driver, struct ifstat_list *ifs) { int i; struct ifstat_data *cur; mib_ifEntry mib; if (ifs->flags & IFSTAT_HASINDEX) { /* poll by index (ppa) */ for (cur = ifs->first; cur != NULL; cur = cur->next) { i = ifstat_get_interface_index(cur); if (!dlpi_get_ifmib(driver->data, i, &mib)) continue; ifstat_set_interface_stats(cur, mib.ifInOctets, mib.ifOutOctets); ifstat_set_interface_index(cur, i); } return 1; } return dlpi_map_ifs(driver->data, &dlpi_map_stats, (void *) ifs); } void dlpi_close_driver(struct ifstat_driver *driver) { struct dlpi_driver_data *dlpi = driver->data; free(dlpi->buf); close(dlpi->fd); free(dlpi); } #endif #ifdef USE_WIN32 struct win32_driver_data { void *buf; int len; }; static int win32_open_driver(struct ifstat_driver *driver, char *options) { struct win32_driver_data *data; if ((data = malloc(sizeof(struct win32_driver_data))) == NULL) { ifstat_perror("malloc"); return 0; } data->buf = NULL; data->len = 0; driver->data = (void *) data; return 1; } static int win32_getiftable(struct ifstat_driver *driver, PMIB_IFTABLE *iftable) { struct win32_driver_data *data = driver->data; ULONG size; DWORD ret; size = data->len; while ((ret = GetIfTable((PMIB_IFTABLE) data->buf, &size, 1)) == ERROR_INSUFFICIENT_BUFFER) { data->len = size * 2; if ((data->buf = realloc(data->buf, data->len)) == NULL) { perror("realloc"); return 0; } } if (ret == NO_ERROR) { *iftable = (PMIB_IFTABLE) data->buf; return 1; } perror("GetIfTable"); return 0; } static int win32_scan_interfaces(struct ifstat_driver *driver, struct ifstat_list *ifs) { PMIB_IFTABLE iftable; DWORD i; if (!win32_getiftable(driver, &iftable)) return 0; for (i = 0; i < iftable->dwNumEntries; i++) examine_interface(ifs, iftable->table[i].bDescr, ((iftable->table[i].dwOperStatus == MIB_IF_OPER_STATUS_OPERATIONAL) ? IFF_UP : 0) | ((iftable->table[i].dwType == MIB_IF_TYPE_LOOPBACK) ? IFF_LOOPBACK : 0), 0); return 1; } static int win32_get_stats(struct ifstat_driver *driver, struct ifstat_list *ifs) { PMIB_IFTABLE iftable; DWORD i; struct ifstat_data *cur; if (!win32_getiftable(driver, &iftable)) return 0; for (i = 0; i < iftable->dwNumEntries; i++) { if ((cur = ifstat_get_interface(ifs, iftable->table[i].bDescr)) != NULL) ifstat_set_interface_stats(cur, (unsigned long) iftable->table[i].dwInOctets, (unsigned long) iftable->table[i].dwOutOctets); } return 1; } void win32_close_driver(struct ifstat_driver *driver) { struct win32_driver_data *data = driver->data; if (data->buf != NULL) free(data->buf); free(data); } #endif static struct ifstat_driver drivers[] = { #ifdef USE_KSTAT { "kstat", &kstat_open_driver, &ioctl_scan_interfaces, &kstat_get_stats, &kstat_close_driver }, #endif #ifdef USE_IFMIB { "ifmib", NULL, &ifmib_scan_interfaces, &ifmib_get_stats, NULL }, #endif #ifdef USE_IFDATA { "ifdata", &ifdata_open_driver, &ifdata_scan_interfaces, &ifdata_get_stats, &ifdata_close_driver }, #endif #ifdef USE_ROUTE { "route", &route_open_driver, &route_scan_interfaces, &route_get_stats, &route_close_driver }, #endif #ifdef USE_KVM { "kvm", &kvm_open_driver, &kvm_scan_interfaces, &kvm_get_stats, &kvm_close_driver }, #endif #ifdef USE_PROC { "proc", &proc_open_driver, &ioctl_scan_interfaces, &proc_get_stats, &proc_close_driver }, #endif #ifdef USE_DLPI { "dlpi", &dlpi_open_driver, &dlpi_scan_interfaces, &dlpi_get_stats, &dlpi_close_driver }, #endif #ifdef USE_WIN32 { "win32", &win32_open_driver, &win32_scan_interfaces, &win32_get_stats, &win32_close_driver }, #endif #ifdef USE_SNMP { "snmp", &snmp_open_driver, &snmp_scan_interfaces, &snmp_get_stats, &snmp_close_driver }, #endif { NULL } }; int ifstat_get_driver(char *name, struct ifstat_driver *driver) { int num = 0; if (name != NULL) for (num = 0; drivers[num].name != NULL; num++) if (!strcasecmp(drivers[num].name, name)) break; if (drivers[num].name == NULL) return 0; memcpy(driver, &(drivers[num]), sizeof(struct ifstat_driver)); driver->data = NULL; return 1; } char* ifstat_list_drivers() { int num; int len = 0, pos = 0; char *res; for(num = 0; drivers[num].name != NULL; num++) len += strlen(drivers[num].name) + 2; if ((res = malloc(len + 1)) == NULL) { ifstat_perror("malloc"); return NULL; } for(num = 0; drivers[num].name != NULL; num++) { if (num != 0) { memcpy(res + pos, ", ", 2); pos += 2; } len = strlen(drivers[num].name); memcpy(res + pos, drivers[num].name, len); pos += len; } res[pos] = '\0'; return res; } ifstat-1.1/ifstat.c0100644000031000000620000004046407757535627013122 0ustar gaelstaff/* * ifstat - InterFace STATistics * Copyright (c) 2001, Gaël Roualland * * 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 program 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. * * 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., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id: ifstat.c,v 1.47 2003/11/22 01:27:51 gael Exp $ */ #ifdef HAVE_CONFIG_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #if STDC_HEADERS #include #else # ifndef HAVE_STRCHR # define strchr index # define strrchr rindex # endif char *strchr (), *strrchr (); # ifndef HAVE_MEMCPY # define memcpy(d, s, n) bcopy ((s), (d), (n)) # define memmove(d, s, n) bcopy ((s), (d), (n)) # endif #endif #ifdef HAVE_CTYPE_H #include #endif #if TIME_WITH_SYS_TIME # include # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif #ifdef HAVE_SYS_TERMIOS_H #include #endif #ifdef HAVE_SYS_IOCTL_H #include #endif #ifdef HAVE_SIGNAL_H #include #endif #include #include #include "ifstat.h" #ifdef HAVE_SIGACTION static void _setsig(int sig, RETSIGTYPE (*handler)(int)) { struct sigaction sa; memset(&sa, 0, sizeof(struct sigaction)); sa.sa_handler = handler; sigemptyset(&sa.sa_mask); sa.sa_flags = SA_RESTART; sigaction(sig, &sa, NULL); } #define SIGNAL(si, handler) _setsig((si), (handler)) #define RESIGNAL(si, handler) #else #define SIGNAL(si, handler) signal((si), (handler)) #define RESIGNAL(si, handler) signal((si), (handler)) #endif #ifndef HAVE_SNPRINTF /* bogus implementation with vsprintf */ #ifdef HAVE_STDARG_H #include #endif #include int snprintf(char *str, size_t size, const char *format, ...) { int res; va_list ap; va_start(ap, format); res = vsprintf(str, format, ap); va_end(ap); assert(res + 1 <= size); return res; } #endif #ifdef WIN32 /* native win32 misses gettimeofday and its select doesn't behave the same way, so replace them by bogus versions that work as expected here */ #include #include static int win_select(int nfds, void *fdr, void *fdw, void *fde, struct timeval *tv) { Sleep(tv->tv_sec * 1000 + tv->tv_usec / 1000); return 0; } #define select win_select static int win_gettimeofday(struct timeval *tv, void *tz) { struct _timeb timeb; _ftime(&timeb); tv->tv_sec = timeb.time; tv->tv_usec = timeb.millitm * 1000; return 0; } #define gettimeofday win_gettimeofday #endif /* parse interface list, using \ as escape character */ static int parse_interfaces(char *string, struct ifstat_list *ifs) { char *s, *d, *buf; int len, escaped = 0; if (string == NULL || (len = strlen(string)) <= 0) return 0; if ((buf = malloc(len + 1)) == NULL) { ifstat_perror("malloc"); return 0; } d = buf; for(s = string; *s != '\0'; s++) { if (!escaped) { if (*s == '\\') { escaped = 1; continue; } if (*s == ',') { *d = '\0'; ifstat_add_interface(ifs, buf, 0); d = buf; continue; } } else escaped = 0; *d++ = *s; } *d = '\0'; if (*buf != '\0') ifstat_add_interface(ifs, buf, 0); free(buf); return 1; } static void usage(int result) { fprintf(stderr, "usage: %s [-a] [-l] [-z] [-n] [-v] [-h] [-t] [-i if0,if1,...]\n" " [-d drv[:opt]] [-s [comm@][#]host[/nn]] [-T] [-A] [-w]\n" " [-W] [-S] [-b] [-q] [delay[/delay] [count]]\n", ifstat_progname); exit(result); } static void print_center(char *s, int len, int width) { int ofs, i; ofs = (width - len) / 2; for (i = 0; i < ofs; i++) putc(' ', stdout); for (i = 0; i < len; i++) putc(s[i], stdout); for (i = 0; i < (width - (ofs + len)); i++) putc(' ', stdout); } struct { int cols, lines, datalines; } termsize; int _sigwinch = 0; static RETSIGTYPE update_termsize(int sig) { #ifdef TIOCGWINSZ struct winsize ws; if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == 0 && ws.ws_row > 0 && ws.ws_col > 0) { termsize.cols = ws.ws_col; termsize.lines = ws.ws_row; } else { /* defaults if unknown */ termsize.lines = 25; termsize.cols = 80; } #ifdef SIGWINCH if (sig == SIGWINCH) _sigwinch = 1; RESIGNAL(SIGWINCH, &update_termsize); #endif #endif } int _sigcont = 0; #ifdef SIGCONT static RETSIGTYPE sigcont(int sig) { _sigcont = 1; RESIGNAL(SIGCONT, &sigcont); } #endif #define OPT_TIMESTAMP 1 #define OPT_FIXEDWIDTH 2 #define OPT_UNITBITS 4 #define OPT_NOINDEX 8 #define OPT_NONULL 16 #define OPT_NOSCAN 32 #define OPT_WRAP 64 #define OPT_NOTITLE 128 #define OPT_NOSCROLL 256 #define SPACE " " #define NUM "12345.12" #define NA " n/a" #define WIDTH (sizeof(NUM) - 1) * 2 + (sizeof(SPACE) - 1) #define LEN(options, namelen) (((options) & OPT_FIXEDWIDTH || (namelen) < WIDTH) ? WIDTH : (namelen)) #define FMT(n) (((n) < 1e+5) ? "%8.2f" : (((n) < 1e+6) ? "%.1f" : "%.2e")) /* eth0 lo KB/s in KB/s out KB/s in KB/s out 14562.23 12345.25 0.00 0.00 */ static void print_wrap(int options, int line) { putc('\n', stdout); putc((char) (((line - 1) % 26) + 65), stdout); if (options & OPT_TIMESTAMP) fputs(" " SPACE, stdout); } static int pos_next(int pos, int len, int options) { int ofs = (options & OPT_TIMESTAMP) ? 8 + sizeof(SPACE) - 1 : 1; pos += len + sizeof(SPACE) - 1; if (options & OPT_WRAP && pos + ofs + len >= termsize.cols) pos = 0; return pos; } static void print_legend(struct ifstat_data *ptr, int options, int line) { int len, pos; if (line == 0) { putc('\n', stdout); if (options & OPT_TIMESTAMP) fputs("HH:MM:SS" SPACE, stdout); else if (options & OPT_WRAP) putc(' ', stdout); } else print_wrap(options, line); pos = 0; for (; ptr != NULL; ptr = ptr->next) { if (pos > 0) fputs(SPACE, stdout); len = LEN(options, ptr->namelen); print_center((options & OPT_UNITBITS) ? " Kbps in Kbps out" : " KB/s in KB/s out", WIDTH, len); if ((pos = pos_next(pos, len, options)) == 0 && ptr->next != NULL) return; } putc('\n', stdout); } static void print_header(struct ifstat_list *ifs, int options) { struct ifstat_data *ptr, *start; int len, pos, line; if (options & OPT_TIMESTAMP) fputs(" Time " SPACE, stdout); else if (options & OPT_WRAP) putc(' ', stdout); pos = 0; line = 0; start = ifs->first; for (ptr = ifs->first; ptr != NULL; ptr = ptr->next) { if (pos == 0 && ptr != ifs->first) { print_legend(start, options, line); start = ptr; print_wrap(options, ++line); } else if (pos > 0) fputs(SPACE, stdout); len = LEN(options, ptr->namelen); print_center(ptr->name, ptr->namelen < len ? ptr->namelen : len, len); pos = pos_next(pos, len, options); } termsize.datalines = line + 1; print_legend(start, options, line); } static void print_stats(struct ifstat_list *ifs, struct timeval *start, struct timeval *end, int options) { struct ifstat_data *ptr; int hasindex = 1, pos = 0, len, line = 0; char stats[WIDTH + 1]; double delay, kbin, kbout, tkbin, tkbout, scale; struct tm *ltm; if (options & OPT_NOSCROLL) putc('\r', stdout); if (options & OPT_TIMESTAMP) { time_t t = end->tv_sec; if ((ltm = localtime(&t)) != NULL) fprintf(stdout, "%02d:%02d:%02d" SPACE, ltm->tm_hour, ltm->tm_min, ltm->tm_sec); else fputs("--:--:--" SPACE, stdout); } else if (options & OPT_WRAP) putc(' ', stdout); delay = end->tv_sec - start->tv_sec + ((double) (end->tv_usec - start->tv_usec)) / (double) 1000000; scale = delay * (options & OPT_UNITBITS ? 128 : 1024); tkbin = tkbout = 0; for (ptr = ifs->first; ptr != NULL; ptr = ptr->next) { if (ptr->flags & IFSTAT_HASSTATS) { kbin = (double) (ptr->bin - ptr->obin) / (double) scale; tkbin += kbin; kbout = (double) (ptr->bout - ptr->obout) / (double) scale; tkbout += kbout; ptr->flags &= ~IFSTAT_HASSTATS; } else if (ptr->flags & IFSTAT_TOTAL) { kbin = tkbin; kbout = tkbout; } else { kbin = -1; kbout = -1; } if (ptr->flags & IFSTAT_HASINDEX) ptr->flags &= ~IFSTAT_HASINDEX; else hasindex = 0; if (kbin >= 0) snprintf(stats, sizeof(NUM), FMT(kbin), kbin); else strcpy(stats, NA); strcpy(stats + sizeof(NUM) - 1, SPACE); if (kbout >= 0) snprintf(stats + sizeof(NUM) + sizeof(SPACE) - 2, sizeof(NUM), FMT(kbout), kbout); else strcpy(stats + sizeof(NUM) + sizeof(SPACE) - 2, NA); if (pos == 0 && ptr != ifs->first) print_wrap(options, ++line); else if (pos > 0) fputs(SPACE, stdout); len = LEN(options, ptr->namelen); print_center(stats, WIDTH, len); pos = pos_next(pos, len, options); } termsize.datalines = line + 1; if (!(options & OPT_NOSCROLL)) putc('\n', stdout); if (hasindex && !(options & OPT_NOINDEX)) ifs->flags |= IFSTAT_HASINDEX; else ifs->flags &= ~IFSTAT_HASINDEX; } static void filter_interfaces(struct ifstat_list *ifs, int options) { struct ifstat_data *cur, *next, *parent; cur = ifs->first; parent = NULL; while (cur != NULL) { if (!(cur->flags & IFSTAT_HASSTATS) || ((options & OPT_NONULL) && cur->bin == 0 && cur->bout == 0)) { next = cur->next; if (parent != NULL) parent->next = next; else ifs->first = next; ifstat_free_interface(cur); cur = next; } else { parent = cur; cur = cur->next; } } } static void needarg(char opt, int arg, int argc) { if (arg + 1 >= argc) { fprintf(stderr, "%s: option '%c' requires an argument!\n", ifstat_progname, opt); usage(EXIT_FAILURE); } } static double getdelay(char *string) { double delay; if ((delay = atof(string)) < 0.1) { fprintf(stderr, "%s: bad or too short delay '%s'!\n", ifstat_progname, string); exit(EXIT_FAILURE); } return delay; } /* computes time remaining before start + delay */ static int notdone(struct timeval *start, struct timeval *tv_delay, struct timeval *remains) { struct timeval now; struct timeval end; gettimeofday(&now, NULL); end.tv_sec = start->tv_sec + tv_delay->tv_sec; end.tv_usec = start->tv_usec + tv_delay->tv_usec; if (end.tv_usec >= 1000000) { end.tv_sec += (end.tv_usec / 1000000); end.tv_usec %= 1000000; } remains->tv_sec = end.tv_sec - now.tv_sec; remains->tv_usec = end.tv_usec - now.tv_usec; if (remains->tv_usec < 0) { remains->tv_sec--; remains->tv_usec += 1000000; } return (remains->tv_sec >= 0); } int main(int argc, char **argv) { struct ifstat_list ifs; struct ifstat_driver driver; int arg, iter, lasthdr; char *opt; char *dname = NULL; char *dopts = NULL; double delay = 1, first_delay = 1; int count = 0; int options = 0; struct timeval start, tv_delay, tv; if ((ifstat_progname = strrchr(argv[0], '/')) != NULL) ifstat_progname++; else ifstat_progname = argv[0]; ifs.flags = 0; ifs.first = NULL; /* parse options */ for (arg = 1; arg < argc; arg++) { if (argv[arg][0] != '-' || argv[arg][1] == '\0') break; opt = argv[arg]+1; while (*opt) { switch(*opt) { case 'a': ifs.flags |= IFSTAT_LOOPBACK|IFSTAT_DOWN; break; case 'l': ifs.flags |= IFSTAT_LOOPBACK; break; case 'v': printf("ifstat version %s.\n" "Copyright (C) 2001-2003, Gaël Roualland \n", ifstat_version); opt = ifstat_list_drivers(); printf("Compiled-in drivers: %s.\n", (opt != NULL) ? opt : ""); free(opt); exit(EXIT_SUCCESS); case 'A': options |= OPT_NOINDEX; break; case 'n': options |= OPT_NOTITLE; break; case 't': options |= OPT_TIMESTAMP; break; case 'w': options |= OPT_FIXEDWIDTH; break; case 'b': options |= OPT_UNITBITS; break; case 'z': options |= OPT_NONULL; break; case 'W': options |= OPT_WRAP|OPT_FIXEDWIDTH; break; case 'T': ifs.flags |= IFSTAT_TOTAL; break; case 'S': options |= OPT_NOSCROLL|OPT_NOTITLE; break; case 'd': needarg(*opt, arg, argc); dname = argv[++arg]; if ((dopts = strchr(dname, ':')) != NULL) *dopts++ = '\0'; break; case 'i': needarg(*opt, arg, argc); if (!parse_interfaces(argv[++arg], &ifs)) { fprintf(stderr, "%s: error parsing interface list.\n", ifstat_progname); exit(EXIT_FAILURE); } options |= OPT_NOSCAN; break; case 's': needarg(*opt, arg, argc); dname = "snmp"; dopts = argv[++arg]; break; case 'q': ifstat_quiet = 1; break; case 'h': usage(EXIT_SUCCESS); default: fprintf(stderr, "%s: invalid option '-%c'.\n", ifstat_progname, *opt); usage(EXIT_FAILURE); } opt++; } } if (options & OPT_NOSCROLL) options &= ~OPT_WRAP; /* has delay ? */ if (arg < argc) { if ((opt = strchr(argv[arg], '/')) != NULL) *opt++ = '\0'; first_delay = getdelay(argv[arg]); delay = (opt != NULL) ? getdelay(opt) : first_delay; arg++; } /* has count ? */ if (arg < argc) { if ((count = atoi(argv[arg])) <= 0) { fprintf(stderr, "%s: bad count '%s'!\n", ifstat_progname, argv[arg]); return EXIT_FAILURE; } arg++; } /* extra arguments */ if (arg < argc) { fprintf(stderr, "%s: too many arguments!\n", ifstat_progname); return EXIT_FAILURE; } /* look for driver */ if (!ifstat_get_driver(dname, &driver)) { fprintf(stderr, "%s: driver %s not available in this binary!\n", ifstat_progname, dname); return EXIT_FAILURE; } /* init driver */ if (driver.open_driver != NULL && !driver.open_driver(&driver, dopts)) return EXIT_FAILURE; if (ifs.first == NULL) driver.scan_interfaces(&driver, &ifs); /* poll interfaces for the first time */ if (ifs.first != NULL) { if (driver.get_stats != NULL && !driver.get_stats(&driver, &ifs)) return EXIT_FAILURE; gettimeofday(&start, NULL); if (!(options & OPT_NOSCAN)) filter_interfaces(&ifs, options); ifstat_reset_interfaces(&ifs); } if (ifs.first == NULL) { fprintf(stderr, "%s: no interfaces to monitor!\n", ifstat_progname); if (driver.close_driver != NULL) driver.close_driver(&driver); return EXIT_FAILURE; } if (ifs.flags & IFSTAT_TOTAL) ifstat_add_interface(&ifs, "Total", IFSTAT_TOTAL); /* update size of terminal if needed/possible */ if (!(options & OPT_NOTITLE) || (options & OPT_WRAP)) { update_termsize(0); #ifdef SIGWINCH SIGNAL(SIGWINCH, &update_termsize); #endif } #ifdef SIGCONT /* register SIGCONT for redisplay of header */ if (!(options & OPT_NOTITLE) || (options & OPT_NOSCROLL)) SIGNAL(SIGCONT, &sigcont); #endif print_header(&ifs, options); lasthdr = 1; tv_delay.tv_sec = (int) first_delay; tv_delay.tv_usec = (int) ((first_delay - tv_delay.tv_sec) * 1000000); for (iter = 1; count == 0 || iter <= count; iter++) { if (iter == 2 && first_delay != delay) { tv_delay.tv_sec = (int) delay; tv_delay.tv_usec = (int) ((delay - tv_delay.tv_sec) * 1000000); } tv = tv_delay; while (select(0, NULL, NULL, NULL, &tv) != 0 && _sigwinch && notdone(&start, &tv_delay, &tv)) /* restart select if interrupted by sigwinch */ _sigwinch = 0; if (_sigcont || (!(options & OPT_NOTITLE) && termsize.lines > (3 * termsize.datalines) && (iter - lasthdr) * termsize.datalines >= (termsize.lines - (3 * termsize.datalines)))) { print_header(&ifs, options); lasthdr = iter; _sigcont = 0; } if (driver.get_stats != NULL && !driver.get_stats(&driver, &ifs)) return EXIT_FAILURE; gettimeofday(&tv, NULL); print_stats(&ifs, &start, &tv, options); start = tv; fflush(stdout); } if (driver.close_driver != NULL) driver.close_driver(&driver); return EXIT_SUCCESS; } ifstat-1.1/ifstat.h0100644000031000000620000000566507651046562013117 0ustar gaelstaff/* * ifstat - InterFace STATistics * Copyright (c) 2001, Gaël Roualland * * 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 program 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. * * 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., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id: ifstat.h,v 1.21 2003/04/21 19:58:42 gael Exp $ */ #ifndef IFSTAT_H #define IFSTAT_H #define IFSTAT_API 1 /* interface flags */ #define IFSTAT_LOOPBACK 1 #define IFSTAT_DOWN 2 #define IFSTAT_HASSTATS 4 #define IFSTAT_HASINDEX 8 #define IFSTAT_TOTAL 128 /* interface list */ struct ifstat_data { char *name; int namelen; unsigned long obout, obin, bout, bin; int flags, index; struct ifstat_data *next; }; struct ifstat_list { struct ifstat_data *first; int flags; }; /* driver data */ struct ifstat_driver { char *name; /* driver initialisation, returns 1 if successfull */ int (*open_driver) (struct ifstat_driver *driver, char *options); /* scans list of known interfaces by the driver */ int (*scan_interfaces) (struct ifstat_driver *driver, struct ifstat_list *ifs); /* gathers stats and updates interface lists */ int (*get_stats) (struct ifstat_driver *driver, struct ifstat_list *ifs); /* frees/closes driver data */ void (*close_driver) (struct ifstat_driver *driver); /* private driver data */ void *data; }; /* interface managing calls */ void ifstat_add_interface(struct ifstat_list *ifs, char *ifname, int flags); void ifstat_free_interface(struct ifstat_data *data); void ifstat_set_interface_stats(struct ifstat_data *data, unsigned long bytesin, unsigned long bytesout); void ifstat_set_interface_index(struct ifstat_data *data, int index); #define ifstat_get_interface_index(data) ((data)->index) #define ifstat_get_interface_name(data) ((data)->name) struct ifstat_data *ifstat_get_interface(struct ifstat_list *ifs, char *ifname); void ifstat_reset_interfaces(struct ifstat_list *ifs); /* redefine those to override defaults if needed */ extern char *ifstat_progname; extern void (*ifstat_error) (char *format, ...); extern int ifstat_quiet; /* version string */ extern const char *ifstat_version; /* perror reporting --internal */ void ifstat_perror(char *); /* searches for specified driver (NULL = default). Returns 1 if found */ int ifstat_get_driver(char *name, struct ifstat_driver *driver); /* get driver list */ char *ifstat_list_drivers(); #endif ifstat-1.1/ifstat.pod0100644000031000000620000001371507757535627013461 0ustar gaelstaff#!/bin/sh pod2man --center="System Utilities" --release="ifstat `cat VERSION`" --lax --section=1 ifstat.pod > ifstat.1 exit 0; =cut =head1 NAME ifstat - Report InterFace STATistics =head1 SYNOPSIS B [B<-a>] [B<-l>] [B<-z>] [B<-n>] [B<-v>] [B<-h>] [B<-t>] [B<-i> if0,if1,...] [B<-d> drv[:opt]] [B<-s> [comm@][#]host[/nn]] [B<-T>] [B<-A>] [B<-w>] [B<-W>] [B<-S>] [B<-b>] [B<-q>] [delay[/delay] [count]] =head1 DESCRIPTION Ifstat is a little tool to report interface activity, just like iostat/vmstat do for other system statistics. =head1 OPTIONS B accepts the following options: =over 4 =item B<-l> Enables monitoring of loopback interfaces for which statistics are available. By default, ifstat monitors all non-loopback interfaces that are up. =item B<-a> Enables monitoring of all interfaces found for which statistics are available. =item B<-z> Hides interface which counters are null, eg interfaces that are up but not used. =item B<-i> Specifies the list of interfaces to monitor, separated by commas (if an interface name has a comma, it can be escaped with '\'). Multiple instances of the options are added together. =item B<-s> Equivalent to B<-d snmp:[comm@][#]host[/nn]]> to poll a remote host through SNMP. See below for details. =item B<-h> Displays a short help message. =item B<-n> Turns off displaying the header periodically. =item B<-t> Adds a timestamp at the beginning of each line. =item B<-T> Reports total bandwith for all monitored interfaces. =item B<-A> Disables use of interface indexes: by default, when polling mechanism is index based (snmp, ifmib), ifstat remembers indexes of monitored interfaces to poll only them. However, if interfaces indexes change often (new interfaces added, etc), you might loose some stats, hence this flag. Note that if you ask ifstat to monitor a non existent interface, it will poll all interfaces until it finds the requested one (regardless of this flag) so you can poll for an interface that goes up and down. =item B<-w> Uses fixed width columns, instead of enlarging them if needed for interfaces names to fit. =item B<-W> Wrap lines that are larger than the terminal width (implies -w). Wrapped lines are prefixed with a cycling letter to ease reading. =item B<-S> Keep stats updated on the same line if possible (no scrolling nor wrapping). =item B<-b> Reports bandwith in kbits/sec instead of kbytes/sec. =item B<-q> Quiet mode, warnings are not printed. =item B<-v> Displays version and the compiled-in drivers. =item B<-d> Specifies a driver to use to gather stats and an eventual option for this driver separated of the driver name by a colon. If this is not specified, ifstat uses the first driver compiled in, with no options. The following drivers are available (depending on the operating system and compile-time options, not all of them might be present): =over 4 =item B This driver gets statistics from Linux's /proc/net/dev file. An alternate file name to get stats from can be passed as the option. =item B This driver gets statistics from FreeBSD's ifmib sysctl. It doesn't accept any options. =item B This driver gets statistics from Solaris kstat interface. It doesn't accept any options. =item B This driver gets statistics using SIOCGIFDATA ioctl under IRIX and OpenBSD (different semantics). It doesn't accept any options. =item B This driver gets statistics using routing sysctl on BSD based systems. It doesn't accept any options. =item B This driver gets statistics by reading the kernel live structures. It accepts an option specifying which files/devices to use in the following format : [execfile][,[corefile][,swapfile]] (see kvm_open(3) for details on those fields). If a null string is passed for a parameter, the system default will be used for it. Note that for this driver to work, ifstat needs to have read access to the system memory device. This is usually done by running it as root, or by installing setgid mem or kmem. ifstat will NOT install setgid by default; It is up to you to decide if you trust it. =item B This driver gets statistics using the DLPI streams interface available on HP-UX. An alternate device to query statistics from can be passed as the option (default is /dev/dlpi). =item B This driver gets statistics using the GetIfTable interface available on Win32 systems. It doesn't accept any options. =item B This driver gets statistics through SNMP. The option, in the form [comm@][#]host[/nn]], specifies the host and eventual community to poll. Default community is public, but can be changed by prepending "comm@" to the hostname. If host starts by a #, interface names are generated from their index as `ifNN' (this is a workaround for some equipments that give all interfaces the same description). Default host is localhost, and this will be used by default if snmp is the only available driver. The driver will try to poll several interfaces at once by grouping requests in SNMP packets. By default interfaces will be polled by group of 8. If this doesn't work well with your equipments, you can lower that number by suffixing the hostname with /nn, where nn is the number of interfaces to poll at once. You can also increase the number if you want to poll a large number of interfaces efficiently and if your server supports it. =back =item B B is the delay between updates in seconds, which defaults to 1. A decimal number can be specified for intervals shorter than a second. (minimum 0.1) A second delay can also be specified (separated from the first one by a '/'). In that case the first delay will be used for the first poll after start and the second one will be used for all following polls (This can be used to have a "fast" start when running for a long while with a big delay). =item B B is the number of updates before stopping. If not specified, it is unlimited. =back =head1 SEE ALSO vmstat(1), iostat(1) =head1 AUTHOR Gaël Roualland, ifstat-1.1/ifstat.spec0100644000031000000620000000255307775071053013613 0ustar gaelstaff# Time-stamp: <01/12/25 14:04:41 ifstat.spec wbosse@berlin.snafu.de> # $Id: ifstat.spec,v 1.9 2004/01/01 19:16:59 gael Exp $ Name: ifstat Summary: InterFace STATistics Version: 1.1 Release: 1 Group: Applications Copyright: GPL Vendor: Gaël Roualland URL: http://gael.roualland.free.fr/ifstat/ Packager: Werner Bosse Source0: %{name}-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot Requires: ucd-snmp BuildPrereq: ucd-snmp-devel %description ifstat(1) is a little tool to report interface activity like vmstat/iostat do. In addition, ifstat can poll remote hosts through SNMP if you have the ucd-snmp library. It will also be used for localhost if no other known method works (You need to have snmpd running for this though). See also %{_docdir}/%{name}-%{version} %changelog * %(echo `LC_ALL=C date '+%a %b %d %Y'`) %(whoami)@%(hostname) - built %{version} on %(cat /etc/*-release | head -1) * Tue Dec 25 2001 Werner Bosse - initialization of spec file. %prep %setup -q ./configure --prefix=%{_prefix} --enable-optim %build make %install rm -rf $RPM_BUILD_ROOT make prefix=$RPM_BUILD_ROOT%{_prefix} mandir=$RPM_BUILD_ROOT%{_mandir} install %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root) %doc README INSTALL TODO COPYING HISTORY %{_bindir}/* %{_mandir}/man*/* ifstat-1.1/install-sh0100755000031000000620000001273607402774450013453 0ustar gaelstaff#!/bin/sh # # install - install a program, script, or datafile # This comes from X11R5 (mit/util/scripts/install.sh). # # Copyright 1991 by the Massachusetts Institute of Technology # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation, and that the name of M.I.T. not be used in advertising or # publicity pertaining to distribution of the software without specific, # written prior permission. M.I.T. makes no representations about the # suitability of this software for any purpose. It is provided "as is" # without express or implied warranty. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: chmodcmd="" else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 ifstat-1.1/libifstat-config.in0100755000031000000620000000206607542211650015212 0ustar gaelstaff#!/bin/sh prefix=@prefix@ exec_prefix=@exec_prefix@ exec_prefix_set=no usage="\ Usage: libifstat-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--libs] [--cflags]" if test $# -eq 0; then echo "${usage}" 1>&2 exit 1 fi while test $# -gt 0; do case "$1" in -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; *) optarg= ;; esac case $1 in --prefix=*) prefix=$optarg if test $exec_prefix_set = no ; then exec_prefix=$optarg fi ;; --prefix) echo $prefix ;; --exec-prefix=*) exec_prefix=$optarg exec_prefix_set=yes ;; --exec-prefix) echo $exec_prefix ;; --version) echo @VERSION@ ;; --cflags) includedir=-I@includedir@ if [ "x$includedir" = "x-I/usr/include" ] ; then echo # do not add /usr/include else echo $includedir fi ;; --libs) libdir=-L@libdir@ echo $libdir -lifstat @LIBS@ ;; *) echo "${usage}" 1>&2 exit 1 ;; esac shift done ifstat-1.1/snmp.c0100644000031000000620000003751307656042572012574 0ustar gaelstaff/* * ifstat - InterFace STATistics * Copyright (c) 2001, Gaël Roualland * * 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 program 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. * * 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., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id: snmp.c,v 1.26 2003/05/06 23:30:02 gael Exp $ */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include "ifstat.h" #ifdef USE_SNMP #include #include #include #include #include #ifdef HAVE_NET_SNMP #include #include #else #include #include #endif #include "snmp.h" /* define this to use ifcount as a hint to discover interfaces does not work well with routers that do not number interfaces sequentially, but is faster that the ifIndex walk used otherwise */ #undef USE_SNMP_IFCOUNT static char *snmp_sess_errstring(struct snmp_session *ss) { char *res; snmp_error(ss, NULL, NULL, &res); return res; } #ifdef USE_SNMP_IFCOUNT /* report the value interfaces.ifNumber.0, actually the number of interfaces */ static int snmp_get_ifcount(struct snmp_session *ss) { int nifaces = -1; oid ifcount[] = { 1, 3, 6, 1, 2, 1, 2, 1, 0 }; struct snmp_pdu *pdu; struct snmp_pdu *response = NULL; int status; if ((pdu = snmp_pdu_create(SNMP_MSG_GET)) == NULL) { ifstat_error("snmp_pdu_create: %s", snmp_api_errstring(snmp_errno)); return -1; } snmp_add_null_var(pdu, ifcount, sizeof(ifcount) / sizeof(oid)); if ((status = snmp_synch_response(ss, pdu, &response)) != STAT_SUCCESS || response->errstat != SNMP_ERR_NOERROR || response->variables == NULL || response->variables->type != ASN_INTEGER) { if (status == STAT_SUCCESS) ifstat_error("snmp: Error: %s", snmp_errstring(response->errstat)); else ifstat_error("snmpget(interfaces.ifNumber.0): %s", snmp_sess_errstring(ss)); if (response) snmp_free_pdu(response); return -1; } nifaces = *(response->variables->val.integer); snmp_free_pdu(response); if (nifaces < 0) return -1; return nifaces; } #endif static int snmp_get_nextif(struct snmp_session *ss, int index) { oid ifindex[] = { 1, 3, 6, 1, 2, 1, 2, 2, 1, 1, 0 }; int len = sizeof(ifindex) / sizeof(oid); struct snmp_pdu *pdu; struct snmp_pdu *response = NULL; struct variable_list *vars; int status; if (index >= 0) ifindex[len - 1] = index; if ((pdu = snmp_pdu_create(SNMP_MSG_GETNEXT)) == NULL) { ifstat_error("snmp_pdu_create: %s", snmp_api_errstring(snmp_errno)); return -1; } snmp_add_null_var(pdu, ifindex, (index < 0) ? len - 1 : len); if ((status = snmp_synch_response(ss, pdu, &response)) != STAT_SUCCESS || response->errstat != SNMP_ERR_NOERROR || response->variables == NULL) { if (status == STAT_SUCCESS) ifstat_error("snmp: Error: %s", snmp_errstring(response->errstat)); else ifstat_error("snmpgetnext(interfaces.ifTable.ifEntry.ifIndex...): %s", snmp_sess_errstring(ss)); if (response != NULL) snmp_free_pdu(response); return -1; } for(vars = response->variables; vars; vars = vars->next_variable) { /* check that the variable is under the base oid */ if (vars->name_length != len) continue; if (memcmp(ifindex, vars->name, sizeof(ifindex) - sizeof(oid)) != 0) continue; index = vars->name[vars->name_length - 1]; snmp_free_pdu(response); return index; } snmp_free_pdu(response); return -1; } #define S_IFNAMEMAX 64 struct ifsnmp { char name[S_IFNAMEMAX]; unsigned long bout, bin; int flags, index; }; #define S_UP 1 #define S_BIN 2 #define S_BOUT 4 #define S_LOOP 8 #define S_INVALID 16 #define S_NUMNAME 32 #define S_IFNAME 64 /* fill a struct ifsnmp buffer of selected information (flags) for interface index to (index + nifaces - 1). ifsnmp must be large enough, and nifaces shouldb'nt too large since some devices have limited capability for large responses... In case we get a unknown name answer and we're polling several interfaces at once, interfaces will be polled again individually to try to solve the problem. */ static int snmp_get_ifinfos(struct snmp_session *ss, int nifaces, int flags, struct ifsnmp * ifsnmp, int *toobig) { struct snmp_pdu *pdu, *response = NULL; oid ifinfo[] = { 1, 3, 6, 1, 2, 1, 2, 2, 1, 0, 0 }; /* interfaces.ifTable.ifEntry.x.n */ #define ifDescr 2 #define ifType 3 #define ifOperStatus 8 #define ifInOctets 10 #define ifOutOctets 16 struct variable_list *vars; int i, status; if (nifaces <= 0) return 0; if ((pdu = snmp_pdu_create(SNMP_MSG_GET)) == NULL) { ifstat_error("snmp_pdu_create: %s", snmp_api_errstring(snmp_errno)); return 0; } for (i = 0; i < nifaces; i++) { ifsnmp[i].flags = 0; ifsnmp[i].name[0] = 0; /* set interface index */ ifinfo[10] = ifsnmp[i].index; if (flags & S_NUMNAME) { sprintf(ifsnmp[i].name, "if%d", ifsnmp[i].index); } else if (flags & S_IFNAME) { /* require descr */ ifinfo[9] = ifDescr; snmp_add_null_var(pdu, ifinfo, sizeof(ifinfo) / sizeof(oid)); } /* then optional data */ if (flags & S_UP) { ifinfo[9] = ifOperStatus; snmp_add_null_var(pdu, ifinfo, sizeof(ifinfo) / sizeof(oid)); } if (flags & S_BOUT) { ifinfo[9] = ifOutOctets; snmp_add_null_var(pdu, ifinfo, sizeof(ifinfo) / sizeof(oid)); } if (flags & S_BIN) { ifinfo[9] = ifInOctets; snmp_add_null_var(pdu, ifinfo, sizeof(ifinfo) / sizeof(oid)); } if (flags & S_LOOP) { ifinfo[9] = ifType; snmp_add_null_var(pdu, ifinfo, sizeof(ifinfo) / sizeof(oid)); } } if ((status = snmp_synch_response(ss, pdu, &response)) != STAT_SUCCESS || response->errstat != SNMP_ERR_NOERROR || response->variables == NULL) { if (status == STAT_SUCCESS) { if (response->errstat != SNMP_ERR_NOSUCHNAME && response->errstat != SNMP_ERR_TOOBIG) ifstat_error("snmp: Error: %s", snmp_errstring(response->errstat)); else if (nifaces > 1) { /* maybe only one of the interface is broken or too many interfaces polled at once -- repoll inetrface per interface */ if (response->errstat == SNMP_ERR_TOOBIG && toobig != NULL) (*toobig)++; if (response != NULL) snmp_free_pdu(response); status = 0; for (i = 0; i < nifaces; i++) { if (!snmp_get_ifinfos(ss, 1, flags, ifsnmp + i, NULL)) ifsnmp[i].flags |= S_INVALID; else status = 1; } return status; } } else ifstat_error("snmpget(interfaces.ifTable.ifEntry...): %s", snmp_sess_errstring(ss)); if (response != NULL) snmp_free_pdu(response); return 0; } for(vars = response->variables; vars; vars = vars->next_variable) { /* check that the variable is under the base oid */ if (memcmp(ifinfo, vars->name, sizeof(ifinfo) - 2 * sizeof(oid)) != 0) continue; for(i = 0; i < nifaces; i++) { if (ifsnmp[i].index == vars->name[10]) break; } if (i == nifaces) /* not found */ continue; switch (vars->name[9]) { case ifDescr: if (vars->type == ASN_OCTET_STR) { int count = vars->val_len; if (count >= sizeof(ifsnmp[i].name)) count = sizeof(ifsnmp[i].name) - 1; strncpy(ifsnmp[i].name, vars->val.string, count); ifsnmp[i].name[count] = '\0'; } break; case ifOperStatus: if (vars->type == ASN_INTEGER) { if (*(vars->val.integer) == 1) /* up */ ifsnmp[i].flags |= S_UP; } break; case ifType: if (vars->type == ASN_INTEGER) { if (*(vars->val.integer) == 24) /* softwareLoopback */ ifsnmp[i].flags |= S_LOOP; } break; case ifInOctets: if (vars->type == ASN_INTEGER || vars->type == ASN_COUNTER) { ifsnmp[i].flags |= S_BIN; ifsnmp[i].bin = *(vars->val.integer); } break; case ifOutOctets: if (vars->type == ASN_INTEGER || vars->type == ASN_COUNTER) { ifsnmp[i].flags |= S_BOUT; ifsnmp[i].bout = *(vars->val.integer); } break; } } snmp_free_pdu(response); return 1; } /* driver API */ struct snmp_driver_data { struct snmp_session *session; int num_ifnames, num_ifsreqs; struct ifsnmp *ifsnmp; }; /* maximum number of interfaces to poll at once, min 1 */ #define MAXIFSREQS 64 #define DEFIFSREQS 8 /* initiailise the snmp driver, strings syntax is [comm@][#]host*/ int snmp_open_driver(struct ifstat_driver *driver, char *options) { char *host; char *community; struct snmp_session session; struct snmp_driver_data *data; if ((data = malloc(sizeof(struct snmp_driver_data))) == NULL) { ifstat_perror("malloc"); return 0; } if (options == NULL) options = "localhost"; if ((host = strchr(options, '@')) != NULL) { *host++ = '\0'; community = options; } else { host = options; community = "public"; } if (*host == '#') { host++; data->num_ifnames = 1; /* numeric interface names */ } else data->num_ifnames = 0; if ((options = strchr(host, '/')) != NULL) { *options++ = '\0'; data->num_ifsreqs = atoi(options); if (data->num_ifsreqs < 1) { ifstat_error("snmp: bad number of interface requests: %s; ignored.", options); data->num_ifsreqs = DEFIFSREQS; } else if (data->num_ifsreqs > MAXIFSREQS) { ifstat_error("snmp: number of interface requests too large: %d; using %d instead.", data->num_ifsreqs, MAXIFSREQS); data->num_ifsreqs = MAXIFSREQS; } } else data->num_ifsreqs = DEFIFSREQS; if ((data->ifsnmp = calloc(sizeof(struct ifsnmp), data->num_ifsreqs)) == NULL) { ifstat_perror("malloc"); free(data); return 0; } init_snmp(ifstat_progname); snmp_sess_init(&session); session.peername = host; session.version = SNMP_VERSION_1; session.community = community; session.community_len = strlen(community); if ((data->session = snmp_open(&session)) == NULL) { ifstat_error("snmp_open: %s", snmp_api_errstring(snmp_errno)); free(data->ifsnmp); free(data); return 0; } driver->data = (void *) data; return 1; } /* cleanups session */ void snmp_close_driver(struct ifstat_driver *driver) { struct snmp_driver_data *data = driver->data; snmp_close(data->session); free(data->ifsnmp); free(data); } #ifdef USE_SNMP_IFCOUNT static int snmp_map_ifs(struct ifstat_driver *driver, int (*mapf)(struct ifstat_driver *driver, int nifaces, void *pdata), void *pdata) { struct snmp_driver_data *data = driver->data; struct ifsnmp *ifsnmp = data->ifsnmp; int ifaces, nifaces, index, i; if ((ifaces = snmp_get_ifcount(data->session)) <= 0) { ifstat_error("snmp: no interfaces returned."); return 0; } for(index = 0; index <= (ifaces /data->num_ifsreqs); index++) { nifaces = ifaces - index * data->num_ifsreqs; if (nifaces > data->num_ifsreqs) nifaces = data->num_ifsreqs; for (i = 0; i < nifaces; i++) ifsnmp[i].index = index * data->num_ifsreqs + i + 1; if(!mapf(driver, nifaces, pdata)) return 0; } return 1; } #else static int snmp_map_ifs(struct ifstat_driver *driver, int (*mapf)(struct ifstat_driver *driver, int nifaces, void *pdata), void *pdata) { struct snmp_driver_data *data = driver->data; struct ifsnmp *ifsnmp = data->ifsnmp; int ifaces, nifaces, index; index = -1; nifaces = ifaces = 0; while((index = snmp_get_nextif(data->session, index)) >= 0) { ifaces++; ifsnmp[nifaces++].index = index; if (nifaces >= data->num_ifsreqs) { if(!mapf(driver, nifaces, pdata)) return 0; nifaces = 0; } } if (nifaces > 0) return mapf(driver, nifaces, pdata); return (ifaces != 0); } #endif static int snmp_map_scan(struct ifstat_driver *driver, int nifaces, void *pdata) { struct snmp_driver_data *data = driver->data; struct ifsnmp *ifsnmp = data->ifsnmp; struct ifstat_list *ifs = pdata; struct ifstat_data *iface; int i; if (!snmp_get_ifinfos(data->session, nifaces, S_UP | S_LOOP | (data->num_ifnames ? S_NUMNAME : S_IFNAME), ifsnmp, NULL)) return 1; for (i=0; i < nifaces; i++) { if (ifsnmp[i].flags & S_INVALID) continue; if ((ifsnmp[i].flags & S_LOOP) && !(ifs->flags & IFSTAT_LOOPBACK)) continue; if ((ifsnmp[i].flags & S_UP) || (ifs->flags & IFSTAT_DOWN)) { if ((iface = ifstat_get_interface(ifs, ifsnmp[i].name)) != NULL) { if (!ifstat_quiet && !(iface->flags & IFSTAT_HASSTATS)) { ifstat_error("warning: multiple interfaces detected with same name (%s); " "you should enable numeric mode by prepending # to the hostname.", ifsnmp[i].name); iface->flags |= IFSTAT_HASSTATS; } } else ifstat_add_interface(ifs, ifsnmp[i].name, 0); } } return 1; } int snmp_scan_interfaces(struct ifstat_driver *driver, struct ifstat_list *ifs) { return snmp_map_ifs(driver, &snmp_map_scan, (void *) ifs); } static void snmp_toobig(struct ifstat_driver *driver) { struct snmp_driver_data *data = driver->data; if (data->num_ifsreqs > 1) { data->num_ifsreqs >>= 1; if (!ifstat_quiet) ifstat_error("warning: changing poll grouping to %d to avoid \"too big\" errors", data->num_ifsreqs); } } static int snmp_map_stats(struct ifstat_driver *driver, int nifaces, void *pdata) { struct snmp_driver_data *data = driver->data; struct ifsnmp *ifsnmp = data->ifsnmp; struct ifstat_list *ifs = pdata; struct ifstat_data *cur; int i, toobig = 0; if (!snmp_get_ifinfos(data->session, nifaces, S_BIN | S_BOUT | (data->num_ifnames ? S_NUMNAME : S_IFNAME), ifsnmp, &toobig)) return 1; if (toobig) snmp_toobig(driver); for (i=0; i < nifaces; i++) { if (ifsnmp[i].flags & S_INVALID) continue; if (!(ifsnmp[i].flags & S_BIN && ifsnmp[i].flags & S_BOUT)) continue; /* overwrite if name if needed */ if ((cur = ifstat_get_interface(ifs, ifsnmp[i].name)) != NULL) { ifstat_set_interface_stats(cur, ifsnmp[i].bin, ifsnmp[i].bout); ifstat_set_interface_index(cur, ifsnmp[i].index); } } return 1; } int snmp_get_stats(struct ifstat_driver *driver, struct ifstat_list *ifs) { struct snmp_driver_data *data = driver->data; int ifaces, i, toobig = 0; struct ifstat_data *cur, *block; struct ifsnmp *ifsnmp = data->ifsnmp; if (ifs->flags & IFSTAT_HASINDEX) { /* poll by index */ cur = ifs->first; while (cur != NULL) { /* init as many interface as possible */ block = cur; ifaces = 0; while (ifaces < data->num_ifsreqs && cur != NULL) { ifsnmp[ifaces++].index = cur->index; cur = cur->next; } /* poll them */ if (!snmp_get_ifinfos(data->session, ifaces, S_BIN | S_BOUT | (data->num_ifnames ? 0 : S_IFNAME), ifsnmp, &toobig)) continue; if (toobig) snmp_toobig(driver); for (i = 0; i < ifaces; i++) { if (ifsnmp[i].flags & S_INVALID) continue; if (!(ifsnmp[i].flags & S_BIN && ifsnmp[i].flags & S_BOUT)) continue; if (!data->num_ifnames && strcmp(ifsnmp[i].name, block->name)) continue; /* interface changed of index... */ ifstat_set_interface_stats(block, ifsnmp[i].bin, ifsnmp[i].bout); ifstat_set_interface_index(block, ifsnmp[i].index); block = block->next; } } return 1; } return snmp_map_ifs(driver, &snmp_map_stats, (void *) ifs); } #endif ifstat-1.1/snmp.h0100644000031000000620000000052707541740303012562 0ustar gaelstaff#ifndef SNMP_H #define SNMP_H /* snmp backend */ int snmp_open_driver(struct ifstat_driver *driver, char *options); int snmp_scan_interfaces(struct ifstat_driver *driver, struct ifstat_list *list); int snmp_get_stats(struct ifstat_driver *driver, struct ifstat_list *ifaces); void snmp_close_driver(struct ifstat_driver *driver); #endif ifstat-1.1/configure0100755000031000000620000031156207775071166013364 0ustar gaelstaff#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated automatically using autoconf version 2.13 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. # Defaults: ac_help= ac_default_prefix=/usr/local # Any additions from configure.in: ac_help="$ac_help --enable-debug setup flags (gcc) for debugging (default=no)" ac_help="$ac_help --enable-optim setup flags (gcc) for optimizations (default=no)" ac_help="$ac_help --with-proc[=FILE] include /proc/net/dev support (default=auto)" ac_help="$ac_help --with-kstat include kstat(3K) support (default=auto)" ac_help="$ac_help --with-ifmib include ifmib(4) support (default=auto)" ac_help="$ac_help --with-ifdata include ifdata ioctl support (default=auto)" ac_help="$ac_help --with-route include route(4) sysctl support (default=auto)" ac_help="$ac_help --with-kvm include kvm(3) support (default=auto)" ac_help="$ac_help --with-dlpi include HP DLPI support (default=auto)" ac_help="$ac_help --with-win32 include Win32 support (default=auto)" ac_help="$ac_help --with-snmp[=PREFIX] include UCD-SNMP support (default=yes)" ac_help="$ac_help --with-libcrypto force link with -lcrypto for UCD-SNMP (default=no)" ac_help="$ac_help --enable-library enable build and installation of libifstat (default=no)" # Initialize some variables set by options. # The variables have the same names as the options, with # dashes changed to underlines. build=NONE cache_file=./config.cache exec_prefix=NONE host=NONE no_create= nonopt=NONE no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= target=NONE verbose= x_includes=NONE x_libraries=NONE bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datadir='${prefix}/share' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' libdir='${exec_prefix}/lib' includedir='${prefix}/include' oldincludedir='/usr/include' infodir='${prefix}/info' mandir='${prefix}/man' # Initialize some other variables. subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. ac_max_here_lines=12 ac_prev= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval "$ac_prev=\$ac_option" ac_prev= continue fi case "$ac_option" in -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; *) ac_optarg= ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case "$ac_option" in -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir="$ac_optarg" ;; -build | --build | --buil | --bui | --bu) ac_prev=build ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build="$ac_optarg" ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file="$ac_optarg" ;; -datadir | --datadir | --datadi | --datad | --data | --dat | --da) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ | --da=*) datadir="$ac_optarg" ;; -disable-* | --disable-*) ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } fi ac_feature=`echo $ac_feature| sed 's/-/_/g'` eval "enable_${ac_feature}=no" ;; -enable-* | --enable-*) ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } fi ac_feature=`echo $ac_feature| sed 's/-/_/g'` case "$ac_option" in *=*) ;; *) ac_optarg=yes ;; esac eval "enable_${ac_feature}='$ac_optarg'" ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix="$ac_optarg" ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he) # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat << EOF Usage: configure [options] [host] Options: [defaults in brackets after descriptions] Configuration: --cache-file=FILE cache test results in FILE --help print this message --no-create do not create output files --quiet, --silent do not print \`checking...' messages --version print the version of autoconf that created configure Directory and file names: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [same as prefix] --bindir=DIR user executables in DIR [EPREFIX/bin] --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] --libexecdir=DIR program executables in DIR [EPREFIX/libexec] --datadir=DIR read-only architecture-independent data in DIR [PREFIX/share] --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data in DIR [PREFIX/com] --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] --libdir=DIR object code libraries in DIR [EPREFIX/lib] --includedir=DIR C header files in DIR [PREFIX/include] --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] --infodir=DIR info documentation in DIR [PREFIX/info] --mandir=DIR man documentation in DIR [PREFIX/man] --srcdir=DIR find the sources in DIR [configure dir or ..] --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names EOF cat << EOF Host type: --build=BUILD configure for building on BUILD [BUILD=HOST] --host=HOST configure for HOST [guessed] --target=TARGET configure for TARGET [TARGET=HOST] Features and packages: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --x-includes=DIR X include files are in DIR --x-libraries=DIR X library files are in DIR EOF if test -n "$ac_help"; then echo "--enable and --with options recognized:$ac_help" fi exit 0 ;; -host | --host | --hos | --ho) ac_prev=host ;; -host=* | --host=* | --hos=* | --ho=*) host="$ac_optarg" ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir="$ac_optarg" ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir="$ac_optarg" ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir="$ac_optarg" ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir="$ac_optarg" ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst \ | --locals | --local | --loca | --loc | --lo) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* \ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) localstatedir="$ac_optarg" ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir="$ac_optarg" ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir="$ac_optarg" ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix="$ac_optarg" ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix="$ac_optarg" ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix="$ac_optarg" ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name="$ac_optarg" ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir="$ac_optarg" ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir="$ac_optarg" ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site="$ac_optarg" ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir="$ac_optarg" ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir="$ac_optarg" ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target="$ac_optarg" ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers) echo "configure generated by autoconf version 2.13" exit 0 ;; -with-* | --with-*) ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } fi ac_package=`echo $ac_package| sed 's/-/_/g'` case "$ac_option" in *=*) ;; *) ac_optarg=yes ;; esac eval "with_${ac_package}='$ac_optarg'" ;; -without-* | --without-*) ac_package=`echo $ac_option|sed -e 's/-*without-//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } fi ac_package=`echo $ac_package| sed 's/-/_/g'` eval "with_${ac_package}=no" ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes="$ac_optarg" ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries="$ac_optarg" ;; -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } ;; *) if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then echo "configure: warning: $ac_option: invalid host type" 1>&2 fi if test "x$nonopt" != xNONE; then { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } fi nonopt="$ac_option" ;; esac done if test -n "$ac_prev"; then { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } fi trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 # File descriptor usage: # 0 standard input # 1 file creation # 2 errors and warnings # 3 some systems may open it to /dev/tty # 4 used on the Kubota Titan # 6 checking for... messages and results # 5 compiler messages saved in config.log if test "$silent" = yes; then exec 6>/dev/null else exec 6>&1 fi exec 5>./config.log echo "\ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. " 1>&5 # Strip out --no-create and --no-recursion so they do not pile up. # Also quote any args containing shell metacharacters. ac_configure_args= for ac_arg do case "$ac_arg" in -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c) ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) ac_configure_args="$ac_configure_args '$ac_arg'" ;; *) ac_configure_args="$ac_configure_args $ac_arg" ;; esac done # NLS nuisances. # Only set these to C if already set. These must not be set unconditionally # because not all systems understand e.g. LANG=C (notably SCO). # Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! # Non-C LC_CTYPE values break the ctype check. if test "${LANG+set}" = set; then LANG=C; export LANG; fi if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -rf conftest* confdefs.h # AIX cpp loses on an empty file, so make sure it contains at least a newline. echo > confdefs.h # A filename unique to this package, relative to the directory that # configure is in, which we can look for to find out if srcdir is correct. ac_unique_file=ifstat.c # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then its parent. ac_prog=$0 ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. srcdir=$ac_confdir if test ! -r $srcdir/$ac_unique_file; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r $srcdir/$ac_unique_file; then if test "$ac_srcdir_defaulted" = yes; then { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } else { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } fi fi srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` # Prefer explicitly selected file to automatically selected ones. if test -z "$CONFIG_SITE"; then if test "x$prefix" != xNONE; then CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" else CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" fi fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then echo "loading site script $ac_site_file" . "$ac_site_file" fi done if test -r "$cache_file"; then echo "loading cache $cache_file" . $cache_file else echo "creating cache $cache_file" > $cache_file fi ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross ac_exeext= ac_objext=o if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then ac_n= ac_c=' ' ac_t=' ' else ac_n=-n ac_c= ac_t= fi else ac_n= ac_c='\c' ac_t= fi # Check whether --enable-debug or --disable-debug was given. if test "${enable_debug+set}" = set; then enableval="$enable_debug" CFLAGS="$CFLAGS -O2 -Wall -g" CPPFLAGS="$CPPFLAGS -DDEBUG" LDFLAGS="$LDFLAGS" fi # Check whether --enable-optim or --disable-optim was given. if test "${enable_optim+set}" = set; then enableval="$enable_optim" if test "x$enable_debug" != "xyes" ; then CFLAGS="$CFLAGS -O3 -fomit-frame-pointer -g0" LDFLAGS="$LDFLAGS -s" else echo "configure: warning: enable-optim and enable-debug are incompatible -- disabling optimizations" 1>&2 fi fi ac_aux_dir= for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do if test -f $ac_dir/install-sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f $ac_dir/install.sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break fi done if test -z "$ac_aux_dir"; then { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } fi ac_config_guess=$ac_aux_dir/config.guess ac_config_sub=$ac_aux_dir/config.sub ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 echo "configure:605: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" for ac_dir in $PATH; do # Account for people who put trailing slashes in PATH elements. case "$ac_dir/" in /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do if test -f $ac_dir/$ac_prog; then if test $ac_prog = install && grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : else ac_cv_path_install="$ac_dir/$ac_prog -c" break 2 fi fi done ;; esac done IFS="$ac_save_IFS" fi if test "${ac_cv_path_install+set}" = set; then INSTALL="$ac_cv_path_install" else # As a last resort, use the slow shell script. We don't cache a # path for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the path is relative. INSTALL="$ac_install_sh" fi fi echo "$ac_t""$INSTALL" 1>&6 # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:660: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CC="gcc" break fi done IFS="$ac_save_ifs" fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:690: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_prog_rejected=no ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" break fi done IFS="$ac_save_ifs" if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# -gt 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift set dummy "$ac_dir/$ac_word" "$@" shift ac_cv_prog_CC="$@" fi fi fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi if test -z "$CC"; then case "`uname -s`" in *win32* | *WIN32*) # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:741: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CC="cl" break fi done IFS="$ac_save_ifs" fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi ;; esac fi test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 echo "configure:773: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF #line 784 "configure" #include "confdefs.h" main(){return(0);} EOF if { (eval echo configure:789: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then ac_cv_prog_cc_cross=no else ac_cv_prog_cc_cross=yes fi else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_prog_cc_works=no fi rm -fr conftest* ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 echo "configure:815: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 echo "configure:820: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no fi fi echo "$ac_t""$ac_cv_prog_gcc" 1>&6 if test $ac_cv_prog_gcc = yes; then GCC=yes else GCC= fi ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 echo "configure:848: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else echo 'void f(){}' > conftest.c if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then ac_cv_prog_cc_g=yes else ac_cv_prog_cc_g=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 if test "$ac_test_CFLAGS" = set; then CFLAGS="$ac_save_CFLAGS" elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:882: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_RANLIB="ranlib" break fi done IFS="$ac_save_ifs" test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" fi fi RANLIB="$ac_cv_prog_RANLIB" if test -n "$RANLIB"; then echo "$ac_t""$RANLIB" 1>&6 else echo "$ac_t""no" 1>&6 fi echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 echo "configure:911: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else # This must be in double quotes, not single quotes, because CPP may get # substituted into the Makefile and "${CC-cc}" will confuse make. CPP="${CC-cc} -E" # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:932: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:949: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:966: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP=/lib/cpp fi rm -f conftest* fi rm -f conftest* fi rm -f conftest* ac_cv_prog_CPP="$CPP" fi CPP="$ac_cv_prog_CPP" else ac_cv_prog_CPP="$CPP" fi echo "$ac_t""$CPP" 1>&6 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 echo "configure:991: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include #include #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1004: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* ac_cv_header_stdc=yes else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_header_stdc=no fi rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "memchr" >/dev/null 2>&1; then : else rm -rf conftest* ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "free" >/dev/null 2>&1; then : else rm -rf conftest* ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') #define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF if { (eval echo configure:1071: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -fr conftest* ac_cv_header_stdc=no fi rm -fr conftest* fi fi fi echo "$ac_t""$ac_cv_header_stdc" 1>&6 if test $ac_cv_header_stdc = yes; then cat >> confdefs.h <<\EOF #define STDC_HEADERS 1 EOF fi for ac_hdr in sys/time.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:1098: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1108: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6 echo "configure:1135: checking whether time.h and sys/time.h may both be included" >&5 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include #include int main() { struct tm *tp; ; return 0; } EOF if { (eval echo configure:1149: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_time=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_header_time=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_header_time" 1>&6 if test $ac_cv_header_time = yes; then cat >> confdefs.h <<\EOF #define TIME_WITH_SYS_TIME 1 EOF fi for ac_hdr in unistd.h ctype.h sys/types.h sys/param.h sys/mbuf.h net/route.h net/if.h net/if_var.h net/if_types.h sys/socket.h sys/ioctl.h sys/sockio.h net/soioctl.h sys/termios.h errno.h signal.h stdarg.h limits.h fcntl.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:1173: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1183: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6 echo "configure:1210: checking return type of signal handlers" >&5 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include #ifdef signal #undef signal #endif #ifdef __cplusplus extern "C" void (*signal (int, void (*)(int)))(int); #else void (*signal ()) (); #endif int main() { int i; ; return 0; } EOF if { (eval echo configure:1232: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_type_signal=void else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_type_signal=int fi rm -f conftest* fi echo "$ac_t""$ac_cv_type_signal" 1>&6 cat >> confdefs.h <&6 echo "configure:1253: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:1281: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 fi done # Options for various drivers # auto means try if no other found, no disables, and anything else is try. # Check whether --with-proc or --without-proc was given. if test "${with_proc+set}" = set; then withval="$with_proc" : else with_proc=auto fi # Check whether --with-kstat or --without-kstat was given. if test "${with_kstat+set}" = set; then withval="$with_kstat" : else with_kstat=auto fi # Check whether --with-ifmib or --without-ifmib was given. if test "${with_ifmib+set}" = set; then withval="$with_ifmib" : else with_ifmib=auto fi # Check whether --with-ifdata or --without-ifdata was given. if test "${with_ifdata+set}" = set; then withval="$with_ifdata" : else with_ifdata=auto fi # Check whether --with-route or --without-route was given. if test "${with_route+set}" = set; then withval="$with_route" : else with_route=auto fi # Check whether --with-kvm or --without-kvm was given. if test "${with_kvm+set}" = set; then withval="$with_kvm" : else with_kvm=auto fi # Check whether --with-dlpi or --without-dlpi was given. if test "${with_dlpi+set}" = set; then withval="$with_dlpi" : else with_dlpi=auto fi # Check whether --with-win32 or --without-win32 was given. if test "${with_win32+set}" = set; then withval="$with_win32" : else with_win32=auto fi # Check whether --with-snmp or --without-snmp was given. if test "${with_snmp+set}" = set; then withval="$with_snmp" : else with_snmp=yes fi with_ioctl=no # only enabled if needed by other drivers local=no # yes if one driver is local # checking for proc (Linux) if test "x$with_proc" != "xno"; then case "$with_proc" in /*) file=$with_proc ;; *) file=/proc/net/dev ;; esac echo $ac_n "checking for proc interface in $file""... $ac_c" 1>&6 echo "configure:1390: checking for proc interface in $file" >&5 if grep -q Inter- $file 2>/dev/null; then cat >> confdefs.h <<\EOF #define USE_PROC 1 EOF cat >> confdefs.h <&6 fi # checking for kstat (Solaris) test "x$with_kstat" = "xauto" -a "x$local" = "xyes" && with_kstat=no if test "x$with_kstat" != "xno"; then echo $ac_n "checking for kstat_open""... $ac_c" 1>&6 echo "configure:1413: checking for kstat_open" >&5 if eval "test \"`echo '$''{'ac_cv_func_kstat_open'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char kstat_open(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_kstat_open) || defined (__stub___kstat_open) choke me #else kstat_open(); #endif ; return 0; } EOF if { (eval echo configure:1441: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_kstat_open=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_kstat_open=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'kstat_open`\" = yes"; then echo "$ac_t""yes" 1>&6 with_kstat=yes else echo "$ac_t""no" 1>&6 with_kstat=no fi if test "x$with_kstat" != "xyes" ; then case "x$LIBS" in *-lkstat*) ;; *) echo $ac_n "checking for kstat_open in -lkstat""... $ac_c" 1>&6 echo "configure:1465: checking for kstat_open in -lkstat" >&5 ac_lib_var=`echo kstat'_'kstat_open | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lkstat $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 LIBS="$LIBS -lkstat"; with_kstat=yes else echo "$ac_t""no" 1>&6 fi ;; esac fi if test "x$with_kstat" = "xyes" ; then for ac_hdr in kstat.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:1511: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1521: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done cat >> confdefs.h <<\EOF #define USE_KSTAT 1 EOF with_ioctl=yes local=yes fi fi # checking for ifmib (FreeBSD) test "x$with_ifmib" = "xauto" -a "x$local" = "xyes" && with_ifmib=no if test "x$with_ifmib" != "xno"; then ac_safe=`echo "net/if_mib.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for net/if_mib.h""... $ac_c" 1>&6 echo "configure:1561: checking for net/if_mib.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1571: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 echo $ac_n "checking for sysctl""... $ac_c" 1>&6 echo "configure:1588: checking for sysctl" >&5 if eval "test \"`echo '$''{'ac_cv_func_sysctl'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char sysctl(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_sysctl) || defined (__stub___sysctl) choke me #else sysctl(); #endif ; return 0; } EOF if { (eval echo configure:1616: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_sysctl=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_sysctl=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'sysctl`\" = yes"; then echo "$ac_t""yes" 1>&6 with_ifmib=yes else echo "$ac_t""no" 1>&6 with_ifmib=no fi else echo "$ac_t""no" 1>&6 with_ifmib=no fi if test "x$with_ifmib" = "xyes"; then for ac_hdr in sys/sysctl.h net/if_mib.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:1646: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1656: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done echo $ac_n "checking for working ifmib sysctl""... $ac_c" 1>&6 echo "configure:1683: checking for working ifmib sysctl" >&5 # try run since interface is available on darwin but doesn't work if test "$cross_compiling" = yes; then with_ifmib=maybe else cat > conftest.$ac_ext < #include #ifdef HAVE_SYS_PARAM_H #include #endif #ifdef HAVE_SYS_SYSCTL_H #include #endif #ifdef HAVE_NET_IF_H #include #endif #ifdef HAVE_NET_IF_MIB_H #include #endif int ifcount[] = {CTL_NET, PF_LINK, NETLINK_GENERIC, IFMIB_SYSTEM, IFMIB_IFCOUNT}; int size; int main() { return sysctl(ifcount, 5, NULL, &size, NULL, NULL); } EOF if { (eval echo configure:1710: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then with_ifmib=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -fr conftest* with_ifmib=no fi rm -fr conftest* fi echo "$ac_t""$with_ifmib" 1>&6 if test "x$with_ifmib" != "xno" ; then cat >> confdefs.h <<\EOF #define USE_IFMIB 1 EOF local=yes fi fi fi # checking for ioctl ifdata (Irix, ...) test "x$with_ifdata" = "xauto" -a "x$local" = "xyes" && with_ifdata=no if test "x$with_ifdata" != "xno"; then echo $ac_n "checking for SIOCGIFDATA and ifdatareq""... $ac_c" 1>&6 echo "configure:1737: checking for SIOCGIFDATA and ifdatareq" >&5 cat > conftest.$ac_ext < #include #include #ifdef HAVE_SYS_SOCKIO_H #include #endif #ifdef HAVE_NET_SOIOCTL_H #include #endif #include int main() { struct ifdatareq ifd; ioctl(0, SIOCGIFDATA, (char *) &ifd); ifd.ifd_ifd.ifi_ibytes = ifd.ifd_ifd.ifi_obytes; ; return 0; } EOF if { (eval echo configure:1757: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* with_ifdata=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* with_ifdata=no fi rm -f conftest* echo "$ac_t""$with_ifdata" 1>&6 test "x$with_ifdata" = "xno" && with_ifdata=checkifr fi if test "x$with_ifdata" = "xcheckifr"; then echo $ac_n "checking for SIOCGIFDATA and ifreq.ifr_data""... $ac_c" 1>&6 echo "configure:1772: checking for SIOCGIFDATA and ifreq.ifr_data" >&5 cat > conftest.$ac_ext < #include #include #ifdef HAVE_SYS_SOCKIO_H #include #endif #ifdef HAVE_NET_SOIOCTL_H #include #endif #include int main() { struct ifreq ifr; struct if_data ifd; ifr.ifr_data = &ifd; ioctl(0, SIOCGIFDATA, (char *) &ifr); ifd.ifi_ibytes = ifd.ifi_obytes; ; return 0; } EOF if { (eval echo configure:1793: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* with_ifdata=yes cat >> confdefs.h <<\EOF #define HAVE_IFREQ_IFR_DATA 1 EOF else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* with_ifdata=no fi rm -f conftest* echo "$ac_t""$with_ifdata" 1>&6 fi if test "x$with_ifdata" = "xyes"; then cat >> confdefs.h <<\EOF #define USE_IFDATA 1 EOF local=yes with_ioctl=yes fi # checking for route sysctl (*BSDs) test "x$with_route" = "xauto" -a "x$local" = "xyes" && with_route=no if test "x$with_route" != "xno"; then for ac_hdr in sys/sysctl.h net/if_dl.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:1825: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1835: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done echo $ac_n "checking for sysctl""... $ac_c" 1>&6 echo "configure:1862: checking for sysctl" >&5 if eval "test \"`echo '$''{'ac_cv_func_sysctl'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char sysctl(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_sysctl) || defined (__stub___sysctl) choke me #else sysctl(); #endif ; return 0; } EOF if { (eval echo configure:1890: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_sysctl=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_sysctl=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'sysctl`\" = yes"; then echo "$ac_t""yes" 1>&6 with_route=yes else echo "$ac_t""no" 1>&6 with_route=no fi if test "x$with_route" = "xyes"; then echo $ac_n "checking for route info sysctl""... $ac_c" 1>&6 echo "configure:1912: checking for route info sysctl" >&5 cat > conftest.$ac_ext < #include #ifdef HAVE_SYS_PARAM_H #include #endif #ifdef HAVE_SYS_SYSCTL_H #include #endif #ifdef HAVE_NET_IF_H #include #endif #ifdef HAVE_NET_IF_DL_H #include #endif int main() { struct sockaddr_dl dl; struct if_msghdr ifm; int iflist[] = {CTL_NET, PF_ROUTE, 0, AF_LINK, NET_RT_IFLIST}; ifm.ifm_type = dl.sdl_nlen; dl.sdl_data + ifm.ifm_msglen; ifm.ifm_data.ifi_ibytes; ; return 0; } EOF if { (eval echo configure:1939: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* with_route=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* with_route=no fi rm -f conftest* echo "$ac_t""$with_route" 1>&6 if test "x$with_route" != "xno"; then cat >> confdefs.h <<\EOF #define USE_ROUTE 1 EOF local=yes fi fi fi # checking for kvm (*BSDs) test "x$with_kvm" = "xauto" -a "x$local" = "xyes" && with_kvm=no if test "x$with_kvm" != "xno"; then echo $ac_n "checking for kvm_openfiles""... $ac_c" 1>&6 echo "configure:1964: checking for kvm_openfiles" >&5 if eval "test \"`echo '$''{'ac_cv_func_kvm_openfiles'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char kvm_openfiles(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_kvm_openfiles) || defined (__stub___kvm_openfiles) choke me #else kvm_openfiles(); #endif ; return 0; } EOF if { (eval echo configure:1992: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_kvm_openfiles=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_kvm_openfiles=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'kvm_openfiles`\" = yes"; then echo "$ac_t""yes" 1>&6 with_kvm=yes else echo "$ac_t""no" 1>&6 with_kvm=no fi if test "x$with_kvm" != "xyes" ; then case "x$LIBS" in *-lkvm*) ;; *) echo $ac_n "checking for kvm_openfiles in -lkvm""... $ac_c" 1>&6 echo "configure:2016: checking for kvm_openfiles in -lkvm" >&5 ac_lib_var=`echo kvm'_'kvm_openfiles | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lkvm $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 LIBS="$LIBS -lkvm"; with_kvm=yes else echo "$ac_t""no" 1>&6 fi ;; esac fi if test "x$with_kvm" != "xyes"; then # see if emulation is possible for ac_hdr in nlist.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:2063: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:2073: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 echo "configure:2097: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:2125: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 echo "configure:2146: checking whether knlist takes 3 arguments" >&5 cat > conftest.$ac_ext < int main() { knlist((struct nlist *) 0, 0, 10); ; return 0; } EOF if { (eval echo configure:2155: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* knlist3=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* knlist3=no fi rm -f conftest* echo "$ac_t""$knlist3" 1>&6 if test "x$knlist3" = "xyes"; then cat >> confdefs.h <<\EOF #define HAVE_KNLIST_ARGS3 1 EOF fi else echo "$ac_t""no" 1>&6 echo $ac_n "checking for nlist""... $ac_c" 1>&6 echo "configure:2176: checking for nlist" >&5 if eval "test \"`echo '$''{'ac_cv_func_nlist'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char nlist(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_nlist) || defined (__stub___nlist) choke me #else nlist(); #endif ; return 0; } EOF if { (eval echo configure:2204: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_nlist=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_nlist=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'nlist`\" = yes"; then echo "$ac_t""yes" 1>&6 with_kvm=yes else echo "$ac_t""no" 1>&6 fi fi done else echo "$ac_t""no" 1>&6 fi done if test "x$with_kvm" = "xyes"; then for ac_func in readx do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:2236: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:2264: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 fi done for ac_hdr in paths.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:2292: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:2302: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done fi else for ac_hdr in kvm.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:2334: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:2344: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done cat >> confdefs.h <<\EOF #define HAVE_KVM 1 EOF fi if test "x$with_kvm" = "xyes"; then echo $ac_n "checking whether struct ifnet has needed interface data""... $ac_c" 1>&6 echo "configure:2377: checking whether struct ifnet has needed interface data" >&5 cat > conftest.$ac_ext < #include #include #ifdef HAVE_NET_IF_VAR_H #include #endif int main() { struct ifnet in; in.if_ibytes = in.if_obytes; in.if_type = in.if_flags ; return 0; } EOF if { (eval echo configure:2392: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* with_kvm=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* with_kvm=no fi rm -f conftest* echo "$ac_t""$with_kvm" 1>&6 fi if test "x$with_kvm" = "xyes"; then echo $ac_n "checking for struct ifnet if_xname member""... $ac_c" 1>&6 echo "configure:2406: checking for struct ifnet if_xname member" >&5 cat > conftest.$ac_ext < #include #include #ifdef HAVE_NET_IF_VAR_H #include #endif int main() { struct ifnet in; in.if_xname[0] = 'a'; ; return 0; } EOF if { (eval echo configure:2420: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ifxname=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ifxname=no fi rm -f conftest* test "x$ifxname" = "xyes" && cat >> confdefs.h <<\EOF #define HAVE_IFNET_IF_XNAME 1 EOF echo "$ac_t""$ifxname" 1>&6 echo $ac_n "checking for struct ifnet if_next member""... $ac_c" 1>&6 echo "configure:2437: checking for struct ifnet if_next member" >&5 cat > conftest.$ac_ext < #include #include #ifdef HAVE_NET_IF_VAR_H #include #endif int main() { struct ifnet in; in.if_next; ; return 0; } EOF if { (eval echo configure:2451: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ifnext=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ifnext=no fi rm -f conftest* echo "$ac_t""$ifnext" 1>&6 if test "x$ifnext" = "xyes"; then cat >> confdefs.h <<\EOF #define HAVE_IFNET_IF_NEXT 1 EOF else echo $ac_n "checking for struct ifnet if_link member""... $ac_c" 1>&6 echo "configure:2469: checking for struct ifnet if_link member" >&5 cat > conftest.$ac_ext < #include #include #ifdef HAVE_NET_IF_VAR_H #include #endif int main() { struct ifnet in; in.if_link; ; return 0; } EOF if { (eval echo configure:2483: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* iflink=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* iflink=no fi rm -f conftest* test "x$iflink" = "xyes" && cat >> confdefs.h <<\EOF #define HAVE_IFNET_IF_LINK 1 EOF echo "$ac_t""$iflink" 1>&6 fi cat >> confdefs.h <<\EOF #define USE_KVM 1 EOF echo "configure: warning: you might need to make ifstat SGID kmem to run as simple user" 1>&2 local=yes fi fi # checking for hp dlpi interface test "x$with_dlpi" = "xauto" -a "x$local" = "xyes" && with_dlpi=no if test "x$with_dlpi" != "xno"; then for ac_hdr in sys/dlpi.h sys/dlpi_ext.h stropts.h sys/mib.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:2516: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:2526: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done echo $ac_n "checking for dlpi streams interface""... $ac_c" 1>&6 echo "configure:2553: checking for dlpi streams interface" >&5 cat > conftest.$ac_ext < #endif #ifdef HAVE_SYS_DLPI_H #include #endif #ifdef HAVE_SYS_DLPI_EXT_H #include #endif #ifdef HAVE_STROPTS_H #include #endif #ifdef HAVE_SYS_MIB_H #include #endif int main() { mib_ifEntry mib; dl_hp_ppa_req_t req; struct strbuf ctlptr; putmsg(0, &ctlptr, NULL, 0); ; return 0; } EOF if { (eval echo configure:2577: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* with_dlpi=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* with_dlpi=no fi rm -f conftest* echo "$ac_t""$with_dlpi" 1>&6 if test "x$with_dlpi" = "xyes"; then cat >> confdefs.h <<\EOF #define USE_DLPI 1 EOF local=yes fi fi test "x$with_win32" = "xauto" -a "x$local" = "xyes" && with_win32=no if test "x$with_win32" != "xno"; then echo $ac_n "checking for win32 GetIfTable interface""... $ac_c" 1>&6 echo "configure:2600: checking for win32 GetIfTable interface" >&5 OLIBS="$LIBS" LIBS="$LIBS -liphlpapi" cat > conftest.$ac_ext < #include int main() { GetIfTable(NULL, NULL, 0); ; return 0; } EOF if { (eval echo configure:2612: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* with_win32=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* with_win32=no; LIBS="$OLIBS" fi rm -f conftest* echo "$ac_t""$with_win32" 1>&6 if test "x$with_win32" = "xyes"; then cat >> confdefs.h <<\EOF #define USE_WIN32 1 EOF local=yes fi fi # checking for ioctl (siocgifconf) to get interfaces test "x$with_ioctl" = "xauto" -a "x$local" = "xyes" && with_ioctl=no if test "x$with_ioctl" != "xno"; then cat >> confdefs.h <<\EOF #define USE_IOCTL 1 EOF echo $ac_n "checking for socket""... $ac_c" 1>&6 echo "configure:2640: checking for socket" >&5 if eval "test \"`echo '$''{'ac_cv_func_socket'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char socket(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_socket) || defined (__stub___socket) choke me #else socket(); #endif ; return 0; } EOF if { (eval echo configure:2668: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_socket=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_socket=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'socket`\" = yes"; then echo "$ac_t""yes" 1>&6 checksocket=no else echo "$ac_t""no" 1>&6 checksocket=yes fi if test "x$checksocket" = "xyes"; then case "x$LIBS" in *-lsocket*);; *) echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6 echo "configure:2692: checking for socket in -lsocket" >&5 ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lsocket $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_lib=HAVE_LIB`echo socket | sed -e 's/[^a-zA-Z0-9_]/_/g' \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` cat >> confdefs.h <&6 fi ;; esac fi echo $ac_n "checking for if_nameindex""... $ac_c" 1>&6 echo "configure:2741: checking for if_nameindex" >&5 if eval "test \"`echo '$''{'ac_cv_func_if_nameindex'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char if_nameindex(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_if_nameindex) || defined (__stub___if_nameindex) choke me #else if_nameindex(); #endif ; return 0; } EOF if { (eval echo configure:2769: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_if_nameindex=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_if_nameindex=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'if_nameindex`\" = yes"; then echo "$ac_t""yes" 1>&6 ifnameindex=yes else echo "$ac_t""no" 1>&6 ifnameindex=no fi if test "x$ifnameindex" != "xyes"; then case "x$LIBS" in *-lnsl*);; *) echo $ac_n "checking for if_nameindex in -lnsl""... $ac_c" 1>&6 echo "configure:2793: checking for if_nameindex in -lnsl" >&5 ac_lib_var=`echo nsl'_'if_nameindex | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 ifnameindex=yes; LIBS="$LIBS -lnsl" else echo "$ac_t""no" 1>&6 fi ;; esac fi if test "x$ifnameindex" != "xyes"; then echo $ac_n "checking for sockaddr sa_len member""... $ac_c" 1>&6 echo "configure:2836: checking for sockaddr sa_len member" >&5 cat > conftest.$ac_ext < #include int main() { struct sockaddr sa; sa.sa_len = 1; ; return 0; } EOF if { (eval echo configure:2847: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* salen=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* salen=no fi rm -f conftest* test "x$salen" = "xyes" && cat >> confdefs.h <<\EOF #define HAVE_SOCKADDR_SA_LEN 1 EOF echo "$ac_t""$salen" 1>&6 else cat >> confdefs.h <<\EOF #define USE_IFNAMEINDEX 1 EOF fi fi # checking for snmp (NET-SNMP/UCD-SNMP) if test "x$with_snmp" != "xno" ; then OCPPFLAGS="$CPPFLAGS" OLDFLAGS="$LDFLAGS" snmp_ok=no # Extract the first word of "net-snmp-config", so it can be a program name with args. set dummy net-snmp-config; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:2879: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_netsnmpconfig'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else case "$netsnmpconfig" in /*) ac_cv_path_netsnmpconfig="$netsnmpconfig" # Let the user override the test with a path. ;; ?:/*) ac_cv_path_netsnmpconfig="$netsnmpconfig" # Let the user override the test with a dos path. ;; *) IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH:$with_snmp" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_path_netsnmpconfig="$ac_dir/$ac_word" break fi done IFS="$ac_save_ifs" test -z "$ac_cv_path_netsnmpconfig" && ac_cv_path_netsnmpconfig="no" ;; esac fi netsnmpconfig="$ac_cv_path_netsnmpconfig" if test -n "$netsnmpconfig"; then echo "$ac_t""$netsnmpconfig" 1>&6 else echo "$ac_t""no" 1>&6 fi if test "x$netsnmpconfig" != "xno"; then CPPFLAGS="$CPPFLAGS `$netsnmpconfig --base-cflags 2>/dev/null`" LDFLAGS="$LDFLAGS `$netsnmpconfig --libs 2>/dev/null`" echo $ac_n "checking whether net-snmp-config hints compiles and links fine""... $ac_c" 1>&6 echo "configure:2916: checking whether net-snmp-config hints compiles and links fine" >&5 cat > conftest.$ac_ext < int main() { snmp_sess_init((void *) 0); ; return 0; } EOF if { (eval echo configure:2925: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* snmp_ok=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* snmp_ok=no fi rm -f conftest* echo "$ac_t""$snmp_ok" 1>&6 if test "x$snmp_ok" = "xyes"; then with_snmp=yes snmp_type=net else CPPFLAGS="$OCPPFLAGS" LDFLAGS="$OLDFLAGS" fi fi if test "x$snmp_ok" != "xyes"; then if test "x$with_snmp" != "xyes" ; then CPPFLAGS="$CPPFLAGS -I$with_snmp/include" LDFLAGS="$LDFLAGS -L$with_snmp/lib" fi ac_safe=`echo "net-snmp/net-snmp-config.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for net-snmp/net-snmp-config.h""... $ac_c" 1>&6 echo "configure:2952: checking for net-snmp/net-snmp-config.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:2962: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 snmp_type=net else echo "$ac_t""no" 1>&6 ac_safe=`echo "ucd-snmp/ucd-snmp-config.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for ucd-snmp/ucd-snmp-config.h""... $ac_c" 1>&6 echo "configure:2983: checking for ucd-snmp/ucd-snmp-config.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:2993: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 snmp_type=ucd else echo "$ac_t""no" 1>&6 with_snmp=no fi fi if test "x$with_snmp" != "xno"; then if test "x$snmp_type" = "xnet"; then libsnmp="-lnetsnmp" else libsnmp="-lsnmp" fi with_snmp=no SNMPLIBALONE="$libsnmp" # Setting to be able to force linking with -lcrypto.... # This is needed on OpenBSD (at least) where the snmplib port links without -lcrypto, # but fails to run. # Check whether --with-libcrypto or --without-libcrypto was given. if test "${with_libcrypto+set}" = set; then withval="$with_libcrypto" : else with_libcrypto=no fi if test "x$with_libcrypto" = "xyes" ; then SNMPLIBALONE="" fi for lib in $SNMPLIBALONE "$libsnmp -lcrypto" ; do if test "x$with_snmp" != "xyes" ; then echo $ac_n "checking for snmp support in $lib""... $ac_c" 1>&6 echo "configure:3044: checking for snmp support in $lib" >&5 OLIBS="$LIBS" LIBS="$LIBS $lib" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* with_snmp=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* LIBS="$OLIBS" fi rm -f conftest* echo "$ac_t""$with_snmp" 1>&6 fi done fi fi if test "x$with_snmp" = "xyes" ; then cat >> confdefs.h <<\EOF #define USE_SNMP 1 EOF if test "x$snmp_type" = "xnet"; then cat >> confdefs.h <<\EOF #define HAVE_NET_SNMP 1 EOF fi SNMPSRC=snmp.c # hint users about the possible needed option case `uname -s` in *OpenBSD*) case "$LIBS" in *-lcrypto*) ;; *) echo "configure: warning: SNMP test linked fine, but you might need to use --with-libcrypto for SNMP to work on this OS." 1>&2;; esac ;; esac else CPPFLAGS="$OCPPFLAGS" LDFLAGS="$OLDFLAGS" fi fi # checking that we do have at least one driver if test "x$local" != "xyes"; then if test "x$with_snmp" = "xyes"; then echo "configure: warning: no native stats gathering mechanism found; will use SNMP." 1>&2 else { echo "configure: error: no statistics gathering methods found, porting needed." 1>&2; exit 1; } fi fi # check for library # Check whether --enable-library or --disable-library was given. if test "${enable_library+set}" = set; then enableval="$enable_library" LIBTARGET=libifstat.a fi VERSION="`cat VERSION`" test -z $VERSION && VERSION="0.0" # perl -MPOSIX -e 'print strftime("%Y%m%d", localtime((stat("CVS"))[9]));' test -d CVS && VERSION="$VERSION-cvs"`date +%Y%m%d` cat >> confdefs.h < confcache <<\EOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs. It is not useful on other systems. # If it contains results you don't want to keep, you may remove or edit it. # # By default, configure uses ./config.cache as the cache file, # creating it if it does not exist already. You can give configure # the --cache-file=FILE option to use a different cache file; that is # what configure does when it calls configure scripts in # subdirectories, so they share the cache. # Giving --cache-file=/dev/null disables caching, for debugging configure. # config.status only pays attention to the cache file if you give it the # --recheck option to rerun configure. # EOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, don't put newlines in cache variables' values. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. (set) 2>&1 | case `(ac_space=' '; set | grep ac_space) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote substitution # turns \\\\ into \\, and sed turns \\ into \). sed -n \ -e "s/'/'\\\\''/g" \ -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" ;; *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' ;; esac >> confcache if cmp -s $cache_file confcache; then : else if test -w $cache_file; then echo "updating cache $cache_file" cat confcache > $cache_file else echo "not updating unwritable cache $cache_file" fi fi rm -f confcache trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # Any assignment to VPATH causes Sun make to only execute # the first set of double-colon rules, so remove it if not needed. # If there is a colon in the path, we need to keep it. if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' fi trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 DEFS=-DHAVE_CONFIG_H # Without the "./", some shells look in PATH for config.status. : ${CONFIG_STATUS=./config.status} echo creating $CONFIG_STATUS rm -f $CONFIG_STATUS cat > $CONFIG_STATUS </dev/null | sed 1q`: # # $0 $ac_configure_args # # Compiler output produced by configure, useful for debugging # configure, is in ./config.log if it exists. ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" for ac_option do case "\$ac_option" in -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) echo "$CONFIG_STATUS generated by autoconf version 2.13" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; *) echo "\$ac_cs_usage"; exit 1 ;; esac done ac_given_srcdir=$srcdir ac_given_INSTALL="$INSTALL" trap 'rm -fr `echo "Makefile config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 EOF cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF $ac_vpsub $extrasub s%@SHELL@%$SHELL%g s%@CFLAGS@%$CFLAGS%g s%@CPPFLAGS@%$CPPFLAGS%g s%@CXXFLAGS@%$CXXFLAGS%g s%@FFLAGS@%$FFLAGS%g s%@DEFS@%$DEFS%g s%@LDFLAGS@%$LDFLAGS%g s%@LIBS@%$LIBS%g s%@exec_prefix@%$exec_prefix%g s%@prefix@%$prefix%g s%@program_transform_name@%$program_transform_name%g s%@bindir@%$bindir%g s%@sbindir@%$sbindir%g s%@libexecdir@%$libexecdir%g s%@datadir@%$datadir%g s%@sysconfdir@%$sysconfdir%g s%@sharedstatedir@%$sharedstatedir%g s%@localstatedir@%$localstatedir%g s%@libdir@%$libdir%g s%@includedir@%$includedir%g s%@oldincludedir@%$oldincludedir%g s%@infodir@%$infodir%g s%@mandir@%$mandir%g s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g s%@INSTALL_DATA@%$INSTALL_DATA%g s%@CC@%$CC%g s%@RANLIB@%$RANLIB%g s%@CPP@%$CPP%g s%@netsnmpconfig@%$netsnmpconfig%g s%@SNMPSRC@%$SNMPSRC%g s%@VERSION@%$VERSION%g s%@LIBTARGET@%$LIBTARGET%g CEOF EOF cat >> $CONFIG_STATUS <<\EOF # Split the substitutions into bite-sized pieces for seds with # small command number limits, like on Digital OSF/1 and HP-UX. ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. ac_file=1 # Number of current file. ac_beg=1 # First line for current file. ac_end=$ac_max_sed_cmds # Line after last line for current file. ac_more_lines=: ac_sed_cmds="" while $ac_more_lines; do if test $ac_beg -gt 1; then sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file else sed "${ac_end}q" conftest.subs > conftest.s$ac_file fi if test ! -s conftest.s$ac_file; then ac_more_lines=false rm -f conftest.s$ac_file else if test -z "$ac_sed_cmds"; then ac_sed_cmds="sed -f conftest.s$ac_file" else ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" fi ac_file=`expr $ac_file + 1` ac_beg=$ac_end ac_end=`expr $ac_end + $ac_max_sed_cmds` fi done if test -z "$ac_sed_cmds"; then ac_sed_cmds=cat fi EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case "$ac_file" in *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; *) ac_file_in="${ac_file}.in" ;; esac # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. # Remove last slash and all that follows it. Not all systems have dirname. ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then # The file is in a subdirectory. test ! -d "$ac_dir" && mkdir "$ac_dir" ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" # A "../" for each directory in $ac_dir_suffix. ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` else ac_dir_suffix= ac_dots= fi case "$ac_given_srcdir" in .) srcdir=. if test -z "$ac_dots"; then top_srcdir=. else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; *) # Relative path. srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" top_srcdir="$ac_dots$ac_given_srcdir" ;; esac case "$ac_given_INSTALL" in [/$]*) INSTALL="$ac_given_INSTALL" ;; *) INSTALL="$ac_dots$ac_given_INSTALL" ;; esac echo creating "$ac_file" rm -f "$ac_file" configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." case "$ac_file" in *Makefile*) ac_comsub="1i\\ # $configure_input" ;; *) ac_comsub= ;; esac ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` sed -e "$ac_comsub s%@configure_input@%$configure_input%g s%@srcdir@%$srcdir%g s%@top_srcdir@%$top_srcdir%g s%@INSTALL@%$INSTALL%g " $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file fi; done rm -f conftest.s* # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where # NAME is the cpp macro being defined and VALUE is the value it is being given. # # ac_d sets the value in "#define NAME VALUE" lines. ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' ac_dC='\3' ac_dD='%g' # ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' ac_uB='\([ ]\)%\1#\2define\3' ac_uC=' ' ac_uD='\4%g' # ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' ac_eB='$%\1#\2define\3' ac_eC=' ' ac_eD='%g' if test "${CONFIG_HEADERS+set}" != set; then EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF fi for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case "$ac_file" in *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; *) ac_file_in="${ac_file}.in" ;; esac echo creating $ac_file rm -f conftest.frag conftest.in conftest.out ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` cat $ac_file_inputs > conftest.in EOF # Transform confdefs.h into a sed script conftest.vals that substitutes # the proper values into config.h.in to produce config.h. And first: # Protect against being on the right side of a sed subst in config.status. # Protect against being in an unquoted here document in config.status. rm -f conftest.vals cat > conftest.hdr <<\EOF s/[\\&%]/\\&/g s%[\\$`]%\\&%g s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp s%ac_d%ac_u%gp s%ac_u%ac_e%gp EOF sed -n -f conftest.hdr confdefs.h > conftest.vals rm -f conftest.hdr # This sed command replaces #undef with comments. This is necessary, for # example, in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. cat >> conftest.vals <<\EOF s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% EOF # Break up conftest.vals because some shells have a limit on # the size of here documents, and old seds have small limits too. rm -f conftest.tail while : do ac_lines=`grep -c . conftest.vals` # grep -c gives empty output for an empty file on some AIX systems. if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi # Write a limited-size here document to conftest.frag. echo ' cat > conftest.frag <> $CONFIG_STATUS sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS echo 'CEOF sed -f conftest.frag conftest.in > conftest.out rm -f conftest.in mv conftest.out conftest.in ' >> $CONFIG_STATUS sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail rm -f conftest.vals mv conftest.tail conftest.vals done rm -f conftest.vals cat >> $CONFIG_STATUS <<\EOF rm -f conftest.frag conftest.h echo "/* $ac_file. Generated automatically by configure. */" > conftest.h cat conftest.in >> conftest.h rm -f conftest.in if cmp -s $ac_file conftest.h 2>/dev/null; then echo "$ac_file is unchanged" rm -f conftest.h else # Remove last slash and all that follows it. Not all systems have dirname. ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then # The file is in a subdirectory. test ! -d "$ac_dir" && mkdir "$ac_dir" fi rm -f $ac_file mv conftest.h $ac_file fi fi; done EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF exit 0 EOF chmod +x $CONFIG_STATUS rm -fr confdefs* $ac_clean_files test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 ifstat-1.1/config.h.in0100644000031000000620000001110607775071165013466 0ustar gaelstaff/* config.h.in. Generated automatically from configure.in by autoheader 2.13. */ /* Define as the return type of signal handlers (int or void). */ #undef RETSIGTYPE /* Define if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Define if you have the knlist function. */ #undef HAVE_KNLIST /* Define if you have the readx function. */ #undef HAVE_READX /* Define if you have the sigaction function. */ #undef HAVE_SIGACTION /* Define if you have the snprintf function. */ #undef HAVE_SNPRINTF /* Define if you have the header file. */ #undef HAVE_CTYPE_H /* Define if you have the header file. */ #undef HAVE_ERRNO_H /* Define if you have the header file. */ #undef HAVE_FCNTL_H /* Define if you have the header file. */ #undef HAVE_KSTAT_H /* Define if you have the header file. */ #undef HAVE_KVM_H /* Define if you have the header file. */ #undef HAVE_LIMITS_H /* Define if you have the header file. */ #undef HAVE_NET_IF_H /* Define if you have the header file. */ #undef HAVE_NET_IF_DL_H /* Define if you have the header file. */ #undef HAVE_NET_IF_MIB_H /* Define if you have the header file. */ #undef HAVE_NET_IF_TYPES_H /* Define if you have the header file. */ #undef HAVE_NET_IF_VAR_H /* Define if you have the header file. */ #undef HAVE_NET_ROUTE_H /* Define if you have the header file. */ #undef HAVE_NET_SOIOCTL_H /* Define if you have the header file. */ #undef HAVE_NLIST_H /* Define if you have the header file. */ #undef HAVE_PATHS_H /* Define if you have the header file. */ #undef HAVE_SIGNAL_H /* Define if you have the header file. */ #undef HAVE_STDARG_H /* Define if you have the header file. */ #undef HAVE_STROPTS_H /* Define if you have the header file. */ #undef HAVE_SYS_DLPI_H /* Define if you have the header file. */ #undef HAVE_SYS_DLPI_EXT_H /* Define if you have the header file. */ #undef HAVE_SYS_IOCTL_H /* Define if you have the header file. */ #undef HAVE_SYS_MBUF_H /* Define if you have the header file. */ #undef HAVE_SYS_MIB_H /* Define if you have the header file. */ #undef HAVE_SYS_PARAM_H /* Define if you have the header file. */ #undef HAVE_SYS_SOCKET_H /* Define if you have the header file. */ #undef HAVE_SYS_SOCKIO_H /* Define if you have the header file. */ #undef HAVE_SYS_SYSCTL_H /* Define if you have the header file. */ #undef HAVE_SYS_TERMIOS_H /* Define if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define if you have the header file. */ #undef HAVE_UNISTD_H /* Define if you have the socket library (-lsocket). */ #undef HAVE_LIBSOCKET /* Define if you want to use /proc to get stats */ #undef USE_PROC /* Proc file to poll for stats */ #undef PROC_FILE /* Define if you want to use kstat to get stats */ #undef USE_KSTAT /* Define if you want to use if_mib to get stats */ #undef USE_IFMIB /* Define if you have a ifr_data member in struct ifreq */ #undef HAVE_IFREQ_IFR_DATA /* Define if you want to use ifdata to get stats */ #undef USE_IFDATA /* Define this if you want to use roue(4) sysctl to get stats */ #undef USE_ROUTE /* Define if knlist needs 3 arguments */ #undef HAVE_KNLIST_ARGS3 /* Define if you have the kvm(3) interface */ #undef HAVE_KVM /* Define if you have a if_xname member in struct ifnet */ #undef HAVE_IFNET_IF_XNAME /* Define if you have a if_next member in struct ifnet */ #undef HAVE_IFNET_IF_NEXT /* Define if you have a if_link member in struct ifnet */ #undef HAVE_IFNET_IF_LINK /* Define if you want to use kvm to get stats */ #undef USE_KVM /* Define if you want to use dlpi to get stats */ #undef USE_DLPI /* Define if you want to use win32 to get stats */ #undef USE_WIN32 /* Define if you want to use ioctls to get if list */ #undef USE_IOCTL /* Define if you have a sa_len member in struct sockaddr */ #undef HAVE_SOCKADDR_SA_LEN /* Define if you want ot use if_nameindex to find interfaces */ #undef USE_IFNAMEINDEX /* Define if you have SNMP support */ #undef USE_SNMP /* Define if your SNMP implementation is net-snmp v5.0 or greater */ #undef HAVE_NET_SNMP /* Version */ #undef VERSION ifstat-1.1/ifstat.10100644000031000000620000002442307775071167013027 0ustar gaelstaff.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.13 .\" .\" Standard preamble: .\" ======================================================================== .de Sh \" Subsection heading .br .if t .Sp .ne 5 .PP \fB\\$1\fR .PP .. .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. | will give a .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' .\" expand to `' in nroff, nothing in troff, for use with C<>. .tr \(*W-|\(bv\*(Tr .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .\" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .hy 0 .if n .na .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "IFSTAT 1" .TH IFSTAT 1 "2003-11-22" "ifstat 1.1" "System Utilities" .SH "NAME" ifstat \- Report InterFace STATistics .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBifstat\fR [\fB\-a\fR] [\fB\-l\fR] [\fB\-z\fR] [\fB\-n\fR] [\fB\-v\fR] [\fB\-h\fR] [\fB\-t\fR] [\fB\-i\fR if0,if1,...] [\fB\-d\fR drv[:opt]] [\fB\-s\fR [comm@][#]host[/nn]] [\fB\-T\fR] [\fB\-A\fR] [\fB\-w\fR] [\fB\-W\fR] [\fB\-S\fR] [\fB\-b\fR] [\fB\-q\fR] [delay[/delay] [count]] .SH "DESCRIPTION" .IX Header "DESCRIPTION" Ifstat is a little tool to report interface activity, just like iostat/vmstat do for other system statistics. .SH "OPTIONS" .IX Header "OPTIONS" \&\fBifstat\fR accepts the following options: .IP "\fB\-l\fR" 4 .IX Item "-l" Enables monitoring of loopback interfaces for which statistics are available. By default, ifstat monitors all non-loopback interfaces that are up. .IP "\fB\-a\fR" 4 .IX Item "-a" Enables monitoring of all interfaces found for which statistics are available. .IP "\fB\-z\fR" 4 .IX Item "-z" Hides interface which counters are null, eg interfaces that are up but not used. .IP "\fB\-i\fR" 4 .IX Item "-i" Specifies the list of interfaces to monitor, separated by commas (if an interface name has a comma, it can be escaped with '\e'). Multiple instances of the options are added together. .IP "\fB\-s\fR" 4 .IX Item "-s" Equivalent to \fB\-d snmp:[comm@][#]host[/nn]]\fR to poll a remote host through \s-1SNMP\s0. See below for details. .IP "\fB\-h\fR" 4 .IX Item "-h" Displays a short help message. .IP "\fB\-n\fR" 4 .IX Item "-n" Turns off displaying the header periodically. .IP "\fB\-t\fR" 4 .IX Item "-t" Adds a timestamp at the beginning of each line. .IP "\fB\-T\fR" 4 .IX Item "-T" Reports total bandwith for all monitored interfaces. .IP "\fB\-A\fR" 4 .IX Item "-A" Disables use of interface indexes: by default, when polling mechanism is index based (snmp, ifmib), ifstat remembers indexes of monitored interfaces to poll only them. However, if interfaces indexes change often (new interfaces added, etc), you might loose some stats, hence this flag. Note that if you ask ifstat to monitor a non existent interface, it will poll all interfaces until it finds the requested one (regardless of this flag) so you can poll for an interface that goes up and down. .IP "\fB\-w\fR" 4 .IX Item "-w" Uses fixed width columns, instead of enlarging them if needed for interfaces names to fit. .IP "\fB\-W\fR" 4 .IX Item "-W" Wrap lines that are larger than the terminal width (implies \-w). Wrapped lines are prefixed with a cycling letter to ease reading. .IP "\fB\-S\fR" 4 .IX Item "-S" Keep stats updated on the same line if possible (no scrolling nor wrapping). .IP "\fB\-b\fR" 4 .IX Item "-b" Reports bandwith in kbits/sec instead of kbytes/sec. .IP "\fB\-q\fR" 4 .IX Item "-q" Quiet mode, warnings are not printed. .IP "\fB\-v\fR" 4 .IX Item "-v" Displays version and the compiled-in drivers. .IP "\fB\-d\fR" 4 .IX Item "-d" Specifies a driver to use to gather stats and an eventual option for this driver separated of the driver name by a colon. If this is not specified, ifstat uses the first driver compiled in, with no options. .Sp The following drivers are available (depending on the operating system and compile-time options, not all of them might be present): .RS 4 .IP "\fBproc\fR" 4 .IX Item "proc" This driver gets statistics from Linux's /proc/net/dev file. An alternate file name to get stats from can be passed as the option. .IP "\fBifmib\fR" 4 .IX Item "ifmib" This driver gets statistics from FreeBSD's ifmib sysctl. It doesn't accept any options. .IP "\fBkstat\fR" 4 .IX Item "kstat" This driver gets statistics from Solaris kstat interface. It doesn't accept any options. .IP "\fBifdata\fR" 4 .IX Item "ifdata" This driver gets statistics using \s-1SIOCGIFDATA\s0 ioctl under \s-1IRIX\s0 and OpenBSD (different semantics). It doesn't accept any options. .IP "\fBroute\fR" 4 .IX Item "route" This driver gets statistics using routing sysctl on \s-1BSD\s0 based systems. It doesn't accept any options. .IP "\fBkvm\fR" 4 .IX Item "kvm" This driver gets statistics by reading the kernel live structures. It accepts an option specifying which files/devices to use in the following format : [execfile][,[corefile][,swapfile]] (see \fIkvm_open\fR\|(3) for details on those fields). If a null string is passed for a parameter, the system default will be used for it. .Sp Note that for this driver to work, ifstat needs to have read access to the system memory device. This is usually done by running it as root, or by installing setgid mem or kmem. ifstat will \s-1NOT\s0 install setgid by default; It is up to you to decide if you trust it. .IP "\fBdlpi\fR" 4 .IX Item "dlpi" This driver gets statistics using the \s-1DLPI\s0 streams interface available on \s-1HP\-UX\s0. An alternate device to query statistics from can be passed as the option (default is /dev/dlpi). .IP "\fBwin32\fR" 4 .IX Item "win32" This driver gets statistics using the GetIfTable interface available on Win32 systems. It doesn't accept any options. .IP "\fBsnmp\fR" 4 .IX Item "snmp" This driver gets statistics through \s-1SNMP\s0. The option, in the form [comm@][#]host[/nn]], specifies the host and eventual community to poll. Default community is public, but can be changed by prepending \*(L"comm@\*(R" to the hostname. If host starts by a #, interface names are generated from their index as `ifNN' (this is a workaround for some equipments that give all interfaces the same description). Default host is localhost, and this will be used by default if snmp is the only available driver. .Sp The driver will try to poll several interfaces at once by grouping requests in \s-1SNMP\s0 packets. By default interfaces will be polled by group of 8. If this doesn't work well with your equipments, you can lower that number by suffixing the hostname with /nn, where nn is the number of interfaces to poll at once. You can also increase the number if you want to poll a large number of interfaces efficiently and if your server supports it. .RE .RS 4 .RE .IP "\fBdelay\fR" 4 .IX Item "delay" \&\fBdelay\fR is the delay between updates in seconds, which defaults to 1. A decimal number can be specified for intervals shorter than a second. (minimum 0.1) .Sp A second delay can also be specified (separated from the first one by a '/'). In that case the first delay will be used for the first poll after start and the second one will be used for all following polls (This can be used to have a \*(L"fast\*(R" start when running for a long while with a big delay). .IP "\fBcount\fR" 4 .IX Item "count" \&\fBcount\fR is the number of updates before stopping. If not specified, it is unlimited. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIvmstat\fR\|(1), \fIiostat\fR\|(1) .SH "AUTHOR" .IX Header "AUTHOR" Gaël Roualland,