How do I start the EP Agent service on system boot as a non root user?

book

Article ID: 141733

calendar_today

Updated On:

Products

CA Application Performance Management Agent (APM / Wily / Introscope) CA Application Performance Management (APM / Wily / Introscope) INTROSCOPE DX Application Performance Management

Issue/Introduction

I have followed the instructions in the documentation on installing the EP Agent as a UNIX Daemon but the process always starts as root how can this be started as a non root user that owns the software?

Cause

The install option for the EPACtrl.sh script creates a link in the  /etc/init.d folder call EPAgent which is a link back to the EPACtrl.sh script e.g.

lrwxrwxrwx. 1 root root    36 Dec 11 09:19 EPAgent -> /opt/apm107/epagent/bin/./EPACtrl.sh

By default when the system boots the service will be started as the root user by the operating system even if the software is not owned by root.

Environment

Release : 10.7.0

Component : APM Agents

Resolution

There are ways you can change the way that the service starts, here is one mechanism.

Delete the link /etc/init.d/EPAgent and replace it with a script which just contains the following command

su -c "/opt/apm107/epagent/bin/EPACtrl.sh $*" apmusr

[[email protected] init.d]# cat EPAgent
su -c "/opt/apm107/epagent/bin/EPACtrl.sh $*" apmusr

Then starting the service when logged in as root

[[email protected] init.d]# service EPAgent start
Starting CA APM Environment Performance Agent...
Waiting for CA APM Environment Performance Agent......
...running: PID:144593

results in the process running as the requested user

[[email protected] bin]# ps -ef |grep 144593
apmusr   144593      1  0 03:27 ?        00:00:00 /opt/apm107/epagent/bin/../bin/wrapper-linux-x86-64 /opt/apm107/epagent/bin/../conf/EPAService.conf wrapper.syslog.ident=EPAgent wrapper.pidfile=/opt/apm107/epagent/bin/./EPAgent.pid wrapper.name=EPAgent wrapper.displayname=CA APM Environment Performance Agent wrapper.daemonize=TRUE wrapper.statusfile=/opt/apm107/epagent/bin/./EPAgent.status wrapper.java.statusfile=/opt/apm107/epagent/bin/./EPAgent.java.status wrapper.script.version=3.5.25 --
apmusr   144595 144593  8 03:27 ?        00:00:02 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-7.b13.el7.x86_64/jre/bin/java -Dcom.wily.introscope.epagent.properties=../IntroscopeEPAgent.properties -Xms512m -Xmx1024m -Djava.library.path=../lib -classpath ../lib/wrapper.jar -Dwrapper.key=OXm0tQBDuAO9zoPjU258svsocRBwyEQs -Dwrapper.port=32001 -Dwrapper.jvm.port.min=31000 -Dwrapper.jvm.port.max=31999 -Dwrapper.disable_console_input=TRUE -Dwrapper.pid=144593 -Dwrapper.version=3.5.25-st -Dwrapper.native_library=wrapper -Dwrapper.arch=x86 -Dwrapper.service=TRUE -Dwrapper.cpu.timeout=10 -Dwrapper.jvmid=1 -Dwrapper.lang.domain=wrapper -Dwrapper.lang.folder=../lang org.tanukisoftware.wrapper.WrapperJarApp ../lib/EPAgent.jar