diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 8d3f0ae..b21531e 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; +use Carbon\Carbon; use Illuminate\Http\Request; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Auth; @@ -242,4 +243,51 @@ class HomeController extends Controller return view('setup') ->with('o',$o); } + + public function status() + { + $date = Carbon::now()->yesterday()->endOfday(); + + // Nodes with uncollected mail + $e = Address::select(['addresses.id',DB::raw('count(*) as e'),DB::raw('0 as n'),DB::raw('0 as f')]) + ->join('echomail_seenby',['echomail_seenby.address_id'=>'addresses.id']) + ->join('echomails',['echomails.id'=>'echomail_seenby.echomail_id']) + ->whereNotNull('export_at') + ->whereNull('sent_at') + ->where('datetime','<',$date) + ->groupBy('addresses.id'); + + $n = Address::select(['addresses.id',DB::raw('0 as e'),DB::raw('count(*) as n'),DB::raw('0 as f')]) + ->join('netmails',['netmails.tftn_id'=>'addresses.id']) + ->whereNull('sent_at') + ->where('datetime','<',$date) + ->groupBy('addresses.id'); + + $f = Address::select(['addresses.id',DB::raw('0 as e'),DB::raw('0 as n'),DB::raw('count(*) as f')]) + ->join('file_seenby',['file_seenby.address_id'=>'addresses.id']) + ->join('files',['files.id'=>'file_seenby.file_id']) + ->whereNotNull('export_at') + ->whereNull('sent_at') + ->where('datetime','<',$date) + ->groupBy('addresses.id'); + + $r = Address::select([ + 'a.id', + 'system_id', + 'zone_id', + 'host_id', + 'node_id', + DB::raw('sum(a.e) as e'), + DB::raw('sum(a.n) as n'), + DB::raw('sum(a.f) as f') + ]) + ->from($e->union($n)->union($f),'a') + ->join('addresses',['addresses.id'=>'a.id']) + ->groupBy('system_id','a.id','zone_id','host_id','node_id') + ->with(['system','zone.domain']); + + return view('status') + ->with('date',$date) + ->with('uncollected',$r->get()); + } } \ No newline at end of file diff --git a/resources/views/layouts/partials/topmenu.blade.php b/resources/views/layouts/partials/topmenu.blade.php index e70ca66..b1c56cc 100644 --- a/resources/views/layouts/partials/topmenu.blade.php +++ b/resources/views/layouts/partials/topmenu.blade.php @@ -6,6 +6,7 @@
  • About
  • FTN List
  • BBS List
  • +
  • Status
  • {{--
  • Help
  • --}} diff --git a/resources/views/status.blade.php b/resources/views/status.blade.php new file mode 100644 index 0000000..75a8e0a --- /dev/null +++ b/resources/views/status.blade.php @@ -0,0 +1,88 @@ +@extends('layouts.app') +@section('htmlheader_title') + Stats +@endsection + +@section('content') +
    +
    +

    Network Status

    +
    +
    + +
    +
    +

    Nodes with uncollected mail as at {{ $date }}:

    + + + + + + + + + + + + + + + + + + @foreach($uncollected as $o) + + + + + + + + + + + + @endforeach + +
    NetworkSystemAddressEchomailsNetmailsFilesLast SessionPoll ModeAuto Hold
    {{ $o->zone->domain->name }}{{ $o->system->name }}{{ $o->ftn4d }}{{ number_format($o->e ?? 0) }}{{ number_format($o->n ?? 0) }}{{ number_format($o->f ?? 0) }}{{ $o->system->last_session?->format('Y-m-d H:i') }}{{ is_null($o->system->pollmode) ? 'HOLD' : ($o->system->pollmode ? 'CRASH' : 'DAILY') }}{{ $o->system->autohold ? 'YES' : 'NO' }}
    +
    +
    +@endsection + +@section('page-css') + @css('datatables') +@append +@section('page-scripts') + @js('datatables') + + +@append \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index b7e3978..0bc7e03 100644 --- a/routes/web.php +++ b/routes/web.php @@ -45,6 +45,7 @@ Route::view('domain/list','domain.list'); Route::get('domain/view/{o}',[DomainController::class,'view']) ->where('o','[0-9]+'); Route::match(['get','post'],'pkt',[HomeController::class,'pkt']); +Route::get('/status',[HomeController::class,'status']); Route::view('system/list','system.list'); Route::get('system/view/{o}',[SystemController::class,'view']) ->where('o','[0-9]+');