mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-02-25 17:57:28 +00:00
Chore(tools): Added phpcs & fixed x-quota-usage
This commit is contained in:
@@ -8,6 +8,9 @@ indent_style = space
|
|||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.php]
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
[.git{ignore,modules}]
|
[.git{ignore,modules}]
|
||||||
indent_style = tab
|
indent_style = tab
|
||||||
indent_size = 1
|
indent_size = 1
|
||||||
|
|||||||
8
.phpcs.xml
Normal file
8
.phpcs.xml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<ruleset name="PHP_CodeSniffer">
|
||||||
|
<description>PHP_CodeSniffer configuration</description>
|
||||||
|
<rule ref="PSR12">
|
||||||
|
<exclude name="PSR12.Operators.OperatorSpacing"/>
|
||||||
|
<exclude name="PSR1.Files.SideEffects.FoundWithSymbols"/>
|
||||||
|
</rule>
|
||||||
|
</ruleset>
|
||||||
BIN
local/bin/phpcs
Executable file
BIN
local/bin/phpcs
Executable file
Binary file not shown.
@@ -8,24 +8,16 @@ $quota = '';
|
|||||||
$output = [];
|
$output = [];
|
||||||
$fsCharLenght = 0;
|
$fsCharLenght = 0;
|
||||||
|
|
||||||
if ($debug) {
|
$quota = shell_exec("quota -w");
|
||||||
$quota = "Disk quotas for user viir (uid 2913):
|
|
||||||
Filesystem blocks quota limit grace files quota limit grace
|
|
||||||
10.0.0.89:/www/webroots/2 8277615 52428800 52428800 0 0 0
|
|
||||||
10.0.0.179:/users1/users/2 1999431 52428800 52428800 0 0 0
|
|
||||||
10.0.0.90:/siilo/2 24835106 524288000 524288000 0 0 0";
|
|
||||||
} else {
|
|
||||||
// $quota = system("quota -w");
|
|
||||||
$quota = shell_exec("quota -w");
|
|
||||||
}
|
|
||||||
|
|
||||||
function pad($i, $n = 3, $p = ' ') {
|
function pad($i, $n = 3, $p = ' ')
|
||||||
|
{
|
||||||
return str_pad($i, $n, $p, STR_PAD_LEFT);
|
return str_pad($i, $n, $p, STR_PAD_LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($quota)) {
|
if (empty($quota)) {
|
||||||
var_dump($quota);
|
var_dump($quota);
|
||||||
die("quota was empty\n");
|
die("quota was empty\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
$quota = explode("\n", $quota);
|
$quota = explode("\n", $quota);
|
||||||
@@ -41,34 +33,34 @@ foreach ($quota as $lineNum => $line) {
|
|||||||
if (count($values) != 4) {
|
if (count($values) != 4) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = array_combine(['fs', 'used', 'quota', 'limit'], $values);
|
$result = array_combine(['fs', 'used', 'quota', 'limit'], $values);
|
||||||
|
|
||||||
$result['used_percentage'] = round($result['used'] / $result['quota'] * 100, 3);
|
$result['used_percentage'] = round($result['used'] / $result['quota'] * 100, 3);
|
||||||
$result['used_gb'] = round($result['used'] / 1024 / 1024, 2);
|
$result['used_gb'] = round($result['used'] / 1024 / 1024, 2);
|
||||||
$result['quota_gb'] = round($result['quota'] / 1024 / 1024, 2);
|
$result['quota_gb'] = round($result['quota'] / 1024 / 1024, 2);
|
||||||
|
|
||||||
$char = strlen($result['fs']);
|
$char = strlen($result['fs']);
|
||||||
if ($char > $fsCharLenght) {
|
if ($char > $fsCharLenght) {
|
||||||
$fsCharLenght = $char;
|
$fsCharLenght = $char;
|
||||||
}
|
}
|
||||||
|
|
||||||
$output[] = $result;
|
$output[] = $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($output)) {
|
if (!empty($output)) {
|
||||||
|
$header = sprintf(
|
||||||
$header = sprintf("%s | %s | %s | %s",
|
"%s | %s | %s | %s",
|
||||||
str_pad("Mount", $fsCharLenght),
|
str_pad("Mount", $fsCharLenght),
|
||||||
'Usage%',
|
'Usage%',
|
||||||
'Used/Total',
|
'Used/Total',
|
||||||
'Bar'
|
'Bar'
|
||||||
);
|
);
|
||||||
$headerWidth = strlen($header);
|
$headerWidth = strlen($header);
|
||||||
|
|
||||||
echo "\n" . $header . "\n";
|
echo "\n" . $header . "\n";
|
||||||
echo str_repeat('-', $headerWidth + 24) . "\n";
|
echo str_repeat('-', $headerWidth + 24) . "\n";
|
||||||
|
|
||||||
foreach ($output as $i) {
|
foreach ($output as $i) {
|
||||||
$barUsed = round($i['used_percentage']) / 4;
|
$barUsed = round($i['used_percentage']) / 4;
|
||||||
echo sprintf(
|
echo sprintf(
|
||||||
@@ -82,4 +74,3 @@ if (!empty($output)) {
|
|||||||
|
|
||||||
echo "\n\n";
|
echo "\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user