HP Proliant / SmartArray RAID-Status (Code)

PatrickR

Member
Hallo Zusammen,
da wir ausschließlich HP ProliantServer einsetzen, habe ich mir mal die Mühe gemacht, den ISPConfig Raid-Status für die SmartArray Controler zu implementieren. Das Tool hpacucli muss auf dem Server installiert sein (Unterstützung für nahezu alle HP Proliant-Server mit SmartArray Controller )

Dazu habe ich in
Code:
/usr/local/ispconfig/server/lib/classes
nachfolgenden Code in die Datei
Code:
monitor_tools.inc.php
bei Zeile 1171 vor:
PHP:
     /*
      * Return the Result
      */
hinzugefügt: Evtl kanns ja jemand gebrauchen oder es findet sich soagr in einer der nächsten ISPConfig-Versionen wieder:

Code:
PHP:
        /*
         * HP SmartArray Controller -> use hpacucli software
         */

                if (file_exists('/usr/sbin/hpacucli')) {
             
                /*
                 * Initial State - ok
                 */
                $state = 'ok';
             
                /*
                 * Fetch the output
                 */
                $data['output'] = shell_exec('/usr/sbin/hpacucli ctrl all show config');
                $tmp = explode("\n", $data['output']);
             
                /*
                 * Then set the state.
                 */
                if(is_array($tmp)) {
                    foreach ($tmp as $item) {
                     
                        /*
                         * The output contains information for every RAID and every HDD.
                         * We check primary the state of the RAID and secondary the state of HDD.
                         */
                        if (strpos($item, 'logicaldrive') !== false) {
                         
                            /*
                             * We found a raid... process the state of it
                             */
                            if (strpos($item, 'OK') !== false) {
                                $this->_setState($state = 'ok');
                         
                            } elseif (strpos($item, 'Recovery Mode') !== false) {
                                $this->_setState($state = 'critical');
                                break;
                         
                            } elseif (strpos($item, 'Failed') !== false) {
                                $this->_setState($state = 'error');
                                break;
                         
                            } elseif (strpos($item, 'Recovering') !== false) {
                                $this->_setState($state = 'info');
                                break;
                         
                            } else {
                             
                                /* unknown state. so we set the state to critical, that the
                                * admin is warned, that something is wrong. this will only set if there are no physicaldrives detected
                                */
                                $this->_setState($state = 'critical');
                             
                            }
                        }
                     
                        if (strpos($item, 'physicaldrive') !== false) {
                         
                            /*
                             * We found HDD... process the state of it
                             */
                            if (strpos($item, 'OK') !== false) {
                                $this->_setState($state = 'ok');
                         
                            } elseif (strpos($item, 'Failed') !== false) {
                                $this->_setState($state = 'critical');
                                break;
                         
                            } elseif (strpos($item, 'Rebuilding') !== false) {
                                $this->_setState($state = 'info');
                                break; 
                         
                            } else {
                             
                               /* unknown state. so we set the state to critical, that the
                                * admin is warned, that something is wrong
                                */
                                $this->_setState($state = 'critical');
                                break;
                            }
                        }
                    }
                }
            }

Viele Grüße
 

PatrickR

Member
Mir ist zur später Stund´ ein kleiner Flüchtigkeitsfehler unterlaufen. Fnktionierte zwar, aber verursacht im Cronlog ein PHP Warning ( PHP Warning: Missing argument 2 for monitor_tools::_setState(), called in /usr/local.....)

falsch:
PHP:
$this->_setState($state = 'info');

richtig:
PHP:
$this->_setState($state, 'info');

usw.

Viele Grüße
 

Werbung

Top