[Home]

Summary:ASTERISK-12620: [patch] 'core show sysinfo' on systems that dont have sysinfo but do have sysctl
Reporter:Michiel van Baak (mvanbaak)Labels:
Date Opened:2008-08-20 17:25:16Date Closed:2008-09-06 18:40:49
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/Portability
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) 2008082000_core-show-sysinfo-sysctl.diff
( 1) 2008082000_core-show-sysinfo-sysctl-v2.diff
Description:'core show sysinfo' and the SYSINFO function use the sysinfo call.
This call is only present on linux systems.

Since I'm using OpenBSD and want at least the memory stats I created a version of 'core show sysinfo' that uses sysctl and swap.h to grab the numbers.


****** ADDITIONAL INFORMATION ******

I tested this on OpenBSD 4.4 (not yet released, but snapshots are available and the CVS tree is tagged) and OpenBSD 4.3
I also tested that the old sysinfo version still works on linux.
More test reports needed, as I cannot test it on anything besides linux and openbsd.

Right now I do a simple #else in the code that checks for HAVE_SYSINFO.
This is not correct and should be some magic #elif
If anyone has pointers what it should be please comment on this bug.

This is how it looks like on my OpenBSD boxen:
     *CLI> core show sysinfo
     System Statistics
     -----------------
       Total Physical memory:     993244 KiB
       Total active memory:       218376 KiB
       Total used memory:         461752 KiB
       Free memory:               506760 KiB
       Total Swap Space:          1048005 KiB
       Free Swap Space:           1048005 KiB

       Number of Processes:       81
Comments:By: Michiel van Baak (mvanbaak) 2008-08-20 17:59:49

new patch that adds sysctl check to configure.ac thanks to seanbright.

TODO:
- in main/asterisk.c replace the #if defined(HAVE_SYSINFO).... #else with #if defined(HAVE_SYSINFO)... #elif defined(HAVE_SYSCTL)....
- we now have two functions with the same name, depending on the #if #else stuff.
 It would be better to seperate the printing and data-gathering and only call the correct data-gathering function based on the defined(HAVE_X) stuff. That way we are not replicating code while there's no use for that.

Thanks go to seanbright for the feedback etc.