Add to Favourites Add to Favourites    Print this Article Print this Article

Actively testing a DirectAdmin connection to ensure it is running

By default, the dataskq will make sure that the "directadmin" process is running.
You can take it a step further if you'd like to confirm that DA is responding and a user/pass is working correctly.
  1. First, create a login key for a sample DirectAdmin account.
    • Key Name: curltest
    • Key Value: Random
    • Expires On: Never
    • Uses: 0
    • Commands: Allow: CMD_API_LOGIN_TEST
    • Allowed IPs:
    and enter your current password to create the key.  The long string on the next page will be the password you'll use below.
  2. Type in your and here.
  3. Edit the script:


    and paste in the code


    #DEBUG=0 normal running after settings confirmed
    #DEBUG=1 basic output during testing to confirm settings
    #DEBUG=2 raw output to see what's going on



    echo -n '' > ${CONFIG}
    echo "user = \"${USER}:${PASSWORD}\"" >> ${CONFIG}

    RUN="curl --config ${CONFIG} --silent --show-error"

    if [ "${DEBUG}" -ge 2 ]; then
           eval $RUN
           #stderr to cron output
           RESULT=`eval $RUN 2>&1`
           COUNT=`echo "$RESULT" | grep -c 'error=0'`
           if [ "${COUNT}" -gt 0 ]; then
                   if [ "${DEBUG}" -ge 1 ]; then
                           echo "all is well";
                   exit 0;
                   if [ "${RET}" -eq 0 ]; then
                           echo "Unable to verify login. Try DEBUG=2";
                           echo "curl returned code 0, so is likely a user/pass issue";
                           exit 1;
                           echo "$RESULT";
                           echo "curl returned code ${RET}";
                           exit ${RET}

    and chmod to 700

    chmod 700 /home/username/

    If you're running DA with https, change http to https in the RUN variable.  Same applies if you're not using port 2222, adjust the port there.
  4. Manually run the script to see if it work:

    /home/username/; echo $?

    If you see '0' as the output, that's a good thing.  Set DEBUG to 1 or 2 to help sort out any issues.

  5. Once you're happy it's working, create a cronjob under the username account:

    User Level -> CronJobs

    Leave all time values as *, but set the command to be:


    and do not press the "Prevent E-Mail", or else you won't get any notices.
  6. On the same Cronjobs page, type in your E-Mail in the "Send all Cron output to E-Mail" section.
    Check that account for any emails containing output if DA isn't running.

Was this answer helpful?

Also Read