本文整理汇总了Python中cuckoo.core.database.Database.fetch方法的典型用法代码示例。如果您正苦于以下问题:Python Database.fetch方法的具体用法?Python Database.fetch怎么用?Python Database.fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cuckoo.core.database.Database
的用法示例。
在下文中一共展示了Database.fetch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Scheduler
# 需要导入模块: from cuckoo.core.database import Database [as 别名]
# 或者: from cuckoo.core.database.Database import fetch [as 别名]
#.........这里部分代码省略.........
# error message and wait another round (this check is ignored
# when the freespace configuration variable is set to zero).
if self.cfg.cuckoo.freespace:
# Resolve the full base path to the analysis folder, just in
# case somebody decides to make a symbolic link out of it.
dir_path = cwd("storage", "analyses")
# TODO: Windows support
if hasattr(os, "statvfs"):
dir_stats = os.statvfs(dir_path.encode("utf8"))
# Calculate the free disk space in megabytes.
space_available = dir_stats.f_bavail * dir_stats.f_frsize
space_available /= 1024 * 1024
if space_available < self.cfg.cuckoo.freespace:
log.error(
"Not enough free disk space! (Only %d MB!)",
space_available, extra={
"action": "scheduler.diskspace",
"status": "error",
"available": space_available,
}
)
continue
# If we have limited the number of concurrently executing machines,
# are we currently at the maximum?
maxvm = self.cfg.cuckoo.max_machines_count
if maxvm and len(machinery.running()) >= maxvm:
logger(
"Already maxed out on running machines",
action="scheduler.machines", status="maxed"
)
continue
# If no machines are available, it's pointless to fetch for
# pending tasks. Loop over.
if not machinery.availables():
logger(
"No available machines",
action="scheduler.machines", status="none"
)
continue
# Exits if max_analysis_count is defined in the configuration
# file and has been reached.
if self.maxcount and self.total_analysis_count >= self.maxcount:
if active_analysis_count <= 0:
log.debug("Reached max analysis count, exiting.", extra={
"action": "scheduler.max_analysis",
"status": "success",
"limit": self.total_analysis_count,
})
self.stop()
else:
logger(
"Maximum analyses hit, awaiting active to finish off",
action="scheduler.max_analysis", status="busy",
active=active_analysis_count
)
continue
# Fetch a pending analysis task.
# TODO This fixes only submissions by --machine, need to add
# other attributes (tags etc).
# TODO We should probably move the entire "acquire machine" logic
# from the Analysis Manager to the Scheduler and then pass the
# selected machine onto the Analysis Manager instance.
task, available = None, False
for machine in self.db.get_available_machines():
task = self.db.fetch(machine=machine.name)
if task:
break
if machine.is_analysis():
available = True
# We only fetch a new task if at least one of the available
# machines is not a "service" machine (again, please refer to the
# services auxiliary module for more information on service VMs).
if not task and available:
task = self.db.fetch(service=False)
if task:
log.debug("Processing task #%s", task.id)
self.total_analysis_count += 1
# Initialize and start the analysis manager.
analysis = AnalysisManager(task.id, errors)
analysis.daemon = True
analysis.start()
# Deal with errors.
try:
raise errors.get(block=False)
except Queue.Empty:
pass
log.debug("End of analyses.")