Error: IndexError: string index out of range ==> Execute
Opened this issue · 4 comments
Traceback (most recent call last):
File "/usr/local/bin/zabbix-ipsec.py", line 117, in
ret = getPayload()
File "/usr/local/bin/zabbix-ipsec.py", line 111, in getPayload
if conf[-1] == ',':
IndexError: string index out of range
I use Python 3.7 and ZabbixAgentd 4.0.27. My pfSense version is 2.5.1-RELEASE(amd64)
Solved!
https://github.com/smejdil/zabbix_ipsec_pfsense/blob/master/scripts/zabbix-ipsec.py
/usr/local/bin/python3.7 /usr/local/bin/zabbix-ipsec3.py
Traceback (most recent call last):
File "/usr/local/bin/zabbix-ipsec3.py", line 126, in
ret = getPayload()
File "/usr/local/bin/zabbix-ipsec3.py", line 107, in getPayload
data = parseConf().items()
File "/usr/local/bin/zabbix-ipsec3.py", line 79, in parseConf
m1 = m1.group(0)
AttributeError: 'NoneType' object has no attribute 'group'
@krolingo I just make some improvement on zabbix-ipsec script (the most part of then, identation). Can you check if is working know?
Hi,
Thank you @alanwds for this work, I find it really useful and well done.
Maybe this issue is resolved since then, but I encountered the same problem.
Here are the modifications I made for the zabbix-ipsec.py script to work again after the tunnels name has been changed from connxxxx to conx, and for the description to be well displayed :
-
line 8, ensure that the variable IPSEC_CONF points to the new path : IPSEC_CONF = '/var/etc/ipsec/swanctl.conf'
-
line 61 in the parseConf() function, edit the regex for the reg_conn variable : from re.compile('^conn\s((?!%default).*)') to reg_conn = re.compile('^\s*con[0-9]')
-
I added the following variable to fetch the IPSEC VPN description (line 65 for me) :
reg_descr = re.compile('(?<=# P1 (ikeid [0-9]): ).*') -
line 89 for me, after
if m2:
right_tmp.append(m2)
I added the following operations :
descr_tmp = list()
m3 = re.search(reg_descr, g)
m3 = m3.group(0)
if m3:
descr_tmp.append(m3)
- And finally line 98 for me, the new data variable is populated with the description : data[conn_tmp[0]] = [left_tmp[0], right_tmp[0], descr_tmp[0]]
I attached the edited version of zabbix-ipsec.py to this reply, hope someone will find this useful!