コード例 #1
0
 def DoServerInfo(self, info):
     filewt = diskWriter()
     filename = (info["timestamp"].split(" ")[0]) + "-" + info["dev_name"]
     filepath = "data/" + info["dev_name"] + "/"
     targetpath = os.path.dirname(filepath)
     if not os.path.isdir(targetpath):
         os.makedirs(targetpath)
     filename = filepath + filename
     filewt.write(filename, str(info) + '\n')
     cpu = float(info["cpu_percent"])
     if cpu > self.cpu_max:
         self.cpu_busy = 1
     mem = float(info["mem_percent"])
     if mem > self.mem_busy:
         self.mem_busy = 1
     disk_info_list = str(info["mem_percent"])
     disk_list = disk_info_list.split(',')
     for pama in disk_list:
         if 'mountpath' not in pama:
             disk = float(pama)
             if disk > self.disk_max:
                 self.disk_busy = 1
     if self.cpu_busy == 1 | self.mem_busy == 1 | self.disk_busy == 1:
         new_time = time.time()
         if (new_time - self.last_mail_time) > 3600:
             print "#################### info user ######################"
             print "now_time=" + str(new_time) + "last_mail_time" + str(
                 self.last_mail_time)
             EmergencyReport(self.dev_name, info["cpu_percent"],
                             info["mem_percent"], info["disk_percent"])
             self.last_mail_time = time.time()
         self.cpu_busy = 0
         self.disk_busy = 0
         self.mem_busy = 0
コード例 #2
0
ファイル: WebServer.py プロジェクト: apophise/Apophise
 def DoServerInfo(self,info):
     filewt = diskWriter()                                                       
     filename = (info["timestamp"].split(" ")[0]) + "-"+ info["dev_name"]             
     filepath = "data/"+ info["dev_name"] + "/"                        
     targetpath = os.path.dirname(filepath)                                      
     if not os.path.isdir(targetpath):
         os.makedirs(targetpath)                                                 
     filename = filepath + filename                                              
     filewt.write( filename, str(info)+'\n')
     cpu = float(info["cpu_percent"])
     if cpu > self.cpu_max:
         self.cpu_busy = 1
     mem = float(info["mem_percent"])
     if mem > self.mem_busy:
         self.mem_busy = 1
     disk_info_list = str(info["mem_percent"])
     disk_list = disk_info_list.split(',')
     for pama in disk_list:
         if 'mountpath' not in pama:
             disk = float(pama)
             if disk > self.disk_max:
                 self.disk_busy = 1
     if self.cpu_busy == 1 | self.mem_busy == 1 | self.disk_busy == 1:
         new_time = time.time()
         if (new_time - self.last_mail_time) > 3600:
             print "#################### info user ######################"
             print "now_time="+str(new_time)+"last_mail_time"+str(self.last_mail_time)
             EmergencyReport(self.dev_name,info["cpu_percent"],info["mem_percent"],info["disk_percent"])
             self.last_mail_time = time.time()
         self.cpu_busy = 0
         self.disk_busy = 0
         self.mem_busy = 0
コード例 #3
0
ファイル: Ser.py プロジェクト: apophise/Apophise
def deskWriteJob(arglist, kwargs):
    filewt = diskWriter()
    info = arglist[0]
    print "in the thread is:" + str(info)
    filename = (info["timestamp"].split(" ")[0]) + "-" + info["dev_name"]
    filepath = "data/" + info["dev_name"] + "/"
    targetpath = os.path.dirname(filepath)
    if not os.path.isdir(targetpath):
        os.makedirs(targetpath)
    filename = filepath + filename
    filewt.write(filename, str(info) + '\n')
コード例 #4
0
ファイル: Ser.py プロジェクト: apophise/Apophise
def deskWriteJob( arglist, kwargs):
    filewt = diskWriter()                                                       
    info = arglist[0]
    print "in the thread is:" + str(info)
    filename = (info["timestamp"].split(" ")[0]) + "-"+ info["dev_name"]                           
    filepath = "data/"+ info["dev_name"] + "/"                        
    targetpath = os.path.dirname(filepath)                                      
    if not os.path.isdir(targetpath):
        os.makedirs(targetpath)                                                 
    filename = filepath + filename                                              
    filewt.write( filename, str(info)+'\n')