This was a bit bumpy but I think I have the bases covered in order to have a single epagent deployment that I can deploy to all AIX, SLES and RHEL servers including servers that have custom configuration outside of the base epagent configuration.
First is the agent configuration file. Each of the IntroscopeEPAgent.properties files are specific to an OS since not all of the Perl plugins we run will even make sense on another platform. An example of OS based configuration is the lparstat on AIX or free on SLES or RHEL.
Not all hosts are created equal. Sometimes there is a plugin that requires a bit of environment information in order to connect, query or locate the metric target. So, we have an IntroscopeEPAgent.properties file that will override the OS configuration located at /syshome/wilyapm/config
With the below code, if we don't have a configuration file, we will exit the epactrl.sh
Yes, the code is pretty ugly, but don't want to go through and try to get the indention and such sorted out. In my implementation, everything is four spaced per block intended, which makes it really easy to line up the if and fi
#Use a custom file instead of default
agentconfig="unset";
#Use a custom file instead of default
FILE="/syshome/wilyapm/config/IntroscopeEPAgent.properties"
if [ -f "$FILE" ];
then
agentconfig="-Dcom.wily.introscope.epagent.properties=/syshome/wilyapm/config/IntroscopeEPAgent.properties"
echo "[INFO][EPACtrl.sh] agentconfig = $agentconfig";
else
#custom configuration not found, determine which platform configuration to use
value=`uname`
if [ $value = "AIX" ]; then
echo "[INFO][EPACtrl.sh] This is AIX";
agentconfig="-Dcom.wily.introscope.epagent.properties=/wilyagent/IntroscopeEPAgent.properties.aix"
else
if [ $value = "Linux" ]; then
value=`cat /etc/os-release |grep -c SUSE`
if [ $value != 0 ]; then
echo "[INFO][EPACtrl.sh] This is SLES";
agentconfig="-Dcom.wily.introscope.epagent.properties=/wilyagent/IntroscopeEPAgent.properties.sles"
echo "[INFO][EPACtrl.sh] agentconfig = $agentconfig";
fi
value=`cat /etc/os-release |grep -c Red`
if [ $value != 0 ]; then
echo "[INFO][EPACtrl.sh] This is RHEL";
agentconfig="-Dcom.wily.introscope.epagent.properties=/wilyagent/IntroscopeEPAgent.properties.rhel"
echo "[INFO][EPACtrl.sh] agentconfig = $agentconfig";
fi
fi
fi
fi
echo "[INFO][EPACtrl.sh] agentconfig = $agentconfig";
if [ $agentconfig == "unset" ]; then
echo "[ERROR][EPACtrl.sh] operating system unknown!";
exit -1;
fi
The second issue is the APM environment assignment. Which of the Enterprise Managers (MOM) and in which environment should the agent report.
Thought about trying to have an environment variable with the EM host but then, what if something changed or was added. Then you would need to locate the specific hosts that had the value and change them. If we decouple from the actual EM host name and instead have logic within the EPACtrl.sh to determine which EM to report to, we can, if there is a change, just redeploy the consolidated agent across the board and the problem is fixed.
#Determine which MOM to use
if [ -f "/syshome/wilyapm/config/caapm.conf" ]; then
#load environment value
. /syshome/wilyapm/config/caapm.conf;
if [ -z "$CAAPM_ENV" ]; then
echo "{ERROR][EPACtrl.sh] CAAPM_MOM NOT set! Please configure the appropriate MOM in /syshome/wilyapm/config/wilymom.conf"
exit 1;
fi
case "$CAAPM_ENV" in
"PROD") CAAPM_MOM="production host"
;;
"NON-PROD") CAAPM_MOM="non prod host"
;;
"TEST") CAAPM_MOM="test host"
;;
*) # default - if value is unknown
echo "[ERROR][EPACtrl.sh] CAAPM_ENV = $CAAPM_ENV. Value is unknown. Check the EPACtrl.sh file."
exit 1
;;
esac
echo "[INFO][EPACtrl.sh] CAAPM_ENV = $CAAPM_ENV. CAAPM_MOM = $CAAPM_MOM";
fi
We tried to comment out introscope.agent.enterprisemanager.transport.tcp.host.DEFAULT=localhost
from the IntroscopeEPAgent.properties file but found that on AIX, if the value is not present in the properties file, then it will go to default "localhost". So we had to uncomment this line and to keep everything the same, applied the same on all of the platforms.
So as you can see, to define an environment, there is a config file caapm.conf within the /syshome/wilyapm/config directory. If the file isn't there, we don't guess, we log an error and exit so we never have an issue with a production server sending data to a non-production environment.
Then to add both to the EpaCmd line
EpaCmd="java -Xms${MIN_HEAP_VAL_IN_MB}m -Xmx${MAX_HEAP_VAL_IN_MB}m
-Dintroscope.agent.enterprisemanager.transport.tcp.host.DEFAULT=$CAAPM_MOM -cp lib/EPAgent.jar:lib/IntroscopeServices.jar:lib/Agent.jar:epaplugins/epaMQMonitor/epaMQMonitor.jar:epaplugins/epaMQMonitor:epaplugins/epaMQMonitor/lib/com.ibm.mq.pcf.jar:epaplugins/epaMQMonitor/lib/com.ibm.mq.jar:epaplugins/epaMQMonitor/lib/connector.jar:epaplugins/epaMQMonitor/lib/com.ibm.mqjms.jar $agentconfig com.wily.introscope.api.IntroscopeEPAgent"
With these additions, we can have a single epagent directory that we can deploy to all hosts (AIX, SLES, RHEL) regardless of which environment and permits custom configuration.
On a side note, any of our Perl plugins that require environment, database, port, etc information. Within the plugin we have the code read in a plugin specific configuration file from the /syshome/wilyapm/config directory so the plugin can be added to the consolidated agent and is only activated with the custom IntroscopeEPAgent.properties file and the presence of the plugin specific configuration file.
With this, we can test what we deploy and deploy what we have tested.