From 3c5dd2f19a838548700981eef7b4a80acba1faaf Mon Sep 17 00:00:00 2001 From: thecityofguanyu Date: Wed, 20 Apr 2016 09:20:50 -0500 Subject: [PATCH 1/4] I agree to the conditions of the Contributor Agreement contained in doc/General/Contributing.md. --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 28d60480df..fec1d61546 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -97,6 +97,7 @@ LibreNMS contributors: - Karsten Nerdinger (piratonym) - Michael Nguyen (mnguyen1289) - Casey Schoonover (cschoonover91) +- Chris A. Evans (thecityofguanyu) [1]: http://observium.org/ "Observium web site" Observium was written by: From 114608045884bb3afbe70ce3687fee08ef5ee296 Mon Sep 17 00:00:00 2001 From: "xavier.beaudouin" Date: Wed, 20 Apr 2016 16:23:16 +0200 Subject: [PATCH 2/4] Add FreeBSD detection to distro file --- scripts/distro | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/distro b/scripts/distro index 96cbbe75f7..8a2ebd02ef 100755 --- a/scripts/distro +++ b/scripts/distro @@ -86,6 +86,9 @@ elif [ "${OS}" = "Darwin" ] ; then if [ -f /usr/bin/sw_vers ] ; then OSSTR=`/usr/bin/sw_vers|grep -v Build|sed 's/^.*:.//'| tr "\n" ' '` fi + +elif [ "${OS}" = "FreeBSD" ] ; then + OSSTR=`/usr/bin/uname -mior` fi echo ${OSSTR} From c99fee75df563bacab8731bc839ef119fc191661 Mon Sep 17 00:00:00 2001 From: Paul Gear Date: Thu, 21 Apr 2016 08:08:17 +1000 Subject: [PATCH 3/4] Sort services list --- html/includes/modal/new_service.inc.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/html/includes/modal/new_service.inc.php b/html/includes/modal/new_service.inc.php index e1b973c74f..9891c2441e 100644 --- a/html/includes/modal/new_service.inc.php +++ b/html/includes/modal/new_service.inc.php @@ -11,17 +11,20 @@ * the source code distribution for details. */ -if(is_admin() !== false) { +if (is_admin() !== false) { // Build the types list. - if ($handle = opendir($config['nagios_plugins'])) { - while (false !== ($file = readdir($handle))) { - if ($file != '.' && $file != '..' && !strstr($file, '.') && strstr($file, 'check_')) { - list(,$check_name) = explode('_',$file,2); + $dir = $config['nagios_plugins']; + if (file_exists($dir) && is_dir($dir)) { + $files = scandir($dir); + $dir .= DIRECTORY_SEPARATOR; + d_print_r($files); + foreach ($files as $file) { + if (is_executable($dir.$file) && is_file($dir.$file) && strstr($file, 'check_')) { + list(,$check_name) = explode('_', $file, 2); $stype .= ""; } } - closedir($handle); } ?> @@ -142,4 +145,4 @@ $('#service-submit').click('', function(e) { Date: Thu, 21 Apr 2016 14:38:21 +0000 Subject: [PATCH 4/4] Added support + docs for FreeBSD --- doc/Extensions/Agent-Setup.md | 10 +++++++++- includes/polling/unix-agent.inc.php | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/doc/Extensions/Agent-Setup.md b/doc/Extensions/Agent-Setup.md index 652d9a7922..767e179bf2 100644 --- a/doc/Extensions/Agent-Setup.md +++ b/doc/Extensions/Agent-Setup.md @@ -15,7 +15,15 @@ On each of the hosts you would like to use the agent on then you need to do the cd /opt/ git clone https://github.com/librenms/librenms-agent.git cd librenms-agent -cp check_mk_agent /usr/bin/check_mk_agent +``` + +Now copy the relevant check_mk_agent: + +| linux | freebsd | +| --- | --- | +| `cp check_mk_agent /usr/bin/check_mk_agent` | `cp check_mk_agent_freebsd /usr/bin/check_mk_agent` | + +```shell chmod +x /usr/bin/check_mk_agent ``` diff --git a/includes/polling/unix-agent.inc.php b/includes/polling/unix-agent.inc.php index 8f9f8582f4..43a4f499a5 100644 --- a/includes/polling/unix-agent.inc.php +++ b/includes/polling/unix-agent.inc.php @@ -97,7 +97,7 @@ if ($device['os_group'] == 'unix') { dbDelete('processes', 'device_id = ?', array($device['device_id'])); $data=array(); foreach (explode("\n", $agent_data['ps']) as $process) { - $process = preg_replace('/\((.*),([0-9]*),([0-9]*),([0-9\:]*),([0-9]*)\)\ (.*)/', '\\1|\\2|\\3|\\4|\\5|\\6', $process); + $process = preg_replace('/\((.*),([0-9]*),([0-9]*),([0-9\:\.]*),([0-9]*)\)\ (.*)/', '\\1|\\2|\\3|\\4|\\5|\\6', $process); list($user, $vsz, $rss, $cputime, $pid, $command) = explode('|', $process, 6); if (!empty($command)) { $data[]=array('device_id' => $device['device_id'], 'pid' => $pid, 'user' => $user, 'vsz' => $vsz, 'rss' => $rss, 'cputime' => $cputime, 'command' => $command);