-
-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ilia Rostovtsev
committed
Nov 27, 2017
1 parent
2c7e2ed
commit 42efbd0
Showing
28 changed files
with
332 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# | ||
# Authentic Theme (https://github.com/qooob/authentic-theme) | ||
# Copyright Ilia Rostovtsev <[email protected]> | ||
# Licensed under MIT (https://github.com/qooob/authentic-theme/blob/master/LICENSE) | ||
# | ||
|
||
BEGIN {push(@INC, "..");} | ||
use WebminCore; | ||
use lib (dirname(__FILE__) . '/../lib'); | ||
use JSON qw( decode_json ); | ||
|
||
ReadParse(); | ||
|
||
our %config = (); | ||
read_file_cached(get_env('webmin_config') . "/config", \%config); | ||
|
||
sub get_env | ||
{ | ||
my ($key) = @_; | ||
return $ENV{ uc($key) }; | ||
} | ||
|
||
sub get_env_local_path | ||
{ | ||
my ($system, $path) = @_; | ||
if ($system eq 'freebsd') { | ||
return "/usr/local/$path/"; | ||
} | ||
|
||
} | ||
|
||
sub enforce_command | ||
{ | ||
my ($system, $command) = @_; | ||
if (!has_command($command)) { | ||
if ($system eq 'freebsd') { | ||
backquote_logged("pkg install -y $command 2>&1 </dev/null"); | ||
} | ||
} | ||
} | ||
|
||
sub get_json | ||
{ | ||
return JSON->new->latin1->encode(@_); | ||
} | ||
|
||
sub print_json | ||
{ | ||
print "Content-type: text/html\n\n"; | ||
print get_json(@_); | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# | ||
# Authentic Theme (https://github.com/qooob/authentic-theme) | ||
# Copyright Ilia Rostovtsev <[email protected]> | ||
# Licensed under MIT (https://github.com/qooob/authentic-theme/blob/master/LICENSE) | ||
# | ||
|
||
use File::Basename; | ||
require(dirname(__FILE__) . '/../init.pm'); | ||
|
||
my %data; | ||
if ($in{'xhr-stats'} =~ /[[:alpha:]]/) { | ||
my $target = $in{'xhr-stats'}; | ||
if ($target eq 'general') { | ||
my $os = $config{'os_type'}; | ||
if ($os =~ /-linux$/ || $os eq 'freebsd') { | ||
|
||
# CPU stats | ||
my $cpu = backquote_command("vmstat 1 2 2>/dev/null"); | ||
if (!$?) { | ||
my @lines = split(/\r?\n/, $cpu); | ||
my @w = split(/\s+/, $lines[$#lines]); | ||
!length($w[0]) && shift(@w); | ||
if ($os =~ /-linux$/) { | ||
if ($w[8] =~ /^\d+$/ && $w[9] =~ /^\d+$/) { | ||
$data{'io'} = [$w[8], $w[9]]; | ||
$data{'cpu'} = int($w[12]); | ||
} | ||
} else { | ||
$data{'cpu'} = int($w[16]); | ||
} | ||
} | ||
|
||
# Memory stats | ||
my $memory = 'free'; | ||
if ($os eq 'freebsd') { | ||
$memory .= 'color'; | ||
enforce_command($os, $memory); | ||
$memory = get_env_local_path($os, 'bin') . $memory . ' -o'; | ||
} | ||
|
||
my $memory = backquote_command($memory); | ||
if (!$?) { | ||
my @lines = split(/\s+/, $memory); | ||
if ($lines[8] =~ /^\d+$/ && $lines[9] =~ /^\d+$/) { | ||
$data{'mem'} = | ||
[($lines[9] / $lines[8]) * 100, [nice_size(int($lines[8]* 1024 )), nice_size(int($lines[9]* 1024 ))]]; | ||
} | ||
if ($lines[15] =~ /^\d+$/ && $lines[16] =~ /^\d+$/) { | ||
$data{'virt'} = | ||
[($lines[16] / $lines[15]) * 100, [nice_size(int($lines[15]* 1024 ) ), nice_size(int($lines[16]* 1024 ))]]; | ||
} | ||
} | ||
|
||
# Load average | ||
my $load_average = backquote_command("uptime 2>&1"); | ||
$data{'cpu'} = [$data{'cpu'}, | ||
($load_average =~ /average(s)?:\s+([0-9\.]+),?\s+([0-9\.]+),?\s+([0-9\.]+)/i ? [$2, $3, $4] : [])]; | ||
|
||
} | ||
} | ||
} | ||
print_json(\%data); |
Empty file.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/*! | ||
* Authentic Theme (https://github.com/qooob/authentic-theme) | ||
* Copyright Ilia Rostovtsev <[email protected]> | ||
* Licensed under MIT (https://github.com/qooob/authentic-theme/blob/master/LICENSE) | ||
*/ | ||
|
||
/* jshint esversion: 6 */ | ||
/* jshint jquery: true */ | ||
|
||
// Register statistics object | ||
const stats = { | ||
general: { | ||
timeout: 500, | ||
stopped: 1, | ||
call: {}, | ||
|
||
// Get data | ||
query: function() { | ||
|
||
// Repeat right after success | ||
this.stopped && (() => { | ||
this.stopped = 0; | ||
this.call = {}; | ||
|
||
this.call = $.ajax({ | ||
context: this, | ||
url: v___server_extensions_path + "/stats/stats.cgi?xhr-stats=general", | ||
success: function(data) { | ||
|
||
// Take half a second delay, render and restart | ||
setTimeout(() => { | ||
this.render(data); | ||
}, this.timeout); | ||
|
||
this.stopped = 1; | ||
}, | ||
dataType: "json", | ||
}) | ||
})(); | ||
}, | ||
|
||
// Display changes | ||
render: function(data) { | ||
|
||
// Iterate through response | ||
Object.entries(data).map(([target, data]) => { | ||
let v = parseInt(data), | ||
$pc = $('#system-status .piechart[data-charts*="' + target + '"]'), | ||
$lc = $('.info-container .' + target + '_percent'); | ||
|
||
if (Number.isInteger(v)) { | ||
|
||
// Update pie-charts | ||
if ($pc.length) { | ||
$pc.data('easyPieChart').update(v); | ||
} | ||
|
||
// Update line-charts | ||
if ($lc.length) { | ||
$lc.find('.bar').attr('style', 'width:' + v + '%'); | ||
|
||
// Update line-charts' text | ||
let $dp = $lc.find('.description'), | ||
$tx = $dp.text().split(/\s+/), | ||
$ts; | ||
|
||
$.each($tx, function(id, vd) { | ||
if (vd.includes(':')) { | ||
$tx[id + 1] = (v + '%'); | ||
$ts = id; | ||
} | ||
}) | ||
$dp.text($tx.join(' ')).attr('title', $tx.splice($ts + 2, Infinity).join(' ').slice(1, -1)); | ||
} | ||
} | ||
}) | ||
this.query(); | ||
}, | ||
|
||
// Stop querying | ||
kill: function() { | ||
let abort = this.call.abort; | ||
|
||
typeof abort === "function" && (abort.call(), this.stopped = 0); | ||
|
||
setTimeout(() => { | ||
this.stopped = 1, this.call = {}; | ||
}, this.timeout + 2); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.