Mgrctl utility
Mgrctl is a utility that is used for performing operations with a control panel and calling its functions from the command line. The default location of the utility is /usr/local/mgr5/sbin/mgrctl.
Syntax
/usr/local/mgr5/sbin/mgrctl [-m <manager>] [-u | -i [lang=<language>] | -l | [[-o <output format>] [-R | <funcname> [[<param>=<value>] ...]] [[-e ‘<param>=$<ENV_NAME>’] ...]]]
-m
- core — COREmanager;
- ispmgr — ISPmanager;
- ispmgrnode — a cluster node in ISPmanager Business;
- billmgr — BILLmanager;
- vmmgr — VMmanager KVM or Cloud;
- vemgr — VMmanager OVZ;
- dcimgr — DCImanager;
- dcimini — DCImanager location;
- ipmgr — IPmanager;
- dnsmgr — DNSmanager.
-i — brief information about the functions of the control panel. If the function
-o
-l — suspend a control panel. The panel is suspended with the function exit. It cannot be restarted.
-u — resume the control panel that has been suspended with the -l key.
- The command mgrctl -m
-l was executed to suspend several control panels on the server including COREmanager. - COREmanager was activated with the command mgrctl -m core -u.
-R — restart the control panel before the function is executed.
=
-e ‘=$
Conveying parameters via environment variables
To convey secret data in mrgctl parameters, you can use environment variables. Run the utility with the parameter
-e ‘<param>=$<ENV_NAME>’
Example of conveying a password
- Set the password value in the SECRET_PASSWORD environment variable:
export SECRET_PASSWORD=secret
- Create an FTP user in ISPmanager:
/usr/local/mgr5/sbin/mgrctl -m ispmgr ftp.user.edit name=ftpuser home=/ owner=www-root -e 'passwd=$SECRET_PASSWORD' sok=ok
Examples
General examples
Terminate the control panel
/usr/local/mgr5/sbin/mgrctl -m <manager> exit
Retrieve a list of all the mgrctl functions for the control panel
/usr/local/mgr5/sbin/mgrctl -m <manager> -i
Retrieve a list of parameters of a certain function
/usr/local/mgr5/sbin/mgrctl -m <manager> -i funcname lang=ru
Examples for ISPmanager
Retrieve a list of all Web-domains
/usr/local/mgr5/sbin/mgrctl -m ispmgr webdomain | sed 's/=/ /' | awk '{print $2}'
A list of all Web-domains that belong to the certain user
/usr/local/mgr5/sbin/mgrctl -m ispmgr webdomain su=<user> | sed 's/=/ /' | awk '{print $2}'
Update all domains on external name servers
for i in $(/usr/local/mgr5/sbin/mgrctl -m ispmgr webdomain | awk '{print $1}' | awk -F = '{print $2}'); do /usr/local/mgr5/sbin/mgrctl -m ispmgr domain.fix elid=$i; done
Disable PHP for all WWW-domains
for i in $(/usr/local/mgr5/sbin/mgrctl -m ispmgr webdomain | awk '{print $1}' | awk -F = '{print $2}'); do /usr/local/mgr5/sbin/mgrctl -m ispmgr webdomain.edit php=off elid=$i sok=ok; done
Examples for BILLmanager
Disable the tariff plan
/usr/local/mgr5/sbin/mgrctl -m billmgr pricelist.suspend elid=<id>
Examples for VMmanager KVM and Cloud
Stop virtual machines
/usr/local/mgr5/sbin/mgrctl -m vmmgr vm.stop elid=<id1>,<id2>
Stop all virtual machines
for i in $(/usr/local/mgr5/sbin/mgrctl -m vmmgr vm | awk '{print $1}' | awk -F= '{print $2}'); do /usr/local/mgr5/sbin/mgrctl -m vmmgr vm.stop elid=$i; done
Retrieve the names of all running virtual machines
/usr/local/mgr5/sbin/mgrctl -m vmmgr vm | grep running | awk '{print $2}' | awk -F= '{print $2}'
Examples for VMmanager OVZ
Restart the container
/usr/local/mgr5/sbin/mgrctl -m vemgr vm.restart elid=<id>
Retrieve a list of all OS templates
/usr/local/mgr5/sbin/mgrctl -m vemgr osmgr | sed 's/=/ /g' | awk '{print $4}'
Install/Update OS templates
for i in $(/usr/local/mgr5/sbin/mgrctl -m vemgr osmgr | sed 's/=/ /g' | awk '{print $2}'); do /usr/local/mgr5/sbin/mgrctl -m vemgr osmgr.install elid=$i sok=ok; done
Examples for DCImanager
Retrieve the names of all the servers located in the rack
/usr/local/mgr5/sbin/mgrctl -m dcimgr server su=<admin> | grep '<rack>' | awk '{print $2}' | awk -F= '{print $2}'
Create a control panel administrator
/usr/local/mgr5/sbin/mgrctl -m dcimgr user.edit name=<admin> level=lvAdmin passwd=<pass> confirm=<pass> sok=ok
Examples for IPmanager
Statistics on allocated IP addresses
/usr/local/mgr5/sbin/mgrctl -m ipmgr permstat
Examples for DNSmanager
Updates domain names of slave servers
/usr/local/mgr5/sbin/mgrctl -m dnsmgr domain.refresh elid=<domain>
Updated data for all the user's domains
for i in $(/usr/local/mgr5/sbin/mgrctl -m dnsmgr domain su=<user> | awk '{print $4}' | awk -F= '{print $2}'); do /usr/local/mgr5/sbin/mgrctl -m dnsmgr domain.refresh elid=$i; done