]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MONITOR/alionlinemonitor.cxx
update from salvatore
[u/mrichter/AliRoot.git] / MONITOR / alionlinemonitor.cxx
index eab7195a107dd6b728498225edd93f6a0edf4457..5f1c401367cb0692759bae001e5b7f9d029c81d1 100644 (file)
@@ -46,13 +46,42 @@ int main(int argc, char **argv)
       return 0;
     }
 
-    const char *dbHost = "aldaqdb";
-    Int_t dbPort = 3306;
-    const char *dbName = "LOGBOOK";
-    const char *user = "logbook";
-    const char *password = "alice";
+    TString dbHost = gSystem->Getenv("ONLINERECO_DB_HOST");
+    if (dbHost.IsNull())
+    {
+      printf("ERROR: ONLINERECO_DB_HOST is not set. Exiting...");
+      return 0;
+    }
+
+    TString dbPort = gSystem->Getenv("ONLINERECO_DB_PORT");
+    if (dbPort.IsNull())
+    {
+      printf("ERROR: ONLINERECO_DB_PORT is not set. Exiting...");
+      return 0;
+    }
+
+    TString dbName = gSystem->Getenv("ONLINERECO_DB_NAME");
+    if (dbName.IsNull())
+    {
+      printf("ERROR: ONLINERECO_DB_NAME is not set. Exiting...");
+      return 0;
+    }
+
+    TString user = gSystem->Getenv("ONLINERECO_DB_USER");
+    if (user.IsNull())
+    {
+      printf("ERROR: ONLINERECO_DB_USER is not set. Exiting...");
+      return 0;
+    }
+
+    TString password = gSystem->Getenv("ONLINERECO_DB_PASSWORD");
+    if (password.IsNull())
+    {
+      printf("ERROR: ONLINERECO_DB_PASSWORD is not set. Exiting...");
+      return 0;
+    }
 
-    TSQLServer* server = TSQLServer::Connect(Form("mysql://%s:%d/%s", dbHost, dbPort, dbName), user, password);
+    TSQLServer* server = TSQLServer::Connect(Form("mysql://%s:%s/%s", dbHost.Data(), dbPort.Data(), dbName.Data()), user.Data(), password.Data());
     if (!server) {
       printf("ERROR: Could not connect to DAQ Logbook");
       return 0;
@@ -60,7 +89,7 @@ int main(int argc, char **argv)
     TString sqlQuery;
     TTimeStamp ts;
     sqlQuery.Form("SELECT run FROM logbook WHERE DAQ_time_start > %u AND DAQ_time_end IS NULL AND partition REGEXP 'PHYSICS.*'",
-                 (UInt_t)ts.GetSec()-86400);
+      (UInt_t)ts.GetSec()-86400);
     TSQLResult* result = server->Query(sqlQuery);
     if (!result)
     {
@@ -75,16 +104,17 @@ int main(int argc, char **argv)
     {
       for (Int_t iRow = 0; iRow < result->GetRowCount(); iRow++)
       {
-       TSQLRow* row = result->Next();
-       TString runStr = row->GetField(0);
-       if (runStr.IsDigit())
-         win->StartOfRun(runStr.Atoi());
-       delete row;
+        TSQLRow* row = result->Next();
+        TString runStr = row->GetField(0);
+        if (runStr.IsDigit())
+          win->StartOfRun(runStr.Atoi());
+        delete row;
       }
     }
     delete result;
   }
 
   app.Run(kTRUE);
+  
   return 0;
 }