Software Development Kit

cPanel & WHM's API [+] cPanel & WHM's API [-]


Modules and Plugins [+] Modules and Plugins [-]


cPanel & WHM Hooks [+] cPanel & WHM Hooks [-]


cPAddons (Site Software) [+] cPAddons (Site Software) [-]


System Administration [+] System Administration [-]


Developer Software [+] Developer Software [-]


Back to All Documentation

Configure a Service — configureservice

This function is only available in version 11.25 and later.

This function allows you to enable or disable a service, and enable or disable monitoring of that service in the same manner as the WHM Service Manager. Services enabled will be started if not already running. Services disabled will be terminated if currently running.

Calling Functions

Using the XML API

To use the XML API to perform the configureservice function from within your custom script:

  • Append the /xml-api/configureservice function call name, plus the required variables (see below), to a URL which includes the address of your server.

  • For example, on a server whose hostname is example.com, you would include the following string in your script: https://example.com:2087/xml-api/configureservice

  • You need to be logged in with the proper permissions in order to call a function. See our document about Authenticating API Function Calls for more information about authenticating APIs from within a script.

  • You can also perform the function by entering the string in your web browser's address bar. This may be useful for testing the function call and viewing its output.

Using the JSON API

To use the JSON API to perform the configureservice function from within your custom script:

  • Append the /json-api/configureservice function call name, plus the required variables (see below), to a URL which includes the address of your server.

  • For example, on a server whose hostname is example.com, you would include the following string in your script: https://example.com:2087/json-api/configureservice

  • You need to be logged in with the proper permissions in order to call a function. See our document about Authenticating API Function Calls for more information about authenticating APIs from within a script.

  • You can also perform the function by entering the string in your web browser's address bar. This may be useful for testing the function call and viewing its output.

Variables

Input

The configureservice function takes the following required variable as input:

  • service (string) — The short name of the service you wish to configure.
    • Example: mysql

note Note: Short names for services can be found in the WHM Service Manager or in our Service Manager documentation.

This function also takes the following optional variables as input:

  • enabled (boolean) — Whether you wish to enable the service.
    • 1 — yes.
    • 0 — no.
  • monitored (boolean) — Whether you wish to monitor the service using the cPanel Service Status screen.
    • 1 — yes.
    • 0 — no.

PICK About Exim: There is currently no way of assigning Exim to a non-default port via the XML API; you must use the exim on another port option in the WHM Service Manager. Disabling Exim via the XML API will disable it on all ports. Re-enabling Exim via the XML API will cause it to run on the same port(s) to which it was assigned before it was disabled.

Output

  • configureservice — Root-level XML tag for the output of the configureservice function.
    • result — Container for the information about the configureservice function call.
      • status (boolean) — Whether the call was successful.
        • 1 — success.
        • 0 — failure.
      • statusmsg (string) — Status or error message about the configureservice function call.

Examples

XML API

Calling the following function in WebHost Manager:

https://example.com:2087/xml-api/configureservice?service=melange&enabled=0&monitored=0

will produce output similar to:

<configureservice>
     <result>
          <status>1</status>
          <statusmsg>
          Disabled melange.  Disabled monitoring for melange.
          </statusmsg>
     </result>
</configureservice>

JSON API

Calling the following function in WebHost Manager:

https://example.com:2087/json-api/configureservice?service=melange&enabled=0&monitored=0

will produce output similar to:

{
   "result":[
      {
         "status":1,
         "statusmsg":"Disabled monitoring for melange."
      }
   ]
}

Topic revision: r5 - 29 Oct 2010 - 15:24:22 - MelanieSeibert