正在显示
2 个修改的文件
包含
68 行增加
和
0 行删除
app/Console/Commands/ServiceCount.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :ServiceCount.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2024/1/29 15:29 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Console\Commands; | ||
| 11 | + | ||
| 12 | +use App\Models\Devops\ServerConfig; | ||
| 13 | +use App\Models\Project\Project; | ||
| 14 | +use Illuminate\Console\Command; | ||
| 15 | + | ||
| 16 | +class ServiceCount extends Command | ||
| 17 | +{ | ||
| 18 | + /** | ||
| 19 | + * The name and signature of the console command. | ||
| 20 | + * | ||
| 21 | + * @var string | ||
| 22 | + */ | ||
| 23 | + protected $signature = 'service_count'; | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * The console command description. | ||
| 27 | + * | ||
| 28 | + * @var string | ||
| 29 | + */ | ||
| 30 | + protected $description = '服务器数据库使用统计'; | ||
| 31 | + | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * @remark :执行脚本 | ||
| 35 | + * @name :handle | ||
| 36 | + * @author :lyh | ||
| 37 | + * @method :post | ||
| 38 | + * @time :2024/1/29 15:31 | ||
| 39 | + */ | ||
| 40 | + public function handle(){ | ||
| 41 | + $this->serverConfigCount(); | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * @remark :域名统计统计 | ||
| 46 | + * @name :domainCount | ||
| 47 | + * @author :lyh | ||
| 48 | + * @method :post | ||
| 49 | + * @time :2024/1/29 15:33 | ||
| 50 | + */ | ||
| 51 | + public function serverConfigCount(){ | ||
| 52 | + $model = new ServerConfig(); | ||
| 53 | + $list = $model->list(); | ||
| 54 | + $projectModel = new Project(); | ||
| 55 | + foreach ($list as $k => $v){ | ||
| 56 | + if($v['type'] == 1){ | ||
| 57 | + $count = $projectModel->formatQuery(['serve_id'=>$v['id']])->count(); | ||
| 58 | + //服务器 | ||
| 59 | + }else{ | ||
| 60 | + $count = $projectModel->formatQuery(['mysql_id'=>$v['id']])->count(); | ||
| 61 | + //数据库 | ||
| 62 | + } | ||
| 63 | + $model->edit(['count'=>$count],['id'=>$v['id']]); | ||
| 64 | + } | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | +} |
| @@ -26,6 +26,7 @@ class Kernel extends ConsoleKernel | @@ -26,6 +26,7 @@ class Kernel extends ConsoleKernel | ||
| 26 | $schedule->command('rank_data_week')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据,每周一凌晨执行一次 | 26 | $schedule->command('rank_data_week')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据,每周一凌晨执行一次 |
| 27 | // $schedule->command('share_user')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次 | 27 | // $schedule->command('share_user')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次 |
| 28 | $schedule->command('count')->dailyAt('01:00')->withoutOverlapping(1); //每天凌晨1点执行一次 | 28 | $schedule->command('count')->dailyAt('01:00')->withoutOverlapping(1); //每天凌晨1点执行一次 |
| 29 | + $schedule->command('service_count')->dailyAt('01:00')->withoutOverlapping(1); //服务器使用情况,每天凌晨1点执行一次 | ||
| 29 | $schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次 | 30 | $schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次 |
| 30 | $schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次 | 31 | $schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次 |
| 31 | $schedule->command('web_traffic 3')->cron('*/12 * * * *'); // 引流 大于9个月的项目,12分钟一次 | 32 | $schedule->command('web_traffic 3')->cron('*/12 * * * *'); // 引流 大于9个月的项目,12分钟一次 |
-
请 注册 或 登录 后发表评论