Skip to content

Commit b33cde7

Browse files
committed
feat: Introduce xymon-client plugin
Closes #4259
1 parent db59671 commit b33cde7

File tree

16 files changed

+378
-0
lines changed

16 files changed

+378
-0
lines changed
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
3+
# We need to add one "include" line in the default config file from xymon-client
4+
# to load values from our own template
5+
6+
INCLUDE="include /usr/local/etc/xymon/xymonclient.cfg"
7+
FILE=/usr/local/www/xymon/client/etc/xymonclient.cfg
8+
9+
grep -q "^${INCLUDE}$" "${FILE}" && exit 0
10+
11+
sed -i '' "/^LOGFETCHOPTS=/a \\
12+
\\
13+
# Added by OPNsense os-xymon-client plugin\\
14+
${INCLUDE}\\
15+
" "${FILE}"

net-mgmt/xymon-client/LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Kumy
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

net-mgmt/xymon-client/Makefile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
PLUGIN_NAME= xymon-client
2+
PLUGIN_VERSION= 1.0.0
3+
PLUGIN_REVISION= 1
4+
PLUGIN_DEPENDS= xymon-client
5+
PLUGIN_COMMENT= Client for the Xymon network monitor
6+
PLUGIN_MAINTAINER= [email protected]
7+
8+
.include "../../Mk/plugins.mk"

net-mgmt/xymon-client/pkg-descr

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Client data collection package for Xymon (previously known as Hobbit).
2+
3+
This gathers statistics and data from a single system and reports it to
4+
the Xymon monitor.
5+
6+
WWW: https://sourceforge.net/projects/xymon/
7+
8+
Plugin Changelog
9+
================
10+
11+
1.0.0
12+
13+
* Initial release
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
/*
4+
Copyright (c) 2024 Kumy
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
*/
24+
25+
function xymon_services()
26+
{
27+
global $config;
28+
29+
$services = [];
30+
31+
$fqdn = sprintf("%s.%s",
32+
$config['system']['hostname'],
33+
$config['system']['domain'],
34+
);
35+
36+
if (
37+
isset($config['kumy']['xymon']['enabled']) &&
38+
$config['kumy']['xymon']['enabled'] == 1
39+
) {
40+
$services[] = [
41+
'description' => gettext('Xymon client'),
42+
'configd' => [
43+
'restart' => ['xymon restart'],
44+
'start' => ['xymon start'],
45+
'stop' => ['xymon stop'],
46+
],
47+
'name' => 'xymon',
48+
'pidfile' => "/usr/local/www/xymon/client/logs/clientlaunch.$fqdn.pid"
49+
];
50+
}
51+
52+
return $services;
53+
}
54+
55+
function xymon_xmlrpc_sync()
56+
{
57+
$result = [];
58+
59+
$result[] = [
60+
'description' => gettext('Xymon client'),
61+
'section' => 'kumy.xymon',
62+
'id' => 'Xymon client',
63+
'services' => ["Xymon client"],
64+
];
65+
66+
return $result;
67+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
/*
4+
Copyright (c) 2024 Kumy
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
*/
24+
25+
namespace Kumy\Xymon\Api;
26+
27+
use OPNsense\Base\ApiMutableServiceControllerBase;
28+
use OPNsense\Core\Backend;
29+
30+
class ServiceController extends ApiMutableServiceControllerBase
31+
{
32+
protected static $internalServiceClass = '\Kumy\Xymon\Settings';
33+
protected static $internalServiceTemplate = 'Kumy\Xymon';
34+
protected static $internalServiceEnabled = 'enabled';
35+
protected static $internalServiceName = 'xymon';
36+
37+
public function reloadAction()
38+
{
39+
$status = 'failed';
40+
if ($this->request->isPost()) {
41+
$status = strtolower(trim((new Backend())->configdRun('template reload Kumy/Xymon')));
42+
}
43+
return ['status' => $status];
44+
}
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/*
4+
Copyright (c) 2024 Kumy
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
*/
24+
25+
namespace Kumy\Xymon\Api;
26+
27+
use OPNsense\Base\ApiMutableModelControllerBase;
28+
29+
class SettingsController extends ApiMutableModelControllerBase
30+
{
31+
protected static $internalModelClass = '\Kumy\Xymon\Settings';
32+
protected static $internalModelName = 'xymon';
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/*
4+
Copyright (c) 2024 Kumy
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
*/
24+
25+
namespace Kumy\Xymon;
26+
27+
class IndexController extends \OPNsense\Base\IndexController
28+
{
29+
public function indexAction()
30+
{
31+
$this->view->formSettings = $this->getForm('settings');
32+
$this->view->pick('Kumy/Xymon/index');
33+
}
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<form>
2+
<field>
3+
<id>xymon.enabled</id>
4+
<label>Enabled</label>
5+
<type>checkbox</type>
6+
</field>
7+
<field>
8+
<id>xymon.XYMSERVERS</id>
9+
<label>Server addresses</label>
10+
<type>text</type>
11+
<help>Xymon server addresses.</help>
12+
</field>
13+
</form>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<menu>
2+
<Services>
3+
<Xymon cssClass="fa fa-heartbeat fa-fw" url="/ui/xymon"></Xymon>
4+
</Services>
5+
</menu>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/*
4+
Copyright (c) 2024 Kumy
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
*/
24+
25+
namespace Kumy\Xymon;
26+
27+
use OPNsense\Base\BaseModel;
28+
29+
class Settings extends BaseModel {
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<model>
2+
<mount>//kumy/xymon</mount>
3+
<description>Xymon Settings</description>
4+
<version>0.0.0</version>
5+
<items>
6+
<enabled type="BooleanField">
7+
<default>1</default>
8+
<Required>Y</Required>
9+
</enabled>
10+
<XYMSERVERS type="TextField">
11+
<default/>
12+
<Required>N</Required>
13+
</XYMSERVERS>
14+
</items>
15+
</model>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<script type="text/javascript">
2+
$(document).ready(function() {
3+
function spinStart(selector) {
4+
$(selector).addClass("fa fa-spinner fa-pulse");
5+
}
6+
function spinStop(selector) {
7+
$(selector).removeClass("fa fa-spinner fa-pulse");
8+
}
9+
10+
mapDataToFormUI({"frm_Settings": "/api/xymon/settings/get"}).done(function(data) {
11+
updateServiceControlUI('xymon');
12+
});
13+
14+
// Handle save button
15+
$("body").on("click", ".save-button", function() {
16+
spinStart("#button-save_progress");
17+
saveFormToEndpoint("/api/xymon/settings/set", "frm_Settings", function() {
18+
ajaxCall(url="/api/xymon/service/reload", sendData={}, callback=function(data, status) {
19+
spinStop("#button-save_progress");
20+
setTimeout(function() {
21+
window.location.reload(true)
22+
}, 300);
23+
});
24+
});
25+
});
26+
27+
});
28+
</script>
29+
30+
{%- macro action_button(button, text, class="btn-default") %}
31+
<button class="btn btn-{{ class }} {{ button }}-button" type="button">
32+
<b>{{ text }}</b>
33+
<i id="button-{{ button }}_progress"></i>
34+
</button>
35+
{%- endmacro %}
36+
37+
<section class="page-content-main">
38+
<div class="content-box">
39+
{{ partial("layout_partials/base_form", ["fields": formSettings, "id": "frm_Settings"]) }}
40+
</div>
41+
</div>
42+
<br><br>
43+
44+
<div class="content-box">
45+
<div class="col-md-12">
46+
<br/>
47+
{{ action_button("save", lang._("Save"), "primary") }}
48+
<br/><br/>
49+
</div>
50+
</div>
51+
</section>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[start]
2+
command: /usr/local/www/xymon/client/runclient.sh start
3+
parameters:
4+
type:script
5+
message:xymon service start
6+
7+
[stop]
8+
command: /usr/local/www/xymon/client/runclient.sh stop
9+
parameters:
10+
type:script
11+
message:xymon service stop
12+
13+
[restart]
14+
command: /usr/local/www/xymon/client/runclient.sh restart
15+
parameters:
16+
type:script
17+
message:xymon service restart
18+
19+
[status]
20+
command: /usr/local/www/xymon/client/runclient.sh status && echo "xymon client is running" || echo "xymon client is not running"
21+
parameters:
22+
type:script_output
23+
message:xymon service status
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
xymonclient.cfg:/usr/local/etc/xymon/xymonclient.cfg
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Automatically managed config do not edit manually
2+
3+
XYMSRV="0.0.0.0"
4+
XYMSERVERS="{% if not helpers.empty('kumy.xymon.XYMSERVERS') %}{{ kumy.xymon.XYMSERVERS }}{% endif %}"

0 commit comments

Comments
 (0)