Skip to content

Commit

Permalink
cs fixed
Browse files Browse the repository at this point in the history
Signed-off-by: akhil <akhil.potukuchi@gmail.com>
  • Loading branch information
akhil1508 committed Jan 12, 2021
1 parent 547a277 commit 3c9c9b6
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 31 deletions.
24 changes: 12 additions & 12 deletions lib/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ public function __construct($appName,
SessionStatistics $sessionStatistics) {
parent::__construct($appName, $request);

$this->os = $os;
$this->systemStatistics = $systemStatistics;
$this->storageStatistics = $storageStatistics;
$this->phpStatistics = $phpStatistics;
$this->os = $os;
$this->systemStatistics = $systemStatistics;
$this->storageStatistics = $storageStatistics;
$this->phpStatistics = $phpStatistics;
$this->databaseStatistics = $databaseStatistics;
$this->shareStatistics = $shareStatistics;
$this->sessionStatistics = $sessionStatistics;
$this->shareStatistics = $shareStatistics;
$this->sessionStatistics = $sessionStatistics;
}

/**
Expand All @@ -96,14 +96,14 @@ public function __construct($appName,
public function info() {
return new DataResponse([
'nextcloud' => [
'system' => $this->systemStatistics->getSystemStatistics(),
'system' => $this->systemStatistics->getSystemStatistics(),
'storage' => $this->storageStatistics->getStorageStatistics(),
'shares' => $this->shareStatistics->getShareStatistics()
'shares' => $this->shareStatistics->getShareStatistics()
],
'server' => [
'webserver' => $this->getWebserver(),
'php' => $this->phpStatistics->getPhpStatistics(),
'database' => $this->databaseStatistics->getDatabaseStatistics()
'php' => $this->phpStatistics->getPhpStatistics(),
'database' => $this->databaseStatistics->getDatabaseStatistics()
],
'activeUsers' => $this->sessionStatistics->getSessionStatistics()
]);
Expand All @@ -113,8 +113,8 @@ public function info() {
* @return DataResponse
*/
public function BasicData(): DataResponse {
$servertime = $this->os->getTime();
$uptime = $this->formatUptime($this->os->getUptime());
$servertime = $this->os->getTime();
$uptime = $this->formatUptime($this->os->getUptime());

return new DataResponse([
'servertime' => $servertime,
Expand Down
12 changes: 6 additions & 6 deletions lib/OperatingSystems/DefaultOs.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,14 @@ public function getNetworkInterfaces() {
$result = [];

foreach ($interfaces as $interface) {
$iface = [];
$iface = [];
$iface['interface'] = basename($interface);
$iface['mac'] = shell_exec('ip addr show dev ' . $iface['interface'] . ' | grep "link/ether " | cut -d \' \' -f 6 | cut -f 1 -d \'/\'');
$iface['ipv4'] = shell_exec('ip addr show dev ' . $iface['interface'] . ' | grep "inet " | cut -d \' \' -f 6 | cut -f 1 -d \'/\'');
$iface['ipv6'] = shell_exec('ip -o -6 addr show ' . $iface['interface'] . ' | sed -e \'s/^.*inet6 \([^ ]\+\).*/\1/\'');
$iface['mac'] = shell_exec('ip addr show dev ' . $iface['interface'] . ' | grep "link/ether " | cut -d \' \' -f 6 | cut -f 1 -d \'/\'');
$iface['ipv4'] = shell_exec('ip addr show dev ' . $iface['interface'] . ' | grep "inet " | cut -d \' \' -f 6 | cut -f 1 -d \'/\'');
$iface['ipv6'] = shell_exec('ip -o -6 addr show ' . $iface['interface'] . ' | sed -e \'s/^.*inet6 \([^ ]\+\).*/\1/\'');
if ($iface['interface'] !== 'lo') {
$iface['status'] = shell_exec('cat /sys/class/net/' . $iface['interface'] . '/operstate');
$iface['speed'] = shell_exec('cat /sys/class/net/' . $iface['interface'] . '/speed');
$iface['speed'] = shell_exec('cat /sys/class/net/' . $iface['interface'] . '/speed');
if ($iface['speed'] !== '') {
$iface['speed'] = $iface['speed'] . 'Mbps';
} else {
Expand All @@ -169,7 +169,7 @@ public function getNetworkInterfaces() {
}
} else {
$iface['status'] = 'up';
$iface['speed'] = 'unknown';
$iface['speed'] = 'unknown';
$iface['duplex'] = '';
}
$result[] = $iface;
Expand Down
12 changes: 6 additions & 6 deletions lib/OperatingSystems/FreeBSD.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ public function getNetworkInterfaces() {
preg_match_all("/^(?<=(?!\t)).*(?=:)/m", $ifconfig, $interfaces);

foreach ($interfaces[0] as $interface) {
$iface = [];
$iface = [];
$iface['interface'] = $interface;
$intface = $this->executeCommand('/sbin/ifconfig ' . $iface['interface']);
$intface = $this->executeCommand('/sbin/ifconfig ' . $iface['interface']);
preg_match_all("/(?<=inet ).\S*/m", $intface, $ipv4);
preg_match_all("/(?<=inet6 )((.*(?=%))|(.\S*))/m", $intface, $ipv6);
$iface['ipv4'] = implode(' ', $ipv4[0]);
$iface['ipv6'] = implode(' ', $ipv6[0]);
$iface['ipv4'] = implode(' ', $ipv4[0]);
$iface['ipv6'] = implode(' ', $ipv6[0]);

if ($iface['interface'] !== 'lo0') {
preg_match_all("/(?<=ether ).*/m", $intface, $mac);
Expand All @@ -168,7 +168,7 @@ public function getNetworkInterfaces() {
preg_match("/(?<=\<).*(?=-)/m", $intface, $duplex);

$iface['mac'] = implode(' ', $mac[0]);
$iface['speed'] = $speed[0];
$iface['speed'] = $speed[0];

if (isset($status[0])) {
$iface['status'] = $status[0];
Expand All @@ -194,7 +194,7 @@ public function getNetworkInterfaces() {
}
} else {
$iface['status'] = 'active';
$iface['speed'] = 'unknown';
$iface['speed'] = 'unknown';
$iface['duplex'] = '';
}
$result[] = $iface;
Expand Down
2 changes: 1 addition & 1 deletion lib/SystemStatistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ protected function getMemoryUsage() {
$return = array_map('intval', $return);
if ($return === array_filter($return, 'is_int')) {
return [
'mem_total' => (int)$return[0]/1024,
'mem_total' => (int)$return[0] / 1024,
'mem_free' => (int)$return[1] * ($return[2] + $return[3] + $return[4]) / 1024,
'swap_free' => (isset($swapFree)) ? $swapFree : 'N/A',
'swap_total' => (isset($swapTotal)) ? $swapTotal : 'N/A'
Expand Down
12 changes: 6 additions & 6 deletions tests/lib/SessionStatisticsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ protected function setUp(): void {
}

private function addDummyValues() {
$this->addDummyValuesWithLastLogin($this->currentTime - $this->offset5Minutes +1, 10);
$this->addDummyValuesWithLastLogin($this->currentTime - $this->offset1Hour +1, 20);
$this->addDummyValuesWithLastLogin($this->currentTime - $this->offset1Day +1, 30);
$this->addDummyValuesWithLastLogin($this->currentTime - $this->offset7Days +1, 40);
$this->addDummyValuesWithLastLogin($this->currentTime - $this->offset30Days +1, 50);
$this->addDummyValuesWithLastLogin($this->currentTime - $this->offset5Minutes + 1, 10);
$this->addDummyValuesWithLastLogin($this->currentTime - $this->offset1Hour + 1, 20);
$this->addDummyValuesWithLastLogin($this->currentTime - $this->offset1Day + 1, 30);
$this->addDummyValuesWithLastLogin($this->currentTime - $this->offset7Days + 1, 40);
$this->addDummyValuesWithLastLogin($this->currentTime - $this->offset30Days + 1, 50);
}

private function addDummyValuesWithLastLogin($lastActivity, $numOfEntries) {
Expand All @@ -87,7 +87,7 @@ private function addDummyValuesWithLastLogin($lastActivity, $numOfEntries) {
'login_name' => $query->createNamedParameter('user-' . ($numOfEntries + $i % 2)),
'password' => $query->createNamedParameter('password'),
'name' => $query->createNamedParameter('user agent'),
'token' => $query->createNamedParameter('token-' . ($i + $numOfEntries*10)),
'token' => $query->createNamedParameter('token-' . ($i + $numOfEntries * 10)),
'type' => $query->createNamedParameter(0),
'last_activity' => $query->createNamedParameter($lastActivity),
'last_check' => $query->createNamedParameter($lastActivity),
Expand Down

0 comments on commit 3c9c9b6

Please sign in to comment.