@@ -666,15 +666,15 @@ function monitorOpenVzUserBeancounter() {
666666 foreach ($ test as $ item ) {
667667 /*
668668 * eliminate all doubled spaces and spaces at the beginning and end
669- */
669+ */
670670 while (strpos ($ item , ' ' ) !== false ) {
671671 $ item = str_replace (' ' , ' ' , $ item );
672672 }
673673 $ item = trim ($ item );
674674
675675 /*
676676 * The failcounter is the LAST
677- */
677+ */
678678 if ($ item != '' ) {
679679 $ tmp = explode (' ' , $ item );
680680 $ failCounter = $ tmp [sizeof ($ tmp )-1 ];
@@ -885,7 +885,15 @@ function monitorRaid() {
885885 /** The type of the data */
886886 $ type = 'raid_state ' ;
887887
888- /* This monitoring is only available if mdadm is installed */
888+ /*
889+ * We support some RAIDS. But if we can't find any of them, we have no data
890+ */
891+ $ state = 'no_state ' ;
892+ $ data ['output ' ]= '' ;
893+
894+ /*
895+ * Check, if we have mdadm installed (software-raid)
896+ */
889897 system ('which mdadm ' , $ retval );
890898 if ($ retval === 0 ) {
891899 /*
@@ -935,20 +943,56 @@ function monitorRaid() {
935943 }
936944 }
937945 }
938-
939946 }
940- else {
947+ /*
948+ * Check, if we have mpt-status installed (LSIsoftware-raid)
949+ */
950+ system ('which mpt-status ' , $ retval );
951+ if ($ retval === 0 ) {
941952 /*
942- * mdadm is not installed, so there is no data and no state
943- *
944- * no_state, NOT unknown, because "unknown" is shown as state
945- * inside the GUI. no_state is hidden.
946- *
947- * We have to write NO DATA inside the DB, because the GUI
948- * could not know, if there is any dat, or not...
953+ * Fetch the output
949954 */
950- $ state = 'no_state ' ;
951- $ data ['output ' ]= '' ;
955+ $ data ['output ' ] = shell_exec ('mpt-status --autoload -n ' );
956+
957+ /*
958+ * Then calc the state.
959+ */
960+ $ state = 'ok ' ;
961+ foreach ($ data ['output ' ] as $ item ) {
962+ /*
963+ * The output contains information for every RAID and every HDD.
964+ * We only need the state of the RAID
965+ */
966+ if (strpos ($ item , 'raidlevel: ' ) !== false ) {
967+ /*
968+ * We found a raid, process the state of it
969+ */
970+ if (strpos ($ item , ' ONLINE ' ) !== false ) {
971+ $ this ->_setState ($ state , 'ok ' );
972+ }
973+ else if (strpos ($ item , ' OPTIMAL ' ) !== false ) {
974+ $ this ->_setState ($ state , 'ok ' );
975+ }
976+ else if (strpos ($ item , ' INITIAL ' ) !== false ) {
977+ $ this ->_setState ($ state , 'info ' );
978+ }
979+ else if (strpos ($ item , ' INACTIVE ' ) !== false ) {
980+ $ this ->_setState ($ state , 'critical ' );
981+ }
982+ else if (strpos ($ item , ' RESYNC ' ) !== false ) {
983+ $ this ->_setState ($ state , 'info ' );
984+ }
985+ else if (strpos ($ item , ' DEGRADED ' ) !== false ) {
986+ $ this ->_setState ($ state , 'critical ' );
987+ }
988+ else {
989+ /* we don't know the state. so we set the state to critical, that the
990+ * admin is warned, that something is wrong
991+ */
992+ $ this ->_setState ($ state , 'critical ' );
993+ }
994+ }
995+ }
952996 }
953997
954998 /*
0 commit comments