-
Notifications
You must be signed in to change notification settings - Fork 658
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #4259
- Loading branch information
Showing
16 changed files
with
378 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/sh | ||
|
||
# We need to add one "include" line in the default config file from xymon-client | ||
# to load values from our own template | ||
|
||
INCLUDE="include /usr/local/etc/xymon/xymonclient.cfg" | ||
FILE=/usr/local/www/xymon/client/etc/xymonclient.cfg | ||
|
||
grep -q "^${INCLUDE}$" "${FILE}" && exit 0 | ||
|
||
sed -i '' "/^LOGFETCHOPTS=/a \\ | ||
\\ | ||
# Added by OPNsense os-xymon-client plugin\\ | ||
${INCLUDE}\\ | ||
" "${FILE}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Kumy | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
PLUGIN_NAME= xymon-client | ||
PLUGIN_VERSION= 1.0.0 | ||
PLUGIN_REVISION= 1 | ||
PLUGIN_DEPENDS= xymon-client | ||
PLUGIN_COMMENT= Client for the Xymon network monitor | ||
PLUGIN_MAINTAINER= github+opnsense-xymon-client@kumy.net | ||
|
||
.include "../../Mk/plugins.mk" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Client data collection package for Xymon (previously known as Hobbit). | ||
|
||
This gathers statistics and data from a single system and reports it to | ||
the Xymon monitor. | ||
|
||
WWW: https://sourceforge.net/projects/xymon/ | ||
|
||
Plugin Changelog | ||
================ | ||
|
||
1.0.0 | ||
|
||
* Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
/* | ||
Copyright (c) 2024 Kumy | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
*/ | ||
|
||
function xymon_services() | ||
{ | ||
global $config; | ||
|
||
$services = []; | ||
|
||
$fqdn = sprintf('%s.%s', | ||
$config['system']['hostname'], | ||
$config['system']['domain'], | ||
); | ||
|
||
if ( | ||
isset($config['kumy']['xymon']['enabled']) && | ||
$config['kumy']['xymon']['enabled'] == 1 | ||
) { | ||
$services[] = [ | ||
'description' => gettext('Xymon client'), | ||
'configd' => [ | ||
'restart' => ['xymon restart'], | ||
'start' => ['xymon start'], | ||
'stop' => ['xymon stop'], | ||
], | ||
'name' => 'xymon', | ||
'pidfile' => "/usr/local/www/xymon/client/logs/clientlaunch.$fqdn.pid" | ||
]; | ||
} | ||
|
||
return $services; | ||
} | ||
|
||
function xymon_xmlrpc_sync() | ||
{ | ||
$result = []; | ||
|
||
$result[] = [ | ||
'description' => gettext('Xymon client'), | ||
'section' => 'kumy.xymon', | ||
'id' => 'Xymon client', | ||
'services' => ['Xymon client'], | ||
]; | ||
|
||
return $result; | ||
} |
45 changes: 45 additions & 0 deletions
45
net-mgmt/xymon-client/src/opnsense/mvc/app/controllers/Kumy/Xymon/Api/ServiceController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
/* | ||
Copyright (c) 2024 Kumy | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
*/ | ||
|
||
namespace Kumy\Xymon\Api; | ||
|
||
use OPNsense\Base\ApiMutableServiceControllerBase; | ||
use OPNsense\Core\Backend; | ||
|
||
class ServiceController extends ApiMutableServiceControllerBase | ||
{ | ||
protected static $internalServiceClass = '\Kumy\Xymon\Settings'; | ||
protected static $internalServiceTemplate = 'Kumy\Xymon'; | ||
protected static $internalServiceEnabled = 'enabled'; | ||
protected static $internalServiceName = 'xymon'; | ||
|
||
public function reloadAction() | ||
{ | ||
$status = 'failed'; | ||
if ($this->request->isPost()) { | ||
$status = strtolower(trim((new Backend())->configdRun('template reload Kumy/Xymon'))); | ||
} | ||
return ['status' => $status]; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
net-mgmt/xymon-client/src/opnsense/mvc/app/controllers/Kumy/Xymon/Api/SettingsController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
/* | ||
Copyright (c) 2024 Kumy | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
*/ | ||
|
||
namespace Kumy\Xymon\Api; | ||
|
||
use OPNsense\Base\ApiMutableModelControllerBase; | ||
|
||
class SettingsController extends ApiMutableModelControllerBase | ||
{ | ||
protected static $internalModelClass = '\Kumy\Xymon\Settings'; | ||
protected static $internalModelName = 'xymon'; | ||
} |
34 changes: 34 additions & 0 deletions
34
net-mgmt/xymon-client/src/opnsense/mvc/app/controllers/Kumy/Xymon/IndexController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/* | ||
Copyright (c) 2024 Kumy | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
*/ | ||
|
||
namespace Kumy\Xymon; | ||
|
||
class IndexController extends \OPNsense\Base\IndexController | ||
{ | ||
public function indexAction() | ||
{ | ||
$this->view->formSettings = $this->getForm('settings'); | ||
$this->view->pick('Kumy/Xymon/index'); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
net-mgmt/xymon-client/src/opnsense/mvc/app/controllers/Kumy/Xymon/forms/settings.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<form> | ||
<field> | ||
<id>xymon.enabled</id> | ||
<label>Enabled</label> | ||
<type>checkbox</type> | ||
</field> | ||
<field> | ||
<id>xymon.XYMSERVERS</id> | ||
<label>Server addresses</label> | ||
<type>text</type> | ||
<help>Xymon server addresses.</help> | ||
</field> | ||
</form> |
5 changes: 5 additions & 0 deletions
5
net-mgmt/xymon-client/src/opnsense/mvc/app/models/Kumy/Xymon/Menu/Menu.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<menu> | ||
<Services> | ||
<Xymon cssClass="fa fa-heartbeat fa-fw" url="/ui/xymon"></Xymon> | ||
</Services> | ||
</menu> |
30 changes: 30 additions & 0 deletions
30
net-mgmt/xymon-client/src/opnsense/mvc/app/models/Kumy/Xymon/Settings.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
/* | ||
Copyright (c) 2024 Kumy | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
*/ | ||
|
||
namespace Kumy\Xymon; | ||
|
||
use OPNsense\Base\BaseModel; | ||
|
||
class Settings extends BaseModel { | ||
} |
15 changes: 15 additions & 0 deletions
15
net-mgmt/xymon-client/src/opnsense/mvc/app/models/Kumy/Xymon/Settings.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<model> | ||
<mount>//kumy/xymon</mount> | ||
<description>Xymon Settings</description> | ||
<version>0.0.0</version> | ||
<items> | ||
<enabled type="BooleanField"> | ||
<default>1</default> | ||
<Required>Y</Required> | ||
</enabled> | ||
<XYMSERVERS type="TextField"> | ||
<default/> | ||
<Required>N</Required> | ||
</XYMSERVERS> | ||
</items> | ||
</model> |
51 changes: 51 additions & 0 deletions
51
net-mgmt/xymon-client/src/opnsense/mvc/app/views/Kumy/Xymon/index.volt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<script type="text/javascript"> | ||
$(document).ready(function() { | ||
function spinStart(selector) { | ||
$(selector).addClass("fa fa-spinner fa-pulse"); | ||
} | ||
function spinStop(selector) { | ||
$(selector).removeClass("fa fa-spinner fa-pulse"); | ||
} | ||
|
||
mapDataToFormUI({"frm_Settings": "/api/xymon/settings/get"}).done(function(data) { | ||
updateServiceControlUI('xymon'); | ||
}); | ||
|
||
// Handle save button | ||
$("body").on("click", ".save-button", function() { | ||
spinStart("#button-save_progress"); | ||
saveFormToEndpoint("/api/xymon/settings/set", "frm_Settings", function() { | ||
ajaxCall(url="/api/xymon/service/reload", sendData={}, callback=function(data, status) { | ||
spinStop("#button-save_progress"); | ||
setTimeout(function() { | ||
window.location.reload(true) | ||
}, 300); | ||
}); | ||
}); | ||
}); | ||
|
||
}); | ||
</script> | ||
|
||
{%- macro action_button(button, text, class="btn-default") %} | ||
<button class="btn btn-{{ class }} {{ button }}-button" type="button"> | ||
<b>{{ text }}</b> | ||
<i id="button-{{ button }}_progress"></i> | ||
</button> | ||
{%- endmacro %} | ||
|
||
<section class="page-content-main"> | ||
<div class="content-box"> | ||
{{ partial("layout_partials/base_form", ["fields": formSettings, "id": "frm_Settings"]) }} | ||
</div> | ||
</div> | ||
<br><br> | ||
|
||
<div class="content-box"> | ||
<div class="col-md-12"> | ||
<br/> | ||
{{ action_button("save", lang._("Save"), "primary") }} | ||
<br/><br/> | ||
</div> | ||
</div> | ||
</section> |
23 changes: 23 additions & 0 deletions
23
net-mgmt/xymon-client/src/opnsense/service/conf/actions.d/actions_xymon.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[start] | ||
command: /usr/local/www/xymon/client/runclient.sh start | ||
parameters: | ||
type:script | ||
message:xymon service start | ||
|
||
[stop] | ||
command: /usr/local/www/xymon/client/runclient.sh stop | ||
parameters: | ||
type:script | ||
message:xymon service stop | ||
|
||
[restart] | ||
command: /usr/local/www/xymon/client/runclient.sh restart | ||
parameters: | ||
type:script | ||
message:xymon service restart | ||
|
||
[status] | ||
command: /usr/local/www/xymon/client/runclient.sh status && echo "xymon client is running" || echo "xymon client is not running" | ||
parameters: | ||
type:script_output | ||
message:xymon service status |
1 change: 1 addition & 0 deletions
1
net-mgmt/xymon-client/src/opnsense/service/templates/Kumy/Xymon/+TARGETS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
xymonclient.cfg:/usr/local/etc/xymon/xymonclient.cfg |
4 changes: 4 additions & 0 deletions
4
net-mgmt/xymon-client/src/opnsense/service/templates/Kumy/Xymon/xymonclient.cfg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Automatically managed config do not edit manually | ||
|
||
XYMSRV="0.0.0.0" | ||
XYMSERVERS="{% if not helpers.empty('kumy.xymon.XYMSERVERS') %}{{ kumy.xymon.XYMSERVERS }}{% endif %}" |