Adding Event Handlers

To add an Event Handler:

For instance, let's create an event handler for the 'client account creation' event. The handler will accept a client name as the first parameter, and the client's login as the second. For simplicity we will use a batch file called test-handler.bat that looks as follows:

echo "--------------" >> c:\windows\temp\event_handler.log

rem information on the event date and time

date /T >> c:\windows\temp\event_handler.log

rem information on the created client account

echo "client created" >> c:\windows\temp\event_handler.log

rem client's name

echo "name: %1" >> c:\windows\temp\event_handler.log

rem client's login

echo "login: %2" >> c:\windows\temp\event_handler.log

echo "--------------" >> c:\windows\temp\event_handler.log

This script prints some information to a file so that we could control its execution.

Suppose, that our script is located in the directory c:\program files\swsoft\plesk\scripts\. Let's register it by creating an event handler via the control panel:

  1. Select the Server shortcut in the navigation pane.
  2. Click Event Manager in the Control Panel group.
  3. Click Add New Event Handler. The event handler setup page appears:
  4. Select the event you wish to assign a handler to in the Event drop-down box.
  5. Select the priority for handler execution, or specify a custom value. To do this, select custom in the Priority drop-down list and type in the value.

    When assigning several handlers to a single event you can specify the handler execution sequence, setting different priorities (higher value corresponds to a higher priority).

  6. Select the system user, on behalf of which the handler will be executed.
  7. In the Command input field, specify a command to be executed upon the selected event. In our example it is c:\program files\swsoft\plesk\scripts\test-handler.bat" <new_contact_name> <new_login_name>.

    Note that if directory names or the file name contains spaces, the path should be quoted.

  8. Click OK.

Note: In the command we have specified the parameters in the angle brackets <new_contact_name> and <new_login_name>. Before executing the handler, they will be replaced with name and login of the created client respectively. The entire list of available parameters is provided below. You should keep in mind that with the removal operations, the parameters of type new_xxx contain an empty string. And with creation operations the parameters of type old_xxx contain an empty string.

Now if you login to your Plesk control panel and create a new client, specifying the value 'Some Client' in the Contact name field, and 'some_client' in the field Login, the handler will be invoked, and the following records will be added to the c:\windows\temp\event_handler.log:

Sat Jun 26 21:46:34 NOVT 2004

client created

name: Some client

login: some_client

If you want to specify one or few handlers more, repeat the actions above for another handler.

The events that can be processed by the Event Handler are listed in the Table 2.1.

Table 2.1

Event (action) name

Description

client_create

Client account created

client_update

Client account updated

client_delete

Client account deleted

domain_create

Domain created

domain_update

Domain properties updated

domain_delete

Domain deleted

subdomain_create

Subdomain created

subdomain_update

Subdomain properties updated

subdomain_delete

Subdomain deleted

phys_hosting_create

Physical hosting created

phys_hosting_update

Physical hosting account updated

phys_hosting_delete

Physical hosting account deleted

mailname_create

Mail account created

mailname_update

Mail account updated

mailname_delete

Mail account deleted

webuser_create

Web user created

webuser_update

Web user properties updated

webuser_delete

Web user account deleted

client_limits_update

Client limits updated

domain_limits_update

Domain limits updated

maillist_create

Mailing list created

maillist_update

Mailing list updated

maillist_delete

Mailing list deleted

cp_user_login

User logged in to control panel

cp_user_logout

User logged out of control panel

dl_user_update

Domain administrator properties updated

siteapp_install

Site application installed

siteapp_reconfigure

Site application reconfigured

siteapp_unchain

Information about site application removed from database; however, the application still functions on the domain

siteapp_uninstall

Site application uninstalled

siteapppkg_install

Site application package added to application vault

siteapppkg_uninstall

Site application package removed from application vault

admin_alias_create

Additional administrator account created

admin_alias_update

Additional administrator account updated

admin_alias_delete

Additional administrator account deleted

ftpuser_create

FTP account created

ftpuser_update

FTP account updated

ftpuser_delete

FTP account deleted

client_permissions_update

Client permissions updated

service_stop

Service stopped

service_start

Service started

service_restart

Service restarted

domain_alias_create

Domain alias created

domain_alias_update

Domain alias updated

domain_alias_delete

Domain alias deleted

database_server_create

Connection to database server created

database_server_update

Connection to database server updated

database_server_delete

Connection to database server deleted

remote_dns_status_update

Remote DNS status updated

The parameter templates that can be used when setting up an event handler are presented in Table 2.2.

Table 2.2

Component name/description

Command line parameter

Notes

Old component value

New component value

For the events 'Client account created', 'Client account updated', 'Client account removed'

Login Name

old_login_name

new_login_name

required

Password

old_password

new_password

 

Contact Name

old_contact_name

new_contact_name

required

Company Name

old_company_name

new_company_name

 

Phone

old_phone

new_phone

 

Fax

old_fax

new_fax

 

E-mail

old_email

new_email

 

Address

old_address

new_address

 

City

old_city

new_city

 

State/Province

old_state_province

new_state_province

 

Postal/ZIP Code

old_postal_zip_code

new_postal_zip_code

 

Country

old_country

new_country

 

For the events 'Domain created', 'Domain updated', 'Domain deleted'

Domain Name

old_domain_name

new_domain_name

required

For the events 'Subdomain created', 'Subdomain updated', 'Subdomain deleted'

Subdomain Name

old_subdomain_name

new_subdomain_name

required

Parent Domain Name

old_domain_name

new_domain_name

required

FTP account login

old_system_user_type

new_system_user_type

 

Subdomain owner's login

old_system_user

new_system_user

 

FTP account password

old_system_user_password

new_system_user_password

 

Hard disk quota

old_hard_disk_quota

new_hard_disk_quota

 

SSI support

old_ssi_support

new_ssi_support

 

PHP support

old_php_support

new_php_support

 

CGI support

old_cgi_support

new_cgi_support

 

Perl support

old_perl_support

new_perl_support

 

Python support

old_python_support

new_python_support

 

ColdFusion support

old_coldfusion_support

new_coldfusion_support

 

ASP support

old_asp_support

new_asp_support

 

For the events 'Physical hosting created', 'Physical hosting updated'

Domain Name

old_domain_name

new_domain_name

required

IP Address

old_ip_address

new_ip_address

 

IP Type

old_ip_type

new_ip_type

 

Domain Administrator login

old_system_user

new_system_user

 

Domain Administrator password

old_system_user_password

new_system_user_password

 

Access to system

old_system_shell

new_system_shell

 

MS FrontPage Support

old_fp_support

new_fp_support

 

MS FrontPage over SSL Support

old_fpssl_support

new_fpssl_support

 

MS FrontPage Authoring

old_fp_authoring

new_fp_authoring

 

MS FrontPage Admin Login

old_fp_admin_login

new_fp_admin_login

 

MS FrontPage Admin Password

old_fp_admin_password

new_fp_admin_password

 

SSI Support

old_ssi_support

new_ssi_support

 

PHP Support

old_php_support

new_php_support

 

CGI Support

old_cgi_support

new_cgi_support

 

Perl Support

old_perl_support

new_perl_support

 

Python support

old_python_support

new_python_support

 

ColdFusion support

old_coldfusion_support

new_coldfusion_support

 

ASP Support

old_asp_support

new_asp_support

 

SSL Support

old_ssl_support

new_ssl_support

 

Custom Error Documents

old_custom_error_documents

new_custom_error_documents

 

Web Statistics

old_web_statistics

new_web_statistics

 

Hard Disk Quota

old_hard_disk_quota

new_hard_disk_quota

 

For the event 'Physical hosting deleted'

Domain Administrator login

old_system_user

new_system_user

 

Domain Name

old_domain_name

new_domain_name

required

For the events 'Mail account created', 'Mail account deleted'

Mail account

old_mailname

new_mailname

required (in the format mailname@domain)

For the event 'Mail account updated'

Mail account

old_mailname

new_mailname

required (in the format mailname@domain)

Mailbox

old_mailbox

new_mailbox

 

Password

old_password

new_password

 

Mailbox Quota

old_mailbox_quota

new_mailbox_quota

 

Redirect

old_redirect

new_redirect

 

Redirect Address

old_redirect_address

new_redirect_address

 

Mail Group

old_mail_group

new_mail_group

 

Autoresponders

old_autoresponders

new_autoresponders

 

For the event 'Web user deleted'

Domain Name

old_domain_name

new_domain_name

required

Web User Name

old_webuser_name

new_webuser_name

required

For the events 'Web user created', 'Web user updated'

Domain Name

old_domain_name

new_domain_name

required

Web User Name

old_webuser_name

new_webuser_name

required

Web User Password

old_webuser_password

new_webuser_password

 

SSI Support

old_ssi_support

new_ssi_support

 

PHP Support

old_php_support

new_php_support

 

CGI Support

old_cgi_support

new_cgi_support

 

Perl Support

old_perl_support

new_perl_support

 

Python Support

old_python_support

new_python_support

 

ColdFusion support

old_coldfusion_support

new_coldfusion_support

 

ASP Support

old_sp_support

new_asp_support

 

Hard Disk Quota

old_hard_disk_quota

new_hard_disk_quota

 

For the event 'Client limits updated'

Client Login Name

old_login_name

new_login_name

required

Maximum Number of Domains

old_maximum_domains

new_maximum_domains

 

Maximum Amount of Disk Space

old_maximum_disk_space

new_maximum_disk_space

 

Maximum Amount of Traffic

old_maximum_traffic

new_maximum_traffic

 

Maximum Number of Web Users

old_maximum_webusers

new_maximum_webusers

 

Maximum Number of Databases

old_maximum_databases

new_maximum_databases

 

Maximum Number of Mailboxes

old_maximum_mailboxes

new_maximum_mailboxes

 

Mailbox Quota

old_maximum_mailbox_quota

new_maximum_mailbox_quota

 

Maximum Number of Mail Redirects

old_maximum_mail_redirects

new_maximum_mail_redirects

 

Maximum Number of Mail Groups

old_maximum_mail_groups

new_maximum_mail_groups

 

Maximum Number of Mail Autoresponders

old_maximum_mail_autorespon ders

new_maximum_mail_autorespon ders

 

Maximum Number of Mailing Lists

old_maximum_mail_lists

new_maximum_mail_lists

 

Maximum Number of Web Applications

old_maximum_tomcat_web_appli cations

new_maximum_tomcat_web_appli cations

 

Expiration Date

old_expiration_date

new_expiration_date

 

For the event 'Domain limits updated'

Domain Name

old_domain_name

new_domain_name

required

Maximum Amount of Disk Space

old_maximum_disk_space

new_maximum_disk_space

 

Maximum Amount of Traffic

old_maximum_traffic

new_maximum_traffic

 

Maximum Number of Web Users

old_maximum_webusers

new_maximum_webusers

 

Maximum Number of Databases

old_maximum_databases

new_maximum_databases

 

Maximum Number of Mailboxes

old_maximum_mailboxes

new_maximum_mailboxes

 

Mailbox Quota

old_maximum_mailbox_quota

new_maximum_mailbox_quota

 

Maximum Number of Mail Redirects

old_maximum_mail_redirects

new_maximum_mail_redirects

 

Maximum Number of Mail Groups

old_maximum_mail_groups

new_maximum_mail_groups

 

Maximum Number of Mail Autoresponders

old_maximum_mail_autorespon ders

new_maximum_mail_autorespon ders

 

Maximum Number of Mailing Lists

old_maximum_mail_lists

new_maximum_mail_lists

 

Maximum Number of Web Applications

old_maximum_tomcat_web_appli cations

new_maximum_tomcat_web_appli cations

 

Domain Expiration Date

old_expiration_date

new_expiration_date

 

For the events 'Mailing list created', 'Mailing list updated', 'Mailing list deleted'

Domain Name

old_domain_name

new_domain_name

required

Mailing list name

old_mail_list_name

new_mail_list_name

required

Mailing list switched on

old_mail_list_enabled

new_mail_list_enabled

 

For the events 'Control panel user logged in', 'Control panel user logged out'

Contact Name

old_contact_name

new_contact_name

 

For the event 'Domain administrator account updated'

Allow domain administrator access

old_allow_domain_user_access

new_allow_domain_user_access

 

Login Name

old_login_name

new_login_name

required

Password

old_password

new_password

required

Domain Name

old_domain_name

new_domain_name

required

Contact Name

old_contact_name

new_contact_name

 

Company Name

old_company_name

new_company_name

 

Phone

old_phone

new_phone

 

Fax

old_fax

new_fax

 

E-mail

old_email

new_email

 

Address

old_address

new_address

 

City

old_city

new_city

 

State/Province

old_state_province

new_state_province

 

Postal/ZIP Code

old_postal_zip_code

new_postal_zip_code

 

Country

old_country

new_country

 

For the events 'Client site application installed', 'Client site application uninstalled'

Client Login Name

old_login_name

new_login_name

required

For the events 'Site application package installed', 'Site application package uninstalled'

Site application package name

old_site_application_package_ name

new_site_application_package_ name

required

For the events 'IP address created', 'IP address updated'

IP address

old_ip_address

new_ip_address

required

IP mask

old_ip_mask

new_ip_mask

 

Interface

old_interface

new_interface

 

IP type

old_ip_type

new_ip_type

 

For the events 'Forwarding created', 'Forwarding updated'

Domain name

old_domain_name

new_domain_name

required

IP address

old_ip_address

new_ip_address

 

Forwarding type

old_forwarding_type

new_forwarding_type

 

URL

old_url

new_url

 

For the event 'Administrator information updated'

Login name

old_login_name

new_login_name

required

Contact name

old_contact_name

new_contact_name

 

Company name

old_company_name

new_company_name

 

Phone number

old_phone

new_phone

 

Fax

old_fax

new_fax

 

E-mail

old_email

new_email

 

Address

old_address

new_address

 

CIty

old_city

new_city

 

State/Province

old_state_province

new_state_province

 

Postal/Zip code

old_postal_zip_code

new_postal_zip_code

 

Country

old_country

new_country

 

For the events 'Site application installed, reconfigured, uninstalled'

Site application name

old_package_name

new_package_name

required

For the events 'Client status updated'

Contact name

old_contact_name

new_contact_name

required

Login name

old_login_name

new_login_name

required

Status

old_status

new_status

 

For the events 'Client preferences updated'

Contact name

old_contact_name

new_contact_name

required

Login name

old_login_name

new_login_name

required

Interface skin

old_interface_skin

new_interface_skin

 

For the event 'Client's IP pool updated'

Client login name

old_login_name

new_login_name

required

IP address

old_ip_address

new_ip_address

required

Status

old_status

new_status

 

For the event 'Limit on disk space reached for the client account'

Contact name

old_contact_name

new_contact_name

required

Disk space limit

old_maximum_disk_space

new_maximum_disk_space

required

For the events 'Limit on traffic reached for the client account'

Contact name

old_contact_name

new_contact_name

required

Traffic limit

old_maximum_traffic

new_maximum_traffic

 

For the events 'Domain status updated'

Domain name

old_domain_name

new_domain_name

required

Domain status

old_status

new_status

 

For the event 'DNS zone updated for domain'

Domain name

old_domain_name

new_domain_name

required

For the event 'Limit on disk space reached for domain'

Domain name

old_domain_name

new_domain_name

required

Disk space limit

old_maximum_disk_space

new_maximum_disk_space

 

For the event 'Limit on traffic reached for domain'

Domain name

old_domain_name

new_domain_name

required

Traffic limit

old_maximum_traffic

new_maximum_traffic

 

For the event 'License key update'

License key number

old_license

new_license

required

License key type (Plesk, additional)

old_license_type

new_license_type

 

License key name (for additional keys)

old_license_name

new_license_name

 

For the events 'Additional administrator account created', 'Additional administrator account updated'

Login Name

old_login_name

new_login_name

required

Contact Name

old_contact_name

new_contact_name

 

Password

old_password

new_password

 

Account status

old_status

new_status

 

E-mail

old_email

new_email

 

For the events 'FTP account created', 'FTP account updated'

Domain Name

old_domain_name

new_domain_name

required

FTP account name

old_system_user

new_system_user

required

FTP account password

old_system_user_password

new_system_user_password

 

Hard Disk Quota

old_hard_disk_quota

new_hard_disk_quota

 

Home Directory

old_home_directory

new_home_directory

 

Read Permission

old_read_permission

new_read_permission

 

Write Permission

old_write_permission

new_write_permission

 

For the event 'FTP account removed'

FTP account name

old_system_user

new_system_user

required

Domain Name

old_domain_name

new_domain_name

required

For the event 'IP address deleted'

IP address

old_ip_address

new_ip_address

required

For the event 'Forwarding deleted'

Domain name

old_domain_name

new_domain_name

required

Forwarding type

old_forwarding_type

new_forwarding_type

 

For the event 'Client permissions updated'

Client Login Name

old_login_name

new_login_name

required

For the events 'Domain alias created', 'Domain alias updated'

Domain status

old_status

new_status

required

For more information about using Event Handler, refer to Plesk SDK documentation available at SWsoft website (swsoft.com).