Code Duplication    Length = 8-9 lines in 3 locations

src/AWSCustomMetric/Plugin/MemoryUsage.php 1 location

@@ 58-65 (lines=8) @@
55
            }
56
57
            return $metrics;
58
        } else {
59
            if ($this->diObj->getLogger()) {
60
                $this->diObj->getLogger()->error(
61
                    '/proc/meminfo parse failed!, RETVAL: ' . $retVal . ', OUT: ' . implode('|', $memInfoLines)
62
                );
63
            }
64
            return false;
65
        }
66
    }
67
}
68

src/AWSCustomMetric/Plugin/RedisCheck.php 2 locations

@@ 90-98 (lines=9) @@
87
            $redisKeyCount = $this->diObj->getCommandRunner()->getOutput();
88
            error_log('redisKeyCount: ' . json_encode($redisKeyCount).PHP_EOL, 3, '/tmp/php_error.log');
89
90
            if ($retVal!==0) {
91
                if ($this->diObj->getLogger()) {
92
                    $this->diObj->getLogger()->error(
93
                        'Redis KEyCount cmd failed!, RETVAL: ' . $retVal
94
                        . ', OUT: ' . implode('|', $redisKeyCount)
95
                    );
96
                }
97
                return false;
98
            }
99
            if ($redisKeyCount[0]>0) {
100
                $this->diObj->getCommandRunner()->execute($this->getRedisCliCmd() . ' --raw keys *');
101
                $retVal = $this->diObj->getCommandRunner()->getReturnCode();
@@ 103-111 (lines=9) @@
100
                $this->diObj->getCommandRunner()->execute($this->getRedisCliCmd() . ' --raw keys *');
101
                $retVal = $this->diObj->getCommandRunner()->getReturnCode();
102
                $redisKeyList = $this->diObj->getCommandRunner()->getOutput();
103
                if ($retVal!==0) {
104
                    if ($this->diObj->getLogger()) {
105
                        $this->diObj->getLogger()->error(
106
                            'Redis KeyList cmd failed!, RETVAL: ' . $retVal
107
                            . ', OUT: ' . implode('|', $redisKeyList)
108
                        );
109
                    }
110
                    return false;
111
                }
112
                return $redisKeyList;
113
            } else {
114
                return false;