trafficmonitor init...1

This commit is contained in:
choi.jh 2025-11-13 14:10:00 +09:00
parent 63d159c1be
commit 506890535e
2 changed files with 10 additions and 4 deletions

View File

@ -98,11 +98,12 @@ class TrafficController extends AdminController
try {
// 모델 로드 및 데이터 조회
$collectorService = service('collectorservice');
$data = $collectorService->getAggregated($entity, $startDate, $endDate);
$aggregateDatas = $collectorService->getAggregateDatas($entity, $startDate, $endDate);
// 데이터를 JSON 형식으로 반환
return $this->response->setJSON([
'message' => sprintf("[%s~%s] %s 트랙픽차트 ", $startDate, $endDate, $entity->getCustomTitle("%s[%s]", ['client', 'server_ip'])),
'status' => 'success',
'data' => $data // 이 데이터는 이제 사용자가 제공한 필드 구조를 가집니다.
'data' => $aggregateDatas // 이 데이터는 이제 사용자가 제공한 필드 구조를 가집니다.
]);
} catch (\Exception $e) {
// 예외 처리

View File

@ -77,8 +77,13 @@ class CollectorService extends CommonService
parent::setSearchWord($word);
}
//Chart용
public function getAggregated(TrafficEntity $trafficEntity, string $startDate, string $endDate) {
d
public function getAggregateDatas(TrafficEntity $trafficEntity, string $startDate, string $endDate): array
{
$entities = [];
foreach ($this->getEntities(["trafficinfo_uid" => $trafficEntity->getPK(), "created_at >=" => $startDate, "created_at <=" => $endDate]) as $entity) {
$entities[] = ['in_kbits' => $entity->getIn(), 'out_kbits' => $entity->getOut(), 'created_at' => $entity->getCreatedAt()];
}
return $entities;
}
//SNMP연결
private function getSNMPOctets(TrafficEntity $trafficEntity, string $oid): ?int