def create_task_CleanData_template_deleted(hosts_ids): for host_id in hosts_ids: hosts = Host.objects.filter(id=host_id) for host in hosts: lista_PeriodicTasks_cadastradas = PeriodicTask.objects.filter( name__contains=('CLEANDATATASK=' + host.host_nomeTabela_snmpGet)) print(lista_PeriodicTasks_cadastradas) for periodicTask in lista_PeriodicTasks_cadastradas: periodicTask.delete() if host.host_status: itens = getItens( host_nomeTabela_snmpGet=host.host_nomeTabela_snmpGet, host_ip=host.host_ip, host_porta=host.host_porta, host_status=host.host_status) for item in itens: templates = Template.objects.filter( template_item__id=item.id, host__host_nomeTabela_snmpGet=host.host_nomeTabela_snmpGet, host__host_ip=host.host_ip, host__host_porta=host.host_porta, host__host_status=host.host_status) createTaskCleanData( host_nomeTabela_snmpGet=host.host_nomeTabela_snmpGet, templates=templates, item_id=item.id, item_tempoArmazenamentoDados=item. item_tempoArmazenamentoDados, item_tempoArmazenamentoDadosUn=item. item_tempoArmazenamentoDadosUn)
def create_task_snmpGet_host_created(host_nomeTabela_snmpGet, host_ip, host_porta, host_status, host_community): itens = getItens(host_nomeTabela_snmpGet=host_nomeTabela_snmpGet, host_ip=host_ip, host_porta=host_porta, host_status=host_status) for item in itens: templates = Template.objects.filter( template_item__id=item.id, host__host_nomeTabela_snmpGet=host_nomeTabela_snmpGet, host__host_ip=host_ip, host__host_porta=host_porta, host__host_status=host_status) createTaskSnmpGet( host_nomeTabela_snmpGet=host_nomeTabela_snmpGet, host_ip=host_ip, host_porta=host_porta, host_community=host_community, templates=templates, item_id=item.id, item_nome=item.item_nome, item_oid=item.item_oid, item_intervaloAtualizacao=item.item_intervaloAtualizacao, item_intervaloAtualizacaoUn=item.item_intervaloAtualizacaoUn, )
def create_task_CleanData_host_updated(host_nomeTabela_snmpGet, host_ip, host_porta, host_status): lista_PeriodicTasks_cadastradas = PeriodicTask.objects.filter( name__contains=('CLEANDATATASK=' + host_nomeTabela_snmpGet)) for periodicTask in lista_PeriodicTasks_cadastradas: try: periodicTask.delete() except Exception as e: print(str(e.args[0])) time.sleep(4) periodicTask.delete() if host_status: itens = getItens(host_nomeTabela_snmpGet=host_nomeTabela_snmpGet, host_ip=host_ip, host_porta=host_porta, host_status=host_status) for item in itens: templates = Template.objects.filter( template_item__id=item.id, host__host_nomeTabela_snmpGet=host_nomeTabela_snmpGet, host__host_ip=host_ip, host__host_porta=host_porta, host__host_status=host_status) createTaskCleanData( host_nomeTabela_snmpGet=host_nomeTabela_snmpGet, templates=templates, item_id=item.id, item_tempoArmazenamentoDados=item.item_tempoArmazenamentoDados, item_tempoArmazenamentoDadosUn=item. item_tempoArmazenamentoDadosUn)
def create_task_CleanData_host_created(host_nomeTabela_snmpGet, host_ip, host_porta, host_status): itens = getItens(host_nomeTabela_snmpGet=host_nomeTabela_snmpGet, host_ip=host_ip, host_porta=host_porta, host_status=host_status) for item in itens: templates = Template.objects.filter( template_item__id=item.id, host__host_nomeTabela_snmpGet=host_nomeTabela_snmpGet, host__host_ip=host_ip, host__host_porta=host_porta, host__host_status=host_status) createTaskCleanData( host_nomeTabela_snmpGet=host_nomeTabela_snmpGet, templates=templates, item_id=item.id, item_tempoArmazenamentoDados=item.item_tempoArmazenamentoDados, item_tempoArmazenamentoDadosUn=item.item_tempoArmazenamentoDadosUn)
def create_task_snmpGet_template_deleted(hosts_ids): for host_id in hosts_ids: hosts = Host.objects.filter(id=host_id) for host in hosts: lista_PeriodicTasks_cadastradas = PeriodicTask.objects.filter( name__contains=('SNMPGETTASK=' + host.host_nomeTabela_snmpGet)) print(lista_PeriodicTasks_cadastradas) for periodicTask in lista_PeriodicTasks_cadastradas: periodicTask.delete() if host.host_status: itens = getItens( host_nomeTabela_snmpGet=host.host_nomeTabela_snmpGet, host_ip=host.host_ip, host_porta=host.host_porta, host_status=host.host_status) for item in itens: templates = Template.objects.filter( template_item__id=item.id, host__host_nomeTabela_snmpGet=host.host_nomeTabela_snmpGet, host__host_ip=host.host_ip, host__host_porta=host.host_porta, host__host_status=host.host_status) createTaskSnmpGet( host_nomeTabela_snmpGet=host.host_nomeTabela_snmpGet, host_ip=host.host_ip, host_porta=host.host_porta, host_community=host.host_community, templates=templates, item_id=item.id, item_nome=item.item_nome, item_oid=item.item_oid, item_intervaloAtualizacao=item.item_intervaloAtualizacao, item_intervaloAtualizacaoUn=item. item_intervaloAtualizacaoUn)
def create_task_snmpGet_host_updated(host_nomeTabela_snmpGet, host_ip, host_porta, host_status, host_community): lista_PeriodicTasks_cadastradas = PeriodicTask.objects.filter( name__contains=('SNMPGETTASK=' + host_nomeTabela_snmpGet)) for periodicTask in lista_PeriodicTasks_cadastradas: try: periodicTask.delete() except Exception as e: print(str(e.args[0])) time.sleep(4) periodicTask.delete() if host_status: itens = getItens(host_nomeTabela_snmpGet=host_nomeTabela_snmpGet, host_ip=host_ip, host_porta=host_porta, host_status=host_status) for item in itens: templates = Template.objects.filter( template_item__id=item.id, host__host_nomeTabela_snmpGet=host_nomeTabela_snmpGet, host__host_ip=host_ip, host__host_porta=host_porta, host__host_status=host_status) createTaskSnmpGet( host_nomeTabela_snmpGet=host_nomeTabela_snmpGet, host_ip=host_ip, host_porta=host_porta, host_community=host_community, templates=templates, item_id=item.id, item_nome=item.item_nome, item_oid=item.item_oid, item_intervaloAtualizacao=item.item_intervaloAtualizacao, item_intervaloAtualizacaoUn=item.item_intervaloAtualizacaoUn)