mirror of
https://github.com/netbirdio/plugins.git
synced 2026-05-22 18:44:07 -07:00
sysutils/monit: service control improvements and tweaks; closes #85
This commit is contained in:
+16
-9
@@ -94,17 +94,24 @@ class ServiceController extends ApiControllerBase
|
||||
*/
|
||||
public function statusAction()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$this->sessionClose();
|
||||
}
|
||||
$result['function'] = "status";
|
||||
$result['result'] = "failed";
|
||||
$result['status'] = 'stopped';
|
||||
$status = $this->callBackend('status');
|
||||
if (substr($status, 0, 16) == 'monit is running') {
|
||||
$result['result'] = "ok";
|
||||
$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';
|
||||
}
|
||||
} elseif (strpos($response, 'is running') > 0) {
|
||||
$result['status'] = 'running';
|
||||
} elseif ($mdlMonit->general->enabled->__toString() == '0') {
|
||||
$result['status'] = 'disabled';
|
||||
} else {
|
||||
$result['result'] = 'failed';
|
||||
$result['status'] = 'unknown';
|
||||
$result['error'] = $status;
|
||||
}
|
||||
return $result;
|
||||
|
||||
+1
-1
@@ -358,7 +358,7 @@ class SettingsController extends ApiControllerBase
|
||||
$svcMonit = new ServiceController();
|
||||
$result = $svcMonit->configtestAction();
|
||||
if ($nodeType == 'general' && $node->enabled->__toString() == 0) {
|
||||
$result['stop'] = $svcMonit->stopAction();
|
||||
$result['stop'] = $svcMonit->stopAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,11 +70,33 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
});
|
||||
$('#btn_ApplyGeneralSettings').unbind('click').click(function(){
|
||||
$("#frm_GeneralSettings_progress").addClass("fa fa-spinner fa-pulse");
|
||||
saveFormToEndpoint(
|
||||
url = "/api/monit/settings/setGeneral",
|
||||
formid = "frm_GeneralSettings",
|
||||
callback_ok=function(){
|
||||
$("#frm_GeneralSettings_progress").removeClass("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 {
|
||||
// request service status after successful save and update status box (wait a few seconds before update)
|
||||
setTimeout(function(){
|
||||
ajaxCall(url="/api/monit/service/status", sendData={}, callback=function(data,status) {
|
||||
updateServiceStatusUI(data['status']);
|
||||
});
|
||||
},3000);
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
$("#btn_ApplyGeneralSettings").blur();
|
||||
|
||||
@@ -61,25 +61,25 @@ $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;
|
||||
$generalSettings['mailserver'] = $cfgObj->notifications->smtp->ipaddress;
|
||||
}
|
||||
if (!empty($cfgObj->notifications->smtp->port)) {
|
||||
$generalSettings['port'] = $cfgObj->notifications->smtp->port;
|
||||
$generalSettings['port'] = $cfgObj->notifications->smtp->port;
|
||||
}
|
||||
if (!empty($cfgObj->notifications->smtp->username)) {
|
||||
$generalSettings['username'] = $cfgObj->notifications->smtp->username;
|
||||
$generalSettings['username'] = $cfgObj->notifications->smtp->username;
|
||||
}
|
||||
if (!empty($cfgObj->notifications->smtp->password)) {
|
||||
$generalSettings['password'] = $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;
|
||||
(!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;
|
||||
$alertSettings['recipient'] = $cfgObj->notifications->smtp->notifyemailaddress;
|
||||
}
|
||||
|
||||
// define some tests
|
||||
|
||||
Reference in New Issue
Block a user