File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace IXP \Models ;
4+
5+ use Illuminate \Database \Eloquent \Factories \HasFactory ;
6+ use Illuminate \Database \Eloquent \Model ;
7+
8+ class P2pDailyStats extends Model
9+ {
10+ use HasFactory;
11+ }
Original file line number Diff line number Diff line change @@ -309,10 +309,16 @@ private function getIndexKeys(): array
309309 * @throws
310310 */
311311 public function data (): array
312+ {
313+ return $ this ->dataCollect (time () - self ::PERIOD_TIME [ $ this ->graph ()->period () ], time ());
314+ }
315+
316+ public function dataCollect ($ start ,$ end ): array
312317 {
313318 $ rrd = rrd_fetch ( $ this ->file , [
314319 'AVERAGE ' ,
315- '--start ' , time () - self ::PERIOD_TIME [ $ this ->graph ()->period () ]
320+ '--start ' , $ start ,
321+ '--end ' , $ end ,
316322 ]);
317323
318324 if ( $ rrd === false || !is_array ( $ rrd ) ) {
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use Illuminate \Database \Migrations \Migration ;
4+ use Illuminate \Database \Schema \Blueprint ;
5+ use Illuminate \Support \Facades \Schema ;
6+
7+ return new class extends Migration
8+ {
9+ /**
10+ * Run the migrations.
11+ */
12+ public function up (): void
13+ {
14+ Schema::create ('p2p_daily_stats ' , function (Blueprint $ table ) {
15+ $ table ->id ();
16+ $ table ->integer ('cust_id ' );
17+ $ table ->foreign ('cust_id ' )->references ('id ' )->on ('cust ' )->onDelete ('cascade ' );
18+ $ table ->date ('day ' );
19+ $ table ->string ('peer_id ' );
20+ $ table ->integer ('ipv4_total_in ' )->nullable ();
21+ $ table ->integer ('ipv4_total_out ' )->nullable ();
22+ $ table ->integer ('ipv6_total_in ' )->nullable ();
23+ $ table ->integer ('ipv6_total_out ' )->nullable ();
24+ $ table ->integer ('ipv4_max_in ' )->nullable ();
25+ $ table ->integer ('ipv4_max_out ' )->nullable ();
26+ $ table ->integer ('ipv6_max_in ' )->nullable ();
27+ $ table ->integer ('ipv6_max_out ' )->nullable ();
28+ $ table ->timestamps ();
29+ });
30+ }
31+
32+ /**
33+ * Reverse the migrations.
34+ */
35+ public function down (): void
36+ {
37+ Schema::dropIfExists ('p2p_daily_stats ' );
38+ }
39+ };
You can’t perform that action at this time.
0 commit comments