mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 15:44:45 +02:00
Remove telemetry
This commit is contained in:
parent
883314b74a
commit
2f3d4e2819
@ -43,8 +43,7 @@ class AppSettingsCommand extends Command
|
||||
{--redis-host= : Redis host to use for connections.}
|
||||
{--redis-pass= : Password used to connect to redis.}
|
||||
{--redis-port= : Port to connect to redis over.}
|
||||
{--settings-ui= : Enable or disable the settings UI.}
|
||||
{--telemetry= : Enable or disable anonymous telemetry.}';
|
||||
{--settings-ui= : Enable or disable the settings UI.}';
|
||||
|
||||
protected array $variables = [];
|
||||
|
||||
@ -119,12 +118,6 @@ class AppSettingsCommand extends Command
|
||||
$this->variables['APP_ENVIRONMENT_ONLY'] = $this->confirm('Enable UI based settings editor?', true) ? 'false' : 'true';
|
||||
}
|
||||
|
||||
$this->output->comment('Please reference our website for more detailed information regarding telemetry data and collection.');
|
||||
$this->variables['PANEL_TELEMETRY_ENABLED'] = $this->option('telemetry') ?? $this->confirm(
|
||||
'Enable sending anonymous telemetry data?',
|
||||
config('panel.telemetry.enabled', true)
|
||||
) ? 'true' : 'false';
|
||||
|
||||
// Make sure session cookies are set as "secure" when using HTTPS
|
||||
if (str_starts_with($this->variables['APP_URL'], 'https://')) {
|
||||
$this->variables['SESSION_SECURE_COOKIE'] = 'true';
|
||||
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\VarDumper\VarDumper;
|
||||
use App\Services\Telemetry\TelemetryCollectionService;
|
||||
|
||||
class TelemetryCommand extends Command
|
||||
{
|
||||
protected $description = 'Displays all the data that would be sent to the Telemetry Service if telemetry collection is enabled.';
|
||||
|
||||
protected $signature = 'p:telemetry';
|
||||
|
||||
/**
|
||||
* TelemetryCommand constructor.
|
||||
*/
|
||||
public function __construct(private TelemetryCollectionService $telemetryCollectionService)
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle execution of command.
|
||||
*
|
||||
* @throws \App\Exceptions\Model\DataValidationException
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->output->info('Collecting telemetry data, this may take a while...');
|
||||
|
||||
VarDumper::dump($this->telemetryCollectionService->collect());
|
||||
}
|
||||
}
|
@ -2,13 +2,10 @@
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use App\Models\ActivityLog;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Database\Console\PruneCommand;
|
||||
use App\Repositories\Eloquent\SettingsRepository;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
use App\Services\Telemetry\TelemetryCollectionService;
|
||||
use App\Console\Commands\Schedule\ProcessRunnableCommand;
|
||||
use App\Console\Commands\Maintenance\PruneOrphanedBackupsCommand;
|
||||
use App\Console\Commands\Maintenance\CleanServiceBackupFilesCommand;
|
||||
@ -43,34 +40,5 @@ class Kernel extends ConsoleKernel
|
||||
if (config('activity.prune_days')) {
|
||||
$schedule->command(PruneCommand::class, ['--model' => [ActivityLog::class]])->daily();
|
||||
}
|
||||
|
||||
if (config('panel.telemetry.enabled')) {
|
||||
$this->registerTelemetry($schedule);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* I wonder what this does.
|
||||
*
|
||||
* @throws \App\Exceptions\Model\DataValidationException
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
private function registerTelemetry(Schedule $schedule): void
|
||||
{
|
||||
$settingsRepository = app()->make(SettingsRepository::class);
|
||||
|
||||
$uuid = $settingsRepository->get('app:telemetry:uuid');
|
||||
if (is_null($uuid)) {
|
||||
$uuid = Uuid::uuid4()->toString();
|
||||
$settingsRepository->set('app:telemetry:uuid', $uuid);
|
||||
}
|
||||
|
||||
// Calculate a fixed time to run the data push at, this will be the same time every day.
|
||||
$time = hexdec(str_replace('-', '', substr($uuid, 27))) % 1440;
|
||||
$hour = floor($time / 60);
|
||||
$minute = $time % 60;
|
||||
|
||||
// Run the telemetry collector.
|
||||
$schedule->call(app()->make(TelemetryCollectionService::class))->description('Collect Telemetry')->dailyAt("$hour:$minute");
|
||||
}
|
||||
}
|
||||
|
@ -1,187 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Telemetry;
|
||||
|
||||
use Exception;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Models\Egg;
|
||||
use App\Models\Nest;
|
||||
use App\Models\Node;
|
||||
use App\Models\User;
|
||||
use App\Models\Mount;
|
||||
use App\Models\Backup;
|
||||
use App\Models\Server;
|
||||
use App\Models\Location;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Models\Allocation;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Repositories\Eloquent\SettingsRepository;
|
||||
use App\Repositories\Daemon\DaemonConfigurationRepository;
|
||||
|
||||
class TelemetryCollectionService
|
||||
{
|
||||
/**
|
||||
* TelemetryCollectionService constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
private DaemonConfigurationRepository $daemonConfigurationRepository,
|
||||
private SettingsRepository $settingsRepository
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects telemetry data and sends it to the Telemetry Service.
|
||||
*/
|
||||
public function __invoke(): void
|
||||
{
|
||||
try {
|
||||
$data = $this->collect();
|
||||
} catch (Exception) {
|
||||
return;
|
||||
}
|
||||
|
||||
Http::post('https://telemetry.example.com', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects telemetry data and returns it as an array.
|
||||
*
|
||||
* @throws \App\Exceptions\Model\DataValidationException
|
||||
*/
|
||||
public function collect(): array
|
||||
{
|
||||
$uuid = $this->settingsRepository->get('app:telemetry:uuid');
|
||||
if (is_null($uuid)) {
|
||||
$uuid = Uuid::uuid4()->toString();
|
||||
$this->settingsRepository->set('app:telemetry:uuid', $uuid);
|
||||
}
|
||||
|
||||
$nodes = Node::all()->map(function ($node) {
|
||||
try {
|
||||
$info = $this->daemonConfigurationRepository->setNode($node)->getSystemInformation(2);
|
||||
} catch (Exception) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $node->uuid,
|
||||
'version' => Arr::get($info, 'version', ''),
|
||||
|
||||
'docker' => [
|
||||
'version' => Arr::get($info, 'docker.version', ''),
|
||||
|
||||
'cgroups' => [
|
||||
'driver' => Arr::get($info, 'docker.cgroups.driver', ''),
|
||||
'version' => Arr::get($info, 'docker.cgroups.version', ''),
|
||||
],
|
||||
|
||||
'containers' => [
|
||||
'total' => Arr::get($info, 'docker.containers.total', -1),
|
||||
'running' => Arr::get($info, 'docker.containers.running', -1),
|
||||
'paused' => Arr::get($info, 'docker.containers.paused', -1),
|
||||
'stopped' => Arr::get($info, 'docker.containers.stopped', -1),
|
||||
],
|
||||
|
||||
'storage' => [
|
||||
'driver' => Arr::get($info, 'docker.storage.driver', ''),
|
||||
'filesystem' => Arr::get($info, 'docker.storage.filesystem', ''),
|
||||
],
|
||||
|
||||
'runc' => [
|
||||
'version' => Arr::get($info, 'docker.runc.version', ''),
|
||||
],
|
||||
],
|
||||
|
||||
'system' => [
|
||||
'architecture' => Arr::get($info, 'system.architecture', ''),
|
||||
'cpuThreads' => Arr::get($info, 'system.cpu_threads', ''),
|
||||
'memoryBytes' => Arr::get($info, 'system.memory_bytes', ''),
|
||||
'kernelVersion' => Arr::get($info, 'system.kernel_version', ''),
|
||||
'os' => Arr::get($info, 'system.os', ''),
|
||||
'osType' => Arr::get($info, 'system.os_type', ''),
|
||||
],
|
||||
];
|
||||
})->filter(fn ($node) => !is_null($node))->toArray();
|
||||
|
||||
return [
|
||||
'id' => $uuid,
|
||||
|
||||
'panel' => [
|
||||
'version' => config('app.version'),
|
||||
'phpVersion' => phpversion(),
|
||||
|
||||
'drivers' => [
|
||||
'backup' => [
|
||||
'type' => config('backups.default'),
|
||||
],
|
||||
|
||||
'cache' => [
|
||||
'type' => config('cache.default'),
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'type' => config('database.default'),
|
||||
'version' => DB::getPdo()->getAttribute(\PDO::ATTR_SERVER_VERSION),
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
'resources' => [
|
||||
'allocations' => [
|
||||
'count' => Allocation::count(),
|
||||
'used' => Allocation::whereNotNull('server_id')->count(),
|
||||
],
|
||||
|
||||
'backups' => [
|
||||
'count' => Backup::count(),
|
||||
'bytes' => Backup::sum('bytes'),
|
||||
],
|
||||
|
||||
'eggs' => [
|
||||
'count' => Egg::count(),
|
||||
// Egg UUIDs are generated randomly on import, so there is not a consistent way to
|
||||
// determine if servers are using default eggs or not.
|
||||
// 'server_usage' => Egg::all()
|
||||
// ->flatMap(fn (Egg $egg) => [$egg->uuid => $egg->servers->count()])
|
||||
// ->filter(fn (int $count) => $count > 0)
|
||||
// ->toArray(),
|
||||
],
|
||||
|
||||
'locations' => [
|
||||
'count' => Location::count(),
|
||||
],
|
||||
|
||||
'mounts' => [
|
||||
'count' => Mount::count(),
|
||||
],
|
||||
|
||||
'nests' => [
|
||||
'count' => Nest::count(),
|
||||
// Nest UUIDs are generated randomly on import, so there is not a consistent way to
|
||||
// determine if servers are using default eggs or not.
|
||||
// 'server_usage' => Nest::all()
|
||||
// ->flatMap(fn (Nest $nest) => [$nest->uuid => $nest->eggs->sum(fn (Egg $egg) => $egg->servers->count())])
|
||||
// ->filter(fn (int $count) => $count > 0)
|
||||
// ->toArray(),
|
||||
],
|
||||
|
||||
'nodes' => [
|
||||
'count' => Node::count(),
|
||||
],
|
||||
|
||||
'servers' => [
|
||||
'count' => Server::count(),
|
||||
'suspended' => Server::where('status', Server::STATUS_SUSPENDED)->count(),
|
||||
],
|
||||
|
||||
'users' => [
|
||||
'count' => User::count(),
|
||||
'admins' => User::where('root_admin', true)->count(),
|
||||
],
|
||||
],
|
||||
|
||||
'nodes' => $nodes,
|
||||
];
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user