• 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

Issue Event handlers are not being executed

Visnet

Basic Pleskian
Product version: Plesk Onyx 17.5.3 Update #47
Update date: 2018/05/10 15:21
Build date: 2017/03/17 16:00
OS version: CentOS 7.4.1708
Revision: 55d1b49a272f44666e1920eca8b6e4da449a38cd
Architecture: 64-bit
Wrapper version: 1.2

Issue:

Event handler do not seem to be executed after domain creation or domain status update.

How to reproduce:

1. Create a simple custom script that logs to syslog when called:
Code:
# cat /usr/sbin/plesk-test
#!/bin/bash

# Test working of Plesk event handler by logging simple message to syslog
logger -it "plesk-test" "Plesk handler was called"

exit 0

2. Set and check script permissions:
Code:
# chmod +x /usr/sbin/plesk-test
# stat /usr/sbin/plesk-test
  File: ‘/usr/sbin/plesk-test’
  Size: 150           Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 580006      Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Context: unconfined_u:object_r:bin_t:s0
Access: 2018-05-18 16:08:11.933520672 +0200
Modify: 2018-05-18 15:07:52.607733925 +0200
Change: 2018-05-18 16:11:04.956102696 +0200
 Birth: -

3. Add event handler:
Code:
# stat /opt/psa/var/root.event.handler.lock
stat: cannot stat ‘/opt/psa/var/root.event.handler.lock’: No such file or directory

# plesk bin event_handler --list-events | grep 112
112                      Domain created

# plesk bin event_handler --create -command '/usr/sbin/plesk-test > /dev/null' -priority 0 -user root -event 112

# plesk bin event_handler --list
   Id               1
   Name             Service stopped
   Priority         0
   User             root
   Command          /usr/local/psa/admin/bin/modules/watchdog/wd --unmonit-service=<new_service> --plesk-name

   Id               2
   Name             Service started
   Priority         0
   User             root
   Command          /usr/local/psa/admin/bin/modules/watchdog/wd --monit-service=<new_service> --plesk-name

   Id               4
   Name             Domain created
   Priority         0
   User             root
   Command          /usr/sbin/plesk-test > /dev/null

4. Add a subscription or domain through Plesk

5. The script is not executed by the event handler, it does not show anything in the syslog:
Code:
# grep 'plesk-test' /var/log/messages

----------

I want to use a simple script to write all Plesk domains to a text file. This file should be updated when a domain is created or deleted. How can I use event handlers to do this?

Why is the event handler example above not executing?
 
Last edited:
What about using another command? Like:

# mysql -uadmin -p`cat /etc/psa/.psa.shadow` psa -B -e 'select name from domains' > /tmp/domain_list
 
IgorG,

Thanks for responding.
Getting a list of the domains is not the issue here.

The issue is that the Plesk event handler does not seem to execute the configured script (as shown in the example).
How to debug or fix this?
 
Have you tried to use Plesk Event Manager UI for this command?
 
Hi guys,

Thanks for your response.

I have also tried the Plesk Event Manager UI with the following commands, both to no avail:
Code:
/usr/sbin/plesk-test > /dev/null
Code:
/usr/sbin/plesk-test
No difference, the script is still not executed...

Yes, I have SELinux enabled and set to enforcing mode.
However, both `/var/log/messages` and `/var/log/audit/audit.log` do not mention anything about the script at `/usr/sbin/plesk-test` being blocked. It looks like the Plesk Event Handler is simply not executed at all (after having created a new subscription/domain).

Even after changing the SELinux user to `system_u`, no difference:
Code:
# stat /usr/sbin/plesk-test
  File: ‘/usr/sbin/plesk-test’
  Size: 155           Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 70112       Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Context: system_u:object_r:bin_t:s0
Access: 2018-06-25 10:55:19.180894015 +0200
Modify: 2018-06-25 10:48:07.635095469 +0200
Change: 2018-06-25 11:24:59.277800249 +0200
 Birth: -

The script is not executed and there is no mention in the syslog or audit log:
Code:
# grep 'plesk-test' /var/log/messages
# grep 'plesk-test' /var/log/audit/audit.log
#

Any suggestions?
 
I've removed the Event Handler, set SELinux to Permissive mode, rebooted my server:
Code:
# getenforce
Permissive
Then, I've added the Event Handler again through Plesk Event Manager providing the same command (without `> /dev/null`):
Code:
/usr/sbin/plesk-test

Does not work... No lines in the sys log related to this command either.

Why does using a simple Event Handler like this not work out of the box?
 
Apparently the "Domain created" handler is not executed when adding a new subscription (with a new domain).

I am aware that there are multiple Event Handlers for "Domain created", "Domain alias created", "Default domain (the first domain added to a subscription) created", "Default domain, alias created". Unfortunately, it seems that there is no generic handler for when a domain is created.

I would like to re-populate a list of all domains currently active in Plesk. (e.g. after a domain/domain alias is created or deleted)

Is adding the same command under all the different handlers (mentioned above) the only way to execute the command for all cases?
If so, that would mean a lot of overhead for something very simple.
A suggestion would be to create an global Event Handler for domain creation, updating or deleting.
 
Back
Top