Add support for AIX 5.x - 9.x. Many thanks to Jens Rehsack <rehsack@googlemail.com> for providing the patch for this work. Thanks!
Fix link speed on FreeBSD (and others?). Rather than using our own mask make use of the system macro to do it for us. Test on FreeBSD, but a look at if_media.h on the other BSDs suggests it'll work there too.
When checking the interface up status check the link status as well. Suggested by: "Vassallo, Michelangelo (Michelangelo)" <vassallo@lucent.com>
Move reading the interface name to earlier in the function. This fixes problems for us on a host with slightly peculiar interfaces.
Make sure we always close kstat. Spotted by: "Javier Donaire" <jyuyu@fraguel.org> (in load_stats.c)
Fix bug on Solaris; network interfaces always seem to be up. Reported by: joanmoraleda@ono.com
Add WIN32 support via MINGW. We'll need to add stuff to the README file about what this requires to build. All the hard work done by: skel
Use <asm/types.h> to define __u32 etc., and always define u32 etc. because the Debian 2.6.0-test9 headers still use them in ethtool.h.
Change the name of the duplex value from "dup" to "duplex". This will break the ABI, but we're changing the fs stats anyway. The API change is minimal, so hopefully won't affect too many people.
Apply patch from Scott Lampert to make the network ethtool bits compile on Linux 2.6.
The labels in this case statement were the wrong way round, so the duplex settings were being reported incorrectly on linux. Use the defines instead of the values so we can be sure they're right. Spotted by Pete.
Raise SG_ERROR_UNSUPPORTED for interface stats on Cygwin and HP-UX.
HP-UX can't do network stats.
Use sg_set_error_with_errno whenever errno's valid. Change the one user of SG_ERROR_ENOENT to SG_ERROR_SYSCTL instead (since that's what it should have been).
Add comparison functions for names where that's likely to be useful. Make the network_iface_stats example show how to use bsearch to find an interface by name.
Shift a bunch of parsing functions to be linux/cygwin only. Prompted by a regex related compile error on FreeBSD (we don't use regex's on FreeBSD).
The rest of the error handling stuff (except the vector code). I've been extremely unimaginative with the string names in error.c, but they're all in one place so much easier to tidy up. I'm also beginning to wonder if we actually needed an SG_ERROR_SYSTEM_CALL to indicate some call into the system failed - because the majority of our errors are those :-) Still to do, then: - vector code - better string names in error.c - deal with arg string in some way - make use of the error status in statgrab/saidar/examples
Whitespace tidyup - change spaces to tabs.
Update name of project at the top of all soure files. These files now exist in their own right, rather than as part of the "CMS".
Make sg_update_string return an int to indicate success, so that it can be used to set a string to NULL. Make Linux process_stats code set proctitle to NULL if it's empty rather than "".
Rename all the functions, types and enums in the API to be consistent. Types are now of the form "sg_mem_stats"; functions of the form "sg_get_mem_stats"; enums of the form "SG_PROCESS_STATE_RUNNING". (The old get_proc_snapshot follows the usual calling convention now.) Make internal functions static where possible. Rename non-static internal functions to have an sg_ prefix so they don't collide with those from other libraries. In particular, strlcpy and strlcat are now called sg_strlcpy and sg_strlcat and are always included. Fix saidar and statgrab to use the new API.
Fix a couple of warnings on Solaris.
Use update_string.
Make network_stats use vectors.
Fix a bunch of warnings.
Silence another (harmless) "may be used uninitialised" error.
Rework transfer_diff so that it doesn't need an inexpressible constant on 64-bit systems. Add OpenBSD to the platforms with 32-bit transfer stats.
Add a FIXME note on the network interface stats code; some Solaris interfaces have packet counts but not byte counts, so it would be useful to return those once we have a way of indicating the byte count is unknown.
On OpenBSD IFM_1000_TX is defined to be IFM_1000_T. We can't have both in our case statement, so ignore IFM_1000_TX.
Add support for new network stats on Solaris. Please check this change cos this is the first time I've coded Solaris stuff :-)
Change MAXVAL to Hex. I've made an assumption that they were +1 too big before. I might be wrong, though.
"And if a 4 turned out to be 9, I don't mind, I don't mind..." Fix regexec result count.
Make the network stats regexp simpler. Since /proc/net/dev is a fixed format, there's no need to use [[:space:]] and [[:digit:]]; a literal space and [0-9] will suffice.
Make the regexp match array the right size for Linux.
Add support for errors/packets/collisions to Linux.
Make the rest of the code aware of the new values in the struct.
Add getting errors, packets, and collisions for network interfaces on BSD.
Add support for DragonFly BSD 1.0. Also a minor tweak to the network interface code to make it more portable.
Rework iface_stat code for Solaris so that it uses SIOCGIFFLAGS to find out whether an interface is up or not. This means that we need to link with -lsocket -lnsl now to get socket(). Also make the comment about when bytes-transferred stats a bit more explicit. We're now in the slightly odd situation where it's possible for an interface to show up in either or both of get_network_stats and get_network_iface_stats: for instance, on raptor at the moment, ce0 is in use so shows up in both, lo0 doesn't have kstats for bytes transferred and thus only shows up in the second, and ce1 exists but hasn't been plumbed so only shows up in the first. I'd be mildly inclined to "fix" this by making get_network_stats do a SIOCGIFFLAGS ioctl so unplumbed interfaces don't show up at all (and add packets received/transmited to the get_network_stats result so we can at least show something for lo0).
ifaces doesn't need to be static.
Define u64 to fix Linux 2.4.21 build.
Fixed compile error. We not sure that link_up gets us what we want tho.
Rearrange the BSD network_iface_stat code in the same way as the Linux code; try SIOCGIFFLAGS first to find out whether the interface is up, then only fill in the other information if it's available.
Make the unknown speed 0 to match the BSD code.
Tidy up the Linux iface_stat code. - fclose(f) once we're done to avoid fd leak - no need to malloc struct ethtool_cmd since it's of constant size (and this avoids some odd-looking casts) - use switch rather than multiple ifs for duplex codes - use SIOCGIFFLAGS ioctl first to find out whether the interface is up, since this works on all interfaces The user-visible change here is that ->speed and ->dup now get filled in with -1, UNKNOWN_DUPLEX for interfaces that don't support SIOCETHTOOL. Fixing this properly is on the todo list...
Rename BSD "int s" to "int sock" to match Linux code and fix compile error. Make BSD code set the interface name before calling ioctl so it gets the stats for the right interface.
*bsd didn't do what i wanted. Still needs testing for all platforms.
Added up/down interface detection. Not tested (or even compiled) on any os. So that really needs to be done :)
Add example for network_iface_stats. Fix duplex on Solaris.
Solaris bug fix for duplex detection.
Fix another DUPEX-for-DUPLEX typo. Include <unistd.h> to get the definition of close().
DUPLEX, not DUPEX. NetBSD has FreeBSD 5-like speed definitions.
Added a couple of forgotten close's.
Couple of name changes, and a tidy up.
Fix on FreeBSD 5. Also add IFM_1000_FX missed on FreeBSD 4.
Added network interface stats for linux. Points to remember: a) This code will need to be run as root. Otherwise, it should safely return null. b) the "speed" may be incorrect if the interface is not actually up and talking to anything. However, duplex will be set to NO_DUPLEX so as long as they use that test first, there should be no problem. (This is safe assumption to work on, even for other platforms) c) This was a nastyish and hard bit of code. Maybe bugs, would appricate a look over by people :)
Added code for freebsd to do the network interface speeds. I've put it under the label ALLBSD however, as i suspect it will work on all the BSD's of intrest.
Added the ability to get the interface speed/duplex for solaris. Not really checked code, but it appears to work.
Tidy up get_network_stats_diff and get_diskio_stats_diff.
A whole bunch of minor cosmetic changes.
Alter the licensing of libstatgrab. The library part is now under the LGPL, whilst the tools/examples are under the GPL. Both licenses are included in the distribution (and are both now in CVS). Also made a minor alteration to the webpage where it said everything was licensed under the GPL.
Add a couple of missing checks for NULL return values; this fixes the crash when libstatgrab runs out of FDs.
Make libstatgrab functions return NULL for stats that can't be fetched on cygwin.
Add the correct type to a couple of long long constants.
Initial support for NetBSD. This adds NetBSD support for everything except diskio stats (since they're even more disturbingly complex to get at on NetBSD than the three OSs we already support). Tested against NetBSD 1.6 on i386.
Fix for freebsd network traffic too.. Everything stores it in 32bit with the exception of SOL8+ hosts. Its a stupid world ;)
Linux stores it as a 32bit unsigned long, so suffers the same wrap around bug as sol 7 hosts. This increases the chances it may happen on freebsd too so some testing maybe needed. If so, we prob should change this to a default and have a #ifdef 64bit for the odd (good) ones :)
Tidy up of lots of little things. :)
Now works on freebsd. This is the last of parts that needed to be ported so its now "finished" for testing. Solaris and Linux should also be tested as minor changes in code may of disturbed them (it shouldn't have, i just may of made a mistake :) ) Certain things will require setgid kmem permissions (swap and processor stats)
Fixed memory leak in regex stuff
Fixed some issues with not closing FILE*'s.
Fix another #include.
Another stupid bug in the wrap around code.
Well, i carefully made the function to look after wrap around issues, and then apparently didn't use it :) It now uses it :)
Ok, wrap around fixed for 32bit machines, not 64. I really ought to change all the long long's to ulong long's. I'll ponder if i can be bothered :)
Make network stats work on pre sol8. BUGS: On pre sol8 systems, it doesn't cope with a wrap around once the 32bit uint becomes too big. So when this happens it will report one set of dodgy data, then continue. This bug technically is there in the 64bit version too, but it will need to of sent 9223372036854775808 bytes first. (8388608 terrabytes, so basically a *big enough* number that will come around and byte me in 20 years time or something ;) )
Made network stats work with linux.
bug fix
Tidy up of configure script, and includes.
network stats now returns a diff() style function, to make it easy to show the exact average network traffic over a period of time.
Changed the kstat_close to not return NULL in event of a failure. If we cant close it, well there is nothing i can do about that, so i may as well at least return something useful since its done all the hardwork by that point. And anywan, it should never fail to close :)
The new revesion of libstatgrab, which is a complete rewrite essentially. Firstly the data is now returned in structures rather than xml strings. The structures returned are all static, so what ever calls the library doesn't have to deal with the memory management of it. Secondly the general efficency of the code is now significantly faster. It no longer needs to fork a process, connect file descriptors and run ps, and then parse the output like it used to. Now it walks /proc and reads it into the correct data structures. This works without needing any special privilages, so it can still run as a normal mortal without needing any special group. (Freebsd will be an exception to this, but this commit only works with solaris, and that requires nothing special) Thridly it has more functionality than it used to. It not for instance is capable of showing network traffic stats, (although its not completely finished yet). It also in the near future be able to disk io stats as well. Several bug fixes have been aplied over the original version. For example the cpu_stats used to only reply the stats for the first processor. This now will report the total stats of all of them. Paging stats will also be fixed, but haven't been done yet.
This form allows you to request diffs between any two revisions of this file. For each of the two "sides" of the diff, select a symbolic revision name using the selection box, or choose 'Use Text Field' and enter a numeric revision.