69 if (
file->InheritsFrom(
"TXNetFile"))
104 Int_t mselapsed = std::round(std::floor(((timenow - t) * 1000)));
105 mselapsed = std::max(mselapsed, 1);
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 (std::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!");
777 std::map<UInt_t, MonitoredTFileInfo *>::iterator iter =
fMonInfoRepo->find(
file->GetUniqueID());
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) {
826 Int_t selapsed = std::round(std::floor(timelapsed * 1000));
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);
869 Error(
"SendFileCheckpoint",
870 "Monitoring is not properly initialized!");
892 std::map<UInt_t, MonitoredTFileInfo *>::iterator iter =
fMonInfoRepo->find(
file->GetUniqueID());
921 valuelist->
Add(valhost);
923 valuelist->
Add(valsid);
968 TIter nxt2(&summary);
972 if (
sum->fReadThroughput >= 0) {
973 valname =
sum->GetName();
974 valname +=
"_avgthrpt_rd";
976 valuelist->
Add(valreadthr);
979 if (
sum->fWriteThroughput >= 0 ) {
980 valname =
sum->GetName();
981 valname +=
"_avgthrpt_wr";
983 valuelist->
Add(valwritethr);
1004 Error(
"SendParameters",
"Monitoring is not properly initialized!");
1009 Error(
"SendParameters",
"No values in the value list!");
1013 if (identifier == 0)
1016 TIter nextvalue(valuelist);
1023 char **apmon_params = 0;
1024 Int_t *apmon_types = 0;
1025 char **apmon_values = 0;
1028 if (apmon_nparams) {
1030 apmon_params = (
char **)
malloc(apmon_nparams *
sizeof(
char *));
1031 apmon_values = (
char **)
malloc(apmon_nparams *
sizeof(
char *));
1032 apmon_types = (
int *)
malloc(apmon_nparams *
sizeof(
int));
1033 bufDouble =
new Double_t[apmon_nparams];
1036 while ((monobj = nextvalue())) {
1037 if (!strcmp(monobj->
ClassName(),
"TMonaLisaValue")) {
1041 Info(
"SendParameters",
"adding tag %s with val %f",
1044 apmon_params[looper] = (
char *) objval->
GetName();
1045 apmon_types[looper] = XDR_REAL64;
1046 apmon_values[looper] = (
char *) (objval->
GetValuePtr());
1049 if (!strcmp(monobj->
ClassName(),
"TMonaLisaText")) {
1053 Info(
"SendParameters",
"adding tag %s with text %s",
1056 apmon_params[looper] = (
char *) objtext->
GetName();
1057 apmon_types[looper] = XDR_STRING;
1058 apmon_values[looper] = (
char *) (objtext->
GetText());
1061 if (!strcmp(monobj->
ClassName(),
"TNamed")) {
1065 Info(
"SendParameters",
"adding tag %s with text %s",
1068 apmon_params[looper] = (
char *) objNamed->
GetName();
1069 apmon_types[looper] = XDR_STRING;
1070 apmon_values[looper] = (
char *) (objNamed->
GetTitle());
1074 if (!strcmp(monobj->
ClassName(),
"TParameter<double>")) {
1078 Info(
"SendParameters",
"adding tag %s with val %f",
1081 apmon_params[looper] = (
char *) objParam->
GetName();
1082 apmon_types[looper] = XDR_REAL64;
1083 apmon_values[looper] = (
char *) &(objParam->
GetVal());
1086 if (!strcmp(monobj->
ClassName(),
"TParameter<Long64_t>")) {
1090 Info(
"SendParameters",
"adding tag %s with val %lld",
1093 apmon_params[looper] = (
char *) objParam->
GetName();
1094 apmon_types[looper] = XDR_REAL64;
1095 bufDouble[looper] = objParam->
GetVal();
1096 apmon_values[looper] = (
char *) (bufDouble + looper);
1099 if (!strcmp(monobj->
ClassName(),
"TParameter<long>")) {
1103 Info(
"SendParameters",
"adding tag %s with val %ld",
1106 apmon_params[looper] = (
char *) objParam->
GetName();
1107 apmon_types[looper] = XDR_REAL64;
1108 bufDouble[looper] = objParam->
GetVal();
1109 apmon_values[looper] = (
char *) (bufDouble + looper);
1112 if (!strcmp(monobj->
ClassName(),
"TParameter<float>")) {
1116 Info(
"SendParameters",
"adding tag %s with val %f",
1119 apmon_params[looper] = (
char *) objParam->
GetName();
1120 apmon_types[looper] = XDR_REAL64;
1121 bufDouble[looper] = objParam->
GetVal();
1122 apmon_values[looper] = (
char *) (bufDouble + looper);
1125 if (!strcmp(monobj->
ClassName(),
"TParameter<int>")) {
1129 Info(
"SendParameters",
"adding tag %s with val %d",
1132 apmon_params[looper] = (
char *) objParam->
GetName();
1133 apmon_types[looper] = XDR_REAL64;
1134 bufDouble[looper] = objParam->
GetVal();
1135 apmon_values[looper] = (
char *) (bufDouble + looper);
1141 apmon_nparams = looper;
1144 Info(
"SendParameters",
"n: %d name: %s identifier %s ...,",
1145 apmon_nparams,
GetName(), identifier);
1147 ((ApMon *)
fApmon)->sendParameters((
char *)
GetName(), (
char*)identifier,
1148 apmon_nparams, apmon_params,
1149 apmon_types, apmon_values);
1164 ((ApMon *)
fApmon)->setLogLevel((
char *) loglevel);
1172 std::cout <<
"Site (Farm) : " <<
fName << std::endl;
1173 std::cout <<
"JobId (Node) : " <<
fJobId << std::endl;
1174 std::cout <<
"SubJobId (Node) : " <<
fSubJobId << std::endl;
1175 std::cout <<
"HostName : " <<
fHostname << std::endl;
1176 std::cout <<
"Pid : " <<
fPid << std::endl;
1177 std::cout <<
"Inititialized : " <<
fInitialized << std::endl;
1178 std::cout <<
"Verbose : " <<
fVerbose << std::endl;
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
R__EXTERN TSystem * gSystem
R__EXTERN TVirtualMonitoringWriter * gMonitoringWriter
Long64_t fLastBytesWritten
MonitoredTFileInfo(TFile *file, Double_t timenow)
void GetThroughputs(Long64_t &readthr, Long64_t &writethr, Double_t timenow, Double_t prectime)
void ResetFileStatus(Double_t timenow)
void UpdateFileStatus(TFile *file)
void ResetFileStatus(TFile *file, Double_t timenow)
Long64_t fTempWrittenBytes
void Update(MonitoredTFileInfo *mi, Double_t timenow, Double_t prectime)
Long64_t fWriteThroughput
MonitoredTFileSummary(TString &fileclassname)
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 composed of a header, followed by consecutive data records (TKey instances) with a wel...
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 override
Find object using its name.
void AddLast(TObject *obj) override
Add object at the end of the list.
void Clear(Option_t *option="") override
Remove all objects from the list.
void Add(TObject *obj) override
TObject * Last() const override
Return the last object in the list. Returns 0 when list is empty.
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
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.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
virtual void SetName(const char *name)
Set the name of the TNamed.
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 char * GetName() const override
Returns name of object.
const AParamType & GetVal() const
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 uint64_t sum(uint64_t i)