Skip to content

Commit

Permalink
Remove button 'Monitor Server' and its associated endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
csavelief committed Oct 10, 2024
1 parent d433474 commit a0cf5a6
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 77 deletions.
10 changes: 0 additions & 10 deletions app/Contracts/Requests/MonitorServer.php

This file was deleted.

15 changes: 0 additions & 15 deletions app/Http/Controllers/YnhServerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use App\Http\Requests\DownloadBackupRequest;
use App\Http\Requests\ExecuteShellCommandRequest;
use App\Http\Requests\InstallAppRequest;
use App\Http\Requests\MonitorServerRequest;
use App\Http\Requests\PullServerInfosRequest;
use App\Http\Requests\RemoveHostRequest;
use App\Http\Requests\RemoveUserPermissionRequest;
Expand Down Expand Up @@ -195,20 +194,6 @@ public function configure(YnhServer $server, ConfigureHostRequest $request)
return response()->json(['success' => "Your host is being configured!"]);
}

public function monitorServer(YnhServer $server, MonitorServerRequest $request)
{
if ($server->isFrozen()) {
return response()->json(['error' => "The server configuration is frozen."]);
}

$uid = Str::random(10);
$ssh = $server->sshConnection($uid, Auth::user());
if ($server->sshMonitorServer($ssh)) {
return response()->json(['success' => "Osquery has been installed!"]);
}
return response()->json(['error' => "An error occurred."]);
}

public function create(CreateHostRequest $request)
{
$orderId = $request->input('order', 0);
Expand Down
31 changes: 0 additions & 31 deletions app/Http/Requests/MonitorServerRequest.php

This file was deleted.

4 changes: 2 additions & 2 deletions app/Models/YnhServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,12 @@ public function sshTestConnection(): bool
public function sshMonitorServer(SshConnection2 $ssh): bool
{
$installScript = YnhOsquery::monitorServer($this);
$ssh->newTrace(SshTraceStateEnum::IN_PROGRESS, 'Installing Osquery...');
$ssh->newTrace(SshTraceStateEnum::IN_PROGRESS, 'Installing tools for monitoring servers...');
$filename = 'install-yunohost-' . Str::random(10);
$isOk = $ssh->upload($filename, $installScript);
$isOk = $isOk && $ssh->executeScript($filename, true);
if ($isOk) {
$ssh->newTrace(SshTraceStateEnum::DONE, 'Osquery installed.');
$ssh->newTrace(SshTraceStateEnum::DONE, 'Tools for monitoring servers installed.');
}
return $isOk;
}
Expand Down
1 change: 0 additions & 1 deletion resources/lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@
"Overview": "Aperçu",
"Settings": "Paramètres",
"Server Settings": "Paramètres serveurs",
"Monitor Host": "Surveiller l'hôte",
"Configure Host": "Configurer l'hôte",
"Monitor >": "Surveiller >",
"User's name": "Nom de l'utilisateur",
Expand Down
17 changes: 0 additions & 17 deletions resources/views/home/forms/_servers.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,6 @@ class="bi bi-clipboard" viewBox="0 0 16 16">
{{ __('Configure Host') }}
</button>
@endif
@if(Auth::user()->canManageServers() && !$server->addedWithCurl())
<button type="button" onclick="monitorHost()" class="btn btn-outline-primary mx-4">
{{ __('Monitor Host') }}
</button>
@endif
</div>
@if(Auth::user()->canManageServers())
<div>
Expand Down Expand Up @@ -208,18 +203,6 @@ function setupHost() {
}).catch(error => toaster.toastAxiosError(error));
}
function monitorHost() {
axios.post("{{ route('ynh.servers.monitor-server', $server) }}", {}).then(function (response) {
if (response.data.success) {
toaster.toastSuccess(response.data.success);
} else if (response.data.error) {
toaster.toastError(response.data.error);
} else {
console.log(response.data);
}
}).catch(error => toaster.toastAxiosError(error));
}
function removeFromInventory() {
const response = confirm(`Are you sure you want to remove {{ $server->name }} from the inventory?`);
Expand Down
1 change: 0 additions & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@
Route::post('{server}/pull-server-infos', 'YnhServerController@pullServerInfos')->name('pull-server-infos');
Route::post('{server}/test-ssh-connection', 'YnhServerController@testSshConnection')->name('test-ssh-connection');
Route::post('{server}/configure', 'YnhServerController@configure')->name('configure');
Route::post('{server}/monitor-server', 'YnhServerController@monitorServer')->name('monitor-server');
Route::post('{server}/backup', 'YnhServerController@createBackup')->name('create-backup');
Route::get('{server}/backup/{backup}', 'YnhServerController@downloadBackup')->name('download-backup');
Route::post('{server}/execute-shell-command', 'YnhServerController@executeShellCommand')->name('execute-shell-command');
Expand Down

0 comments on commit a0cf5a6

Please sign in to comment.