Update Tmux and TmuxOutput classes

This commit is contained in:
DariusIII
2018-01-30 13:32:34 +01:00
parent a5ede60117
commit 3116fa79c8
3 changed files with 20 additions and 17 deletions
+1
View File
@@ -1,4 +1,5 @@
2018-01-30 DariusIII
* Chg: Update Tmux and TmuxOutput classes
* Fix: Fix missing use statement for Category model in AniDB class
* Chg: Use fixtures to populate tables when nntmux is in production, adapt install process
* Fix: Fix reference to wrong column in dnzb_failures migration foreign key creation
+3 -3
View File
@@ -129,15 +129,15 @@ class Tmux
$runVar['conncounts'][$which]['active'] = str_replace("\n", '', shell_exec('ss -n | grep '.$connections[$ip].':'.$connections[$port].' | grep -c ESTAB'));
$runVar['conncounts'][$which]['total'] = str_replace("\n", '', shell_exec('ss -n | grep -c '.$connections[$ip].':'.$connections[$port]));
if ($runVar['conncounts'][$which]['active'] == 0 && $runVar['conncounts'][$which]['total'] == 0) {
if ((int) $runVar['conncounts'][$which]['active'] === 0 && (int) $runVar['conncounts'][$which]['total'] === 0) {
$runVar['conncounts'][$which]['active'] = str_replace("\n", '', shell_exec('ss -n | grep '.$connections[$ip].':https | grep -c ESTAB'));
$runVar['conncounts'][$which]['total'] = str_replace("\n", '', shell_exec('ss -n | grep -c '.$connections[$ip].':https'));
}
if ($runVar['conncounts'][$which]['active'] == 0 && $runVar['conncounts'][$which]['total'] == 0) {
if ((int) $runVar['conncounts'][$which]['active'] === 0 && (int) $runVar['conncounts'][$which]['total'] === 0) {
$runVar['conncounts'][$which]['active'] = str_replace("\n", '', shell_exec('ss -n | grep '.$connections[$port].' | grep -c ESTAB'));
$runVar['conncounts'][$which]['total'] = str_replace("\n", '', shell_exec('ss -n | grep -c '.$connections[$port]));
}
if ($runVar['conncounts'][$which]['active'] == 0 && $runVar['conncounts'][$which]['total'] == 0) {
if ((int) $runVar['conncounts'][$which]['active'] === 0 && (int) $runVar['conncounts'][$which]['total'] === 0) {
$runVar['conncounts'][$which]['active'] = str_replace("\n", '', shell_exec('ss -n | grep '.$connections[$ip].' | grep -c ESTAB'));
$runVar['conncounts'][$which]['total'] = str_replace("\n", '', shell_exec('ss -n | grep -c '.$connections[$ip]));
}
+16 -14
View File
@@ -36,6 +36,8 @@ class TmuxOutput extends Tmux
* TmuxOutput constructor.
*
* @param \nntmux\db\DB|null $pdo
*
* @throws \Exception
*/
public function __construct(DB $pdo = null)
{
@@ -56,7 +58,7 @@ class TmuxOutput extends Tmux
$buffer .= $this->_getMonitor();
}
if ($runVar['settings']['show_query'] == 1) {
if ((int)$runVar['settings']['show_query'] === 1) {
$buffer .= $this->_getQueries();
}
@@ -70,7 +72,7 @@ class TmuxOutput extends Tmux
$buffer = sprintf($this->tmpMasks[3], 'Groups', 'Active', 'Backfill');
$buffer .= $this->_getSeparator();
if ($this->runVar['settings']['backfilldays'] == '1') {
if ($this->runVar['settings']['backfilldays'] === '1') {
$buffer .= sprintf(
$this->tmpMasks[4],
'Activated',
@@ -107,7 +109,7 @@ class TmuxOutput extends Tmux
protected function _getFormatMasks($compressed)
{
$index = ($compressed == 1 ? '2.1' : '2.0');
$index = ((int) $compressed === 1 ? '2.1' : '2.0');
return [
1 => &$this->_colourMasks[1],
@@ -121,7 +123,7 @@ class TmuxOutput extends Tmux
protected function _getHeader()
{
$buffer = '';
$state = ($this->runVar['settings']['is_running'] == 1) ? 'Running' : 'Disabled';
$state = ((int) $this->runVar['settings']['is_running'] === 1) ? 'Running' : 'Disabled';
$version = $this->_vers->versions->git->tag;
$buffer .= sprintf(
@@ -200,7 +202,7 @@ class TmuxOutput extends Tmux
number_format($this->runVar['counts']['now']['missed_parts_table'])
);
if (($this->runVar['settings']['post'] == '1' || $this->runVar['settings']['post'] == '3') && $this->runVar['constants']['sequential'] != 2) {
if (((int) $this->runVar['settings']['post'] === 1 || (int) $this->runVar['settings']['post'] === 3) && (int) $this->runVar['constants']['sequential'] !== 2) {
$buffer .= sprintf(
$this->tmpMasks[1],
'Postprocess:',
@@ -412,17 +414,17 @@ class TmuxOutput extends Tmux
$monitor_path_a = $this->runVar['settings']['monitor_path_a'];
$monitor_path_b = $this->runVar['settings']['monitor_path_b'];
if (((isset($monitor_path)) && (file_exists($monitor_path)))
|| ((isset($monitor_path_a)) && (file_exists($monitor_path_a)))
|| ((isset($monitor_path_b)) && (file_exists($monitor_path_b)))) {
if ((isset($monitor_path) && file_exists($monitor_path))
|| (isset($monitor_path_a) && file_exists($monitor_path_a))
|| (isset($monitor_path_b) && file_exists($monitor_path_b))) {
$buffer .= "\n";
$buffer .= sprintf($this->tmpMasks[3], 'File System', 'Used', 'Free');
$buffer .= $this->_getSeparator();
if (isset($monitor_path) && $monitor_path != '' && file_exists($monitor_path)) {
if (isset($monitor_path) && $monitor_path !== '' && file_exists($monitor_path)) {
$disk_use = $this->decodeSize(disk_total_space($monitor_path) - disk_free_space($monitor_path));
$disk_free = $this->decodeSize(disk_free_space($monitor_path));
if (basename($monitor_path) == '') {
if (basename($monitor_path) === '') {
$show = '/';
} else {
$show = basename($monitor_path);
@@ -430,10 +432,10 @@ class TmuxOutput extends Tmux
$buffer .= sprintf($this->tmpMasks[4], $show, $disk_use, $disk_free);
}
if (isset($monitor_path_a) && $monitor_path_a != '' && file_exists($monitor_path_a)) {
if (isset($monitor_path_a) && $monitor_path_a !== '' && file_exists($monitor_path_a)) {
$disk_use = $this->decodeSize(disk_total_space($monitor_path_a) - disk_free_space($monitor_path_a));
$disk_free = $this->decodeSize(disk_free_space($monitor_path_a));
if (basename($monitor_path_a) == '') {
if (basename($monitor_path_a) === '') {
$show = '/';
} else {
$show = basename($monitor_path_a);
@@ -441,10 +443,10 @@ class TmuxOutput extends Tmux
$buffer .= sprintf($this->tmpMasks[4], $show, $disk_use, $disk_free);
}
if (isset($monitor_path_b) && $monitor_path_b != '' && file_exists($monitor_path_b)) {
if (isset($monitor_path_b) && $monitor_path_b !== '' && file_exists($monitor_path_b)) {
$disk_use = $this->decodeSize(disk_total_space($monitor_path_b) - disk_free_space($monitor_path_b));
$disk_free = $this->decodeSize(disk_free_space($monitor_path_b));
if (basename($monitor_path_b) == '') {
if (basename($monitor_path_b) === '') {
$show = '/';
} else {
$show = basename($monitor_path_b);