Changeset 04144d6


Ignore:
Timestamp:
Sep 17, 2013 10:52:49 AM (7 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1
Children:
b1511eb, e9760d0
Parents:
220bbd4
Message:

Get all the critical zfs messages parsed and added to the watcher/tray

Location:
src-qt4/life-preserver
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/life-preserver/LPTray.cpp

    r220bbd4 r04144d6  
    8383    info = watcher->getMessages(type,info); 
    8484    if(!info.isEmpty()){ 
    85       QString msg = QString(tr("Time: %1")).arg(info[0])+"\n"+QString(tr("Device: %1")).arg(info[2])+"\n"+QString(tr("Alert: %1")).arg(info[1]); 
     85      QString msg = QString(tr("Time: %1")).arg(info[0]); 
     86      //message/device information can have more than one listed 
     87      QStringList devs = info[2].split(":::");       
     88      QStringList msgs = info[1].split(":::"); 
     89      for(int i=0; i<devs.length(); i++){ 
     90        msg.append("\n"+QString(tr("%1: %2")).arg(devs[i],msgs[i]) ); 
     91      } 
    8692      QString title = tr("System Alert"); 
    8793      QMessageBox::warning(0, title ,msg); 
  • src-qt4/life-preserver/LPWatcher.cpp

    r220bbd4 r04144d6  
    287287    //parse the output 
    288288    QString pool, state, timestamp; 
     289    QStringList cDev, cStat, cMsg, cSummary; 
    289290    //qDebug() << "-----zpool status------"; 
    290291    bool newresilver = false; bool newscrub = false; bool newerror = false; 
     
    408409        //Check for state/resilvering of all real devices 
    409410        QString msg, summary, status; 
     411        QString device = zstat[i].section(" ",0,0,QString::SectionSkipEmpty); 
    410412        if(zstat[i].contains("NAME STATE READ")){continue;} //nothing on this header line 
    411         else if(zstat[i].contains("(resilvering)")){ LOGS.insert(51, zstat[i].section("\t",0,0,QString::SectionSkipEmpty) ); continue;} 
     413        else if(zstat[i].contains("(resilvering)")){ LOGS.insert(51, device ); continue;} 
    412414        else if(zstat[i].contains("ONLINE")){continue;} //do nothing for this device - it is good 
    413         else if(zstat[i].contains("OFFLINE")){ } 
    414         else if(zstat[i].contains("DEGRADED")){ } 
    415         else if(zstat[i].contains("FAULTED")){ } 
    416         else if(zstat[i].contains("REMOVED")){ } 
    417         else if(zstat[i].contains("UNAVAIL")){ } 
    418         //Now put the error message into the "critical" message slot 
     415        else if(zstat[i].contains("OFFLINE")){ continue; } //do nothing - this status must be set manually - it is not a "random" status 
     416        else if(zstat[i].contains("DEGRADED")){  
     417          cStat << "DEGRADED"; 
     418          cMsg << tr("The device is in a degraded state, and should be replaced soon."); 
     419          cSummary << QString(tr("%1 is degraded.")).arg(device); 
     420          cDev << device; 
     421        }else if(zstat[i].contains("FAULTED")){  
     422          cStat << "FAULTED"; 
     423          cMsg << tr("The device is faulty, and should be replaced."); 
     424          cSummary << QString(tr("%1 is faulty.")).arg(device); 
     425          cDev << device; 
     426        }else if(zstat[i].contains("REMOVED")){  
     427          cStat << "REMOVED"; 
     428          cMsg << tr("The device was removed, and should be either be re-attached or replaced."); 
     429          cSummary << QString(tr("%1 was removed.")).arg(device); 
     430          cDev << device; 
     431        }else if(zstat[i].contains("UNAVAIL")){  
     432          cStat << "UNAVAILABLE"; 
     433          cMsg << tr("The device is unavailable and should be re-added to the pool."); 
     434          cSummary << QString(tr("%1 is unavailable.")).arg(device); 
     435          cDev << device; 
     436        } 
    419437      } 
    420438    } //end of loop over zpool status lines 
     439     
     440  //Add the critical messages to the hash 
     441  if(cStat.isEmpty()){ 
     442    if(LOGS.contains(30)){ 
     443      LOGS.remove(30); 
     444      LOGS.remove(31); 
     445      LOGS.remove(32); 
     446      LOGS.remove(33); 
     447      LOGS.remove(34); 
     448      LOGS.remove(35); 
     449    } 
     450  }else{ 
     451    if(LOGS.value(30) != cStat.join(":::") ){ newerror = true; } 
     452    LOGS.insert(30, cStat.join(":::") ); 
     453    LOGS.insert(31, cDev.join(":::") ); 
     454    LOGS.insert(32, cSummary.join(":::") ); 
     455    LOGS.insert(33, cMsg.join(":::") ); 
     456    LOGS.insert(34, timestamp); 
     457    LOGS.insert(35, timestamp.section(" ",3,3) ); 
     458  } 
     459     
    421460  //Now emit the appropriate signal 
    422461  if(newerror){ emit MessageAvailable("critical"); } 
Note: See TracChangeset for help on using the changeset viewer.