Design a Hook to monitor the Resources utilized by a Job

Please try the below as execjob_epilogue hook:

f=open(’/tmp/abc.txt’, ‘w+’)
f.write("======================================================================================\n\n\t\t\tResource Usage on %s:\n\nJobId: %s \n\tJob_Name = %s \n\tJob_Owner = %s \n\tresource_used.cpupercent = %s \n\tresource_used.cput = %s \n\tresources_used.mem = %s \n\tresources_used.ncpus = %s \n\tresources_used.vmem = %s \n\tresources_used.walltime = %s \n\tqueue = %s \n\tserver = %s \n\tAccount_Name = %s \n\tError_Path = %s \n\texec_host = %s \n\texec_vnode = %s \n\tJoin_Path = %s \n\tKeep_Files = %s \n\tOutput_Path = %s \n\tRerunable = %s \n\tResource_List.ncpus = %s \n\tResource_List.nodect = %s \n\tResource_List.place = %s \n\tResource_List.mem = %s \n\tResource_List.cput = %s\n\tResource_List.walltime = %s \n\tjobdir = %s \n\tEnvironment_Variables = PBS_O_SYSTEM=%s,PBS_O_SHELL=%s,PBS_O_HOME=%s,PBS_O_LOGNAME=%s,PBS_O_WORKDIR=%s,PBS_O_LANG=%s,PBS_O_PATH=%s,PBS_O_QUEUE=%s,PBS_O_HOST=%s \n\teuser = %s \n\tegroup = %s \n\trun_count = %s \n\t\n======================================================================================\n" % (str(datetime.datetime.now()),ji,j.Job_Name,j.Job_Owner,j.resources_used.cpupercent,j.resources_used.cput,j.resources_used.mem,j.resources_used.ncpus,j.resources_used.vmem,j.resources_used.walltime,j.queue,j.server,j.Account_Name,j.Error_Path,j.exec_host2,j.exec_vnode,j.Join_Path,j.Keep_Files,j.Output_Path,j.Rerunable,j.Resource_List[‘ncpus’],j.Resource_List[‘nodect’],j.Resource_List[‘place’],j.Resource_List[‘mem’],j.Resource_List[‘cput’],j.Resource_List[‘walltime’],j.jobdir,j.Variable_List[“PBS_O_SYSTEM”],j.Variable_List[“PBS_O_SHELL”],j.Variable_List[“PBS_O_HOME”],j.Variable_List[“PBS_O_LOGNAME”],j.Variable_List[“PBS_O_WORKDIR”],j.Variable_List[“PBS_O_LANG”],j.Variable_List[“PBS_O_PATH”],j.Variable_List[“PBS_O_QUEUE”],j.Variable_List[“PBS_O_HOST”],j.euser,j.egroup,j.run_count))
f.close()

If you improvise it, please share it with the community