改进 统计
This commit is contained in:
parent
ee8cf47cb2
commit
11ec3c3a07
@ -59,6 +59,12 @@ public function handle()
|
||||
$this->info('正在获取主机数量...');
|
||||
$hosts = Host::count();
|
||||
|
||||
$this->info('正在获取激活的主机数量...');
|
||||
$active_hosts = Host::active()->count();
|
||||
|
||||
$this->info('正在获取暂停的主机数量...');
|
||||
$suspended_hosts = Host::whereNull('suspended_at')->count();
|
||||
|
||||
$this->info('正在获取工单数量...');
|
||||
$workOrders = WorkOrder::count();
|
||||
|
||||
@ -74,9 +80,13 @@ public function handle()
|
||||
|
||||
$this->warn('用户数量: ' . $users);
|
||||
$this->warn('主机数量: ' . $hosts);
|
||||
$this->warn('正常的主机数量: ' . $active_hosts);
|
||||
$this->warn('暂停的主机数量: ' . $suspended_hosts);
|
||||
$this->warn('服务器数量: ' . $servers);
|
||||
$this->warn('工单数量: ' . $workOrders);
|
||||
$this->warn('工单回复数量: ' . $replies);
|
||||
$this->warn('今年的交易记录: ' . $transactions . ' 条');
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
120
app/Console/Commands/Status.php
Normal file
120
app/Console/Commands/Status.php
Normal file
@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Host;
|
||||
use App\Models\User;
|
||||
use DB;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Redis;
|
||||
|
||||
class Status extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'status';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '获取 莱云 系统状态';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
$this->warn('===== 运行环境 =====');
|
||||
|
||||
|
||||
// php version
|
||||
$this->info('PHP 版本: ' . PHP_VERSION);
|
||||
|
||||
// get mysql version
|
||||
$mysql_version = DB::select('select version() as version')[0]->version;
|
||||
|
||||
|
||||
$this->warn('MySQL 版本: ' . $mysql_version);
|
||||
|
||||
|
||||
$redis_info = Redis::info();
|
||||
|
||||
// get redis version
|
||||
$redis_version = $redis_info['redis_version'];
|
||||
$this->warn('Redis 版本: ' . $redis_version);
|
||||
|
||||
// 是否是 Redis 集群
|
||||
$redis_cluster = $redis_info['cluster_enabled'];
|
||||
|
||||
if ($redis_cluster == 1) {
|
||||
$this->warn('Redis 集群: 是');
|
||||
} else {
|
||||
$this->warn('Redis 集群: 否');
|
||||
}
|
||||
|
||||
// redis 操作系统
|
||||
$redis_os = $redis_info['os'];
|
||||
$this->warn('Redis 操作系统: ' . $redis_os);
|
||||
|
||||
// redis process id
|
||||
$redis_pid = $redis_info['process_id'];
|
||||
$this->warn('Redis 进程 ID: ' . $redis_pid);
|
||||
|
||||
|
||||
// redis used memory
|
||||
$redis_used_memory = $redis_info['used_memory_human'];
|
||||
|
||||
$this->info('Redis 内存: ' . $redis_used_memory);
|
||||
|
||||
// redis memory peak
|
||||
$redis_memory_peak = $redis_info['used_memory_peak_human'];
|
||||
$this->info('Redis 内存峰值: ' . $redis_memory_peak);
|
||||
|
||||
// redis memory lua
|
||||
$redis_memory_lua = $redis_info['used_memory_lua_human'];
|
||||
$this->info('Redis Lua 内存: ' . $redis_memory_lua);
|
||||
|
||||
// redis 连接
|
||||
$redis_connected_clients = $redis_info['connected_clients'];
|
||||
$this->info('Redis 连接数量: ' . $redis_connected_clients);
|
||||
|
||||
// redis 命中率
|
||||
$redis_keyspace_hits = $redis_info['keyspace_hits'];
|
||||
$redis_keyspace_misses = $redis_info['keyspace_misses'];
|
||||
$redis_keyspace_hit_rate = round($redis_keyspace_hits / ($redis_keyspace_hits + $redis_keyspace_misses) * 100, 2);
|
||||
$this->info('Redis 命中率: ' . $redis_keyspace_hit_rate . '%');
|
||||
|
||||
// redis 总连接数
|
||||
$redis_total_connections_received = $redis_info['total_connections_received'];
|
||||
$this->info('Redis 总连接数: ' . $redis_total_connections_received);
|
||||
|
||||
// redis total commands
|
||||
$redis_total_commands_processed = $redis_info['total_commands_processed'];
|
||||
$this->info('Redis 总命令数: ' . $redis_total_commands_processed);
|
||||
|
||||
|
||||
|
||||
$this->warn('===== 莱云 统计 =====');
|
||||
$this->warn('要获取 莱云 统计信息,请运行 count 命令。');
|
||||
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@
|
||||
use App\Console\Commands\Count;
|
||||
use App\Console\Commands\GetUser;
|
||||
use App\Console\Commands\ReduceBalance;
|
||||
use App\Console\Commands\Status;
|
||||
use App\Console\Commands\SuspendUserAllHosts;
|
||||
use App\Console\Commands\UnbanUser;
|
||||
use App\Console\Commands\UserAddBalance;
|
||||
@ -37,6 +38,7 @@ class Kernel extends ConsoleKernel
|
||||
GetUser::class,
|
||||
ReduceBalance::class,
|
||||
Count::class,
|
||||
Status::class,
|
||||
Commands\System\Down::class,
|
||||
Commands\System\Up::class,
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user