|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Api\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use App\Models\Device; |
|
6
|
|
|
use App\Models\General\Eventlog; |
|
7
|
|
|
use App\Models\General\IPv4; |
|
8
|
|
|
use App\Models\General\Syslog; |
|
9
|
|
|
use App\Models\Port; |
|
10
|
|
|
use DB; |
|
11
|
|
|
|
|
12
|
|
|
class ApiController extends Controller |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* Get info about the install |
|
16
|
|
|
*/ |
|
17
|
1 |
|
public function getInfo() |
|
18
|
|
|
{ |
|
19
|
1 |
|
$git = `git rev-parse --short HEAD`; |
|
20
|
|
|
|
|
21
|
1 |
|
$schema = DB::table('dbSchema')->select('version')->pluck('version')->last(); |
|
22
|
1 |
|
$migration = DB::table('migrations')->select('migration')->pluck('migration')->last(); |
|
23
|
1 |
|
$db_schema = $schema ?: $migration; |
|
24
|
|
|
|
|
25
|
1 |
|
$php = phpversion(); |
|
26
|
|
|
|
|
27
|
1 |
|
$db_driver = strtoupper(DB::connection()->getDriverName()); |
|
28
|
|
|
|
|
29
|
1 |
|
if ($db_driver == 'SQLITE') { |
|
30
|
|
|
$db_version = collect(DB::select('SELECT sqlite_version() AS version'))->pluck('version')->first(); |
|
31
|
|
|
} else { |
|
32
|
1 |
|
$db_version = collect(DB::select('SELECT version() AS version'))->pluck('version')->first(); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
1 |
|
return compact('git', 'db_schema', 'php', 'db_driver', 'db_version'); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Get statistics about the install |
|
40
|
|
|
*/ |
|
41
|
1 |
|
public function getStats() |
|
42
|
|
|
{ |
|
43
|
|
|
$stats = [ |
|
44
|
1 |
|
'devices' => Device::count(), |
|
45
|
1 |
|
'ports' => Port::count(), |
|
46
|
1 |
|
'syslog' => Syslog::count(), |
|
47
|
1 |
|
'eventlog' => Eventlog::count(), |
|
48
|
1 |
|
'apps' => DB::table('applications')->count(), |
|
49
|
1 |
|
'services' => DB::table('services')->count(), |
|
50
|
1 |
|
'storage' => DB::table('storage')->count(), |
|
51
|
1 |
|
'diskio' => DB::table('ucd_diskio')->count(), |
|
52
|
1 |
|
'processors' => DB::table('processors')->count(), |
|
53
|
1 |
|
'memory' => DB::table('mempools')->count(), |
|
54
|
1 |
|
'sensors' => DB::table('sensors')->count(), |
|
55
|
1 |
|
'toner' => DB::table('toner')->count(), |
|
56
|
1 |
|
'hrmib' => DB::table('hrDevice')->count(), |
|
57
|
1 |
|
'entmib' => DB::table('entPhysical')->count(), |
|
58
|
1 |
|
'ipv4_addr' => IPv4::count(), |
|
59
|
1 |
|
'ipv4_net' => DB::table('ipv4_networks')->count(), |
|
60
|
1 |
|
'ipv6_addr' => DB::table('ipv6_addresses')->count(), |
|
61
|
1 |
|
'ipv6_net' => DB::table('ipv6_networks')->count(), |
|
62
|
1 |
|
'pw' => DB::table('pseudowires')->count(), |
|
63
|
1 |
|
'vrf' => DB::table('vrfs')->count(), |
|
64
|
1 |
|
'vlans' => DB::table('vlans')->count(), |
|
65
|
|
|
]; |
|
66
|
|
|
|
|
67
|
1 |
|
return $stats; |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|