CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions | Variables
producerFileCleanner Namespace Reference

Functions

def getDirSize
 
def getDiskUsage
 
def logme
 
def sendmail
 

Variables

int aDelQuota = 0
 
list COLLECTDIR = sys.argv[3]
 
 delQuota = diskUsed-quota
 
string destDir = "%s/%sxxxx/%sxx/DQM_V0001_%s_R%s.root"
 
list DIR_LIST = []
 
tuple doneSize = getDirSize(TFILEDONEDIR)
 
list EMAIL = sys.argv[1]
 
int EMAILINTERVAL = 15
 
tuple EXEDIR = os.path.dirname(__file__)
 
list FILE_LIST = []
 
tuple fMatch = re.match(r"(DQM|Playback|Playback_full)_V[0-9]{4}_([0-9a-zA-Z]+)_R([0-9]{9})(_T[0-9]{8}|)\.root",f)
 
string fullFName = "%s/%s"
 
string fullSdName = "%s/%s"
 
tuple HOSTNAME = socket.gethostname()
 
int lastEmailSent = 0
 
string msg = "ERROR: Something is filling up the disks, %s does not"
 
tuple now = time.time()
 
list ORIGINALDONEDIR = sys.argv[4]
 
float PRODUCER_DU_BOT = 50.0
 
float PRODUCER_DU_TOP = 90.0
 
tuple quota = int(diskSize*PRODUCER_DU_BOT/100)
 
tuple run = fMatch.group(3)
 
string SENDMAIL = "/usr/sbin/sendmail"
 
string STOP_FILE = "%s/.stop"
 
tuple subSystem = fMatch.group(2)
 
list TFILEDONEDIR = sys.argv[2]
 
tuple TMP_LIST = glob.glob("%s/*.tmp" % COLLECTDIR)
 
int WAITTIME = 3600
 

Function Documentation

def producerFileCleanner.getDirSize (   path)

Definition at line 41 of file producerFileCleanner.py.

41 
42 def getDirSize(path):
43  import stat
44  size=os.stat(path).st_blksize
45  for directory,subdirs,files in os.walk(path):
46  dStats=os.lstat(directory)
47  size+=(dStats[stat.ST_NLINK]-1)*dStats[stat.ST_SIZE]
48  for f in files:
49  fStats=os.lstat("%s/%s" % (directory,f))
50  fSize=fStats[stat.ST_SIZE]
51  size+=fSize
52 
53  return size
def producerFileCleanner.getDiskUsage (   path)

Definition at line 33 of file producerFileCleanner.py.

33 
34 def getDiskUsage(path):
35  fsStats=os.statvfs(path)
36  size=fsStats.f_bsize*fsStats.f_blocks
37  available=fsStats.f_bavail*fsStats.f_bsize
38  used=size-available
39  usedPer=float(used)/size
40  return (size,available,used,usedPer)
def producerFileCleanner.logme (   msg,
  args 
)

Definition at line 29 of file producerFileCleanner.py.

References print().

Referenced by sendmail().

29 
30 def logme(msg, *args):
31  procid = "[%s/%d]" % (__file__.rsplit("/", 1)[-1], os.getpid())
32  print(datetime.now(), procid, msg % args)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def producerFileCleanner.sendmail (   body = "Hello from producerFileCleanner",
  subject = "Hello!" 
)

Definition at line 54 of file producerFileCleanner.py.

References logme().

54 
55 def sendmail(body="Hello from producerFileCleanner",subject= "Hello!"):
56  scall = Popen("%s -t" % SENDMAIL, shell=True, stdin=PIPE)
57  scall.stdin.write("To: %s\n" % EMAIL)
58  scall.stdin.write("Subject: producerFileCleaner problem on server %s\n" %
59  HOSTNAME)
60  scall.stdin.write("\n") # blank line separating headers from body
61  scall.stdin.write("%s\n" % body)
62  scall.stdin.close()
63  rc = scall.wait()
64  if rc != 0:
65  logme("ERROR: Sendmail exit with status %s", rc)
66 
# --------------------------------------------------------------------

Variable Documentation

int producerFileCleanner.aDelQuota = 0

Definition at line 102 of file producerFileCleanner.py.

list producerFileCleanner.COLLECTDIR = sys.argv[3]

Definition at line 12 of file producerFileCleanner.py.

producerFileCleanner.delQuota = diskUsed-quota

Definition at line 88 of file producerFileCleanner.py.

string producerFileCleanner.destDir = "%s/%sxxxx/%sxx/DQM_V0001_%s_R%s.root"

Definition at line 111 of file producerFileCleanner.py.

list producerFileCleanner.DIR_LIST = []

Definition at line 168 of file producerFileCleanner.py.

int producerFileCleanner.doneSize = getDirSize(TFILEDONEDIR)

Definition at line 75 of file producerFileCleanner.py.

list producerFileCleanner.EMAIL = sys.argv[1]

Definition at line 10 of file producerFileCleanner.py.

int producerFileCleanner.EMAILINTERVAL = 15

Definition at line 19 of file producerFileCleanner.py.

tuple producerFileCleanner.EXEDIR = os.path.dirname(__file__)

Definition at line 22 of file producerFileCleanner.py.

list producerFileCleanner.FILE_LIST = []

Definition at line 103 of file producerFileCleanner.py.

tuple producerFileCleanner.fMatch = re.match(r"(DQM|Playback|Playback_full)_V[0-9]{4}_([0-9a-zA-Z]+)_R([0-9]{9})(_T[0-9]{8}|)\.root",f)

Definition at line 107 of file producerFileCleanner.py.

string producerFileCleanner.fullFName = "%s/%s"

Definition at line 112 of file producerFileCleanner.py.

string producerFileCleanner.fullSdName = "%s/%s"

Definition at line 134 of file producerFileCleanner.py.

tuple producerFileCleanner.HOSTNAME = socket.gethostname()

Definition at line 21 of file producerFileCleanner.py.

producerFileCleanner.lastEmailSent = 0

Definition at line 26 of file producerFileCleanner.py.

string producerFileCleanner.msg = "ERROR: Something is filling up the disks, %s does not"

Definition at line 92 of file producerFileCleanner.py.

tuple producerFileCleanner.now = time.time()

Definition at line 90 of file producerFileCleanner.py.

list producerFileCleanner.ORIGINALDONEDIR = sys.argv[4]

Definition at line 13 of file producerFileCleanner.py.

float producerFileCleanner.PRODUCER_DU_BOT = 50.0

Definition at line 17 of file producerFileCleanner.py.

float producerFileCleanner.PRODUCER_DU_TOP = 90.0

Definition at line 16 of file producerFileCleanner.py.

tuple producerFileCleanner.quota = int(diskSize*PRODUCER_DU_BOT/100)

Definition at line 87 of file producerFileCleanner.py.

tuple producerFileCleanner.run = fMatch.group(3)

Definition at line 110 of file producerFileCleanner.py.

string producerFileCleanner.SENDMAIL = "/usr/sbin/sendmail"

Definition at line 20 of file producerFileCleanner.py.

string producerFileCleanner.STOP_FILE = "%s/.stop"

Definition at line 23 of file producerFileCleanner.py.

tuple producerFileCleanner.subSystem = fMatch.group(2)

Definition at line 109 of file producerFileCleanner.py.

list producerFileCleanner.TFILEDONEDIR = sys.argv[2]

Definition at line 11 of file producerFileCleanner.py.

tuple producerFileCleanner.TMP_LIST = glob.glob("%s/*.tmp" % COLLECTDIR)

Definition at line 162 of file producerFileCleanner.py.

int producerFileCleanner.WAITTIME = 3600

Definition at line 18 of file producerFileCleanner.py.