2011-06-15 Koichiro Kikuchi <koichiro@rworks.jp>

* lib/PandoraFMS/Tools.pm: Added FreeBSD specific code to load_average()
	  and free_mem() functions.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4447 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
koichirok 2011-06-15 07:22:39 +00:00
parent e486dc1203
commit 119d0d718a
2 changed files with 30 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2011-06-15 Koichiro Kikuchi <koichiro@rworks.jp>
* lib/PandoraFMS/Tools.pm: Added FreeBSD specific code to load_average()
and free_mem() functions.
2011-06-13 Sancho Lerena <slerena@artica.es>
* Tools.pm: Avoid errors when provide an empty string to md5.

View File

@ -692,12 +692,35 @@ sub disk_free ($) {
}
sub load_average {
my $load_average = `cat /proc/loadavg | awk '{ print \$1 }'`;
my $load_average;
my $OSNAME = $^O;
if ($OSNAME eq "freebsd"){
$load_average = ((split(/\s+/, `/sbin/sysctl -n vm.loadavg`))[1]);
}
# by default LINUX calls
else {
$load_average = `cat /proc/loadavg | awk '{ print \$1 }'`;
}
return $load_average;
}
sub free_mem {
my $free_mem = `free | grep Mem | awk '{ print \$4 }'`;
my $free_mem;
my $OSNAME = $^O;
if ($OSNAME eq "freebsd"){
my ($pages_free, $page_size) = `/sbin/sysctl -n vm.stats.vm.v_page_size vm.stats.vm.v_free_count`;
# in kilobytes
$free_mem = $pages_free * $page_size / 1024;
}
# by default LINUX calls
else {
$free_mem = `free | grep Mem | awk '{ print \$4 }'`;
}
return $free_mem;
}