mirror of
https://github.com/netbirdio/plugins.git
synced 2026-05-22 18:44:07 -07:00
sysutils/monit: bug fixing, status api response (#563)
This commit is contained in:
committed by
Franco Fichtner
parent
6488afa2dc
commit
fb77f889a1
@@ -1,5 +1,5 @@
|
||||
PLUGIN_NAME= monit
|
||||
PLUGIN_VERSION= 1.4
|
||||
PLUGIN_VERSION= 1.5
|
||||
PLUGIN_COMMENT= Proactive system monitoring
|
||||
PLUGIN_MAINTAINER= frank.brendel@eurolog.com
|
||||
PLUGIN_DEPENDS= monit
|
||||
|
||||
+22
-119
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2017 EURO-LOG AG
|
||||
* Copyright (C) 2017-2018 EURO-LOG AG
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
namespace OPNsense\Monit\Api;
|
||||
|
||||
use \OPNsense\Base\ApiControllerBase;
|
||||
use \OPNsense\Base\ApiMutableServiceControllerBase;
|
||||
use \OPNsense\Core\Backend;
|
||||
use \OPNsense\Monit\Monit;
|
||||
|
||||
@@ -38,8 +38,13 @@ use \OPNsense\Monit\Monit;
|
||||
* Class ServiceController
|
||||
* @package OPNsense\Monit
|
||||
*/
|
||||
class ServiceController extends ApiControllerBase
|
||||
class ServiceController extends ApiMutableServiceControllerBase
|
||||
{
|
||||
static protected $internalServiceClass = '\OPNsense\Monit\Monit';
|
||||
static protected $internalServiceEnabled = 'general.enabled';
|
||||
static protected $internalServiceTemplate = 'OPNsense/Monit';
|
||||
static protected $internalServiceName = 'monit';
|
||||
|
||||
/**
|
||||
* test monit configuration
|
||||
* @return array
|
||||
@@ -48,129 +53,27 @@ class ServiceController extends ApiControllerBase
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$this->sessionClose();
|
||||
}
|
||||
$result['function'] = "configtest";
|
||||
|
||||
$result['template'] = $this->callBackend('template');
|
||||
if ($result['template'] != 'OK') {
|
||||
$result['result'] = "Template error: " . $result['template'];
|
||||
return $result;
|
||||
}
|
||||
$backend = new Backend();
|
||||
|
||||
$result['result'] = $this->callBackend('configtest');
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* reload monit with new configuration
|
||||
* @return array
|
||||
*/
|
||||
public function reloadAction()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$this->sessionClose();
|
||||
}
|
||||
$result['function'] = "reload";
|
||||
|
||||
$result['template'] = $this->callBackend('template');
|
||||
if ($result['template'] != 'OK') {
|
||||
$result['result'] = "Template error: " . $result['template'];
|
||||
return $result;
|
||||
}
|
||||
|
||||
$status = $this->callBackend('status');
|
||||
if (substr($status, 0, 16) != 'monit is running') {
|
||||
$result['result'] = "Monit is not running";
|
||||
return $result;
|
||||
}
|
||||
|
||||
$result['result'] = $this->callBackend('reload');
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* get status of monit process
|
||||
* @return array
|
||||
*/
|
||||
public function statusAction()
|
||||
{
|
||||
$mdlMonit = new Monit();
|
||||
$result = array();
|
||||
$result['function'] = 'status';
|
||||
$result['result'] = 'ok';
|
||||
$response = $this->callBackend('status');
|
||||
if (strpos($response, 'not running') > 0) {
|
||||
if ($mdlMonit->general->enabled->__toString() == '1') {
|
||||
$result['status'] = 'stopped';
|
||||
} else {
|
||||
$result['status'] = 'disabled';
|
||||
$result['function'] = "configtest";
|
||||
$result['template'] = trim($backend->configdRun('template reload OPNsense/Monit'));
|
||||
if ($result['template'] != 'OK') {
|
||||
$result['result'] = "Template error: " . $result['template'];
|
||||
return $result;
|
||||
}
|
||||
} elseif (strpos($response, 'is running') > 0) {
|
||||
$result['status'] = 'running';
|
||||
} elseif ($mdlMonit->general->enabled->__toString() == '0') {
|
||||
$result['status'] = 'disabled';
|
||||
$result['result'] = trim($backend->configdRun('monit configtest'));
|
||||
return $result;
|
||||
} else {
|
||||
$result['result'] = 'failed';
|
||||
$result['status'] = 'unknown';
|
||||
$result['error'] = $status;
|
||||
return array('status' => 'failed');
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* start monit service
|
||||
* @return array
|
||||
*/
|
||||
public function startAction()
|
||||
/**
|
||||
* avoid restarting Relayd on reconfigure
|
||||
*/
|
||||
protected function reconfigureForceRestart()
|
||||
{
|
||||
$result = array("result" => "failed", "function" => "start");
|
||||
if ($this->request->isPost()) {
|
||||
$this->sessionClose();
|
||||
$result['result'] = $this->callBackend('start');
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* stop monit service
|
||||
* @return array
|
||||
*/
|
||||
public function stopAction()
|
||||
{
|
||||
$result = array("result" => "failed", "function" => "stop");
|
||||
if ($this->request->isPost()) {
|
||||
$this->sessionClose();
|
||||
$result['result'] = $this->callBackend('stop');
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* restart monit service
|
||||
* @return array
|
||||
*/
|
||||
public function restartAction()
|
||||
{
|
||||
$result = array("result" => "failed", "function" => "restart");
|
||||
if ($this->request->isPost()) {
|
||||
$this->sessionClose();
|
||||
$result['result'] = $this->callBackend('restart');
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* call backend functions
|
||||
* @param action
|
||||
* @return string
|
||||
*/
|
||||
protected function callBackend($action)
|
||||
{
|
||||
$backend = new Backend();
|
||||
if ($action == 'template') {
|
||||
return trim($backend->configdRun('template reload OPNsense/Monit'));
|
||||
} else {
|
||||
return trim($backend->configdRun('monit ' . $action));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
+146
-272
File diff suppressed because it is too large
Load Diff
+39
-37
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2017 EURO-LOG AG
|
||||
* Copyright (C) 2017-2018 EURO-LOG AG
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -44,57 +44,59 @@ class StatusController extends ApiControllerBase
|
||||
* see monit(1)
|
||||
* @return array
|
||||
*/
|
||||
public function getAction()
|
||||
public function getAction($format = 'xml')
|
||||
{
|
||||
$result = array("result" => "failed", "function" => "getStatus");
|
||||
$result = array("result" => "failed");
|
||||
|
||||
// connect monit httpd socket defined in monitrc by 'set httpd ...'
|
||||
if (file_exists("/var/run/monit.sock") && filetype("/var/run/monit.sock") == "socket") {
|
||||
// throws an exception therefore no error handling
|
||||
$socket = stream_socket_client("unix:///var/run/monit.sock", $errno, $errstr);
|
||||
$socketPath = "/var/run/monit.sock";
|
||||
|
||||
// get monit status page
|
||||
$request = "GET /_status?format=text HTTP/1.0\r\n";
|
||||
// map the requested html format from the status page to the Monit text format
|
||||
$format = $format == 'html' ? 'text' : $format;
|
||||
|
||||
// check monit httpd socket defined in monitrc by 'set httpd ...'
|
||||
if (file_exists($socketPath) && filetype($socketPath) == "socket") {
|
||||
// set curl options
|
||||
$ch = curl_init("http://127.0.0.1/_status?format=" . $format);
|
||||
curl_setopt($ch, CURLOPT_UNIX_SOCKET_PATH, $socketPath);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
// get credentials if configured
|
||||
$mdlMonit = new Monit();
|
||||
if ($mdlMonit->general->httpdUsername->__toString() != null && trim($mdlMonit->general->httpdUsername->__toString()) !== "" &&
|
||||
$mdlMonit->general->httpdPassword->__toString() != null && trim($mdlMonit->general->httpdPassword->__toString()) !== "") {
|
||||
$request .= "Authorization: Basic " . base64_encode($mdlMonit->general->httpdUsername->__toString() . ":" . $mdlMonit->general->httpdPassword->__toString()) . "\r\n";
|
||||
curl_setopt($ch, CURLOPT_USERPWD, $mdlMonit->general->httpdUsername->__toString() . ":" . $mdlMonit->general->httpdPassword->__toString());
|
||||
}
|
||||
$request .= "\r\n";
|
||||
$count = fwrite($socket, $request);
|
||||
$result['count'] = $count;
|
||||
$result['status'] = '';
|
||||
$result['orig'] = '';
|
||||
$result['httpstatus'] = preg_replace("/\r|\n/", "", fgets($socket));
|
||||
$ignorelines = 1;
|
||||
if ($result['httpstatus'] == 'HTTP/1.0 200 OK') {
|
||||
while (!feof($socket)) {
|
||||
$line = fgets($socket);
|
||||
$result['orig'] .= $line;
|
||||
|
||||
// ignore lines (mostly HTTP headers) until a line starts with 'Monit' e.g. 'Monit 5.20.0 uptime: 2d 23h 2m'
|
||||
if (substr($line, 0, 5) == 'Monit') {
|
||||
$ignorelines = 0;
|
||||
}
|
||||
if ($ignorelines) {
|
||||
continue;
|
||||
}
|
||||
$result['status'] .= $line;
|
||||
}
|
||||
// send request
|
||||
if (!$response = curl_exec($ch)) {
|
||||
$result['status'] = curl_error($ch);
|
||||
return $result;
|
||||
}
|
||||
$HTTPCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
|
||||
if ($HTTPCode != 200) {
|
||||
$result['status'] = 'Monit returns with code ' . $HTTPCode;
|
||||
} else {
|
||||
$result['result'] = "ok";
|
||||
}
|
||||
fclose($socket);
|
||||
|
||||
// response contains shell color escape codes; convert them to CSS
|
||||
$result['status'] = '<pre style="color:WhiteSmoke;background-color:DimGrey">' . $this->bashColorToCSS($result['status']) . '</pre>';
|
||||
// format the response
|
||||
if ($format == 'xml') {
|
||||
$result['status'] = simplexml_load_string($response);
|
||||
} elseif ($format === 'text') {
|
||||
$result['status'] = '<pre style="color:WhiteSmoke;background-color:DimGrey">' . $this->bashColorToCSS($response) . '</pre>';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$result['status'] = '<pre style="color:WhiteSmoke;background-color:DimGrey">
|
||||
Either the file /var/run/monit.sock does not exists or it is not a unix socket.
|
||||
$msg = "
|
||||
Either the file " . $socketPath . " does not exists or it is not a unix socket.
|
||||
Please check if the Monit service is running.
|
||||
|
||||
If you have started Monit recently, wait for StartDelay seconds and refresh this page.</pre>';
|
||||
If you have started Monit recently, wait for StartDelay seconds and refresh this page.";
|
||||
if ($format == 'xml') {
|
||||
$result['status'] = $msg;
|
||||
} elseif ($format === 'text') {
|
||||
$result['status'] = '<pre style="color:WhiteSmoke;background-color:DimGrey">' . $msg . '</pre>';
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2016 EURO-LOG AG
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OPNsense\Monit;
|
||||
|
||||
/**
|
||||
* Class ItemController
|
||||
* @package OPNsense\Monit
|
||||
*/
|
||||
class ItemController extends \OPNsense\Base\IndexController
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<model>
|
||||
<mount>//OPNsense/monit</mount>
|
||||
<version>1.0.1</version>
|
||||
<version>1.0.2</version>
|
||||
<description>Monit settings</description>
|
||||
<items>
|
||||
<general>
|
||||
@@ -26,8 +26,9 @@
|
||||
<default>127.0.0.1</default>
|
||||
<Required>Y</Required>
|
||||
<multiple>Y</multiple>
|
||||
<mask>/^((?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9]),?)+$/</mask>
|
||||
<ValidationMessage>Mail Server must be a valid IPv4 address</ValidationMessage>
|
||||
<mask>/^([0-9a-zA-Z\.,_\-:]){0,1024}$/u</mask>
|
||||
<ChangeCase>lower</ChangeCase>
|
||||
<ValidationMessage>Please specify a valid servername or IP address.</ValidationMessage>
|
||||
</mailserver>
|
||||
<port type="IntegerField">
|
||||
<Required>Y</Required>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{#
|
||||
|
||||
Copyright © 2017 by EURO-LOG AG
|
||||
Copyright © 2017-2018 by EURO-LOG AG
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
@@ -30,6 +30,15 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
$( document ).ready(function() {
|
||||
|
||||
/**
|
||||
* add button 'Import System Notification'
|
||||
* can't do it via base_dialog
|
||||
*/
|
||||
$('<button class="btn btn-primary" id="btn_ImportSystemNotification" type="button" style="margin-left: 3px;">' +
|
||||
'<b> Import System Notification </b>' +
|
||||
'<i id="frm_ImportSystemNotification_progress"></i>' +
|
||||
'</button>').insertAfter('#btn_ApplyGeneralSettings');
|
||||
|
||||
/**
|
||||
* UI functions
|
||||
*/
|
||||
|
||||
@@ -45,23 +54,37 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
$('#btn_reload').unbind('click').click(function(){
|
||||
$('#btn_reload_progress').addClass("fa fa-spinner fa-pulse");
|
||||
ajaxCall(url="/api/monit/service/reload", sendData={}, callback=function(data,status) {
|
||||
ajaxCall(url="/api/monit/service/reconfigure", sendData={}, callback=function(data,status) {
|
||||
$('#btn_reload_progress').removeClass("fa fa-spinner fa-pulse");
|
||||
$('#btn_reload').blur();
|
||||
$("#responseMsg").removeClass("hidden");
|
||||
$("#responseMsg").html(data['result']);
|
||||
ajaxCall(url="/api/monit/service/status", sendData={}, callback=function(data,status) {
|
||||
updateServiceStatusUI(data['status']);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$('#btn_ImportSystemNotification').unbind('click').click(function(){
|
||||
$('#frm_ImportSystemNotification_progress').addClass("fa fa-spinner fa-pulse");
|
||||
ajaxCall(url="/api/monit/settings/notification", sendData={}, callback=function(data,status) {
|
||||
$('#frm_ImportSystemNotification_progress').removeClass("fa fa-spinner fa-pulse");
|
||||
$('#btn_ImportSystemNotification').blur();
|
||||
ajaxCall(url="/api/monit/service/status", sendData={}, callback=function(data,status) {
|
||||
mapDataToFormUI({'frm_GeneralSettings':"/api/monit/settings/get/general/"}).done(function(){
|
||||
formatTokenizersUI();
|
||||
$('.selectpicker').selectpicker('refresh');
|
||||
ajaxCall(url="/api/monit/service/status", sendData={}, callback=function(data,status) {
|
||||
updateServiceStatusUI(data['status']);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* general settings
|
||||
*/
|
||||
// load data
|
||||
mapDataToFormUI({'frm_GeneralSettings':"/api/monit/settings/getGeneral"}).done(function(){
|
||||
mapDataToFormUI({'frm_GeneralSettings':"/api/monit/settings/get/general/"}).done(function(){
|
||||
formatTokenizersUI();
|
||||
$('.selectpicker').selectpicker('refresh');
|
||||
ajaxCall(url="/api/monit/service/status", sendData={}, callback=function(data,status) {
|
||||
@@ -93,33 +116,14 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
});
|
||||
|
||||
$('#btn_ApplyGeneralSettings').unbind('click').click(function(){
|
||||
$("#frm_GeneralSettings_progress").addClass("fa fa-spinner fa-pulse");
|
||||
$("#frm_GeneralSettings_progress").addClass("fa fa-spinner fa-pulse");
|
||||
var frm_id = 'frm_GeneralSettings';
|
||||
saveFormToEndpoint(url = "/api/monit/settings/setGeneral",formid=frm_id,callback_ok=function(){
|
||||
// on correct save, perform reconfigure. set progress animation when reloading
|
||||
$("#"+frm_id+"_progress").addClass("fa fa-spinner fa-pulse");
|
||||
|
||||
//
|
||||
ajaxCall(url="/api/monit/service/restart", sendData={}, callback=function(data,status){
|
||||
// when done, disable progress animation.
|
||||
$("#"+frm_id+"_progress").removeClass("fa fa-spinner fa-pulse");
|
||||
|
||||
if (status != "success" || data['result'] != 'OK' ) {
|
||||
// fix error handling
|
||||
BootstrapDialog.show({
|
||||
type:BootstrapDialog.TYPE_WARNING,
|
||||
title: 'Error',
|
||||
message: JSON.stringify(data),
|
||||
draggable: true
|
||||
});
|
||||
} else {
|
||||
ajaxCall(url="/api/monit/service/status", sendData={}, callback=function(data,status) {
|
||||
updateServiceStatusUI(data['status']);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
saveFormToEndpoint(url = "/api/monit/settings/set/general/",formid=frm_id,callback_ok=function(){
|
||||
ajaxCall(url="/api/monit/service/status", sendData={}, callback=function(data,status) {
|
||||
updateServiceStatusUI(data['status']);
|
||||
});
|
||||
});
|
||||
$("#"+frm_id+"_progress").removeClass("fa fa-spinner fa-pulse");
|
||||
$("#btn_ApplyGeneralSettings").blur();
|
||||
});
|
||||
|
||||
@@ -128,8 +132,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
function openAlertDialog(uuid) {
|
||||
var editDlg = "DialogEditAlert";
|
||||
var setUrl = "/api/monit/settings/setAlert/";
|
||||
var getUrl = "/api/monit/settings/getAlert/";
|
||||
var setUrl = "/api/monit/settings/set/alert/";
|
||||
var getUrl = "/api/monit/settings/get/alert/";
|
||||
var urlMap = {};
|
||||
urlMap['frm_' + editDlg] = getUrl + uuid;
|
||||
mapDataToFormUI(urlMap).done(function () {
|
||||
@@ -143,12 +147,12 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
};
|
||||
|
||||
$("#grid-alerts").UIBootgrid({
|
||||
'search':'/api/monit/settings/searchAlert',
|
||||
'get':'/api/monit/settings/getAlert/',
|
||||
'set':'/api/monit/settings/setAlert/',
|
||||
'add':'/api/monit/settings/addAlert/',
|
||||
'del':'/api/monit/settings/delAlert/',
|
||||
'toggle':'/api/monit/settings/toggleAlert/'
|
||||
'search':'/api/monit/settings/search/alert/',
|
||||
'get':'/api/monit/settings/get/alert/',
|
||||
'set':'/api/monit/settings/set/alert/',
|
||||
'add':'/api/monit/settings/set/alert/',
|
||||
'del':'/api/monit/settings/del/alert/',
|
||||
'toggle':'/api/monit/settings/toggle/alert/'
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -215,12 +219,12 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
$('#monit\\.service\\.interface').on('changed.bs.select', function(e) {ShowHideFields();});
|
||||
|
||||
$("#grid-services").UIBootgrid({
|
||||
'search':'/api/monit/settings/searchService',
|
||||
'get':'/api/monit/settings/getService/',
|
||||
'set':'/api/monit/settings/setService/',
|
||||
'add':'/api/monit/settings/addService/',
|
||||
'del':'/api/monit/settings/delService/',
|
||||
'toggle':'/api/monit/settings/toggleService/'
|
||||
'search':'/api/monit/settings/search/service/',
|
||||
'get':'/api/monit/settings/get/service/',
|
||||
'set':'/api/monit/settings/set/service/',
|
||||
'add':'/api/monit/settings/set/service/',
|
||||
'del':'/api/monit/settings/del/service/',
|
||||
'toggle':'/api/monit/settings/toggle/service/'
|
||||
});
|
||||
|
||||
|
||||
@@ -241,8 +245,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
function openTestDialog(uuid) {
|
||||
var editDlg = "TestEditAlert";
|
||||
var setUrl = "/api/monit/settings/setTest/";
|
||||
var getUrl = "/api/monit/settings/getTest/";
|
||||
var setUrl = "/api/monit/settings/set/test/";
|
||||
var getUrl = "/api/monit/settings/get/test/";
|
||||
var urlMap = {};
|
||||
urlMap['frm_' + editDlg] = getUrl + uuid;
|
||||
mapDataToFormUI(urlMap).done(function () {
|
||||
@@ -256,11 +260,11 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
};
|
||||
|
||||
$("#grid-tests").UIBootgrid({
|
||||
'search':'/api/monit/settings/searchTest',
|
||||
'get':'/api/monit/settings/getTest/',
|
||||
'set':'/api/monit/settings/setTest/',
|
||||
'add':'/api/monit/settings/addTest/',
|
||||
'del':'/api/monit/settings/delTest/'
|
||||
'search':'/api/monit/settings/search/test/',
|
||||
'get':'/api/monit/settings/get/test/',
|
||||
'set':'/api/monit/settings/set/test/',
|
||||
'add':'/api/monit/settings/set/test/',
|
||||
'del':'/api/monit/settings/del/test/'
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{#
|
||||
|
||||
Copyright © 2017 by EURO-LOG AG
|
||||
Copyright © 2017-2018 by EURO-LOG AG
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
@@ -34,7 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
textArea.innerHTML = encodedString;
|
||||
return textArea.value;
|
||||
}
|
||||
ajaxCall(url="/api/monit/status/get", sendData={}, callback=function(data,status) {
|
||||
ajaxCall(url="/api/monit/status/get/html", sendData={}, callback=function(data,status) {
|
||||
$("#status").html(decodeEntities(data['status']));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -35,15 +35,15 @@ use OPNsense\Core\Config;
|
||||
use OPNsense\Core\Shell;
|
||||
use OPNsense\Monit\Monit;
|
||||
|
||||
$mdlMonit = new OPNsense\Monit\Monit;
|
||||
$mdlMonit = new Monit();
|
||||
|
||||
$cfg = Config::getInstance();
|
||||
$cfgObj = $cfg->object();
|
||||
$shellObj = new OPNsense\Core\Shell;
|
||||
$generalNode = $mdlMonit->getNodeByReference('general');
|
||||
|
||||
// generate password for local Monit plugin user
|
||||
if (empty($cfgObj->general->httpdUsername) && empty($cfgObj->general->httpdPassword)) {
|
||||
if (empty($cfgObj->OPNsense->monit->general->httpdUsername) && empty($cfgObj->OPNsense->monit->general->httpdPassword)) {
|
||||
print "Generate Monit httpd username and password\n";
|
||||
srand();
|
||||
$generalNode->setNodes(array(
|
||||
"httpdUsername" => "root",
|
||||
|
||||
@@ -9,7 +9,7 @@ type:script
|
||||
message:stopping monit
|
||||
|
||||
[status]
|
||||
command:/usr/local/etc/rc.d/monit status || exit 0
|
||||
command:/usr/local/etc/rc.d/monit status; exit 0
|
||||
type:script_output
|
||||
message:get monit status
|
||||
|
||||
|
||||
Reference in New Issue
Block a user