app/Console/Commands/ShjSixCommand.php を削除
Some checks failed
Deploy main / deploy (push) Has been cancelled
Some checks failed
Deploy main / deploy (push) Has been cancelled
This commit is contained in:
parent
122dfa569a
commit
75e5378622
@ -1,129 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use App\Services\ShjSixService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SHJ-6 サーバ死活監視処理コマンド
|
|
||||||
*
|
|
||||||
* サーバとデバイスの死活監視を行い、異常時にはメール通知を実行する
|
|
||||||
* 定期実行またはオンデマンド実行のバックグラウンドバッチ処理
|
|
||||||
*/
|
|
||||||
class ShjSixCommand extends Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* コンソールコマンドの名前とシグネチャ
|
|
||||||
*
|
|
||||||
* パラメータなしで実行
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'shj:6';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* コンソールコマンドの説明
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'SHJ-6 サーバ死活監視処理 - サーバ・デバイス監視とアラート通知を実行';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SHJ-6サービスクラス
|
|
||||||
*
|
|
||||||
* @var ShjSixService
|
|
||||||
*/
|
|
||||||
protected $shjSixService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* コンストラクタ
|
|
||||||
*
|
|
||||||
* @param ShjSixService $shjSixService
|
|
||||||
*/
|
|
||||||
public function __construct(ShjSixService $shjSixService)
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
$this->shjSixService = $shjSixService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* コンソールコマンドを実行
|
|
||||||
*
|
|
||||||
* 処理フロー:
|
|
||||||
* 1. サーバ死活監視(DBアクセス)
|
|
||||||
* 2. デバイス管理マスタを取得する
|
|
||||||
* 3. デバイス毎のハードウェア状態を取得する
|
|
||||||
* 4. プリンタ制御プログラムログを取得する
|
|
||||||
* 5. バッチ処理ログを作成する
|
|
||||||
* ※ 異常検出時は共通A処理(メール通知)を実行
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
// 開始ログ出力
|
|
||||||
$startTime = now();
|
|
||||||
$this->info('SHJ-6 サーバ死活監視処理を開始します。');
|
|
||||||
|
|
||||||
Log::info('SHJ-6 サーバ死活監視処理開始', [
|
|
||||||
'start_time' => $startTime
|
|
||||||
]);
|
|
||||||
|
|
||||||
// SHJ-6監視処理実行
|
|
||||||
$result = $this->shjSixService->executeServerMonitoring();
|
|
||||||
|
|
||||||
// 処理結果確認
|
|
||||||
if ($result['success']) {
|
|
||||||
$endTime = now();
|
|
||||||
$this->info('SHJ-6 サーバ死活監視処理が正常に完了しました。');
|
|
||||||
$this->info("処理時間: {$startTime->diffInSeconds($endTime)}秒");
|
|
||||||
$this->info("監視結果: {$result['monitoring_summary']}");
|
|
||||||
|
|
||||||
// 警告がある場合は表示
|
|
||||||
if (!empty($result['warnings'])) {
|
|
||||||
$this->warn('警告が検出されました:');
|
|
||||||
foreach ($result['warnings'] as $warning) {
|
|
||||||
$this->warn("- {$warning}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Log::info('SHJ-6 サーバ死活監視処理完了', [
|
|
||||||
'end_time' => $endTime,
|
|
||||||
'duration_seconds' => $startTime->diffInSeconds($endTime),
|
|
||||||
'result' => $result
|
|
||||||
]);
|
|
||||||
|
|
||||||
return self::SUCCESS;
|
|
||||||
} else {
|
|
||||||
$this->error('SHJ-6 サーバ死活監視処理でエラーが発生しました: ' . $result['message']);
|
|
||||||
|
|
||||||
// エラー詳細があれば表示
|
|
||||||
if (!empty($result['error_details'])) {
|
|
||||||
$this->error('エラー詳細:');
|
|
||||||
foreach ($result['error_details'] as $detail) {
|
|
||||||
$this->error("- {$detail}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Log::error('SHJ-6 サーバ死活監視処理エラー', [
|
|
||||||
'error' => $result['message'],
|
|
||||||
'details' => $result['error_details'] ?? null
|
|
||||||
]);
|
|
||||||
|
|
||||||
return self::FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$this->error('SHJ-6 サーバ死活監視処理で予期しないエラーが発生しました: ' . $e->getMessage());
|
|
||||||
Log::error('SHJ-6 サーバ死活監視処理例外エラー', [
|
|
||||||
'exception' => $e->getMessage(),
|
|
||||||
'trace' => $e->getTraceAsString()
|
|
||||||
]);
|
|
||||||
|
|
||||||
return self::FAILURE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user