Completed
Push — master ( dc77f2...9e17e8 )
by Fatih
05:11
created
src/AWSCustomMetric/Plugin/RedisCheck.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
     }
20 20
 
21 21
     /**
22
-     * @return mixed
22
+     * @return string
23 23
      */
24 24
     public function getServer()
25 25
     {
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
 
53 53
     private function getServerPortArgs()
54 54
     {
55
-        return '-h ' . $this->getServer() . ' -p ' . $this->getPort();
55
+        return '-h '.$this->getServer().' -p '.$this->getPort();
56 56
     }
57 57
 
58 58
     private function getRedisCliCmd()
59 59
     {
60
-        return '/usr/bin/redis-cli ' . $this->getServerPortArgs();
60
+        return '/usr/bin/redis-cli '.$this->getServerPortArgs();
61 61
     }
62 62
 
63 63
     /**
@@ -82,29 +82,29 @@  discard block
 block discarded – undo
82 82
     private function findKeys()
83 83
     {
84 84
         try {
85
-            $this->diObj->getCommandRunner()->execute($this->getRedisCliCmd() . ' --raw dbsize');
85
+            $this->diObj->getCommandRunner()->execute($this->getRedisCliCmd().' --raw dbsize');
86 86
             $retVal = $this->diObj->getCommandRunner()->getReturnCode();
87 87
             $redisKeyCount = $this->diObj->getCommandRunner()->getOutput();
88
-            error_log('redisKeyCount: ' . json_encode($redisKeyCount).PHP_EOL, 3, '/tmp/php_error.log');
88
+            error_log('redisKeyCount: '.json_encode($redisKeyCount).PHP_EOL, 3, '/tmp/php_error.log');
89 89
 
90 90
             if ($retVal!==0) {
91 91
                 if ($this->diObj->getLogger()) {
92 92
                     $this->diObj->getLogger()->error(
93
-                        'Redis KEyCount cmd failed!, RETVAL: ' . $retVal
94
-                        . ', OUT: ' . implode('|', $redisKeyCount)
93
+                        'Redis KEyCount cmd failed!, RETVAL: '.$retVal
94
+                        . ', OUT: '.implode('|', $redisKeyCount)
95 95
                     );
96 96
                 }
97 97
                 return false;
98 98
             }
99 99
             if ($redisKeyCount[0]>0) {
100
-                $this->diObj->getCommandRunner()->execute($this->getRedisCliCmd() . ' --raw keys *');
100
+                $this->diObj->getCommandRunner()->execute($this->getRedisCliCmd().' --raw keys *');
101 101
                 $retVal = $this->diObj->getCommandRunner()->getReturnCode();
102 102
                 $redisKeyList = $this->diObj->getCommandRunner()->getOutput();
103 103
                 if ($retVal!==0) {
104 104
                     if ($this->diObj->getLogger()) {
105 105
                         $this->diObj->getLogger()->error(
106
-                            'Redis KeyList cmd failed!, RETVAL: ' . $retVal
107
-                            . ', OUT: ' . implode('|', $redisKeyList)
106
+                            'Redis KeyList cmd failed!, RETVAL: '.$retVal
107
+                            . ', OUT: '.implode('|', $redisKeyList)
108 108
                         );
109 109
                     }
110 110
                     return false;
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
             }
116 116
         } catch (\Exception $e) {
117 117
             if ($this->diObj->getLogger()) {
118
-                $this->diObj->getLogger()->error('Redis client thrown exception! ExcpMsg: ' . $e->getMessage());
118
+                $this->diObj->getLogger()->error('Redis client thrown exception! ExcpMsg: '.$e->getMessage());
119 119
             }
120 120
             return false;
121 121
         }
@@ -127,12 +127,12 @@  discard block
 block discarded – undo
127 127
     public function getMetrics()
128 128
     {
129 129
         try {
130
-            $redisKeyList = count($this->keys)==0?$this->findKeys():$this->keys;
130
+            $redisKeyList = count($this->keys)==0 ? $this->findKeys() : $this->keys;
131 131
             $totalLen     = 0;
132 132
             if ($redisKeyList && is_array($redisKeyList)) {
133 133
                 foreach ($redisKeyList as $redisKey) {
134 134
                     $this->diObj->getCommandRunner()->execute(
135
-                        $this->getRedisCliCmd() . ' --raw llen ' . trim($redisKey)
135
+                        $this->getRedisCliCmd().' --raw llen '.trim($redisKey)
136 136
                     );
137 137
                     $retVal = $this->diObj->getCommandRunner()->getReturnCode();
138 138
                     $redisKeyLen = $this->diObj->getCommandRunner()->getOutput();
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
             ];
147 147
         } catch (\Exception $e) {
148 148
             if ($this->diObj->getLogger()) {
149
-                $this->diObj->getLogger()->error('Redis client thrown exception! ExcpMsg: ' . $e->getMessage());
149
+                $this->diObj->getLogger()->error('Redis client thrown exception! ExcpMsg: '.$e->getMessage());
150 150
             }
151 151
             return false;
152 152
         }
Please login to merge, or discard this patch.