[mythtv] patch to add disk space info to 6544 port connections

Kirby Vandivort kvandivo at ks.uiuc.edu
Sun Sep 21 22:06:55 EDT 2003


This will add current disk space usage information to queries to
port 6544. 


Index: programs/mythbackend/mainserver.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythbackend/mainserver.cpp,v
retrieving revision 1.81
diff -b -u -2 -r1.81 mainserver.cpp
--- programs/mythbackend/mainserver.cpp	20 Sep 2003 04:52:36 -0000	1.81
+++ programs/mythbackend/mainserver.cpp	22 Sep 2003 02:02:57 -0000
@@ -1047,10 +1053,7 @@
 }
 
-void MainServer::HandleQueryFreeSpace(PlaybackSock *pbs)
+void MainServer::getFreeSpace(int &totalspace, int &usedspace)
 {
-    QSocket *pbssock = pbs->getSocket();
-
     struct statfs statbuf;
-    int totalspace = -1, usedspace = -1;
     if (statfs(recordfileprefix.ascii(), &statbuf) == 0) 
     {
@@ -1078,6 +1081,6 @@
     }
 
-    QStringList strlist;
-    QString filename = gContext->GetSetting("RecordFilePrefix") + "/nfslockfile.lock";
+    QString filename = gContext->GetSetting("RecordFilePrefix") + 
+                                             "/nfslockfile.lock";
     QFile checkFile(filename);
 
@@ -1090,5 +1093,15 @@
         }
     }
+}
+
+void MainServer::HandleQueryFreeSpace(PlaybackSock *pbs)
+{
+    QSocket *pbssock = pbs->getSocket();
+
+    int totalspace = -1, usedspace = -1;
 
+    getFreeSpace(totalspace, usedspace);
+
+    QStringList strlist;
     strlist << QString::number(totalspace) << QString::number(usedspace);
     SendResponse(pbssock, strlist);
@@ -2301,4 +2338,5 @@
        << "<BODY>\r\n";
 
+    // encoder information
     QMap<int, EncoderLink *>::Iterator iter = encoderList->begin();
     for (; iter != encoderList->end(); ++iter)
@@ -2327,4 +2365,27 @@
     }
 
+    // drive space
+    int iTotal = -1, iUsed = -1;
+    QString rep;
+
+    getFreeSpace(iTotal, iUsed);
+
+    os << "<P>Disk Usage:\r\n";
+
+    os << "<LI>Total Space: ";
+    rep.sprintf(tr("%d,%03d MB "), (iTotal) / 1000,
+                                             (iTotal) % 1000);
+    os << rep << "\r\n";
+
+    os << "<LI>Space Used: ";
+    rep.sprintf(tr("%d,%03d MB "), (iUsed) / 1000,
+                                             (iUsed) % 1000);
+    os << rep << "\r\n";
+
+    os << "<LI>Space Free: ";
+    rep.sprintf(tr("%d,%03d MB "), (iTotal - iUsed) / 1000,
+                                             (iTotal - iUsed) % 1000);
+    os << rep << "\r\n";
+
     os << "</BODY>\r\n"
        << "</HTTP>\r\n";
Index: programs/mythbackend/mainserver.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythbackend/mainserver.h,v
retrieving revision 1.33
diff -b -u -2 -r1.33 mainserver.h
--- programs/mythbackend/mainserver.h	20 Sep 2003 01:38:07 -0000	1.33
+++ programs/mythbackend/mainserver.h	22 Sep 2003 02:02:57 -0000
@@ -81,4 +82,6 @@
     void SendResponse(QSocket *pbs, QStringList &commands);
 
+    void getFreeSpace(int &total, int &used);
+
     PlaybackSock *getSlaveByHostname(QString &hostname);
     PlaybackSock *getPlaybackBySock(QSocket *socket);
-- 

Kirby Vandivort                      Theoretical and Computational Biophysics 
Email: kvandivo at ks.uiuc.edu          3051 Beckman Institute
http://www.ks.uiuc.edu/~kvandivo/    University of Illinois
Phone: (217) 244-5711                405 N. Mathews Ave
Fax  : (217) 244-6078                Urbana, IL  61801, USA


More information about the mythtv-dev mailing list