alanwds/zabbix_ipsec_pfsense

IndexError: string index out of range

Opened this issue · 5 comments

Bom dia!

Meus parabéns pelo desenvolvimento, estou enfrentando um erro e gostaria da sua ajuda para solucionar.

A situação é a seguinte: quando executo o arquivo zabbix-ipsec.py na linha de comando me retorna o seguinte erro

Traceback (most recent call last):
File "zabbix-ipsec.py", line 119, in
ret = getPayload()
File "zabbix-ipsec.py", line 114, in getPayload
if conf[-1] == ',':
IndexError: string index out of range

Se eu executar via zabbix_get também recebo o mesmo erro

Poderia me ajudar?

Atenciosamente,
Patrick G. C. Costa

Same here, would be grate if someone will help us, please. :)

P.S.: pfsense 2.4.5, Python 3.7

How did you fix the problem of the mixed indentation?

If you run an automatic tool to convert tabs in spaces then you probably end up with the wrong code.

your specific error is because there is not control about the "conf" variable being used as array why it might not be if the previous operations are failing. So conf is not populate as expect by the code.

I personally changed the line like this:
if isinstance(conf, list) and conf[-1] == ',':

That helped to highlight the real problem: indentation on other part of the code was wrong and the code wasn't actually working.

I attached a copy of the script that is working for me

zabbix-ipsec.py.txt

I removed my attempt to fix the indexError because wasn't working.

anyway with the right indentation in file is not necessary. Attached the correct version of the .py

zabbix-ipsec.py.txt

@PGCC123 @denisgrilliGMSL I just make some improvements on script. Can you check if is working now?

PS: Obrigado pelo apoio. Desculpe, não tenho dado manutenção nesse projeto. Estamos usando cada vez menos o pfsense aqui e, portanto, estamos dando pouca manutenção. Vejo que ainda está sendo utilizado por muita gente. Vou tentar dar melhorá-lo aos poucos.

@alanwds: I didn't get a chance to test it yet, but I will do soon and I will let you know. Thanks for making the improvement.