From ea01dc1af3b47d109bf4d4f4752128cc7500c6fe Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 3 Aug 2015 20:26:13 +0200 Subject: checkmk- code style fixes, fix URL again to use last working stable release --- config/checkmk-agent/checkmk.xml | 91 ++++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 46 deletions(-) diff --git a/config/checkmk-agent/checkmk.xml b/config/checkmk-agent/checkmk.xml index 3709dce1..3f150bf1 100644 --- a/config/checkmk-agent/checkmk.xml +++ b/config/checkmk-agent/checkmk.xml @@ -1,61 +1,60 @@ - - + + - - + - - Describe your package here - Describe your package requirements here - Currently there are no FAQ items provided. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ +/* ====================================================================================== */ + ]]> + checkmk - 0.1.1 - Check_mk Agent + 0.1.4 + check_mk Agent /usr/local/pkg/checkmk.inc /usr/local/pkg/ - 0755 https://packages.pfsense.org/packages/config/checkmk-agent/checkmk.inc /usr/local/pkg/ - 0755 https://packages.pfsense.org/packages/config/checkmk-agent/checkmk_sync.xml - Check_mk Agent + check_mk Agent checkmk
Diagnostics
/pkg_edit.php?xml=checkmk.xml @@ -71,21 +70,23 @@ /pkg_edit.php?xml=checkmk_sync.xml - listtopic temp - Check_mk agent configuration + check_mk Agent Configuration Enable check_mk Agent checkmkenable checkbox 60 - - Reference:
https://github.com/sileht/check_mk/tree/master/doc

- Latest check_mk version: fetch -o /usr/local/bin/check_mk_agent 'http://git.mathias-kettner.de/git/?p=check_mk.git;a=blob_plain;f=agents/check_mk_agent.freebsd;hb=HEAD']]>
+ + + For reference, see project documentation at GitHub. + ]]> +
@@ -106,8 +107,6 @@ checkmk_install(); - - checkmk_validate_input($_POST, $input_errors); -- cgit v1.2.3 From 0e42221734800f05486d7452b23d346302aaeaa7 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 3 Aug 2015 20:38:10 +0200 Subject: checkmk- code style fixes, fix URL again to use last working stable release --- config/checkmk-agent/checkmk_sync.xml | 169 +++++++++++++++++++--------------- 1 file changed, 97 insertions(+), 72 deletions(-) diff --git a/config/checkmk-agent/checkmk_sync.xml b/config/checkmk-agent/checkmk_sync.xml index 6603991d..ed99470a 100644 --- a/config/checkmk-agent/checkmk_sync.xml +++ b/config/checkmk-agent/checkmk_sync.xml @@ -2,47 +2,48 @@ - - + - - Describe your package here - Describe your package requirements here - Currently there are no FAQ items provided. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ +/* ====================================================================================== */ + ]]> + checkmksync - 1.1 - Check_mk Agent: Sync + 0.1.4 + check_mk Agent: Sync /usr/local/pkg/checkmk.inc @@ -59,8 +60,8 @@ listtopic temp - Enable checkmk configuration sync - + Enable check_mk configuration sync + Sync Option synconchanges @@ -69,24 +70,48 @@ auto - - - + + + - Sync timeout + Sync Timeout synctimeout Select sync max wait time select 250 - - - - - + + + + + @@ -94,36 +119,36 @@ none rowhelper - - IP Address - ipaddress - IP Address of remote server - input - 20 - - - - User Name - username - user name of remote server - input - 20 - - - Password - password - Password for remote server. - password - 20 - - + + IP Address + ipaddress + IP Address of remote server + input + 20 + + + + Username + username + Username on remote server + input + 20 + + + Password + password + Password for remote server + password + 20 + +
- checkmk_sync_on_changes(); + checkmk_sync_on_changes(); - + unset($_POST['temp']); - \ No newline at end of file + -- cgit v1.2.3 From 5d5fe57725ea31c799b6683a755eea568d2f1705 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 3 Aug 2015 20:38:52 +0200 Subject: checkmk_sync.xml - fix filename in header --- config/checkmk-agent/checkmk_sync.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/checkmk-agent/checkmk_sync.xml b/config/checkmk-agent/checkmk_sync.xml index ed99470a..1165152c 100644 --- a/config/checkmk-agent/checkmk_sync.xml +++ b/config/checkmk-agent/checkmk_sync.xml @@ -7,7 +7,7 @@ /* $Id$ */ /* ====================================================================================== */ /* - checkmk.xml + checkmk_sync.xml part of pfSense (https://www.pfSense.org/) Copyright (C) 2013 Marcello Coutinho Copyright (C) 2015 ESF, LLC -- cgit v1.2.3 From 4e5f4398d932289721a588901e1bb9533166de4c Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 3 Aug 2015 21:56:47 +0200 Subject: checkmk- code style fixes, fix URL again to use last working stable release --- config/checkmk-agent/checkmk.inc | 378 ++++++++++++++++++++------------------- 1 file changed, 195 insertions(+), 183 deletions(-) diff --git a/config/checkmk-agent/checkmk.inc b/config/checkmk-agent/checkmk.inc index def0ae2d..67d82e6b 100644 --- a/config/checkmk-agent/checkmk.inc +++ b/config/checkmk-agent/checkmk.inc @@ -1,302 +1,314 @@ 0) + } + if ($mk_config['checkmkenable']=="on") { + $mk_rc_conf_file .= 'inetd_enable="YES"' . "\n"; + $mk_rc_conf_file .= 'inetd_flags="-wW"' . "\n"; + } + + file_put_contents(ETC_RC_CONF, $mk_rc_conf_file, LOCK_EX); + if ($inet_daemons_count > 0) { mwexec("/etc/rc.d/inetd restart"); - else + } else { mwexec("/etc/rc.d/inetd stop"); + } - //Write config if any file from filesystem was loaded - if ($update_conf > 0) + /* Write config if any file from filesystem was loaded. */ + if ($update_conf > 0) { write_config(); - - // mount filesystem readonly + } + conf_mount_ro(); - + checkmk_sync_on_changes(); } function checkmk_validate_input($post, &$input_errors) { foreach ($post as $key => $value) { - if (empty($value)) + if (empty($value)) { continue; - if (substr($key, 0, 3) == "port" && !preg_match("/^\d+$/", $value)) + } + if (substr($key, 0, 3) == "port" && !preg_match("/^\d+$/", $value)) { $input_errors[] = "{$value} is no a valid port number"; - if (substr($key, 0, 11) == "description" && !preg_match("@^[a-zA-Z0-9 _/.-]+$@", $value)) + } + if (substr($key, 0, 11) == "description" && !preg_match("@^[a-zA-Z0-9 _/.-]+$@", $value)) { $input_errors[] = "Do not use special characters on description"; - if (substr($key, 0, 8) == "fullfile" && !preg_match("@^[a-zA-Z0-9_/.-]+$@", $value)) + } + if (substr($key, 0, 8) == "fullfile" && !preg_match("@^[a-zA-Z0-9_/.-]+$@", $value)) { $input_errors[] = "Do not use special characters on filename"; - + } + } } -############################################## -/* Uses XMLRPC to synchronize the changes to a remote node */ + +/* Uses XMLRPC to synchronize the changes to a remote node. */ function checkmk_sync_on_changes() { global $config, $g; - if (is_array($config['installedpackages']['checkmksync']['config'])){ - $checkmk_sync=$config['installedpackages']['checkmksync']['config'][0]; + if (is_array($config['installedpackages']['checkmksync']['config'])) { + $checkmk_sync = $config['installedpackages']['checkmksync']['config'][0]; $synconchanges = $checkmk_sync['synconchanges']; $synctimeout = $checkmk_sync['synctimeout']; - switch ($synconchanges){ + switch ($synconchanges) { case "manual": - if (is_array($checkmk_sync[row])){ - $rs=$checkmksync[row]; - } - else{ - log_error("[Check_mk-agent] xmlrpc sync is enabled but there is no hosts to push on squid config."); + if (is_array($checkmk_sync[row])) { + $rs = $checkmksync[row]; + } else { + log_error("[check_mk-agent] XMLRPC sync is enabled but there is no hosts to push on squid config."); return; - } + } break; case "auto": - if (is_array($config['installedpackages']['carpsettings']) && is_array($config['installedpackages']['carpsettings']['config'])){ - $system_carp=$config['installedpackages']['carpsettings']['config'][0]; - $rs[0]['ipaddress']=$system_carp['synchronizetoip']; - $rs[0]['username']=$system_carp['username']; - $rs[0]['password']=$system_carp['password']; - } - else{ - log_error("[Check_mk-agent] xmlrpc sync is enabled but there is no system backup hosts to push squid config."); - return; - } - break; + if (is_array($config['installedpackages']['carpsettings']) && is_array($config['installedpackages']['carpsettings']['config'])) { + $system_carp = $config['installedpackages']['carpsettings']['config'][0]; + $rs[0]['ipaddress'] = $system_carp['synchronizetoip']; + $rs[0]['username'] = $system_carp['username']; + $rs[0]['password'] = $system_carp['password']; + } else { + log_error("[check_mk-agent] XMLRPC sync is enabled but there is no system backup hosts to push squid config."); + return; + } + break; default: return; break; } - if (is_array($rs)){ - log_error("[Check_mk-agent] xmlrpc sync is starting."); - foreach($rs as $sh){ + if (is_array($rs)) { + log_error("[check_mk-agent] XMLRPC sync is starting."); + foreach ($rs as $sh) { $sync_to_ip = $sh['ipaddress']; $password = $sh['password']; - if($sh['username']) + if ($sh['username']) { $username = $sh['username']; - else + } else { $username = 'admin'; - if($password && $sync_to_ip) + } + if ($password && $sync_to_ip) { checkmk_do_xmlrpc_sync($sync_to_ip, $username, $password,$synctimeout); } - log_error("[Check_mk-agent] xmlrpc sync is ending."); + log_error("[check_mk-agent] XMLRPC sync is ending."); } - } + } + } } -############################################## -/* Do the actual XMLRPC sync */ + +/* Do the actual XMLRPC sync. */ function checkmk_do_xmlrpc_sync($sync_to_ip, $username, $password,$synctimeout) { global $config, $g; - if(!$username) + if (!$username) { return; - - if(!$password) + } + + if (!$password) { return; + } - if(!$sync_to_ip) + if (!$sync_to_ip) { return; + } $xmlrpc_sync_neighbor = $sync_to_ip; - if($config['system']['webgui']['protocol'] != "") { + if($config['system']['webgui']['protocol'] != "") { $synchronizetoip = $config['system']['webgui']['protocol']; $synchronizetoip .= "://"; - } - $port = $config['system']['webgui']['port']; - /* if port is empty lets rely on the protocol selection */ - if($port == "") { - if($config['system']['webgui']['protocol'] == "http") + } + $port = $config['system']['webgui']['port']; + /* If port is empty, let's rely on the protocol selection. */ + if ($port == "") { + if($config['system']['webgui']['protocol'] == "http") { $port = "80"; - else + } else { $port = "443"; - } + } + } $synchronizetoip .= $sync_to_ip; - /* xml will hold the sections to sync */ + /* xml will hold the sections to sync. */ $xml = array(); $xml['checkmk'] = $config['installedpackages']['checkmk']; - - /* assemble xmlrpc payload */ + + /* Assemble XMLRPC payload. */ $params = array( XML_RPC_encode($password), XML_RPC_encode($xml) ); - /* set a few variables needed for sync code borrowed from filter.inc */ + /* Set a few variables needed for sync code; borrowed from filter.inc. */ $url = $synchronizetoip; - log_error("[Check_mk-agent] Beginning checkmk XMLRPC sync to {$url}:{$port}."); + log_error("[check_mk-agent] Beginning checkmk XMLRPC sync to {$url}:{$port}."); $method = 'pfsense.merge_installedpackages_section_xmlrpc'; $msg = new XML_RPC_Message($method, $params); $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port); $cli->setCredentials($username, $password); - if($g['debug']) + if ($g['debug']) { $cli->setDebug(1); - /* send our XMLRPC message and timeout after 250 seconds */ + } + /* Send our XMLRPC message and timeout after 250 seconds. */ $resp = $cli->send($msg, $synctimeout); - if(!$resp) { - $error = "[Check_mk-agent] A communications error occurred while attempting checkmk XMLRPC sync with {$url}:{$port}."; + if (!$resp) { + $error = "[check_mk-agent] A communications error occurred while attempting checkmk XMLRPC sync with {$url}:{$port}."; log_error($error); file_notice("sync_settings", $error, "checkmk Settings Sync", ""); - } elseif($resp->faultCode()) { + } elseif ($resp->faultCode()) { $cli->setDebug(1); $resp = $cli->send($msg, $synctimeout); - $error = "[Check_mk-agent] An error code was received while attempting checkmk XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString(); + $error = "[check_mk-agent] An error code was received while attempting checkmk XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString(); log_error($error); file_notice("sync_settings", $error, "checkmk Settings Sync", ""); } else { - log_error("[Check_mk-agent] XMLRPC sync successfully completed with {$url}:{$port}."); + log_error("[check_mk-agent] XMLRPC sync successfully completed with {$url}:{$port}."); } - - /* tell checkmk to reload our settings on the destionation sync host. */ + + /* Tell check_mk to reload our settings on the destination sync host. */ $method = 'pfsense.exec_php'; - $execcmd = "require_once('/usr/local/pkg/checkmk.inc');\n"; + $execcmd = "require_once('/usr/local/pkg/checkmk.inc');\n"; $execcmd .= "sync_package_checkmk();"; - /* assemble xmlrpc payload */ + /* Assemble XMLRPC payload. */ $params = array( XML_RPC_encode($password), XML_RPC_encode($execcmd) ); - - log_error("[Check_mk-agent] XMLRPC reload data {$url}:{$port}."); + + log_error("[check_mk-agent] XMLRPC reload data {$url}:{$port}."); $msg = new XML_RPC_Message($method, $params); $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port); $cli->setCredentials($username, $password); $resp = $cli->send($msg, $synctimeout); - if(!$resp) { - $error = "[Check_mk-agent] A communications error occurred while attempting checkmk XMLRPC sync with {$url}:{$port} (pfsense.exec_php)."; + if (!$resp) { + $error = "[check_mk-agent] A communications error occurred while attempting checkmk XMLRPC sync with {$url}:{$port} (pfsense.exec_php)."; log_error($error); file_notice("sync_settings", $error, "checkmk Settings Sync", ""); - } elseif($resp->faultCode()) { + } elseif ($resp->faultCode()) { $cli->setDebug(1); $resp = $cli->send($msg, $synctimeout); - $error = "[Check_mk-agent] An error code was received while attempting checkmk XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString(); + $error = "[check_mk-agent] An error code was received while attempting checkmk XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString(); log_error($error); file_notice("sync_settings", $error, "checkmk Settings Sync", ""); } else { - log_error("[Check_mk-agent] XMLRPC reload data success with {$url}:{$port} (pfsense.exec_php)."); + log_error("[check_mk-agent] XMLRPC reload data success with {$url}:{$port} (pfsense.exec_php)."); } - } ?> -- cgit v1.2.3 From ae59944f4385d4da69e99caa30454217f2725f84 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 3 Aug 2015 21:58:28 +0200 Subject: checkmk.xml - additional whitespace fixes --- config/checkmk-agent/checkmk.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/checkmk-agent/checkmk.xml b/config/checkmk-agent/checkmk.xml index 3f150bf1..786a7977 100644 --- a/config/checkmk-agent/checkmk.xml +++ b/config/checkmk-agent/checkmk.xml @@ -102,7 +102,7 @@ Enter hosts (comma separated) that can communicate with this agent. input 60 - + checkmk_install(); @@ -112,7 +112,7 @@ sync_package_checkmk(); - + sync_package_checkmk(); -- cgit v1.2.3 From 18e3299a933778a2eb993829f366e5970568233f Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 3 Aug 2015 21:59:39 +0200 Subject: Bump checkmk package version --- pkg_config.10.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg_config.10.xml b/pkg_config.10.xml index e6ec5223..8505dcae 100644 --- a/pkg_config.10.xml +++ b/pkg_config.10.xml @@ -1296,7 +1296,7 @@ sysutils/muse https://packages.pfsense.org/packages/config/checkmk-agent/checkmk.xml - 0.1.3 + 0.1.4 RC1 2.2 marcellocoutinho@gmail.com -- cgit v1.2.3