64class MonitoredTFileInfo:
public TObject {
69 if (
file->InheritsFrom(
"TXNetFile"))
70 fFileClassName =
"TXNetFile";
72 fFileClassName =
file->ClassName();
75 fLastBytesWritten = 0;
78 fTempWrittenBytes = 0;
80 fLastResetTime = timenow;
81 fCreationTime = timenow;
102 Double_t t = std::min(prectime, fLastResetTime);
105 mselapsed = std::max(mselapsed, 1);
107 readthr = fTempReadBytes / mselapsed * 1000;
108 writethr = fTempWrittenBytes / mselapsed * 1000;
112 fTempReadBytes =
file->GetBytesRead() - fLastBytesRead;
113 fTempWrittenBytes =
file->GetBytesWritten() - fLastBytesWritten;
118 fLastBytesRead =
file->GetBytesRead();
119 fLastBytesWritten =
file->GetBytesWritten();
121 fTempWrittenBytes = 0;
122 fLastResetTime = timenow;
125 void ResetFileStatus(
Double_t timenow) {
127 ResetFileStatus(fileinst, timenow);
136class MonitoredTFileSummary:
public TNamed {
138 MonitoredTFileSummary(
TString &fileclassname):
TNamed(fileclassname, fileclassname) {
142 fWriteThroughput = 0;
152 mi->GetThroughputs(rth, wth, timenow, prectime);
154 fBytesRead += mi->fTempReadBytes;
155 fBytesWritten += mi->fTempWrittenBytes;
157 if (rth > 0) fReadThroughput += rth;
158 if (wth > 0) fWriteThroughput += wth;
169 const char *monid,
const char *monsubid,
172 fMonInfoRepo =
new std::map<UInt_t, MonitoredTFileInfo *>;
174 Init(monserver, montag, monid, monsubid, option);
271 const char *monsubid,
const char *option)
292 char *apmon_config[1] =
293 { ((monserver == 0) ? (
char *)
gSystem->
Getenv(
"APMON_CONFIG") : (
char *) monserver) };
294 if (apmon_config[0] == 0) {
295 Error(
"TMonaLisaWriter",
296 "Disabling apmon monitoring since env variable APMON_CONFIG was not found and the monitoring server is not specified in the constructor!");
302 fApmon =
new ApMon(1, apmon_config);
303 fApmon->setConfRecheck(
false);
304 fApmon->setJobMonitoring(
false);
307 }
catch (runtime_error &
e) {
308 Error(
"TMonaLisaWriter",
"Error initializing ApMon: %s",
e.what());
309 Error(
"TMonaLisaWriter",
"Disabling apmon.");
326 clustername +=
TString(
"none");
369 Info(
"Initialized for ML Server <%s> - Setting ClusterID <%s> JobID <%s> SubID <%s>\n",
386 std::map<UInt_t, MonitoredTFileInfo *>::iterator iter =
fMonInfoRepo->begin();
410 Error(
"SendInfoStatus",
"Monitoring is not properly initialized!");
421 valuelist->
Add(valtext);
437 Error(
"TMonaLisaWriter",
438 "Monitoring initialization has failed - you can't send to MonaLisa!");
447 const char *localuser;
454 localuser =
"unknown";
460 valuelist->
Add(valtext);
476 Error(
"SendInfoDescription",
477 "Monitoring is not properly initialized!");
488 valuelist->
Add(valtext);
504 Error(
"SendInfoTime",
"Monitoring is not properly initialized!");
517 valuelist->
Add(valtext);
541 Error(
"TMonaLisaWriter",
542 "Monitoring initialization has failed - you can't send to MonaLisa!");
553 valuelist->
Add(valtext);
556 valuelist->
Add(valhost);
559 valuelist->
Add(valsid);
579 Error(
"SendProcessingProgress",
580 "Monitoring is not properly initialized!");
606 valuelist->
Add(valsid);
607 valuelist->
Add(valevent);
608 valuelist->
Add(valbyte);
609 valuelist->
Add(valrealtime);
610 valuelist->
Add(valcputime);
611 valuelist->
Add(valtotmem);
612 valuelist->
Add(valrssmem);
613 valuelist->
Add(valshdmem);
639 valuelist->
Add(textevent);
640 valuelist->
Add(textbyte);
641 valuelist->
Add(textcpu);
642 valuelist->
Add(textreal);
643 valuelist->
Add(texttotmem);
644 valuelist->
Add(textrssmem);
645 valuelist->
Add(textshdmem);
648 valuelist->
Add(valhost);
668 const char *openphasename,
672 Error(
"SendFileOpenProgress",
673 "Monitoring is not properly initialized!");
683 if (!openphasename) {
702 openphases->
Add(nfo);
711 if (!forcesend)
return kTRUE;
725 valuelist->
Add(valhost);
727 valuelist->
Add(valsid);
729 valuelist->
Add(valdest);
732 valuelist->
Add(valfid);
735 valuelist->
Add(valstrfid);
755 valuelist->
Add(valtottime);
767 Error(
"SendFileCloseEvent",
768 "Monitoring is not properly initialized!");
776 MonitoredTFileInfo *mi = 0;
777 std::map<UInt_t, MonitoredTFileInfo *>::iterator iter =
fMonInfoRepo->find(
file->GetUniqueID());
781 if (mi) timelapsed = timenow - mi->fCreationTime;
788 if (
file->InheritsFrom(
"TXNetFile"))
796 valuelist->
Add(valdest);
798 valuelist->
Add(valfid);
800 strfid+=
file->GetFileCounter();
802 valuelist->
Add(valstrfid);
805 valname +=
"readbytes";
807 valuelist->
Add(valread);
815 valname +=
"writtenbytes";
817 valuelist->
Add(valwrite);
825 if (timelapsed > 0.001) {
828 thput =
file->GetBytesRead() / selapsed * 1000;
830 valname +=
"filethrpt_rd";
832 valuelist->
Add(valreadthavg);
834 thput =
file->GetBytesWritten() / selapsed * 1000;
836 valname +=
"filethrpt_wr";
838 valuelist->
Add(valwritethavg);
843 mi->UpdateFileStatus(
file);
869 Error(
"SendFileCheckpoint",
870 "Monitoring is not properly initialized!");
891 MonitoredTFileInfo *mi = 0;
892 std::map<UInt_t, MonitoredTFileInfo *>::iterator iter =
fMonInfoRepo->find(
file->GetUniqueID());
896 mi =
new MonitoredTFileInfo(
file, timenow);
901 if (mi) mi->UpdateFileStatus(
file);
920 valuelist->
Add(valhost);
922 valuelist->
Add(valsid);
933 MonitoredTFileSummary *
sum =
static_cast<MonitoredTFileSummary *
>(summary.
FindObject(mi->fFileClassName));
935 sum =
new MonitoredTFileSummary(mi->fFileClassName);
941 mi->ResetFileStatus(timenow);
967 TIter nxt2(&summary);
968 MonitoredTFileSummary *
sum;
969 while ((
sum = (MonitoredTFileSummary *)nxt2())) {
971 if (
sum->fReadThroughput >= 0) {
972 valname =
sum->GetName();
973 valname +=
"_avgthrpt_rd";
975 valuelist->
Add(valreadthr);
978 if (
sum->fWriteThroughput >= 0 ) {
979 valname =
sum->GetName();
980 valname +=
"_avgthrpt_wr";
982 valuelist->
Add(valwritethr);
1003 Error(
"SendParameters",
"Monitoring is not properly initialized!");
1008 Error(
"SendParameters",
"No values in the value list!");
1012 if (identifier == 0)
1015 TIter nextvalue(valuelist);
1022 char **apmon_params = 0;
1023 Int_t *apmon_types = 0;
1024 char **apmon_values = 0;
1027 if (apmon_nparams) {
1029 apmon_params = (
char **)
malloc(apmon_nparams *
sizeof(
char *));
1030 apmon_values = (
char **)
malloc(apmon_nparams *
sizeof(
char *));
1031 apmon_types = (
int *)
malloc(apmon_nparams *
sizeof(
int));
1032 bufDouble =
new Double_t[apmon_nparams];
1035 while ((monobj = nextvalue())) {
1036 if (!strcmp(monobj->
ClassName(),
"TMonaLisaValue")) {
1040 Info(
"SendParameters",
"adding tag %s with val %f",
1043 apmon_params[looper] = (
char *) objval->
GetName();
1044 apmon_types[looper] = XDR_REAL64;
1045 apmon_values[looper] = (
char *) (objval->
GetValuePtr());
1048 if (!strcmp(monobj->
ClassName(),
"TMonaLisaText")) {
1052 Info(
"SendParameters",
"adding tag %s with text %s",
1055 apmon_params[looper] = (
char *) objtext->
GetName();
1056 apmon_types[looper] = XDR_STRING;
1057 apmon_values[looper] = (
char *) (objtext->
GetText());
1060 if (!strcmp(monobj->
ClassName(),
"TNamed")) {
1064 Info(
"SendParameters",
"adding tag %s with text %s",
1067 apmon_params[looper] = (
char *) objNamed->
GetName();
1068 apmon_types[looper] = XDR_STRING;
1069 apmon_values[looper] = (
char *) (objNamed->
GetTitle());
1073 if (!strcmp(monobj->
ClassName(),
"TParameter<double>")) {
1077 Info(
"SendParameters",
"adding tag %s with val %f",
1080 apmon_params[looper] = (
char *) objParam->
GetName();
1081 apmon_types[looper] = XDR_REAL64;
1082 apmon_values[looper] = (
char *) &(objParam->
GetVal());
1085 if (!strcmp(monobj->
ClassName(),
"TParameter<Long64_t>")) {
1089 Info(
"SendParameters",
"adding tag %s with val %lld",
1092 apmon_params[looper] = (
char *) objParam->
GetName();
1093 apmon_types[looper] = XDR_REAL64;
1094 bufDouble[looper] = objParam->
GetVal();
1095 apmon_values[looper] = (
char *) (bufDouble + looper);
1098 if (!strcmp(monobj->
ClassName(),
"TParameter<long>")) {
1102 Info(
"SendParameters",
"adding tag %s with val %ld",
1105 apmon_params[looper] = (
char *) objParam->
GetName();
1106 apmon_types[looper] = XDR_REAL64;
1107 bufDouble[looper] = objParam->
GetVal();
1108 apmon_values[looper] = (
char *) (bufDouble + looper);
1111 if (!strcmp(monobj->
ClassName(),
"TParameter<float>")) {
1115 Info(
"SendParameters",
"adding tag %s with val %f",
1118 apmon_params[looper] = (
char *) objParam->
GetName();
1119 apmon_types[looper] = XDR_REAL64;
1120 bufDouble[looper] = objParam->
GetVal();
1121 apmon_values[looper] = (
char *) (bufDouble + looper);
1124 if (!strcmp(monobj->
ClassName(),
"TParameter<int>")) {
1128 Info(
"SendParameters",
"adding tag %s with val %d",
1131 apmon_params[looper] = (
char *) objParam->
GetName();
1132 apmon_types[looper] = XDR_REAL64;
1133 bufDouble[looper] = objParam->
GetVal();
1134 apmon_values[looper] = (
char *) (bufDouble + looper);
1140 apmon_nparams = looper;
1143 Info(
"SendParameters",
"n: %d name: %s identifier %s ...,",
1144 apmon_nparams,
GetName(), identifier);
1146 ((ApMon *)
fApmon)->sendParameters((
char *)
GetName(), (
char*)identifier,
1147 apmon_nparams, apmon_params,
1148 apmon_types, apmon_values);
1163 ((ApMon *)
fApmon)->setLogLevel((
char *) loglevel);
1171 std::cout <<
"Site (Farm) : " <<
fName << std::endl;
1172 std::cout <<
"JobId (Node) : " <<
fJobId << std::endl;
1173 std::cout <<
"SubJobId (Node) : " <<
fSubJobId << std::endl;
1174 std::cout <<
"HostName : " <<
fHostname << std::endl;
1175 std::cout <<
"Pid : " <<
fPid << std::endl;
1176 std::cout <<
"Inititialized : " <<
fInitialized << std::endl;
1177 std::cout <<
"Verbose : " <<
fVerbose << std::endl;
char * Form(const char *fmt,...)
R__EXTERN TSystem * gSystem
R__EXTERN TVirtualMonitoringWriter * gMonitoringWriter
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
const char * GetUser() const
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
TObject * FindObject(const char *name) const
Find object using its name.
void AddLast(TObject *obj)
Add object at the end of the list.
virtual void Add(TObject *obj)
virtual TObject * Last() const
Return the last object in the list. Returns 0 when list is empty.
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
virtual void Clear(Option_t *option="")
Remove all objects from the list.
const char * GetText() const
Double_t GetValue() const
virtual Bool_t SendInfoTime()
Sends the current time to MonaLisa following the processing scheme <site> --> <jobid> --> 'time' = >u...
TStopwatch fFileStopwatch
TString fHostname
sub job id
TString fJobId
connection to MonaLisa
virtual Bool_t SendFileWriteProgress(TFile *file)
Int_t fPid
hostname of MonaLisa server
void Print(Option_t *option="") const
Print info about MonaLisa object.
virtual Bool_t SendFileReadProgress(TFile *file)
virtual Bool_t SendParameters(TList *valuelist, const char *identifier=0)
Send the parameters to MonaLisa.
std::map< UInt_t, MonitoredTFileInfo * > * fMonInfoRepo
virtual void SetLogLevel(const char *loglevel="WARNING")
Set MonaLisa log level.
virtual Bool_t SendProcessingProgress(Double_t nevent, Double_t nbytes, Bool_t force=kFALSE)
Send the procesing progress to MonaLisa.
void Init(const char *monserver, const char *montag, const char *monid, const char *monsubid, const char *option)
Creates a TMonaLisaWriter object to send monitoring information to a MonaLisa server using the MonaLi...
Int_t fReportInterval
repo to gather per-file-instance mon info;
virtual Bool_t SendProcessingStatus(const char *status, Bool_t restarttimer=kFALSE)
Send the procesing status 'status' to MonaLisa following the processing scheme: <site> --> <jobid> --...
TMonaLisaWriter(const TMonaLisaWriter &)
Bool_t SendFileCheckpoint(TFile *file)
Bool_t fInitialized
process id
virtual Bool_t SendFileCloseEvent(TFile *file)
Double_t fLastFCloseSendTime
virtual Bool_t SendInfoUser(const char *user=0)
Sends the <user> text to MonaLisa following the process scheme: <site> --> <jobid> --> 'user' = <user...
virtual ~TMonaLisaWriter()
Cleanup.
virtual Bool_t SendInfoStatus(const char *status)
Sends a <status> text to MonaLisa following the process scheme: <site> --> <jobid> --> 'status' = <st...
virtual Bool_t SendFileOpenProgress(TFile *file, TList *openphases, const char *openphasename, Bool_t forcesend=kFALSE)
Send the fileopen progress to MonaLisa.
virtual Bool_t SendInfoDescription(const char *jobtag)
Sends the description <jobtag> following the processing scheme: <site> --> <jobid> --> 'jobname' = <j...
The TNamed class is the base class for all named ROOT classes.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
virtual void SetName(const char *name)
Set the name of the TNamed.
virtual const char * GetTitle() const
Returns title of object.
virtual const char * GetName() const
Returns name of object.
Mother of all ROOT objects.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
@ kHasUUID
if object has a TUUID (its fUniqueID=UUIDNumber)
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Named parameter, streamable and storable.
const AParamType & GetVal() const
const char * GetName() const
Returns name of object.
Double_t RealTime()
Stop the stopwatch (if it is running) and return the realtime (in seconds) passed between the start a...
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
Double_t CpuTime()
Stop the stopwatch (if it is running) and return the cputime (in seconds) passed between the start an...
void Continue()
Resume a stopped stopwatch.
const char * Data() const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual int GetPid()
Get process id.
virtual const char * Getenv(const char *env)
Get environment variable.
virtual int GetProcInfo(ProcInfo_t *info) const
Returns cpu and memory used by this process into the ProcInfo_t structure.
virtual const char * HostName()
Return the system's host name.
static constexpr double s
static long int sum(long int i)