import logging
import KernelBasis
# outFileNameSave stores the content of outFileName during phase of dumping
- with tempfile.NamedTemporaryFile(prefix=os.path.basename(dirNameToInspect2),dir=os.path.dirname(dirNameToInspect2)) as f:
+ with tempfile.NamedTemporaryFile(prefix="fs_monitor_",suffix=".txt") as f:
outFileNameSave = f.name
with tempfile.NamedTemporaryFile(prefix="fs_monitor_",suffix=".py") as f:
tempPyFile = f.name
import time
import datetime
with open("{tempOutFile}","a") as f:
+ f.write( "{{}}\\n".format( "{dirNameToInspect2}" ) )
while(True):
- nbinodes = sp.check_output("{{}} | wc -l".format( " ".join(["find",os.path.dirname( "{dirNameToInspect2}" )]), ), shell = True).decode().strip()
- szOfDirStr = re.split("[\s]+",sp.check_output(["du","-sh",os.path.dirname( "{dirNameToInspect2}" )]).decode())[0]
+ nbinodes = sp.check_output("{{}} | wc -l".format( " ".join(["find","{dirNameToInspect2}"]), ), shell = True).decode().strip()
+ szOfDirStr = re.split("[\s]+",sp.check_output(["du","-sh","{dirNameToInspect2}"]).decode())[0]
f.write( "{{}}\\n".format( str( datetime.datetime.now().timestamp() ) ) )
f.write( "{{}}\\n".format( str( nbinodes ) ) )
f.write( "{{}}\\n".format( str( szOfDirStr ) ) )
outFileName = FileDeleter( tempOutFile )
else:
outFileName = FileHolder(outFileName)
- pid = KernelBasis.LaunchMonitoring( tempPyFile )
- return MonitoringInfo(pyFileName,outFileName,pid)
+ return MonitoringInfo(pyFileName,outFileName,None)
def CPUMemoryMonitoring( intervalInMs, outFileName = None ):
"""
"""
return ReadCPUMemInfoInternal( monitoringInfo.outFileName.filename )
+class InodeSizeInfo:
+ def __init__(self, dirNameMonitored, timeStamps, nbInodes, volumeOfDir):
+ """
+ Args:
+ ----
+ timeStamps (list<datetimestruct>)
+ nbInodes (list<int>)
+ volumeOfDir (list<str>)
+ """
+ self._dir_name_monitored = dirNameMonitored
+ self._data = [(t,a,b) for t,a,b in zip(timeStamps,nbInodes,volumeOfDir)]
+ def __str__(self):
+ st = """Filename monitored : {self.dirNameMonitored}
+Data : ${self.data}
+""".format( **locals() )
+ return st
+ @property
+ def dirNameMonitored(self):
+ return self._dir_name_monitored
+ @property
+ def data(self):
+ """
+ list of triplets. First param of triplet is datetimestruct
+ Second param of triplet is #inodes.
+ Thirst param of triplet is size.
+ """
+ return self._data
+
def ReadInodeSizeInfoInternal( fileName ):
import datetime
+ import os
with open(fileName, "r") as f:
coarseData = [ elt.strip() for elt in f.readlines() ]
+ dirNameMonitored = coarseData[0] ; coarseData = coarseData[1:]
tss = [ datetime.datetime.fromtimestamp( float(elt) ) for elt in coarseData[::3] ]
nbInodes = [int(elt) for elt in coarseData[1::3]]
volumeOfDir = coarseData[2::3]
- return [(t,a,b) for t,a,b in zip(tss,nbInodes,volumeOfDir)]
+ return InodeSizeInfo(dirNameMonitored,tss,nbInodes,volumeOfDir)
def ReadInodeSizeInfo( monitoringInfo ):
"""
Returns
-------
- list<datetime,int,str> : list of triplets. First param of triplet is datetimestruct
- Second param of triplet is #inodes.
- Thirst param of triplet is size.
+ InodeSizeInfo
"""
return ReadInodeSizeInfoInternal( monitoringInfo.outFileName.filename )
salome.logm.clear()
#PROXY_THRES = "-1"
PROXY_THRES = "1"
- with SALOME_PyNode.GenericPythonMonitoringLauncherCtxMgr( SALOME_PyNode.FileSystemMonitoring(1000,salome.__file__) ) as monitoringParamsForFileMaster:
+ with SALOME_PyNode.GenericPythonMonitoringLauncherCtxMgr( SALOME_PyNode.FileSystemMonitoring(1000,os.path.dirname( salome.__file__ )) ) as monitoringParamsForFileMaster:
with SALOME_PyNode.GenericPythonMonitoringLauncherCtxMgr( SALOME_PyNode.CPUMemoryMonitoring(1000) ) as monitoringParamsMaster:
with tempfile.TemporaryDirectory() as tmpdirnameMonitoring:
monitoringFile = os.path.join( str( tmpdirnameMonitoring ), "zeHtop.pckl" )
with tempfile.TemporaryDirectory() as tmpdirnameMonitoring:
fsMonitoringFile = os.path.join( str( tmpdirnameMonitoring ), "zeFS.txt" )
cpuMemMonitoringFile = os.path.join( str( tmpdirnameMonitoring ), "zeCPUMem.txt" )
- with SALOME_PyNode.GenericPythonMonitoringLauncherCtxMgr( SALOME_PyNode.FileSystemMonitoring(1000,salome.__file__,fsMonitoringFile) ) as monitoringParamsForFileMaster:
+ with SALOME_PyNode.GenericPythonMonitoringLauncherCtxMgr( SALOME_PyNode.FileSystemMonitoring(1000,os.path.dirname( salome.__file__ ),fsMonitoringFile) ) as monitoringParamsForFileMaster:
with SALOME_PyNode.GenericPythonMonitoringLauncherCtxMgr( SALOME_PyNode.CPUMemoryMonitoring(1000,cpuMemMonitoringFile) ) as monitoringParamsMaster:
monitoringFile = os.path.join( str( tmpdirnameMonitoring ), "zeHtop.pckl" )
monitoringFileTwo = os.path.join( str( tmpdirnameMonitoring ), "zeHtopTwo.pckl" )