monit: add quotes and timeout to custom program path

This commit is contained in:
Frank Brendel 2018-10-15 09:44:01 +02:00 committed by Franco Fichtner
parent 9634dc64fc
commit d7f25351b2
4 changed files with 23 additions and 2 deletions

View File

@ -35,6 +35,13 @@
<type>text</type>
<help><![CDATA[According to the service type path can be a file or a directory.]]></help>
</field>
<field>
<id>monit.service.timeout</id>
<label>Program Timeout</label>
<type>text</type>
<advanced>true</advanced>
<help><![CDATA[The timeout for custom program checks.]]></help>
</field>
<field>
<id>monit.service.address</id>
<label>Address</label>

View File

@ -214,6 +214,13 @@
<mask>/^(\/[^\/ ]*)+\/?.*$/</mask>
<ValidationMessage>Should be a valid absolute file or folder path.</ValidationMessage>
</path>
<timeout type="IntegerField">
<default>300</default>
<Required>N</Required>
<MinimumValue>1</MinimumValue>
<MaximumValue>86400</MaximumValue>
<ValidationMessage>Program Timeout needs to be an integer value between 1 and 86400</ValidationMessage>>
</timeout>
<address type="TextField">
<Required>N</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>

View File

@ -196,6 +196,7 @@ POSSIBILITY OF SUCH DAMAGE.
$('tr[id="row_monit.service.pidfile"]').addClass('hidden');
$('tr[id="row_monit.service.match"]').addClass('hidden');
$('tr[id="row_monit.service.path"]').addClass('hidden');
$('tr[id="row_monit.service.timeout"]').addClass('hidden');
$('tr[id="row_monit.service.address"]').addClass('hidden');
$('tr[id="row_monit.service.interface"]').addClass('hidden');
$('tr[id="row_monit.service.start"]').removeClass('hidden');
@ -238,6 +239,7 @@ POSSIBILITY OF SUCH DAMAGE.
break;
default:
$('tr[id="row_monit.service.path"]').removeClass('hidden');
$('tr[id="row_monit.service.timeout"]').removeClass('hidden');
}
};
$('#DialogEditService').on('shown.bs.modal', function() {ShowHideFields();});
@ -245,6 +247,7 @@ POSSIBILITY OF SUCH DAMAGE.
$('#monit\\.service\\.pidfile').on('input', function() {ShowHideFields();});
$('#monit\\.service\\.match').on('input', function() {ShowHideFields();});
$('#monit\\.service\\.path').on('input', function() {ShowHideFields();});
$('#monit\\.service\\.timeout').on('input', function() {ShowHideFields();});
$('#monit\\.service\\.address').on('input', function() {ShowHideFields();});
$('#monit\\.service\\.interface').on('changed.bs.select', function(e) {ShowHideFields();});

View File

@ -117,9 +117,13 @@ check {{ service.type }} {{ service.name }} {{ address }} {{ interface }}
{% elif service.type == 'system' %}
check {{ service.type }} {{ service.name }}
{% else %}
{% set path = "with path " ~ service.path %}
{% set path = "with path \"" ~ service.path ~ "\"" %}
{% if service.type == 'custom' %}
check program {{ service.name }} {{ path }}
{% set timeout = '' %}
{% if service.timeout|default('0') != 0 %}
{% set timeout = "timeout " ~ service.timeout ~ " seconds" %}
{% endif %}
check program {{ service.name }} {{ path }} {{ timeout }}
{% else %}
check {{ service.type }} {{ service.name }} {{ path }}
{% endif %}