Closed gizmo15 closed 4 years ago
Please what return this command?
getent group | grep fail2ban
I have this :
getent group | grep fail2ban
fail2ban:x:1006:zabbix
Thank you and:
ls -l /var/run/fail2ban/fail2ban.sock
in the first post ;)
ls -l /var/run/fail2ban/fail2ban.sock
srwx-w---- 1 root fail2ban 0 mai 11 15:21 /var/run/fail2ban/fail2ban.sock
Can you write me message to whatsapp? +420732447184 I think i need remote session, to see where is problem.
not possible, i haven't whatsapp and it's a production server.
I have in my lab debian 10, zabbix-agent2
root@hosting1:~# su - zabbix -s /bin/bash -c "fail2ban-client status | grep 'Jail list:'" `- Jail list: dovecot, ispconfig, postfix-sasl, pure-ftpd, sshd
Do you have selinux?
It's an ubuntu 18.04 LTS so no selinux :
su - zabbix -s /bin/bash -c "fail2ban-client status | grep 'Jail list:'"
NOT root user
`- Jail list: postfix-auth, sshd
root@hosting1:~# fail2ban-client status | grep 'Jail list:' | sed -e 's/^.:\W+//' -e 's/((\w|-)+)/{"{#JAIL}":"\1"}/g' -e 's/./{"data":[\0]}/' {"data":[{"{#JAIL}":"dovecot"}, {"{#JAIL}":"ispconfig"}, {"{#JAIL}":"postfix-sasl"}, {"{#JAIL}":"pure-ftpd"}, {"{#JAIL}":"sshd"}]}
root@hosting1:~# su - zabbix -s /bin/bash -c "fail2ban-client status | grep 'Jail list:' | sed -e 's/^.:\W+//' -e 's/((\w|-)+)/{"{#JAIL}":"\1"}/g' -e 's/./{"data":[\0]}/'" {data:[{{#JAIL}:1}, {{#JAIL}:1}, {{#JAIL}:1}, {{#JAIL}:1}, {{#JAIL}:1}]}
root@hosting1:~# su - zabbix
zabbix@hosting1:~$ fail2ban-client status | grep 'Jail list:' | sed -e 's/^.:\W+//' -e 's/((\w|-)+)/{"{#JAIL}":"\1"}/g' -e 's/./{"data":[\0]}/'
{"data":[{"{#JAIL}":"dovecot"}, {"{#JAIL}":"ispconfig"}, {"{#JAIL}":"postfix-sasl"}, {"{#JAIL}":"pure-ftpd"}, {"{#JAIL}":"sshd"}]}
on the zabbix server side, i have a message "Unknown metric fail2ban.discovery" so, that's why i try.
but i have that in /etc/zabbix/zabbix_agent2.d/fail2ban.conf :
UserParameter=fail2ban.status[*],fail2ban-client status '$1' | grep 'Currently banned:' | grep -E -o '[0-9]+'
UserParameter=fail2ban.discovery,fail2ban-client status | grep 'Jail list:' | sed -e 's/^.*:\W\+//' -e 's/\(\(\w\|-\)\+\)/{"{#JAIL}":"\1"}/g' -e 's/.*/{"data":[\0]}/'
if i switch with zabbix user and launch the command it work, yes.
root@hosting1:~# cat /etc/zabbix/zabbix_agent2.d/fail2ban.conf
UserParameter=fail2ban.status[],fail2ban-client status '$1' | grep 'Currently banned:' | grep -E -o '[0-9]+'
UserParameter=fail2ban.discovery,fail2ban-client status | grep 'Jail list:' | sed -e 's/^.:\W+//' -e 's/((\w|-)+)/{"{#JAIL}":"\1"}/g' -e 's/.*/{"data":[\0]}/'
root@hosting1:~# cat /etc/zabbix/zabbix_agent2.conf| grep -i incl
Include=/etc/zabbix/zabbix_agent2.d/*.conf
The problem is uknow key not in script. You need path:
Download the latest version of configuration file fail2ban.conf from the repo. Put the file here /etc/zabbix/zabbix_agentd2.d/fail2ban.conf
Indeed!
cat /etc/zabbix/zabbix_agent2.conf| grep -i incl
Include=/etc/zabbix/zabbix_agentd.d/*.conf
sorry for the noise and thanks!
You are welcome. I fix howto, thanks. Can i close issue now?
Yes no problem!
Hi,
I try to use your template on a Zabbix 4.4 on Ubuntu 18.04 with zabbix-agent2.
With root your command fail2ban.discovery work :
But with the user zabbix the return is not the same :
I follow your how to
if i remove the sed part :
I missed something?
Thanks!