コード例 #1
0
ファイル: fsWatcher.cpp プロジェクト: nrgmilk/pcbsd
QStringList FSWatcher::getFSmountpoints() {
    //output line format: name::filesystem::totalspace::usedspace::percent
    // -- sizes all in K
    QStringList output;
    //ZFS Checks
    QStringList zpools = runCMD("zpool list -o name");
    if(zpools.length() > 1) {
        //Then there are ZFS pools available
        for(int i=1; i<zpools.length(); i++) { //skip the header line
            QStringList tmp = runCMD("zfs list -o available,used "+zpools[i]);
            //second line contains the data
            QString avail = tmp[1].section(" ",0,0,QString::SectionSkipEmpty);
            QString used = tmp[1].section(" ",1,1,QString::SectionSkipEmpty);
            double iUsed = floor(displayToDouble(used));
            double iTotal = floor(displayToDouble(avail)) + iUsed;
            int percent = calculatePercentage(iUsed, iTotal);
            //qDebug() << "Percent calc: tot:"<<iTotal<<"used"<<iUsed<<"percent"<<percent;
            //format the output string and add it in
            output << zpools[i]+"::zfs::"+QString::number(iTotal)+"::"+QString::number(iUsed)+"::"+QString::number(percent);
        }
    }
    //Now get all the rest of the mounted filesystems
    QStringList dfout = runCMD("df -h -T");
    //Format: name, filesystem, size, used, available, percent, mountpoint
    for(int i=1; i<dfout.length(); i++) {
        //ignore certain filesystems
        if(dfout[i].startsWith("devfs")) {}
        else if(dfout[i].startsWith("procfs")) {}
        else if(dfout[i].startsWith("linprocfs")) {}
        else if(dfout[i].startsWith("linsysfs")) {}
        else if(dfout[i].startsWith("fdescfs")) {}
        else {
            //Now parse out the info
            dfout[i].replace("\t"," ");
            QString fs = dfout[i].section("  ",1,1,QString::SectionSkipEmpty).simplified();
            if(fs != "zfs" && fs!="cd9660" && fs!="nullfs" && fs!="fusefs") { //ignore zfs filesystems (already taken care of)
                QString name = dfout[i].section("  ",6,6,QString::SectionSkipEmpty).simplified();
                QString total = dfout[i].section("  ",2,2,QString::SectionSkipEmpty).simplified();
                QString used = dfout[i].section("  ",3,3,QString::SectionSkipEmpty).simplified();
                //Calculate the percent
                double iUsed = displayToDouble(used);
                double iTotal = displayToDouble(total);
                int percent = calculatePercentage(iUsed, iTotal);
                //qDebug() << "df Item:" << dfout[i];
                //qDebug() << " - Detected:" << name << fs << iTotal << iUsed << percent;
                //format the output string and add it in
                output << name+"::"+fs+"::"+QString::number(iTotal)+"::"+QString::number(iUsed)+"::"+QString::number(percent);
            }
        }
    }
    //Return the results
    //qDebug() << "FS output:" << output;
    return output;

}
コード例 #2
0
ファイル: pbiDBAccess.cpp プロジェクト: prodigeni/pcbsd
//------------------
//  SYNCERS
//------------------
bool PBIDBAccess::syncPkgInstallList(QString jailID, bool reload){
  //qDebug() << "Sync Local PKG Repo";
  bool synced = false;
  if(PKGINSTALLED.isEmpty() || reload || (jailLoaded!=jailID) ){
    PKGINSTALLED.clear();
    QStringList args; 
    if( !jailID.isEmpty() ){ args << "-j" << jailID; }
    args << "query" << "-a" << "APP=%o::::%v::::%sh::::%k::::%t::::%a::::%q";
    // [origin, installed version, installed size, isLocked, timestamp, isOrphan
    QStringList out = runCMD("pkg",args).split("APP=");	
    for(int i=0; i<out.length(); i++){
      QStringList info = out[i].split("::::");
      if(info.length() < 7){ continue; } //invalid
      NGApp app;
      if(PKGAVAIL.contains(info[0])){ app = PKGAVAIL[info[0]]; } //start from the current remote info
      app.origin = info[0];
      app.installedversion = info[1];
      app.installedsize = info[2];
      app.isLocked = (info[3] == "1");
      app.installedwhen = QDateTime::fromTime_t( info[4].toLongLong() ).toString(Qt::DefaultLocaleShortDate);
      app.isOrphan = (info[5] == "1");
      app.installedarch = info[6];
      app.isInstalled = true;
      PKGINSTALLED.insert(info[0], app);
      //if(!jailID.isEmpty()){ qDebug() << "Installed:" << out[i]; }
    }
    //Now get the reverse dependancy lists
    args.clear(); 
    if( !jailID.isEmpty() ){ args << "-j" << jailID; }
    args << "query" << "-a" << "APP=%o::::%ro";
    out = runCMD("pkg", args).split("APP=");
    //qDebug() << "Get reverse Deps:" << out;
    for(int i=0; i<out.length();i++){
      QStringList info = out[i].split("::::");
      NGApp app;
      if(PKGINSTALLED.contains(info[0])){ app = PKGINSTALLED[info[0]]; } //Update existing info
      else{ continue; } //invalid
      app.rdependency.append( info[1].simplified() );
      PKGINSTALLED.insert(info[0], app);
    }
    jailLoaded = jailID; //keep track of which jail this list is for
    synced = true;
  }
  //qDebug() << " - end Local PKG Repo Sync";
  return synced;
}
コード例 #3
0
ファイル: pbiDBAccess.cpp プロジェクト: prodigeni/pcbsd
void PBIDBAccess::syncLargePkgRepoList(bool reload){
  //Detailed list of packages available on the repo (can take a while)
    //  - use PKGAVAIL as the base template for all the other info classes (save on "pkg" calls)
  //qDebug() << "Sync Remote PKG Repo";
  if(PKGAVAIL.isEmpty() || reload){
    PKGAVAIL.clear();
    QStringList args; args << "rquery" << "-a" << "APP=%o::::%n::::%v::::%m::::%w::::%c::::%e::::%sh::::%q";
    QStringList out = runCMD("pkg",args).split("APP=");	  
    for(int i=0; i<out.length(); i++){
      QStringList info = out[i].split("::::");
       //qDebug() << "PKG:" << info;
	//[ origin, name, version, maintainer, website, comment, description, size]
	if(info.length() < 9){ continue; } //invalid
      NGApp app;
	    app.origin = info[0];
	    app.name = info[1];
	    app.version = info[2];
	    app.maintainer = info[3];
	    app.website = info[4];
	    app.shortdescription = cleanupDescription( info[5].split("\n") );
	    app.description = cleanupDescription( info[6].split("\n") );
	    app.size = info[7];
	    app.arch = info[8];
	    app.portcat = info[0].section("/",0,0).simplified();
	    //app = getRemotePkgDetails(app);
      PKGAVAIL.insert(info[0], app);
    }
    //Now get all the dependency information for the packages
    args.clear();
    args << "rquery" << "-a" << "APP=%o::::%do";
    out = runCMD("pkg",args).split("APP=");
    for(int i=0; i<out.length(); i++){
      QStringList info = out[i].split("::::");
      if(info.length() < 2){ continue; }
      if(PKGAVAIL.contains(info[0])){
        NGApp app = PKGAVAIL[info[0]];
	      app.dependency.append(info[1].simplified());
	PKGAVAIL.insert(info[0], app);
      }
    }
  }
  //qDebug() << " - end Remote PKG Repo Sync";
}
コード例 #4
0
ファイル: pbiDBAccess.cpp プロジェクト: prodigeni/pcbsd
QStringList PBIDBAccess::listJailPackages(QString jailID){
  if(jailID.isEmpty()){ return QStringList(); }
  QStringList args; 
    args << "-j" << jailID;
    args << "query" << "-a" << "APP=%o";
    // [origin, installed version, installed size, isLocked, timestamp, isOrphan
    QStringList out = runCMD("pkg",args).split("APP=");
    for(int i=0; i<out.length(); i++){
      out[i] = out[i].simplified(); //remove any extra whitespace
    }
    return out;
}
コード例 #5
0
ファイル: pbiDBAccess.cpp プロジェクト: prodigeni/pcbsd
NGApp PBIDBAccess::getLocalPkgDetails(NGApp app){
  //Simply set the proper bits in the container for locally installed apps
  // NOTE: This is dependant upon which jail is being probed
  QStringList args;
  if( !jailLoaded.isEmpty() ){
    args << "-j" << jailLoaded;
  }
  args << "query" << "%v::::%sh::::%k::::%t::::%a" << app.origin;
  QString out = runCMD("pkg", args);
  if(out.isEmpty()){
    app.isInstalled=false;
  }else{
    app.isInstalled=true;
    app.installedversion = out.section("::::",0,0);
    app.installedsize = out.section("::::",1,1);
    app.isLocked = (out.section("::::",2,2) == "1");
    QString timestamp = out.section("::::",3,3);
      app.installedwhen = QDateTime::fromMSecsSinceEpoch( timestamp.toLongLong() ).toString(Qt::DefaultLocaleShortDate);
    app.isOrphan = (out.section("::::",4,4) == "1");
  }
  return app;
}