示例#1
0
 def export_getAdminInfo():
   """ Send the storage element administration information
   """
   storageDict = {}
   storageDict['BasePath'] = BASE_PATH
   storageDict['MaxCapacity'] = MAX_STORAGE_SIZE
   used_space = getDirectorySize( BASE_PATH )
   available_space = getDiskSpace( BASE_PATH )
   allowed_space = MAX_STORAGE_SIZE - used_space
   actual_space = min( available_space, allowed_space )
   storageDict['AvailableSpace'] = actual_space
   storageDict['UsedSpace'] = used_space
   return S_OK( storageDict )
示例#2
0
 def export_getAdminInfo():
     """ Send the storage element administration information
 """
     storageDict = {}
     storageDict['BasePath'] = BASE_PATH
     storageDict['MaxCapacity'] = MAX_STORAGE_SIZE
     used_space = getDirectorySize(BASE_PATH)
     available_space = getDiskSpace(BASE_PATH)
     allowed_space = MAX_STORAGE_SIZE - used_space
     actual_space = min(available_space, allowed_space)
     storageDict['AvailableSpace'] = actual_space
     storageDict['UsedSpace'] = used_space
     return S_OK(storageDict)
示例#3
0
    def export_getAdminInfo(self):
        """ Send the storage element administration information
    """

        storageDict = {}
        storageDict['BasePath'] = base_path
        storageDict['MaxCapacity'] = max_storage_size
        used_space = getDirectorySize(base_path)
        available_space = getDiskSpace(base_path)
        allowed_space = max_storage_size - used_space
        actual_space = min(available_space, allowed_space)
        storageDict['AvailableSpace'] = actual_space
        storageDict['UsedSpace'] = used_space
        return S_OK(storageDict)
示例#4
0
 def export_getAdminInfo():
   """ Send the storage element administration information
   """
   storageDict = {}
   storageDict['BasePath'] = BASE_PATH
   storageDict['MaxCapacity'] = MAX_STORAGE_SIZE
   used_space = getDirectorySize(BASE_PATH)
   stats = os.statvfs(BASE_PATH)
   available_space = convertSizeUnits(stats.f_bsize * stats.f_bavail, 'B', 'MB')
   allowed_space = convertSizeUnits(MAX_STORAGE_SIZE, 'B', 'MB') - used_space
   actual_space = min(available_space, allowed_space)
   storageDict['AvailableSpace'] = actual_space
   storageDict['UsedSpace'] = used_space
   return S_OK(storageDict)
示例#5
0
 def export_getAdminInfo():
     """ Send the storage element administration information
 """
     storageDict = {}
     storageDict["BasePath"] = BASE_PATH
     storageDict["MaxCapacity"] = MAX_STORAGE_SIZE
     used_space = getDirectorySize(BASE_PATH)
     stats = os.statvfs(BASE_PATH)
     available_space = (stats.f_bsize * stats.f_bavail) / 1024 / 1024
     allowed_space = MAX_STORAGE_SIZE - used_space
     actual_space = min(available_space, allowed_space)
     storageDict["AvailableSpace"] = actual_space
     storageDict["UsedSpace"] = used_space
     return S_OK(storageDict)
  def export_getAdminInfo( self ):
    """ Send the storage element administration information
    """

    storageDict = {}
    storageDict['BasePath'] = base_path
    storageDict['MaxCapacity'] = max_storage_size
    used_space = getDirectorySize( base_path )
    available_space = getDiskSpace( base_path )
    allowed_space = max_storage_size - used_space
    actual_space = min( available_space, allowed_space )
    storageDict['AvailableSpace'] = actual_space
    storageDict['UsedSpace'] = used_space
    return S_OK( storageDict )
示例#7
0
  def execute(self):
    """ Run the module
    """
    result = self.resolveInputVariables()
    if not result['OK']:
      LOG.error("Failed to get the input parameters:", result['Message'])
      return result

    if not self.applicationLog:
      LOG.warn("Log file name missing, reverting to default")
      self.applicationLog = "AnalyseWN.log"

    info = []
    try:
      info.append("Host is %s" % socket.gethostname())
    except EnvironmentError:
      info.append("Could not determine host")
      
    size = getDiskSpace()
    if size>0:
      info.append("Local disk is %s MB"% size)
      
    fileName = '/proc/cpuinfo'
    if os.path.exists( fileName ):
      with open( fileName, 'r' ) as cpuInfoFile:
        cpu = cpuInfoFile.readlines()
      nCPU = 0
      for line in cpu:
        if line.find( 'cpu MHz' ) == 0:
          nCPU += 1
          freq = line.split()[3]
        elif line.find( 'model name' ) == 0:
          cpuModel = line.split( ': ' )[1].strip()
      info.append('CPU (model)    = %s' % cpuModel)
      info.append('CPU (MHz)      = %s x %s' % ( nCPU, freq ))
      
    fileName = '/proc/meminfo'
    if os.path.exists( fileName ):
      with open( fileName, 'r' ) as memInfoFile:
        mem = memInfoFile.readlines()
      freeMem = 0
      for line in mem:
        if line.find( 'MemTotal:' ) == 0:
          totalMem = int( line.split()[1] )
        if line.find( 'MemFree:' ) == 0:
          freeMem += int( line.split()[1] )
        if line.find( 'Cached:' ) == 0:
          freeMem += int( line.split()[1] )
      info.append( 'Memory (kB)    = %s' % totalMem )
      info.append( 'FreeMem. (kB)  = %s' % freeMem )
      
    fs = os.statvfs( "." )
    # bsize;    /* file system block size */
    # frsize;   /* fragment size */
    # blocks;   /* size of fs in f_frsize units */
    # bfree;    /* # free blocks */
    # bavail;   /* # free blocks for non-root */
    # files;    /* # inodes */
    # ffree;    /* # free inodes */
    # favail;   /* # free inodes for non-root */
    # flag;     /* mount flags */
    # namemax;  /* maximum filename length */
    diskSpace = fs[4] * fs[0] / 1024 / 1024
    info.append( 'DiskSpace (MB) = %s' % diskSpace )
      
    sha = getSharedAreaLocation()
    if not sha:
      info.append("No shared Area found here")
    else:
      info.append("Shared Area found: %s" % sha)
      info.append("Content:")
      sha_list = os.listdir(sha)
      for item in sha_list:
        info.append("   %s"% item)
      sha_size = getDirectorySize(sha)
      if sha_size:
        info.append("It uses %s MB of disk"% sha_size)
    
    
    if os.path.isdir("/cvmfs/ilc.cern.ch"):
      info.append("Has CVMFS")
    
    try:
      of = open(self.applicationLog, "w")
      of.write("\n".join(info))
      of.close()
    except OSError:
      LOG.error("Could not create the log file")
      return S_ERROR("Failed saving the site info")
    
    return S_OK()
示例#8
0
    def execute(self):
        """ Run the module
    """
        result = self.resolveInputVariables()
        if not result['OK']:
            self.log.error("Failed to get the input parameters:",
                           result['Message'])
            return result

        if not self.applicationLog:
            self.log.warn("Log file name missing, reverting to default")
            self.applicationLog = "AnalyseWN.log"

        info = []
        try:
            info.append("Host is %s" % socket.gethostname())
        except EnvironmentError:
            info.append("Could not determine host")

        size = getDiskSpace()
        if size > 0:
            info.append("Local disk is %s MB" % size)

        fileName = '/proc/cpuinfo'
        if os.path.exists(fileName):
            with open(fileName, 'r') as cpuInfoFile:
                cpu = cpuInfoFile.readlines()
            nCPU = 0
            for line in cpu:
                if line.find('cpu MHz') == 0:
                    nCPU += 1
                    freq = line.split()[3]
                elif line.find('model name') == 0:
                    cpuModel = line.split(': ')[1].strip()
            info.append('CPU (model)    = %s' % cpuModel)
            info.append('CPU (MHz)      = %s x %s' % (nCPU, freq))

        fileName = '/proc/meminfo'
        if os.path.exists(fileName):
            with open(fileName, 'r') as memInfoFile:
                mem = memInfoFile.readlines()
            freeMem = 0
            for line in mem:
                if line.find('MemTotal:') == 0:
                    totalMem = int(line.split()[1])
                if line.find('MemFree:') == 0:
                    freeMem += int(line.split()[1])
                if line.find('Cached:') == 0:
                    freeMem += int(line.split()[1])
            info.append('Memory (kB)    = %s' % totalMem)
            info.append('FreeMem. (kB)  = %s' % freeMem)

        fs = os.statvfs(".")
        # bsize;    /* file system block size */
        # frsize;   /* fragment size */
        # blocks;   /* size of fs in f_frsize units */
        # bfree;    /* # free blocks */
        # bavail;   /* # free blocks for non-root */
        # files;    /* # inodes */
        # ffree;    /* # free inodes */
        # favail;   /* # free inodes for non-root */
        # flag;     /* mount flags */
        # namemax;  /* maximum filename length */
        diskSpace = fs[4] * fs[0] / 1024 / 1024
        info.append('DiskSpace (MB) = %s' % diskSpace)

        sha = getSharedAreaLocation()
        if not sha:
            info.append("No shared Area found here")
        else:
            info.append("Shared Area found: %s" % sha)
            info.append("Content:")
            sha_list = os.listdir(sha)
            for item in sha_list:
                info.append("   %s" % item)
            sha_size = getDirectorySize(sha)
            if sha_size:
                info.append("It uses %s MB of disk" % sha_size)

        if os.path.isdir("/cvmfs/ilc.cern.ch"):
            info.append("Has CVMFS")

        try:
            of = open(self.applicationLog, "w")
            of.write("\n".join(info))
            of.close()
        except OSError:
            self.log.error("Could not create the log file")
            return S_ERROR("Failed saving the site info")

        return S_OK()