Configure Automatic Restart of a Cloud Agent

Cloud agents are deployed to collect log and metric data from entities. For seamless collection of data, the cloud agent must not stop or fail. To keep the cloud agent running, you must configure it to automatically restart the agent service after a hardware or software failure or whenever your cloud agent host machine restarts.

Ensure that only the root user and agent installation user have write permission on the Agent_Base_Directory. The root user and agent installation user must be the owner of the directory and it’s parent directory.

The following sections contain examples of how you can configure an agent as a service in different operating systems.

Note:

You may need to edit the examples based on your own directory structure.

Linux

  1. Login as the root user.

  2. Create a shell script under the /etc/init.d directory using any standard text editor with the following:
    • #!/bin/sh

    • su — <Agent_Install_User> —c <Agent_Base_Directory>/agent_inst/bin/omcli start agent

    For example, if the agent is installed under the /agent/base/cloudagent directory and agent installation owner is emga, then the content of the shell script should be as follows:

    #!/bin/sh

    su - “emga” -c “/agent/base/cloudagent/agent_inst/bin/omcli start agent”

  3. Save the script file.

  4. Change the permission of the file to 755. Ensure that the owner of the script file and all the other files in the /etc/init.d directory is root.

  5. Create symbolic links under /etc/rc.d/rc2.d, /etc/rc.d/rc3.d, /etc/rc.d/rc5.d, and /etc/rc.d/rc6.d directories. Prefix the symbolic link with S and the priority level.
    • To create the above symbolic link, run the following command:

      ln -s /etc/init.d/S81startomcagent.sh /etc/rc2.d/S81startomcagent.sh

    For example, if the file startomcagent is created under /etc/init.d with priority level 81, then the symbolic link will be as follows:

    lrwxrwxrwx 1 root root 30 Apr  2 04:39 /etc/rc.d/rc2.d/S81startomcagent.sh -> /etc/init.d/startomcagent.sh
  6. Restart the host machine.

Solaris

  1. Login as the root user.

  2. Create a shell script under the /etc/init.d directory using any standard text editor and paste the following into the file.
    • #!/bin/sh

    • su — <Agent_Install_User> —c <Agent_Base_Directory>/agent_inst/bin/omcli start agent

    For example, if the agent is installed under the /agent/base/cloudagent directory and agent installation owner is emga, then the content of the shell script should be as follows:

    #!/bin/sh

    su - “emga” -c “/agent/base/cloudagent/agent_inst/bin/omcli start agent”

  3. Save the script file.

  4. Change the permission of the file to 755. Ensure that the owner of the script file and all the other files in the /etc/init.d directory is root.

  5. Create symbolic links under /etc/rc2.dand /etc/rc3.d directories. Prefix the symbolic link with S and the priority level.
    • To create the above symbolic link, execute the following command:

      ln -s /etc/init.d/S81startomcagent.sh /etc/rc.d/rc2.d/S81startomcagent.sh

    For example, if the file startomcagent is created under /etc/init.d with priority level 81, then the symbolic link will be as follows:

    lrwxrwxrwx 1 root root 30 Apr 2 04:39 /etc/rc2.d/S81startomcagent -> /etc/init.d/startomcagent.sh
  6. Restart the host machine.

AIX

  1. Login as the root user.

  2. Create a shell script under the /etc/rc.d/init.d directory using any standard text editor and paste the following into the file.
    • #!/bin/sh

    • su — <Agent_Install_User> —c <Agent_Base_Directory>/agent_inst/bin/omcli start agent

    For example, if the agent is installed under the /agent/base/cloudagent directory and agent installation owner is emga, then the content of the shell script should be as follows:

    #!/bin/sh

    su - “emga” -c “/agent/base/cloudagent/agent_inst/bin/omcli start agent”

  3. Save the script file.

  4. Change the permission of the file to 755. Ensure that the owner of the script file and all the other files in the /etc/rc.d/init.d directory is root.

  5. Create symbolic links under /etc/rc.d/rc2.d, /etc/rc.d/rc3.d, and /etc/rc.d/rc5.d directories. Prefix the symbolic link with S and the priority level.
    • To create the above symbolic link, execute the following command:

      ln -s /etc/rc.d/init.d/S81startomcagent.sh /etc/rc.d/rc2.d/S81startomcagent.sh

    For example, if the file startomcagent is created under /etc/rc.d/init.d with priority level 81, then the symbolic link will be as follows:

    lrwxrwxrwx 1 root root 30 Apr 2 04:39 /etc/rc.d/rc2.d/S81startomcagent -> /etc/rc.d/init.d/startomcagent.sh
  6. Restart the host machine.