Any hookable events for DNS cluster add/del/park domain ?
Dear All.
I have 2 server:
- SRV1 ('192.168.1.60'): It's a standard CPanel installation
- SRV2 ('192.168.1.61') : It's a Cpanel DNS Only installation.
I Made DNS clustering between them so that every DNS change on SRV1 will also synced to SRV2.
My question is : How to detect in SRV2 if a zone created or deleted?
I try to have hooks in some hookable event :
/usr/local/cpanel/bin/manage_hooks add script /usr/local/cpanel/3rdparty/bin/bino_custom_script.py --manual --category Whostmgr --event Domain::addsubdomain --stage=post
/usr/local/cpanel/bin/manage_hooks add script /usr/local/cpanel/3rdparty/bin/bino_custom_script.py --manual --category Whostmgr --event Domain::delsubdomain --stage=post
/usr/local/cpanel/bin/manage_hooks add script /usr/local/cpanel/3rdparty/bin/bino_custom_script.py --manual --category Whostmgr --event Domain::park --stage=post
/usr/local/cpanel/bin/manage_hooks add script /usr/local/cpanel/3rdparty/bin/bino_custom_script.py --manual --category Whostmgr --event ParkAdmin::park --stage=post
/usr/local/cpanel/bin/manage_hooks add script /usr/local/cpanel/3rdparty/bin/bino_custom_script.py --manual --category Cpanel --event Api2::AddonDomain::addaddondomain --stage=post
/usr/local/cpanel/bin/manage_hooks add script /usr/local/cpanel/3rdparty/bin/bino_custom_script.py --manual --category Cpanel --event Api2::AddonDomain::deladdondomain --stage=post
/usr/local/cpanel/bin/manage_hooks add script /usr/local/cpanel/3rdparty/bin/bino_custom_script.py --manual --category Cpanel --event Api2::SubDomain::addsubdomain --stage=post
/usr/local/cpanel/bin/manage_hooks add script /usr/local/cpanel/3rdparty/bin/bino_custom_script.py --manual --category Cpanel --event Api2::SubDomain::delsubdomain --stage=post
and here is that basic simple script
import sys, json, requests
import traceback
args = sys.stdin.readlines()
payload = {}
for arg in args :
payload.update(json.loads(arg))
print(f'\n\nbino_payload:{payload}\n\n', file=sys.stderr)
sys.exit(0)
but nothing hapend in '/usr/local/cpanel/logs/error_log'
I can only get indication on '/usr/local/cpanel/logs/api_tokens_log'
[2024-03-15 10:12:08 +0700] info [whostmgrd] Host: ['192.168.1.60'] HTTP Status: ['200'], User: ['root'], Token Name: ['DNS-ONLY'], Request: ['POST /scripts2/getzones_local HTTP/1.1']
[2024-03-15 10:12:10 +0700] info [whostmgrd] Host: ['192.168.1.60'] HTTP Status: ['200'], User: ['root'], Token Name: ['DNS-ONLY'], Request: ['POST /scripts2/synczones_local HTTP/1.1']
[2024-03-15 10:12:10 +0700] info [whostmgrd] Host: ['192.168.1.60'] HTTP Status: ['200'], User: ['root'], Token Name: ['DNS-ONLY'], Request: ['POST /scripts2/reloadzones_local HTTP/1.1']
[2024-03-15 10:12:10 +0700] info [whostmgrd] Host: ['192.168.1.60'] HTTP Status: ['200'], User: ['root'], Token Name: ['DNS-ONLY'], Request: ['POST /scripts2/getzones_local HTTP/1.1']
[2024-03-15 10:12:12 +0700] info [whostmgrd] Host: ['192.168.1.60'] HTTP Status: ['200'], User: ['root'], Token Name: ['DNS-ONLY'], Request: ['POST /scripts2/synczones_local HTTP/1.1']
[2024-03-15 10:12:12 +0700] info [whostmgrd] Host: ['192.168.1.60'] HTTP Status: ['200'], User: ['root'], Token Name: ['DNS-ONLY'], Request: ['POST /scripts2/reloadzones_local HTTP/1.1']
[2024-03-15 10:12:13 +0700] info [whostmgrd] Host: ['192.168.1.60'] HTTP Status: ['200'], User: ['root'], Token Name: ['DNS-ONLY'], Request: ['POST /scripts2/removezone_local HTTP/1.1']
[2024-03-15 10:12:15 +0700] info [whostmgrd] Host: ['192.168.1.60'] HTTP Status: ['200'], User: ['root'], Token Name: ['DNS-ONLY'], Request: ['POST /scripts2/getzones_local HTTP/1.1']
I tried to deploy that hook on SRV1, and yes it work.
But I want to do it in SRV2, since there will more and more SRV1 and I dont want to add more complexity everytime my collage build another 'SRV1'
Sincerely
-bino-
-
Hey there! I don't believe that's going to be an option. The DNSOnly machine doesn't know why/how those domains were created, as it is only getting DNS data from the webserver, and doesn't care if those are addons or subdomains or whatnot.
It would be best to add this to your deployment plan for new webservers in order to keep things consistent.
0 -
cPRex .. well .. I don't need to know 'why and how'. I need to know when a domain created or deleted in DNSOnly machine.
Is there any way to get it other than putting a hook on SRV1 (Standard CPanel server) ?0 -
No, there isn't going to be another way to achieve that.
0
Please sign in to leave a comment.
Comments
3 comments