def init_master(log, conf, tasks): global unsend_list_lock global unsend_dir mctx = conf["modules"][module.ctx_index] interval = mctx["zbx_resend_interval"] lockfile = mctx["zbx_unsend_lockfile"] unsend_dir = mctx["zbx_unsend_dir"] tasks.append( { "task_info": '"resend"', "service_task": None, "process_task": zbx_resend, "interval": interval, "record_handlers": None, "conf": conf, } ) try: unsend_list_lock = zc_lock.locked(lockfile) except zc_lock.error, e: cf.log.error("Can't create lock file %s: %s" % (lockfile, e)) return ZC_ERROR
BUFSIZE = 4096 def init_master(cf, conf, tasks): global cpushared, cpulock mctx = conf['modules'][module.ctx_index] lockfile = mctx['system_cpu_lockfile'] try: cpushared = mmap.mmap(-1, SYSTEM_CPU_SIZE, mmap.MAP_SHARED|mmap.MAP_ANONYMOUS, mmap.PROT_READ|mmap.PROT_WRITE) cpushared.seek(0) cpushared.write(struct.pack('%dq' %10, *([0] * 10))) except mmap.error, e: cf.log.error("Cpu shared %s" %(e)) return ZC_ERROR try: cpulock = zc_lock.locked(lockfile) except zc_lock.error, e: cf.log.error("Can't create lock file %s: %s" %(lockfile, e)) return ZC_ERROR return ZC_OK def merge_main_conf(cf, parent, child): ctx = child['modules'][module.ctx_index] pctx = parent['modules'][module.ctx_index] if 'system_cpu_lockfile' not in ctx: ctx['system_cpu_lockfile'] = SYSTEM_DEF_CPU_LOCKFILE return ZC_OK def merge_group_conf(cf, parent, child):