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).
Fix memory leak on NetBSD 2.0. (kl_stats wasn't being free'd)
Skip over argv pointers on OpenBSD.
Attempt to rework the command line argument fetching - mallocing 256Kb was a bit on the large side. Now we start with something sensible and make it bigger as required. This produces odd results on OpenBSD.
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.
Nuke sg_process_sort, and make the process stats example demonstrate how to sort using the compare functions and qsort.
s/sg_sort_method/sg_process_sort_method/
Name change for future friendlyness.
Added some generic sorting methods for process_stats.
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
Fixed tools.c change of enum Fixed a FD leak in solaris and added nice value.
Whitespace tidyup - change spaces to tabs.
More linux code, now does uid/gid.
Change malloc -> sg_malloc, realloc -> sg_realloc, and rewrite the one calloc call to use sg_malloc.
Change the last few instances of strdup to use sg_update_string.
Fix a couple of includes.
A bit more of the linux code.. Need to do uid/gid bit still. Also, haven't done nice on solaris yet.
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".
Add a note about something that needs fixing. We still have problems getting proctitle on some of the BSD's :-(
Fix process stats on NetBSD 2.0 (beta). Also fix the 5-processes-workaround Adam committed yesterday on the rest of the BSD's (not just FreeBSD5).
To quote from the FreeBSD kernel source: "/* overestimate by 5 procs */". This is the workaround.
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.
Fixed, and properly tested.
Instead of reallocing on the fly, work out the size of the buffer in advance and then fill it on a second pass. Suggested by Adam.
NULL -> \0, initialise malloced memory to \0, and plug a memory leak.
Use vectors and update_string. (I haven't really touched the BSD code here yet.)
We nearly forgot to make the process stats work on cygwin again :-)
Returning NULL in a function that returns int's is wrong :) Now returns -1 on failure. Also change code that calls us to check for < 0 for failures.
Minor bugfixes.
Fix a bunch of silly errors.
Fix a bunch of warnings on the BSD's.
Add an get_kvm2 function to open kvm with slightly different args. This set of args doesn't seem to need elevated privileges, but in my last test wouldn't perform the functions required in swap_stats.
Fix a bunch of warnings.
Silence a (harmless) "enumeration value `UNKNOWN' not handled in switch" error.
get_proc_snapshot returns an integer, not a pointer.
Silence 40-odd (harmless) "use of assignment suppression and length modifier together" errors.
This has been a bit more complex than it probably should have been. We now have the command line arguments on FreeBSD5, NetBSD, and probably OpenBSD without using kvm. The sysctl interface provided the required information. However, on FreeBSD 4 and Dragonfly BSD there was no matching sysctl interface, so the kvm way remains. Fortunately neither of those two OS's require elevated privileges to use that bit of kvm. Finally in a decent position with no elevated privileges required for this section of code, on any of the BSD's. Still one bug to fix: there are 5 "null" processes on the end of the list. This has been introduced at some point, because it wasn't there yesterday.
Revert to using sysctl instead of kvm to get process stats. This should be more compatible with NetBSD and OpenBSD. Still need to use kvm to get the command line args, but this seems unavoidable. At this stage we don't bail if kvm fails (eg. not enough privs), instead the command line args will just be set to NULL. Seems a fair compromise.
Add support for DragonFly BSD. Seems to be working correctly, and works without needing any extra privileges. Some stuff comes from proc.h, whilst some comes from thread.h. A word of warning - the DragonFly folk seem to be changing a lot of stuff to do with processes and threads, so it's likely this could break very easily :-)
Support for OpenBSD, although it suffers the same problems as NetBSD.
This adds support for NetBSD, although it currently needs elevated privileges. I will try and fix that.
Handle failure to get a snapshot.
Add default to case statement which uses the UNKNOWN process state.
Add support for FreeBSD 4. I suspect this may work on OpenBSD and NetBSD too, although I'll need to verify that. Also add an additional process state of UNKNOWN.
Got the command line args. Now using kvm to get information, although fortunately this doesn't need any special privileges. Switched to using kvm to get the process listing too. When no command line arguments available doing something similar to ps and putting the command name in brackets.
Fix CPU percentages on FreeBSD 5. Set args to NULL until we can figure out how to collect them. Still need to add code for other BSD's.
Reimplement get_process_stats. I presume the plan was to rewrite this to use the new function for collecting stats :-) Seems to work on FreeBSD5 - but I'm not entirely convinced my BSD code is working yet.
The startings of the BSD code. Only works on FreeBSD 5 so far. Doesn't yet do command line arguments, or CPU percentages correctly.
Basic framework for linux.. Doesn't do CPU on a per process basis, as i'm not sure the best way to approach that yet.
Added the state for solaris
The start of the rework for process_stats to give more information, and to become a standard proc interface.
Add support for DragonFly BSD 1.0. Also a minor tweak to the network interface code to make it more portable.
Move free inside the right #ifdef, and fix a memory leak when sysctl fails.
Look at all the process states on all the BSD's. Tidly done using ifdef's.
Switch process stats to using sysctl on ALLBSD. On OpenBSD and hopefully NetBSD (this hasn't been tested yet - but I'm quite confident) this means we no longer need any elevated privileges.
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.
Use the userspace limits.h header, not the kernel one.
Make libstatgrab functions return NULL for stats that can't be fetched on cygwin.
Add support for cygwin. This is a bit limited, there's a few things that can't be retrieved on cygwin such as load averages, diskio, network io, and process stats. The package compiles and runs, and both saidar and statgrab work. Taken from a patch submitted by Ron Arts <raarts@netland.nl>. Thanks Ron!
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.
Add a helper function for opening the kvm handle. This removes a little bit of duplicated code, and means that we don't open and close kvm (which can potentially be quite expensive) each time we use it. This will also be useful for NetBSD.
Fixed for freebsd 5 to count the new states a process can be in. Reverted back to the proper way for the total now this has been proven was the problem.
Possibly making sure that the total is always correct on freebsd 5, even if some of the states are left out.
Update to work for Freebsd5. Thanks to Tim Bishop for doing the hard work for this patch.
Tidy up of lots of little things. :)
Fix bug report #748942. Moved the ifdef to where it should be :)
Now works on freebsd.. Now why couldn't they follow the same scheme as everything else :) ?
Added linux support.
Bug fix :
Removed debugging printf
Tidy up of configure script, and includes.
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.