mirror of
https://github.com/opnsense/plugins.git
synced 2026-05-28 04:34:15 -04:00
sysutils/monit: version 0.2 by @fbrendel
This commit is contained in:
parent
77eb19b297
commit
197a509ac6
8 changed files with 98 additions and 17 deletions
|
|
@ -1,5 +1,5 @@
|
|||
PLUGIN_NAME= monit
|
||||
PLUGIN_VERSION= 0.1
|
||||
PLUGIN_VERSION= 0.2
|
||||
PLUGIN_COMMENT= Proactive system monitoring
|
||||
PLUGIN_MAINTAINER= frank.brendel@eurolog.com
|
||||
PLUGIN_DEPENDS= monit
|
||||
|
|
|
|||
|
|
@ -37,8 +37,7 @@
|
|||
<id>monit.alert.reminder</id>
|
||||
<label>Reminder</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[]]></help>
|
||||
<help>Send a reminder after some cycles</help>
|
||||
<help><![CDATA[Send a reminder after some cycles]]></help>
|
||||
</field>
|
||||
<field>
|
||||
<id>monit.alert.description</id>
|
||||
|
|
|
|||
|
|
@ -3,24 +3,48 @@
|
|||
<id>monit.general.enabled</id>
|
||||
<label>Enable monit</label>
|
||||
<type>checkbox</type>
|
||||
<help>Enable or disable monit.</help>
|
||||
<help><![CDATA[Enable or disable monit.]]></help>
|
||||
</field>
|
||||
<field>
|
||||
<id>monit.general.interval</id>
|
||||
<label>Polling Interval</label>
|
||||
<type>text</type>
|
||||
<help>Polling interval in seconds</help>
|
||||
<help><![CDATA[Polling interval in seconds]]></help>
|
||||
</field>
|
||||
<field>
|
||||
<id>monit.general.startdelay</id>
|
||||
<label>Start Delay</label>
|
||||
<type>text</type>
|
||||
<help>On system boot wait before Monit starts checking services.</help>
|
||||
<help><![CDATA[On system boot wait before Monit starts checking services.]]></help>
|
||||
</field>
|
||||
<field>
|
||||
<id>monit.general.mailserver</id>
|
||||
<label>Mail Server</label>
|
||||
<type>text</type>
|
||||
<help>Comma separated list of SMTP servers for alert delivery.</help>
|
||||
<help><![CDATA[Comma separated list of SMTP servers for alert delivery.]]></help>
|
||||
</field>
|
||||
<field>
|
||||
<id>monit.general.port</id>
|
||||
<label>Mail Server Port</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[The port of the mail server. Typically 465 for SSL or 25 for TLS and non secure connections.]]></help>
|
||||
</field>
|
||||
<field>
|
||||
<id>monit.general.username</id>
|
||||
<label>Username</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[The username for authentication.]]></help>
|
||||
</field>
|
||||
<field>
|
||||
<id>monit.general.password</id>
|
||||
<label>Password</label>
|
||||
<type>password</type>
|
||||
<help><![CDATA[The password for authentication.]]></help>
|
||||
</field>
|
||||
<field>
|
||||
<id>monit.general.ssl</id>
|
||||
<label>Secure Connection</label>
|
||||
<type>checkbox</type>
|
||||
<help><![CDATA[Enable encryption.]]></help>
|
||||
</field>
|
||||
</form>
|
||||
|
|
|
|||
|
|
@ -23,12 +23,28 @@
|
|||
<ValidationMessage>Start Delay needs to be an integer value between 0 and 86400</ValidationMessage>
|
||||
</startdelay>
|
||||
<mailserver type="TextField">
|
||||
<default>127.0.0.1</default>
|
||||
<Required>Y</Required>
|
||||
<default>127.0.0.1</default>
|
||||
<Required>Y</Required>
|
||||
<mask>/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-4]|2[0-5][0-9]|[01]?[0-9][0-9]?)$/</mask>
|
||||
<mask>/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-4]|2[0-5][0-9]|[01]?[0-9][0-9]?)$/</mask>
|
||||
<ValidationMessage>Mail Server must be a valid IPv4 address</ValidationMessage>
|
||||
</mailserver>
|
||||
<port type="IntegerField">
|
||||
<Required>Y</Required>
|
||||
<default>25</default>
|
||||
<MinimumValue>0</MinimumValue>
|
||||
<MaximumValue>65535</MaximumValue>
|
||||
<ValidationMessage>Port needs to be an integer value between 0 and 65535</ValidationMessage>
|
||||
</port>
|
||||
<username type="TextField">
|
||||
<Required>N</Required>
|
||||
</username>
|
||||
<password type="TextField">
|
||||
<Required>N</Required>
|
||||
</password>
|
||||
<ssl type="BooleanField">
|
||||
<default>0</default>
|
||||
<Required>Y</Required>
|
||||
</ssl>
|
||||
</general>
|
||||
<alert type="ArrayField">
|
||||
<enabled type="BooleanField">
|
||||
|
|
|
|||
|
|
@ -72,9 +72,11 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
$("#frm_GeneralSettings_progress").addClass("fa fa-spinner fa-pulse");
|
||||
saveFormToEndpoint(
|
||||
url = "/api/monit/settings/setGeneral",
|
||||
formid = "frm_GeneralSettings"
|
||||
formid = "frm_GeneralSettings",
|
||||
callback_ok=function(){
|
||||
$("#frm_GeneralSettings_progress").removeClass("fa fa-spinner fa-pulse");
|
||||
}
|
||||
);
|
||||
$("#frm_GeneralSettings_progress").removeClass("fa fa-spinner fa-pulse");
|
||||
$("#btn_ApplyGeneralSettings").blur();
|
||||
});
|
||||
|
||||
|
|
@ -311,8 +313,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
</div>
|
||||
<div class="col-md-12">
|
||||
<hr/>
|
||||
<button class="btn btn-primary" id="btn_configtest" type="button"><b>{{ lang._('Test Configuration') }}</b><i id="configtest_progress" class=""></i></button>
|
||||
<button class="btn btn-primary" id="btn_reload" type="button"><b>{{ lang._('Reload Configuration') }}</b><i id="reload_progress" class=""></i></button>
|
||||
<button class="btn btn-primary" id="btn_configtest" type="button"><b>{{ lang._('Test Configuration') }}</b><i id="btn_configtest_progress" class=""></i></button>
|
||||
<button class="btn btn-primary" id="btn_reload" type="button"><b>{{ lang._('Reload Configuration') }}</b><i id="btn_reload_progress" class=""></i></button>
|
||||
<br/>
|
||||
<br/>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -58,6 +58,30 @@ $LoadAvg15 = $nCPU[0];
|
|||
$hostName = $cfgObj->system->hostname;
|
||||
$domainName = $cfgObj->system->domain;
|
||||
|
||||
// inherit SMTP settings from System->Settings->Notifications
|
||||
$generalSettings = array();
|
||||
if (!empty($cfgObj->notifications->smtp->ipaddress)) {
|
||||
$generalSettings['mailserver'] = $cfgObj->notifications->smtp->ipaddress;
|
||||
}
|
||||
if (!empty($cfgObj->notifications->smtp->port)) {
|
||||
$generalSettings['port'] = $cfgObj->notifications->smtp->port;
|
||||
}
|
||||
if (!empty($cfgObj->notifications->smtp->username)) {
|
||||
$generalSettings['username'] = $cfgObj->notifications->smtp->username;
|
||||
}
|
||||
if (!empty($cfgObj->notifications->smtp->password)) {
|
||||
$generalSettings['password'] = $cfgObj->notifications->smtp->password;
|
||||
}
|
||||
if ((!empty($cfgObj->notifications->smtp->tls) && $cfgObj->notifications->smtp->tls == 1) ||
|
||||
(!empty($cfgObj->notifications->smtp->ssl) && $cfgObj->notifications->smtp->ssl == 1)) {
|
||||
$generalSettings['ssl'] = 1;
|
||||
}
|
||||
|
||||
$alertSettings = array();
|
||||
if (!empty($cfgObj->notifications->smtp->notifyemailaddress)) {
|
||||
$alertSettings['recipient'] = $cfgObj->notifications->smtp->notifyemailaddress;
|
||||
}
|
||||
|
||||
// define some tests
|
||||
$defaultTests = array(
|
||||
array("name" => "Ping", "condition" => "failed ping", "action" => "alert"),
|
||||
|
|
@ -106,8 +130,13 @@ foreach ($defaultTests as $defaultTest) {
|
|||
$systemService['tests'] = substr($systemService['tests'], 0, -1);
|
||||
$rootFsService['tests'] = substr($rootFsService['tests'], 0, -1);
|
||||
|
||||
// add an alert with default settings
|
||||
$mdlMonit->alert->Add();
|
||||
// set general properties
|
||||
$generalNode = $mdlMonit->getNodeByReference('general');
|
||||
$generalNode->setNodes($generalSettings);
|
||||
|
||||
// add an alert with (almost) default settings
|
||||
$alertNode = $mdlMonit->alert->Add();
|
||||
$alertNode->setNodes($alertSettings);
|
||||
|
||||
// add system service
|
||||
$serviceNode = $mdlMonit->service->Add();
|
||||
|
|
|
|||
|
|
@ -9,7 +9,17 @@ set daemon {{ OPNsense.monit.general.interval }} with start delay {{ OPNsense.mo
|
|||
|
||||
set logfile syslog facility log_daemon
|
||||
|
||||
set mailserver {{ OPNsense.monit.general.mailserver }}
|
||||
{% if helpers.exists('OPNsense.monit.general.mailserver') %}
|
||||
{% set port = "port " ~ OPNsense.monit.general.port if OPNsense.monit.general.port|default('') != '' %}
|
||||
{% set username = '' %}
|
||||
{% set password = '' %}
|
||||
{% if helpers.exists('OPNsense.monit.general.username') and helpers.exists('OPNsense.monit.general.password') %}
|
||||
{% set username = "username " ~ OPNsense.monit.general.username %}
|
||||
{% set password = "password " ~ OPNsense.monit.general.password %}
|
||||
{% endif %}
|
||||
{% set ssl = 'using ssl' if OPNsense.monit.general.ssl|default('0') == '1' %}
|
||||
set mailserver {{ OPNsense.monit.general.mailserver }} {{ port }} {{ username }} {{ password }} {{ ssl }}
|
||||
{% endif %}
|
||||
|
||||
{% if helpers.exists('OPNsense.monit.alert') %}
|
||||
{% for alert in helpers.toList('OPNsense.monit.alert') %}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
# DO NOT EDIT THIS FILE -- OPNsense auto-generated file
|
||||
{% if helpers.exists('OPNsense.monit.general.enabled') and OPNsense.monit.general.enabled|default("0") == "1" %}
|
||||
monit_enable="YES"
|
||||
monit_opnsense_bootup_run="/usr/local/opnsense/scripts/OPNsense/Monit/setup.sh"
|
||||
{% else %}
|
||||
monit_enable="NO"
|
||||
{% endif %}
|
||||
|
|
|
|||
Loading…
Reference in a new issue