• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Fail2Ban Installation fails

weelk

Basic Pleskian
Ubuntu 10.04.4 LTS
12.0.18 Update #46, last updated at May 15, 2015 03:57 AM

Just recently (after update #46) Fail2Ban stopped working and I couldn't restart it or pin point the reason behind it. I decided to uninstall F2B component via Plesk installer. F2B uninstalled however when I try to install it again I get error
'Installation will not continue'

Where to start and where can I find log files that could give me some clues? Thanks.
 
Thank you for reply.
I do have it bookmarked and searched through logs however I did not find enough clues to come to conclusion.
Now the problem is fixed but I could not identify the source of the initial problem - F2B failing to start.

My fix:

Reinstall F2B
I my case getting package lists got corrupt and reinstall with Plesk ended up with 'Installation will not continue' (clues found in /var/log/plesk/installautoinstaller3.log)
run:
#sudo dpkg --configure -a
to fix corrupted lists
Try to install Fail2ban again. It should go just fine.
 
After reinstalling Fail2ban problem persists. Service fails to start with timeout.

/var/log/panel.log

Code:
ERROR:f2bmng:Timeout of 10 seconds has been reached. Lock 'service.fail2ban' is already owned by another process with pid <unknown>

file: /opt/psa/admin/plib/Service/Agent/Transport/Local/Exec.php
line: 57
code: 0
trace: #0 /opt/psa/admin/plib/Service/Agent/Transport/Local.php(60): Service_Agent_Transport_Local_Exec->process(0, Object(Service_Agent_Command_Exec), Object(Service_Agent_Transport_LocalTransaction))
#1 /opt/psa/admin/plib/Service/Agent/Transport/Local.php(26): Service_Agent_Transport_Local->_command(0, Object(Service_Agent_Command_Exec), Object(Service_Agent_Transport_LocalTransaction))
#2 /opt/psa/admin/plib/Service/Agent.php(172): Service_Agent_Transport_Local->process('1c15b661460030e...', Array)
#3 /opt/psa/admin/plib/Service/Agent.php(241): Service_Agent->commit()
#4 /opt/psa/admin/plib/Ip/Ban/Manager.php(450): Service_Agent->execAndGetResponse('f2bmng', Array, '')
#5 /opt/psa/admin/plib/Ip/Ban/Manager.php(76): Ip_Ban_Manager->_callUtility('--status')
#6 /opt/psa/admin/plib/CommonPanel/Controller/Helper/Update.php(103): Ip_Ban_Manager->getStatus()
#7 /opt/psa/admin/plib/CommonPanel/Controller/Helper/Update.php(83): CommonPanel_Controller_Helper_Update::_addFail2banInfo(Object(Zend_View))
#8 /opt/psa/admin/application/admin/controllers/HomeController.php(161): CommonPanel_Controller_Helper_Update::getSystemOverview(Object(Zend_View))
#9 /opt/psa/admin/application/admin/controllers/HomeController.php(44): Admin_HomeController->_prepareSystemOverview()
#10 /opt/psa/admin/externals/Zend/Controller/Action.php(516): Admin_HomeController->adminAction()
#11 /opt/psa/admin/externals/Zend/Controller/Dispatcher/Standard.php(295): Zend_Controller_Action->dispatch('adminAction')
#12 /opt/psa/admin/externals/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#13 /opt/psa/admin/plib/Application/Web.php(38): Zend_Controller_Front->dispatch(NULL)
#14 /opt/psa/admin/htdocs/application.php(15): Plesk\Application_Web->run()
#15 {main}

Also getting this after restart:

Code:
ERROR: Zend_Db_Adapter_Exception: SQLSTATE[HY000] [2002] No such file or directory (Abstract.php:144)
 
Thank you for your suggestions. However none of the KBs really worked in my case.

Fail2Ban
  1. Fail2ban will not reinstall with autoinstaller.
  2. F2b service is shown as stopped in plesk dashboard. After clicking change it takes about 3-5 minutes to load config page for f2b (no timeout). After page loaded I've enabled f2b and again a few minutes to get confirmation message that f2b successfully enable. Back to plesk dashboard and now I have dashboard loadin a few minutes with f2b service failed to start
  3. Autoinstaller shows Fail2ban as not installed
  4. Trying to reinstall = no error but autoinstaller still shows the component as not installed (btw f2b is present in plesk dashboard at the same time)
  5. Uninstalled f2b packages manually via command line
  6. Trying to install again with autoinstaller and it since about 30min installing packages (nothing happens)
ERROR: Zend_Db_Adapter_Exception: SQLSTATE[HY000] [2002] No such file or directory

  1. Tried KB solution but ps ax | grep mysql.sock | grep -v grep returns nothing
  2. No /etc/my.cnf file on my server
  3. MYSQL_SOCKET /var/run/mysqld/mysqld.sock is present in /etc/psa/psa.conf
  4. No reference to socket in /opt/psa/admin/conf/php.ini
Further advice much appreciated
 
Autoinstaller still running Fail2ban installation since 12h and got stuck. I'm not sure if I should stop it manually by now and interrupt installation process? As a result I'm getting plesk update error (in the mean time) because installer is busy.
Code:
Execution failed.
Command: autoinstaller
Arguments: Array
(
    [0] => --select-product-id
    [1] => plesk
    [2] => --select-release-current
    [3] => --upgrade-installed-components
    [4] => --include-components-from-class
    [5] => vendor=parallels
    [6] => --include-components-from-class
    [7] => patched
)

Details: Doing restart of Parallels Installer...

BUSY: Update operation was locked by another update process.
 
Thanks for reply Igor. I have killed autoinstaller and restarted the server. Will try to run it again. Currently the situation is as follows.
1. fail2ban is present in dashboard with service failed status
2. Autoinstaller shows fail2ban as uninstalled
 

Attachments

  • 2015-05-26 14_56_24.png
    2015-05-26 14_56_24.png
    10.2 KB · Views: 4
  • 2015-05-26 14_57_06-Parallels Installer.png
    2015-05-26 14_57_06-Parallels Installer.png
    59.4 KB · Views: 4
I have found this in log/plesk/install/plesk_12.0.18_installation.log
Code:
===> Checking for previous installation ... found.
Trying to upgrade Fail2Ban configuration (bootstrapper-post stage)... Unable to upgrade 'fail2ban' to the latest version, since its configuration is in broken state. Run bootstrapper repair to fix.

WARNING!
Some problems are found during upgrade Fail2Ban configuration (bootstrapper-post stage)(see log file: /var/log/plesk/install/plesk_12.0.18_installation.log)

I will run bootstrapper repair and see if it fixes config file
 
Bootstrapper repair doesn't fix the problem. Here's output:

Code:
Trying to upgrade and repair Fail2Ban configuration (bootstrapper-prep stage)... Skipping stage 'bootstrapper-prep' of upgrade for 'fail2ban' as previous upgrade attempt was not finished on another stage.

WARNING!
Some problems are found during upgrade and repair Fail2Ban configuration (bootstrapper-prep stage)(see log file: /var/log/plesk/install/plesk_12.0.18_repair.log)

Continue...

Trying to upgrade and repair Fail2Ban configuration (bootstrapper-post stage)... Skipping stage 'bootstrapper-post' of upgrade for 'fail2ban' as previous upgrade attempt was not finished on another stage.

WARNING!
Some problems are found during upgrade and repair Fail2Ban configuration (bootstrapper-post stage)(see log file: /var/log/plesk/install/plesk_12.0.18_repair.log)

Perhaps I should try to remove f2b with:

sudo apt-get purge --auto-remove fail2ban

Is it safe to purge the configs? Or will this affect f2b plesk integration?

Thanks
 
Thanks UFHH01

I can't remove fail2ban as per KB given above because is not present in autoinstaller.
Please see my previous post #11 Fail2Ban Installation fails

also on my system both files are present:

# ll /etc/init.d/fail2ban /etc/fail2ban/fail2ban.conf
-rw-r--r-- 1 root root 1525 Mar 15 2014 /etc/fail2ban/fail2ban.conf
-rwxr-xr-x 1 root root 2141 Aug 15 2014 /etc/init.d/fail2ban*
 
Hi weelk,

while using "dpkg --configure -a" you seem to have installed the vendor's Fail2Ban version and not the Plesk integrated one. You will certainly have issues this way, as well, because you mix up dpkg and apt-get with Plesk autoinstaller.

Yes, it is "save" and recommended to uninstall your vendor's Fail2Ban installation. Just make a copy of your Fail2Ban jail - configuration(s), if you did some changes ( command: cp /etc/fail2ban /etc/fail.backup ) and remove Fail2Ban with apt-get. Afterwards, please delete any possible left over files from "/etc/fail2ban" and remove as well the folder ( you still have a backup... so nothing will be lost! ).


Your last step would be to re-install Fail2Ban with the Plesk autoinstaller, using the command:

/usr/local/psa/admin/bin/autoinstaller --select-product-id plesk --select-release-current --reinstall-patch --install-component fail2ban


If you experience issues, please always investigate the depending log - files, before you try to "repair" things. The bootstrapper repair.log and the autoinstaller.log are always there to help to solve issues. Please keep in mind to use suggestions from knowledge-base - articles and from the Plesk - Forum, before you try to find resolutions from non-Plesk - sites, because as you can see, this will cause even MORE issues/problems and it is very time investing to guide you back to the initial state to solve your issue.
 
Thank you UFHH01 for your wise words. I do agree indeed. However I'm a one man band and always want to research and try possible solutions before asking anybody for help. Sometimes it does not work out very well.
Your solution worked perfectly. Thank you for your help. It is much appreciated.
 
Continuing fail2ban saga. Everything seemed OK for some short period of time after reinstalling f2b. However it shuts down at random intervals with failed message. this is what I get before it shuts down:

Code:
2015-06-26 09:36:57,423 fail2ban.jail   [14252]: INFO    Jail 'plesk-apache-badbot' started
2015-06-26 09:36:57,434 fail2ban.jail   [14252]: INFO    Jail 'recidive' started
2015-06-26 09:36:57,518 fail2ban.jail   [14252]: INFO    Jail 'plesk-roundcube' started
2015-06-26 09:36:57,519 fail2ban.jail   [14252]: INFO    Jail 'plesk-apache' started
2015-06-26 09:36:57,529 fail2ban.jail   [14252]: INFO    Jail 'plesk-dovecot' started
2015-06-26 09:36:57,533 fail2ban.jail   [14252]: INFO    Jail 'postfix-sasl' started
2015-06-26 09:36:57,535 fail2ban.jail   [14252]: INFO    Jail 'ssh' started
2015-06-26 09:36:57,536 fail2ban.jail   [14252]: INFO    Jail 'plesk-postfix' started
2015-06-26 09:36:57,537 fail2ban.jail   [14252]: INFO    Jail 'plesk-panel' started
2015-06-26 09:36:57,538 fail2ban.jail   [14252]: INFO    Jail 'plesk-horde' started
2015-06-26 09:36:57,538 fail2ban.jail   [14252]: INFO    Jail 'plesk-proftpd' started
2015-06-26 09:36:57,984 fail2ban.actions.action[14252]: ERROR   iptables -N fail2ban-plesk-postfix
iptables -A fail2ban-plesk-postfix -j RETURN
iptables -I INPUT -p tcp -m multiport --dports smtp,smtps,smtpd,submission -j fail2ban-plesk-postfix returned 200
2015-06-26 09:38:25,252 fail2ban.actions.action[649]: ERROR   iptables -D INPUT -p tcp -m multiport --dports http,https,7080,7081 -j fail2ban-BadBots
iptables -F fail2ban-BadBots
iptables -X fail2ban-BadBots returned 100
2015-06-26 09:43:34,400 fail2ban.jail   [649]: INFO    Jail 'plesk-apache-badbot' stopped
2015-06-26 09:52:50,497 fail2ban.jail   [649]: INFO    Jail 'recidive' stopped
2015-06-26 09:52:51,594 fail2ban.jail   [649]: INFO    Jail 'plesk-roundcube' stopped
2015-06-26 09:52:52,613 fail2ban.jail   [649]: INFO    Jail 'plesk-panel' stopped
2015-06-26 09:52:53,587 fail2ban.jail   [649]: INFO    Jail 'plesk-apache' stopped
2015-06-26 09:52:54,641 fail2ban.jail   [649]: INFO    Jail 'plesk-dovecot' stopped
2015-06-26 09:52:55,589 fail2ban.jail   [649]: INFO    Jail 'postfix-sasl' stopped
2015-06-26 09:52:56,501 fail2ban.actions[649]: WARNING [ssh] Unban 182.100.67.114
2015-06-26 09:52:56,515 fail2ban.actions.action[649]: ERROR   iptables -D INPUT -p tcp --dport ssh -j fail2ban-SSH
iptables -F fail2ban-SSH
iptables -X fail2ban-SSH returned 100
2015-06-26 09:52:56,595 fail2ban.jail   [649]: INFO    Jail 'ssh' stopped
2015-06-26 09:52:58,058 fail2ban.jail   [649]: INFO    Jail 'plesk-postfix' stopped
2015-06-26 09:52:58,592 fail2ban.jail   [649]: INFO    Jail 'plesk-horde' stopped
2015-06-26 09:52:59,592 fail2ban.jail   [649]: INFO    Jail 'plesk-proftpd' stopped
2015-06-26 09:52:59,593 fail2ban.server [649]: INFO    Exiting Fail2ban
 
Hi weelk,

Fail2Ban and it's actions are sometimes "too fast" and commands may result in errors. If you would get rid of such errors, you could help yourself, by inserting a sleep timer into the python file "/usr/bin/fail2ban-client".

Suggestion:

Copy "/usr/bin/fail2ban-client" to "/usr/bin/fail2ban-client.backup"
( command: cp /usr/bin/fail2ban-client /usr/bin/fail2ban-client.backup )

Search for ( in : "/usr/bin/fail2ban-client" and insert )
Code:
    def __processCmd(self, cmd, showRet = True):
        beautifier = Beautifier()
        streamRet = True
        for c in cmd:
and insert in the next line:
Code:
       time.sleep(0.1)
Afterwards, please restart Fail2Ban with the command: "service fail2ban restart"​

Be aware that upgrades/updates/patches may overwrite your settings, so please make sure to control "/usr/bin/fail2ban-client", after upgrades/updates/patches, to make sure, that your settings are still existing.
 
Back
Top