Automic Workload Automation

 View Only
  • 1.  Assistance Needed to Configure Automic Agent as a Service on Linux

    Posted Dec 04, 2024 08:29 AM

    We would greatly appreciate your help!

    We are trying to manage the Automic Linux agent as a service. Currently, we start the ServiceManager manually using nohup, but we need guidance on how to configure it properly to start as a service using systemctl.

    Below are the configurations and logs we've used so far:

    Configuration File (/etc/systemd/system/automic-agent.service):

    plaintext
    [Unit] Description=Automic Agent After=network.target [Service] Type=simple User=automic_user # ExecStart=/home/automic/Automic_test_11_24/ServiceManager/bin/ucybsmgr -iINSTANCE -svc 
    WantedBy=multi-user.target

    Manual Start Command:

    bash
    [root@test system]# /home/automic/Automic_test_11_24/ServiceManager/bin/ucybsmgr -iINSTANCE -svc

    Error Encountered:

    plaintext
    /home/automic/Automic_test_11_24/ServiceManager/bin/ucybsmgr: error while loading shared libraries: libzu00132.so: cannot open shared object file: No such file or directory

    Checks Performed:

    • We verified the existence of the library libzu00132.so. The file is located here:
      /home/automic/ServiceManager/bin/libzu00132.so
      bash
      [root@test system]# ls -l /home/automic/ServiceManager/bin/libzu00132.so -rwxr-xr-x 1 automictest automictest 251472 Jan 30 2024 /home/automic/ServiceManager/bin/libzu00132.so

    Despite this, when starting the service with systemctl, it returns an error related to this library.

    Questions:

    1. How can we properly configure the Linux agent to run as a service using systemctl?
    2. What additional steps are required to resolve the shared library issue?

    Your expertise and guidance on this matter would be invaluable.

    Thank you in advance for your assistance!

    Best regards,



  • 2.  RE: Assistance Needed to Configure Automic Agent as a Service on Linux

    Broadcom Employee
    Posted Dec 05, 2024 02:27 AM

    Hi,

    I recommend using a wrapper script to set the required environment.

    [Service]
    type=forking
    ExecStart=/home/automic/ServiceManager/bin/automicsm start
    ExecStop=/home/automic/ServiceManager/bin/automicsm stop

    Within the script you can set PATH and LD_LIBRARY_PATH to point to /home/automic/ServiceManager/bin where the required libraries can be found.

    Regards, Markus




  • 3.  RE: Assistance Needed to Configure Automic Agent as a Service on Linux

    Posted Dec 05, 2024 04:21 AM

    Hi Markus,

    Thank you for your response and helpful suggestion!

    I understand that you're recommending using a wrapper script to manage the environment variables and the start/stop functionality for the service. Based on your feedback, I've outlined a potential approach and would appreciate your confirmation or further input:

    Wrapper Script (/home/automic/ServiceManager/bin/automicsm):

    bash
    #!/bin/bash # Set environment variables export PATH=/home/automic/ServiceManager/bin:$PATH export LD_LIBRARY_PATH=/home/automic/ServiceManager/bin:$LD_LIBRARY_PATH # Start or stop the ServiceManager case "$1" in start) /home/automic/Automic_test_11_24/ServiceManager/bin/ucybsmgr -iINSTANCE -svc ;; stop) kill $(pgrep -f "ucybsmgr") ;; *) echo "Usage: $0 {start|stop}" exit 1 ;; esac

    Updated Service Configuration (/etc/systemd/system/automic-agent.service):

    plaintext
    [Unit] Description=Automic Agent After=network.target [Service] Type=forking ExecStart=/home/automic/ServiceManager/bin/automicsm start ExecStop=/home/automic/ServiceManager/bin/automicsm stop Restart=on-failure [Install] WantedBy=multi-user.target

    Next Steps:

    1. Ensure the wrapper script (automicsm) has executable permissions:
      bash
      chmod +x /home/automic/ServiceManager/bin/automicsm
    2. Reload the systemd configuration:
      bash
      systemctl daemon-reload
    3. Enable the service to start on boot:
      bash
      systemctl enable automic-agent.service
    4. Start the service:
      bash
      systemctl start automic-agent.service
    5. Check the status of the service to ensure it starts correctly:
      bash
      systemctl status automic-agent.service

    Does this approach look good to you, or is there anything you'd suggest tweaking?

    Thanks so much for your help! I really appreciate it!




  • 4.  RE: Assistance Needed to Configure Automic Agent as a Service on Linux

    Posted Dec 05, 2024 12:08 PM

    Hello,

    Recently Ive worked with our UNIX SME on the same thing.
    As per his advise and some security standards our approach was a little different.
    He was against allowing the service to run under root userspace.
    Previously our script was switching to the desired user and then starting the smgr but this will again inherit the root settings and you wont be able to stop the service via non-root user.
    The agents are running with elevated privileges (SUID, 4755) and are also using their own java and not sytemwide java, hence that had to also taken under consideration.


    So we simply enabled the lingering for our service user and installed the systemd in the service user userspace.

    Content of the folders ~/.config/systemd/user/

    automic:~$ ll .config/systemd/user/
    drwxr-xr-x 3 automic aesys  18 Sep 27 10:49 ..
    drwxr-xr-x 2 automic aesys  34 Sep 27 11:11 default.target.wants
    -rw-r--r-- 1 automic aesys 414 Oct 15 09:33 automic_smgr.service
    drwxr-xr-x 4 automic aesys  92 Oct 21 09:30 .
    drwxr-xr-x 2 automic aesys  27 Oct 21 10:02 automic_smgr.service.d
    
    
    automic:~$ ll .config/systemd/user/default.target.wants/
    lrwxrwxrwx 1 automic aesys 54 Sep 27 11:11 automic_smgr.service -> /home/automic/.config/systemd/user/automic_smgr.service
    drwxr-xr-x 2 automic aesys 34 Sep 27 11:11 .
    drwxr-xr-x 4 automic aesys 92 Oct 21 09:30 ..
    
    automic:~$ ll .config/systemd/user/automic_smgr.service.d/
    -rw-r--r-- 1 automic aesys 192 Oct 15 09:32 override.conf
    drwxr-xr-x 4 automic aesys  92 Oct 21 09:30 ..
    drwxr-xr-x 2 automic aesys  27 Oct 21 10:02 .


    Content of override.conf

    [Service]
    Environment="JAVA_HOME=/opt/automic/java/jre"
    Environment="PATH=/opt/automic/java/jre/bin:/home/automic/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

    !Note - systemd does not like variables 

    automic_smgr.service :

    [Unit]
    Description=Automic Service Manager for AUTOMIC_DEV Environment
    After=network.target
    
    [Service]
    Type=forking
    ExecStart=/home/automic/bin/automic_smgr.sh start
    ExecStop=/home/automic/bin/automic_smgr.sh stop
    ExecReload=/home/automic/bin/automic_smgr.sh restart
    WorkingDirectory=/opt/automic/servicemanager/bin
    Restart=on-failure
    Environment="UC4DST=AUTOMIC_DEV"
    KillMode=control-group
    
    [Install]
    WantedBy=default.target

    And automic_smgr.sh

    #!/bin/bash
    
    ### BEGIN INIT INFO
    # Provides:          Automic
    # Required-Start:    $ALL
    # Required-Stop:     $syslog $network
    # Default-Start:     3 5
    # Default-Stop:      0 1 2 6
    # Short-Description: Automic Service Manager
    # Description:       Automic Service Manager
    ### END INIT INFO
    
    SMGRDIR=/opt/automic/servicemanager
    UC4_BIN=${SMGRDIR}/bin/ucybsmgr
    UC4DST=${UC4DST}
    
    test -x $UC4_BIN || { echo -e "$UC4_BIN not installed \n";
            if [ "$1" = "stop" ]; then exit 0;
            else exit 5; fi; }
    
    case "$1" in
            start)
                    echo -e "Starting UC4 ${UC4DST} \n"
                    cd ${SMGRDIR}/bin && ./ucybsmgr ${UC4DST} 1>/dev/null 2>&1 &
                    ;;
            stop)
                    echo -e "Shutting down UC4 ${UC4DST} \n"
                    UC4=$(ps -ef | grep "ucybsmgr ${UC4DST}" | grep -v grep | awk '{print $2}')
                    [ "${UC4}" ] && kill ${UC4}
                    ;;
            restart)
                    $0 stop
                    sleep 5
                    $0 start
                    ;;
            status)
                    UC4=$(ps -ef | grep "ucybsmgr ${UC4DST}" | grep -v grep | awk '{print $2}')
                    echo -e "PID of UC4 smgr ${UC4DST}: ${UC4} \n"
                    ;;
            *)
                    echo "Usage: $0 {start|stop|status|restart}"
                    exit 1
                    ;;
    esac
    
    exit 0


    ------------------------------
    ------------------------------
    Automic SME @ DXC.Technology
    ------------------------------
    ------------------------------



  • 5.  RE: Assistance Needed to Configure Automic Agent as a Service on Linux

    Posted Dec 06, 2024 09:32 AM

    Hi @Markus Embacher,

    Could you explain, why you recommend using automicsm instead of starting the smgr via .service?

    Something like this works without the automicsm-script:

    # Systemd unit file for Automic Service Manager

    [Unit]

    Description=Automic Service Manager

    Requires=network-online.target

    After=network-online.target

    [Service]

    Type=simple

    Environment=LD_LIBRARY_PATH=/oracle/client/12x/client/lib:/usr/lib:/lib

    Environment=ORACLE_HOME=/oracle/client/12x/client

    Environment=CALIB=/opt/automic/capki/lib

    Environment=CABIN=/opt/automic/capki/bin

    Environment=CASHCOMP=/opt/automic/capki

    WorkingDirectory=/opt/automic/smgr/bin

    ExecStart=/opt/automic/smgr/bin/ucybsmgr -i/opt/automic/smgr/bin/ucybsmgr.ini AUTOMIC_V21

    ExecStop=/bin/kill -15 $MAINPID

    User=uc4

    srvGroup=uc4

    TimeoutStartSec=10

    TimeoutStopSec=15

    RestartSec=10

    [Install]

    WantedBy=multi-user.target






    ------------------------------
    --------------------------------------------------------
    Automic Consultant and Trainer since 2000
    --------------------------------------------------------
    now Tricise
    ------------------------------



  • 6.  RE: Assistance Needed to Configure Automic Agent as a Service on Linux

    Broadcom Employee
    Posted Dec 09, 2024 02:11 AM

    Hi @Christoph Rekers at Tricise,

    both solutions have the same results, it's just about the permissions you were granted as an Automic admin. It's not always the case that you are allowed to define the service yourself. But most probably you always have the permission to change the wrapper script yourself in case there are any changes to the environment.

    Regards, Markus