source: tools/eLogStatus/eLogStatus.cc@ 1529

Last change on this file since 1529 was 272, checked in by ogrimm, 14 years ago
Expanded eLogStatus
File size: 2.5 KB
Line 
1//
2// Generate status.xml for elogbook status display
3//
4// Copy executable to /srv/www/htdocs/FACTelog/bin/ and
5// change owner to 'tomcat'.
6//
7// Oliver Grimm, 29/7/2010
8
9#include <iostream>
10#include <fstream>
11
12#include "Evidence.h"
13
14
15using namespace std;
16
17int main() {
18
19 string Status1, Status2, Status3, Status4, Status5;
20
21 // Open file
22 ofstream File("/srv/www/htdocs/FACTelog/jsp/status.xml");
23 if (!File.is_open()) {
24 cerr << "Could not open file for writing" << endl;
25 exit (EXIT_FAILURE);
26 }
27
28 // Request data from DIM
29 DimCurrentInfo Alarm("Alarm/MasterAlarm", NO_LINK);
30 DimCurrentInfo FBState("Feedback/State", NO_LINK);
31 DimCurrentInfo RunNumber("drsdaq/RunNumber", NO_LINK);
32 DimCurrentInfo RunSize("drsdaq/RunSizeMB", NO_LINK);
33 DimCurrentInfo EventNo("drsdaq/EventNumber", NO_LINK);
34
35 // Feedback state
36 if (!EvidenceServer::ServiceOK(&FBState)) Status1 = "Feedback state n/a";
37 else Status1 = EvidenceServer::ToString((char *) "I:1;C", FBState.getData(), FBState.getSize()).substr(2);
38
39 // MasterAlarm level
40 if (!EvidenceServer::ServiceOK(&Alarm)) Status2 = "MasterAlarm n/a";
41 else {
42 switch (Alarm.getInt()) {
43 case 0: Status2 = "OK"; break;
44 case 1: Status2 = "Server WARN"; break;
45 case 2: Status2 = "Server ERROR"; break;
46 case 3: Status2 = "Server FATAL"; break;
47 case 4: Status2 = "Server UNAVAILABLE"; break;
48 default: Status2 = "MasterAlarm ???";
49 }
50 }
51
52 // Run-related information
53 if (!EvidenceServer::ServiceOK(&RunNumber)) Status3 = "Run #n/a";
54 else Status3 = "Run #" + EvidenceServer::ToString((char *) "I", RunNumber.getData(), RunNumber.getSize());
55
56 if (!EvidenceServer::ServiceOK(&RunSize)) Status4 = "Size n/a";
57 else Status4 = "Size " + EvidenceServer::ToString((char *) "F", RunSize.getData(), RunSize.getSize()) + " MB";
58
59 if (!EvidenceServer::ServiceOK(&RunSize)) Status5 = "Event #n/a";
60 else Status5 = "Event #" + EvidenceServer::ToString((char *) "I", EventNo.getData(), EventNo.getSize());
61
62 // Write file
63 File << "<status_info>" << endl;
64 File << "<status_val1>" << Status1 << "</status_val1>" << endl;
65 File << "<status_val2>" << Status2 << "</status_val2>" << endl;
66 File << "<status_val3>" << Status3 << "</status_val3>" << endl;
67 File << "<status_val4>" << Status4 << "</status_val4>" << endl;
68 File << "<status_val5>" << Status5 << "</status_val5>" << endl;
69 File << "<status_val6>" << " " << "</status_val6>" << endl;
70 File << "</status_info>" << endl;
71
72 // Close file
73 File.close();
74}
Note: See TracBrowser for help on using the repository browser.