From 2925d8ce817f91d84c0c72f528ebcd28ee58dd7e Mon Sep 17 00:00:00 2001 From: Karsten Nerdinger Date: Mon, 11 Apr 2016 15:37:09 +0200 Subject: [PATCH 1/4] Use python2 in Python script shebang lines This fixes issue #3336. --- poller-service.py | 2 +- poller-wrapper.py | 2 +- scripts/agent-local/nginx | 2 +- scripts/mysql-stats | 2 +- scripts/nginx-stats | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/poller-service.py b/poller-service.py index b545e4bcd..69a436176 100755 --- a/poller-service.py +++ b/poller-service.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python2 """ poller-service A service to wrap SNMP polling. It will poll up to $threads devices at a time, and will not re-poll devices that have been polled within the last $poll_frequency seconds. It will prioritize devices based diff --git a/poller-wrapper.py b/poller-wrapper.py index 43e91f76a..1fa00b461 100755 --- a/poller-wrapper.py +++ b/poller-wrapper.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python2 """ poller-wrapper A small tool which wraps around the poller and tries to guide the polling process with a more modern approach with a diff --git a/scripts/agent-local/nginx b/scripts/agent-local/nginx index d6319f1b2..b0a6a5092 100755 --- a/scripts/agent-local/nginx +++ b/scripts/agent-local/nginx @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 import urllib2 import re diff --git a/scripts/mysql-stats b/scripts/mysql-stats index 1a215832e..d191bdbbc 100644 --- a/scripts/mysql-stats +++ b/scripts/mysql-stats @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 import warnings import re warnings.filterwarnings(action="ignore", message='the sets module is deprecated') diff --git a/scripts/nginx-stats b/scripts/nginx-stats index a3c14fa52..1cedca5ba 100644 --- a/scripts/nginx-stats +++ b/scripts/nginx-stats @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 import urllib2 import re From c99fee75df563bacab8731bc839ef119fc191661 Mon Sep 17 00:00:00 2001 From: Paul Gear Date: Thu, 21 Apr 2016 08:08:17 +1000 Subject: [PATCH 2/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 e1b973c74..9891c2441 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 3/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 652d9a792..767e179bf 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 8f9f8582f..43a4f499a 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); From 42ffb6bf22b5572db79a9761347dc5eb602b4bd6 Mon Sep 17 00:00:00 2001 From: Vikram Adukia Date: Thu, 21 Apr 2016 14:24:53 -0700 Subject: [PATCH 4/4] only output the mib if there is a match --- includes/discovery/sensors/power/extreme.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/discovery/sensors/power/extreme.inc.php b/includes/discovery/sensors/power/extreme.inc.php index cb1e34c6f..f15be4cd1 100644 --- a/includes/discovery/sensors/power/extreme.inc.php +++ b/includes/discovery/sensors/power/extreme.inc.php @@ -1,8 +1,8 @@