zabbix_ipsec_pfsense icon indicating copy to clipboard operation
zabbix_ipsec_pfsense copied to clipboard

IndexError: string index out of range

Open PGCC123 opened this issue 4 years ago • 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

PGCC123 avatar Aug 27 '20 15:08 PGCC123

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

P.S.: pfsense 2.4.5, Python 3.7

MatrixN3 avatar Aug 28 '20 08:08 MatrixN3

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

denisgrilliGMSL avatar Nov 09 '20 14:11 denisgrilliGMSL

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

denisgrilliGMSL avatar Nov 09 '20 16:11 denisgrilliGMSL

@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 avatar Aug 25 '21 13:08 alanwds

@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.

denisgrilliGMSL avatar Oct 20 '21 08:10 denisgrilliGMSL