Workload Automation

 View Only

systemd unit file for CA WA Agent service on RHEL, CentOS, Oracle Linux 7 & SLES 12 

Jul 21, 2017 03:39 AM

You may already know that RHEL 7 (naturally, CentOS 7 too), Oracle Linux 7, Ubuntu 15.04 and SuSE Linux Enterprise 12 all switched to systemd for system and service management, replacing the SysV and LSB init scripts. Even though most Linux distros still provide backward compatibility with SysV init scripts, looks like systemd is here to stay and eventually entirely replace SysV init concept.

 

For the curious, there's plethora of information available online on systemd so I'll leave you to read and research about it.

 

If you've installed CA Workload Automation System Agent on any of the aforementioned Linux systems and would like to manage the System Agent using systemd, the following steps might help to get you started.

 

The service unit file.

Unit file is simply a configuratioin file that systemd uses to configure and manage the unit. More about it HERE.

Here is how we create our CA WA System Agent file.

a. Create a file named ca-wa-agent.service under /etc/systemd/system/ directory, like so:

# cat /etc/systemd/system/ca-wa-agent.service
[Unit]
Description=CA Workload Automation Agent
After=local-fs.target remote-fs.target network.target sockets.target chronyd.service

 

[Service]
Type=forking
ExecStart=/opt/CA/WA_Agent/cybAgent -a
ExecStop=/opt/CA/WA_Agent/cybAgent -s
WorkingDirectory=/opt/CA/WA_Agent

 

[Install]
WantedBy=multi-user.target

 

Have a read of the Redhat documentation on unit files to understand what each of the items in the above file mean.

 

For the impatient, the [Unit] section describes the unit, sets dependencies and specifies other behaviours of this unit. In our file, we have given a description of "CA Workload Automation Agent" and instructed systemd that the CA WA System Agent service should be started after the local file system, remote file system, network, sockets and chronyd (Redhat's NTP daemon. For SuSE, it's ntpd.service) service are available. The [Service] section tells the unit is of type service and we start the service by forking (most suitable for daemonized services), ExecStart tells what command to execute to start the service, ExecStop, what command to stop and WorkingDirectory, the working directory of the service, as the name suggested. The [Install] section tells the 'when', more specifically, what run-level this service should be started in. We want the CA WA Agent started in multi user level (run level 2,3,4).

 

b. Now, we have the unit file (/etc/systemd/system/ca-wa-agent.service) ready. The following commands will set up the CA WA Agent service for systemd.

 

Tell the systemd that there's a new service unit file:

# systemctl daemon-reload 

 

Read the service unit file via systemctl command:

# systemctl cat ca-wa-agent.service
# /etc/systemd/system/ca-wa-agent.service
[Unit]
Description=CA Workload Automation Agent
After=local-fs.target remote-fs.target network.target sockets.target chronyd.service

 

[Service]
Type=forking
ExecStart=/opt/CA/WA_Agent/cybAgent -a
ExecStop=/opt/CA/WA_Agent/cybAgent -s
WorkingDirectory=/opt/CA/WA_Agent

 

[Install]
WantedBy=multi-user.target

 

Start the service:

# systemctl start ca-wa-agent.service

 

Stop the service:

# systemctl stop ca-wa-agent.service

 

Enable the service (without this the service won't start-up on system boot)

# systemctl enable ca-wa-agent.service

 

Check the status of the service:

# systemctl -l status ca-wa-agent.service

● ca-wa-agent.service - CA Workload Automation Agent
   Loaded: loaded (/etc/systemd/system/ca-wa-agent.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2017-07-21 03:24:22 EDT; 2s ago
  Process: 29268 ExecStart=/opt/CA/WA_Agent/cybAgent -a (code=exited, status=0/SUCCESS)
 Main PID: 29271 (cybAgent.bin)
   CGroup: /system.slice/ca-wa-agent.service
           └─29271 ./cybAgent.bin -a

 

Jul 21 03:24:22 hostname systemd[1]: Starting CA Workload Automation Agent...
Jul 21 03:24:22 hostname systemd[1]: Started CA Workload Automation Agent.

 

# ps -ef|grep [c]yb
root     29271     1  2 03:24 ?        00:00:04 ./cybAgent.bin -a

 

# cat /opt/CA/WA_Agent/status
CA Workload Automation Agent for Linux 11.3, Build 979

Started at: Fri Jul 21 03:24:22 2017

OS component - 29271

 

When you get to test, reboot the system and confirm the CA WA Agent started automatically.

 

I hope this post was helpful.

 

Thank you,

Chandru

Statistics
0 Favorited
6 Views
0 Files
0 Shares
0 Downloads

Tags and Keywords

Related Entries and Links

No Related Resource entered.