Sample log collector script
Copy the sample script and modify it to match your environment to create a log collector in Cognos® Analytics Certified Containers with Agentic AI.
The collectCognosPodLogs.sh script collects logs from each active pod in the /opt/ibm/cognos/analytics/logs directory, stores them in a compressed file, and copies them to a local folder.
The inPodCollector.sh script is a companion script, which captures internal pod processes and their environment information.
- Sample collectCognosPodLogs.sh script
-
The following code snippet is a sample script of the collectCognosPodLogs.sh log collector in the Cognos Analytics Certified Containers with Agentic AI environment:
export NAMESPACE={sample_namespace} export podHoldingLocation=./podLogs export CLI=kubectl export COLLECTOR=inPodCollector.sh function getMainContainerName () { IFS=- read -ra fields <<< $1 echo ${fields[1]} echo ${fields[2]} if [ ${fields[2]} = "cm" ]; then containerName="ca-cm-container" elif [ ${fields[1]} = "frontdoor" ]; then containerName="caproxy" else containerName="${fields[0]}-${fields[1]}-container" fi } if [ ! -d "${podHoldingLocation}" ]; then mkdir ${podHoldingLocation} fi sideCar=caproxy for podName in $($CLI get pods -l release=cognos-analytics -o custom-columns=POD:.metadata.name --no-headers ) do echo "==> Processing Pod $podName" $CLI describe pod $podName >> ${podHoldingLocation}/${podName}_describe.log $CLI logs $podName -c caproxy > ${podHoldingLocation}/${podName}_Velcro.log getMainContainerName $podName $CLI cp -c ${containerName} inPodCollector.sh $podName:/tmp $CLI exec -it $podName -c ${containerName} -- /bin/bash -c /tmp/inPodCollector.sh $CLI cp -c ${containerName} $podName:/tmp/Collect.tar.gz ${podHoldingLocation}/${podName}_Collect.tar.gz done - Sample inPodCollector.sh script
-
The following code snippet is a sample script of the inPodCollector.sh internal log collector in the Cognos Analytics Certified Containers with Agentic AI environment:
export holdingArea=/tmp/Collect export cognosLocation=/opt/ibm/cognos/analytics if [ ! -d ${holdingArea} ] then mkdir ${holdingArea} fi rm -rf ${holdingArea}/* cp -r ${cognosLocation}/logs ${holdingArea}/. mkdir -p ${holdingArea}/wlp/usr/servers cp -r ${cognosLocation}/wlp/usr/servers/cognosserver/logs ${holdingArea}/wlp/usr/servers/cognosserver cp -r ${cognosLocation}/wlp/usr/servers/dataset-service/logs ${holdingArea}/wlp/usr/servers/dataset-service ps -ef > ${holdingArea}/ProcessInformation.txt env > ${holdingArea}/Environment.txt cd ${holdingArea} #zip -r ../Collect.zip . rm -f /tmp/Collect.tar /tmp/Collect.tar.gz tar -cvf /tmp/Collect.tar /tmp/Collect gzip /tmp/Collect.tar
After you copy and adjust the contents of both scripts, move them to a local directory and give them the Execute permissions. You also must make sure that the namespace where the pods are running is an active namespace.
To start collecting logs from each pod, run only the collectCognosPodLogs.sh script.