trafficmonitor init...1
This commit is contained in:
parent
63d159c1be
commit
506890535e
@ -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) {
|
||||
// 예외 처리
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user