Completed
Push — develop ( 49f866...6f4c5d )
by Neil
03:50
created

ApiController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace App\Api\Controllers;
4
5
use DB;
6
use App\Device;
7
use App\Port;
8
9
class ApiController extends Controller
10
{
11
    /**
12
     * Get info about the install
13
     */
14
    public function get_info()
15
    {
16
        $versions              = array();
17
        $versions['git']       = `git rev-parse --short HEAD`;
18
        $versions['db_schema'] = DB::select('SELECT `version` FROM `dbSchema` LIMIT 1')[0]->version;
19
        $versions['php']       = phpversion();
20
        $versions['mysql']     = DB::select('SELECT version() AS version')[0]->version;
21
        return $versions;
22
    }
23
24
    /**
25
     * Get statistics about the install
26
     */
27
    public function get_stats()
28
    {
29
        $stats               = array();
30
        $stats['devices']    = Device::all()->count();
31
        $stats['ports']      = Port::all()->count();
32
        $stats['syslog']     = DB::select('SELECT COUNT(seq) AS `total` FROM `syslog`')[0]->total;
33
        $stats['eventlog']   = DB::select('SELECT COUNT(event_id) AS `total` FROM `eventlog`')[0]->total;
34
        $stats['apps']       = DB::select('SELECT COUNT(app_id) AS `total` FROM `applications`')[0]->total;
35
        $stats['services']   = DB::select('SELECT COUNT(service_id) AS `total` FROM `services`')[0]->total;
36
        $stats['storage']    = DB::select('SELECT COUNT(storage_id) AS `total` FROM `storage`')[0]->total;
37
        $stats['diskio']     = DB::select('SELECT COUNT(diskio_id) AS `total` FROM `ucd_diskio`')[0]->total;
38
        $stats['processors'] = DB::select('SELECT COUNT(processor_id) AS `total` FROM `processors`')[0]->total;
39
        $stats['memory']     = DB::select('SELECT COUNT(mempool_id) AS `total` FROM `mempools`')[0]->total;
40
        $stats['sensors']    = DB::select('SELECT COUNT(sensor_id) AS `total` FROM `sensors`')[0]->total;
41
        $stats['toner']      = DB::select('SELECT COUNT(toner_id) AS `total` FROM `toner`')[0]->total;
42
        $stats['hrmib']      = DB::select('SELECT COUNT(hrDevice_id) AS `total` FROM `hrDevice`')[0]->total;
43
        $stats['entmib']     = DB::select('SELECT COUNT(entPhysical_id) AS `total` FROM `entPhysical`')[0]->total;
44
        $stats['ipv4_addr']  = DB::select('SELECT COUNT(ipv4_address_id) AS `total` FROM `ipv4_addresses`')[0]->total;
45
        $stats['ipv4_net']   = DB::select('SELECT COUNT(ipv4_network_id) AS `total` FROM `ipv4_networks`')[0]->total;
46
        $stats['ipv6_addr']  = DB::select('SELECT COUNT(ipv6_address_id) AS `total` FROM `ipv6_addresses`')[0]->total;
47
        $stats['ipv6_net']   = DB::select('SELECT COUNT(ipv6_network_id) AS `total` FROM `ipv6_networks`')[0]->total;
48
        $stats['pw']         = DB::select('SELECT COUNT(pseudowire_id) AS `total` FROM `pseudowires`')[0]->total;
49
        $stats['vrf']        = DB::select('SELECT COUNT(vrf_id) AS `total` FROM `vrfs`')[0]->total;
50
        $stats['vlans']      = DB::select('SELECT COUNT(vlan_id) AS `total` FROM `vlans`')[0]->total;
51
        return $stats;
52
    }
53
54
}
55