[mythtv] latest compilation of 6544 additions

Kirby Vandivort kvandivo at ks.uiuc.edu
Wed Sep 24 14:08:24 EDT 2003


Attached is my latest compilation of additions to the 6544 status code.
This is, of course, against current CVS.  New for this revision:

- server load average is printed so that you can quickly
  determine if the server you are querying is busy or not

- changed the number of upcoming shows displays to 5, and added
  alternating colors to the table to make it prettier.

-- 

Kirby Vandivort                      Theoretical and 
Senior Research Programmer            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
-------------- next part --------------
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	24 Sep 2003 17:59:47 -0000
@@ -1047,10 +1052,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 +1080,6 @@
     }
 
-    QStringList strlist;
-    QString filename = gContext->GetSetting("RecordFilePrefix") + "/nfslockfile.lock";
+    QString filename = gContext->GetSetting("RecordFilePrefix") + 
+                                             "/nfslockfile.lock";
     QFile checkFile(filename);
 
@@ -1090,5 +1092,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);
@@ -2289,6 +2325,11 @@
 {
     QTextStream os(socket);
+    QString shortdateformat = gContext->GetSetting("ShortDateFormat", "M/d");
+    QString timeformat = gContext->GetSetting("TimeFormat", "h:mm AP");
+
     os.setEncoding(QTextStream::UnicodeUTF8);
 
+    QDateTime qdtNow = QDateTime::currentDateTime();
+
     os << "HTTP/1.0 200 Ok\r\n"
        << "Content-Type: text/html; charset=\"utf-8\"\r\n"
@@ -2297,8 +2338,12 @@
     os << "<HTTP>\r\n"
        << "<HEAD>\r\n"
-       << "  <TITLE>MythTV Status</TITLE>\r\n"
+       << "  <TITLE>MythTV Status - " 
+            << qdtNow.toString(shortdateformat) 
+            << " " << qdtNow.toString(timeformat) << "</TITLE>\r\n"
        << "</HEAD>\r\n"
        << "<BODY>\r\n";
 
+
+    // encoder information ---------------------
     QMap<int, EncoderLink *>::Iterator iter = encoderList->begin();
     for (; iter != encoderList->end(); ++iter)
@@ -2320,5 +2365,13 @@
 
         if (elink->IsBusyRecording())
-            os << "is recording.\r\n";
+	{
+            os << "is recording";
+            if (elink->isLocal())
+	    {
+               ProgramInfo *pi = elink->GetRecording();
+	       os << " '" << pi->title << "'";
+	    }
+            os << ".\r\n";
+	}
         else
             os << "is not recording.\r\n";
@@ -2327,4 +2380,91 @@
     }
 
+    // upcoming shows ---------------------
+    dblock.lock();
+    MythContext::KickDatabase(m_db);
+    Scheduler *sched = new Scheduler(false, encoderList, m_db);
+    sched->FillRecordLists(false);
+    list<ProgramInfo *> *recordinglist = sched->getAllPending();
+    dblock.unlock();
+
+    unsigned int iNum = 5;
+    if (recordinglist->size() < iNum) 
+    {
+       iNum = recordinglist->size();
+    }
+
+    if (0 == iNum)
+    {
+       os << "<P>There are no shows scheduled for recording.\r\n";
+    }
+    else
+    {
+
+       os << "<P>The next " << iNum << " show" << (iNum == 1 ? "" : "s" )
+          << " that " << (iNum == 1 ? "is" : "are") 
+	  << " scheduled for recording:<BR>\r\n";
+
+       os << "<TABLE BORDER WIDTH=80%>\r\n"; 
+       os << "<TR><TH>Start Time</TH><TH>Show</TH><TH>Encoder</TH></TR>\r\n";
+       list<ProgramInfo *>::iterator iter = recordinglist->begin();
+       for (unsigned int i=0; (iter != recordinglist->end()) && i<iNum; 
+                                                          iter++,i++)
+       {
+          if (! (*iter)->recording) // skip it, and don't count it as
+	  {                         // one of our number
+	     i--;
+	  }
+	  else
+	  {
+             os << "<TR " << ((i % 2 == 0) ? "BGCOLOR=EEEEEE" : "") << ">" 
+	        << "<TD>" << ((*iter)->startts).toString(shortdateformat) 
+                  << " " << ((*iter)->startts).toString(timeformat) << "</TD>" 
+                << "<TD>" << (*iter)->title << "</TD>"
+                << "<TD>" << (*iter)->cardid << "</TD></TR>\r\n";
+	  }
+       }
+       os << "</TABLE>";
+    }
+
+    os << "<P>Machine Information:\r\n";
+    os << "<TABLE WIDTH =100% BGCOLOR=EEEEEE>";
+    os << "<TR><TD>";
+
+    // drive space   ---------------------
+    int iTotal = -1, iUsed = -1;
+    QString rep;
+
+    getFreeSpace(iTotal, iUsed);
+
+    os << "Disk Usage:\r\n";
+
+    os << "<UL><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 << "</UL>\r\n";
+
+    os << "</TD><TD>";
+    
+    // load average ---------------------
+    os << "This machine's load average:";
+
+    double rgdAverages[3];
+    getloadavg(rgdAverages, 3);
+    os << "<UL><LI>1 Minute: " << rgdAverages[0] << "\r\n";
+    os << "<LI>5 Minute: " << rgdAverages[1] << "\r\n";
+    os << "<LI>15 Minute: " << rgdAverages[2] << "\r\n</UL>";
+
+    os << "</TD></TR></TABLE>";    // end the machine information table
+
     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	24 Sep 2003 17:59:47 -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);


More information about the mythtv-dev mailing list