Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9090ed2
Fix FreeBSD Exception (null not string returned from speed/duplex)
ConstrictM Oct 11, 2020
52e1da8
Create a default active for a null status
ConstrictM Oct 11, 2020
0e29405
Switch null check to isset
ConstrictM Oct 12, 2020
833998b
[tx-robot] updated from transifex
nextcloud-bot Oct 27, 2020
2bb93ee
Added frontend fix for active user statistics
akhil1508 Oct 28, 2020
8099caf
[tx-robot] updated from transifex
nextcloud-bot Nov 8, 2020
c865545
Add OCI github action
nickvergessen Nov 10, 2020
afdb629
[tx-robot] updated from transifex
nextcloud-bot Nov 14, 2020
90c4b47
[tx-robot] updated from transifex
nextcloud-bot Nov 25, 2020
861cd9d
Properly fetch oracle database information
juliusknorr Nov 19, 2020
3f1e915
[tx-robot] updated from transifex
nextcloud-bot Dec 14, 2020
e4efb47
Fix MySQL database size calculation
nickvergessen Dec 11, 2020
1c7ccf5
[tx-robot] updated from transifex
nextcloud-bot Dec 23, 2020
a5f9e93
[tx-robot] updated from transifex
nextcloud-bot Jan 4, 2021
9c56140
Added test modifications
akhil1508 Jan 8, 2021
0303e43
Changed count assertion to assert 5 instead of 3
akhil1508 Jan 11, 2021
773a5fb
Lint
akhil1508 Jan 11, 2021
c7bf503
Update SessionStatisticsTest.php
akhil1508 Jan 11, 2021
530b24e
Update SessionStatisticsTest.php
akhil1508 Jan 11, 2021
6aa0f65
Fix for lint check
akhil1508 Jan 11, 2021
f56ab1c
Ran composer update
akhil1508 Jan 11, 2021
bd80839
Trying coding standard v0.4.0
akhil1508 Jan 11, 2021
7e0269a
Update SessionStatisticsTest.php
akhil1508 Jan 11, 2021
7f1e877
Fixes linting
akhil1508 Jan 11, 2021
72f48a1
Re-added last 30 days
akhil1508 Jan 11, 2021
1575062
cs fixed
akhil1508 Jan 11, 2021
208815c
Merge branch 'master' into frontend_and_test_fixes
akhil1508 Jan 12, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require-dev": {
"nextcloud/coding-standard": "^0.3.0"
"nextcloud/coding-standard": "^0.4.0"
},
"scripts": {
"cs:check": "php-cs-fixer fix --dry-run --diff",
Expand Down
1,053 changes: 809 additions & 244 deletions composer.lock

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@
function updateActiveUsersStatistics() {

var activeUsers = $('#activeuserscanvas').data('users'),
activeUsersData = [activeUsers.last24hours, activeUsers.last1hour, activeUsers.last5minutes],
activeUsersData = [activeUsers.last30days, activeUsers.last7days, activeUsers.last24hours, activeUsers.last1hour, activeUsers.last5minutes],
stepSize = 0;

if (Math.max.apply(null, activeUsersData) < 10) {
Expand All @@ -294,6 +294,8 @@
type: 'line',
data: {
labels: [
t('serverinfo', '30 days'),
t('serverinfo', '7 days'),
t('serverinfo', '24 hours'),
t('serverinfo', '1 hour'),
t('serverinfo', '5 mins')
Expand Down
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
7 changes: 6 additions & 1 deletion lib/SessionStatistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ class SessionStatistics {

private $offset1Day = 86400;

private $offset7Days = 604800;

private $offset30Days = 2592000;
/**
* SessionStatistics constructor.
*
Expand All @@ -63,7 +66,9 @@ public function getSessionStatistics() {
return [
'last5minutes' => $this->getNumberOfActiveUsers($this->offset5Minutes),
'last1hour' => $this->getNumberOfActiveUsers($this->offset1Hour),
'last24hours' => $this->getNumberOfActiveUsers($this->offset1Day)
'last24hours' => $this->getNumberOfActiveUsers($this->offset1Day),
'last7days' => $this->getNumberOfActiveUsers($this->offset7Days),
'last30days' => $this->getNumberOfActiveUsers($this->offset30Days)
];
}

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
20 changes: 14 additions & 6 deletions tests/lib/SessionStatisticsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,12 @@ class SessionStatisticsTest extends TestCase {
private $offset1Hour = 3600;

private $offset1Day = 86400;

private $offset7Days = 604800;

private $offset30Days = 2592000;

private $currentTime = 100000;
private $currentTime = 10000000;

protected function setUp(): void {
parent::setUp();
Expand All @@ -66,9 +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->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 @@ -81,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 All @@ -98,9 +104,11 @@ public function testGetSessionStatistics() {

$result = $this->instance->getSessionStatistics();

$this->assertSame(3, count($result));
$this->assertSame(5, count($result));
$this->assertSame(2, $result['last5minutes']);
$this->assertSame(4, $result['last1hour']);
$this->assertSame(6, $result['last24hours']);
$this->assertSame(8, $result['last7days']);
$this->assertSame(10, $result['last30days']);
}
}