Line 725... |
Line 725... |
725 |
*
|
725 |
*
|
726 |
* @return void
|
726 |
* @return void
|
727 |
*/
|
727 |
*/
|
728 |
protected function memory()
|
728 |
protected function memory()
|
729 |
{
|
729 |
{
|
730 |
if (PSI_OS == 'FreeBSD' || PSI_OS == 'OpenBSD') {
|
730 |
if (PSI_OS == 'FreeBSD') {
|
- |
|
731 |
$kos = $this->grabkey('kern.osrelease');
|
- |
|
732 |
if (preg_match("/^(\d+\.\d+)/", $kos, $kver) && version_compare("14.1", $kver[1], "<=")) {
|
- |
|
733 |
// vmstat on fbsd 14.1 or greater outputs bytes
|
- |
|
734 |
$multiplier = 1;
|
- |
|
735 |
} else {
|
731 |
// vmstat on fbsd 4.4 or greater outputs kbytes not hw.pagesize
|
736 |
// vmstat on fbsd 4.4 or greater outputs kbytes not hw.pagesize
|
732 |
// I should probably add some version checking here, but for now
|
737 |
// I should probably add some version checking here, but for now
|
733 |
// we only support fbsd 4.4
|
738 |
// we only support fbsd 4.4
|
- |
|
739 |
$$multiplier = 1024;
|
- |
|
740 |
}
|
- |
|
741 |
} elseif (PSI_OS == 'OpenBSD' || PSI_OS == 'NetBSD' || PSI_OS == 'DragonFly') {
|
734 |
$pagesize = 1024;
|
742 |
$multiplier = 1024;
|
735 |
} else {
|
743 |
} else {
|
736 |
$pagesize = $this->grabkey('hw.pagesize');
|
744 |
$multiplier = $this->grabkey('hw.pagesize');
|
737 |
}
|
745 |
}
|
738 |
if (CommonFunctions::executeProgram('vmstat', '', $vmstat, PSI_DEBUG)) {
|
746 |
if (CommonFunctions::executeProgram('vmstat', '', $vmstat, PSI_DEBUG)) {
|
739 |
$lines = preg_split("/\n/", $vmstat, -1, PREG_SPLIT_NO_EMPTY);
|
747 |
$lines = preg_split("/\n/", $vmstat, -1, PREG_SPLIT_NO_EMPTY);
|
740 |
$ar_buf = preg_split("/\s+/", trim($lines[2]), 19);
|
748 |
$ar_buf = preg_split("/\s+/", trim($lines[2]), 19);
|
741 |
if (PSI_OS == 'NetBSD' || PSI_OS == 'DragonFly') {
|
- |
|
742 |
$this->sys->setMemFree($ar_buf[4] * 1024);
|
- |
|
743 |
} else {
|
- |
|
744 |
$this->sys->setMemFree($ar_buf[4] * $pagesize);
|
749 |
$this->sys->setMemFree($ar_buf[4] * $multiplier);
|
745 |
}
|
- |
|
746 |
$this->sys->setMemTotal($this->grabkey('hw.physmem'));
|
750 |
$this->sys->setMemTotal($this->grabkey('hw.physmem'));
|
747 |
$this->sys->setMemUsed($this->sys->getMemTotal() - $this->sys->getMemFree());
|
751 |
$this->sys->setMemUsed($this->sys->getMemTotal() - $this->sys->getMemFree());
|
748 |
|
752 |
|
749 |
if (((PSI_OS == 'OpenBSD' || PSI_OS == 'NetBSD') && CommonFunctions::executeProgram('swapctl', '-l -k', $swapstat, PSI_DEBUG)) || CommonFunctions::executeProgram('swapinfo', '-k', $swapstat, PSI_DEBUG)) {
|
753 |
if (((PSI_OS == 'OpenBSD' || PSI_OS == 'NetBSD') && CommonFunctions::executeProgram('swapctl', '-l -k', $swapstat, PSI_DEBUG)) || CommonFunctions::executeProgram('swapinfo', '-k', $swapstat, PSI_DEBUG)) {
|
750 |
$lines = preg_split("/\n/", $swapstat, -1, PREG_SPLIT_NO_EMPTY);
|
754 |
$lines = preg_split("/\n/", $swapstat, -1, PREG_SPLIT_NO_EMPTY);
|