Skip to content

Instantly share code, notes, and snippets.

View jayankandathil's full-sized avatar

Jayan Kandathil jayankandathil

View GitHub Profile
# ------------------------------------------------
# AWK script to print unique user IDs in a folder
# containing a collection of CQ's access.logs
# ------------------------------------------------
# Usage : gawk -f /opt/scripts/parse-cq-access-logs.awk /opt/aem/crx-quickstart/logs/access.log.*
# Author : Jayan Kandathil
# Last updated : April 16, 2014
# Version : 0.1
@jayankandathil
jayankandathil / Sling-AverageRequestDurationMilliseconds.groovy
Last active August 29, 2015 14:06
Groovy script that reports Apache Sling average request duration
// Author : Jayan Kandathil
// Last Updated : June 18, 2014
// Version : 0.1
// Need following JVM init arguments for JMX access (Windows .bat example)
// set CQ_JVM_OPTS=%CQ_JVM_OPTS% -Dcom.sun.management.jmxremote
// set CQ_JVM_OPTS=%CQ_JVM_OPTS% -Dcom.sun.management.jmxremote.port=10000
// set CQ_JVM_OPTS=%CQ_JVM_OPTS% -Dcom.sun.management.jmxremote.authenticate=false
// set CQ_JVM_OPTS=%CQ_JVM_OPTS% -Dcom.sun.management.jmxremote.ssl=false
@jayankandathil
jayankandathil / Workflow-AverageProcessingTimeMilliseconds.groovy
Last active August 29, 2015 14:06
Groovy script that reports average CQ and AEM workflow processing time
// Author : Jayan Kandathil
// Last Updated : June 18, 2014
// Version : 0.1
// Need following JVM init arguments for JMX access (Windows .bat example)
// set CQ_JVM_OPTS=%CQ_JVM_OPTS% -Dcom.sun.management.jmxremote
// set CQ_JVM_OPTS=%CQ_JVM_OPTS% -Dcom.sun.management.jmxremote.port=10000
// set CQ_JVM_OPTS=%CQ_JVM_OPTS% -Dcom.sun.management.jmxremote.authenticate=false
// set CQ_JVM_OPTS=%CQ_JVM_OPTS% -Dcom.sun.management.jmxremote.ssl=false
@jayankandathil
jayankandathil / cq_trigger_heapdump.sh
Last active August 29, 2015 14:14
Bash Script to Trigger JVM Heap Dump Using JMX
#!/bin/bash
# Bash script to trigger CQ/AEM heap dump using curl via JMX
# Author : Jayan Kandathil
# Version : 0.1
# Last updated : January 27, 2015
# Instructions : Copy to CQ/AEM Linux instance's /tmp folder, make necessary changes, enable the execute bit and run
@jayankandathil
jayankandathil / AWS_User_Policy_for_Access_to_Specific_S3_Bucket
Created May 8, 2015 02:40
AWS user policy that needs to be attached to an IAM user account so that it can have access to only a specific S3 bucket but not the other buckets
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListAllMyBuckets"
],
"Resource": "arn:aws:s3:::*"
},
@jayankandathil
jayankandathil / cq_trigger_blobgc.sh
Last active August 29, 2015 14:21
Shell script to trigger AEM6 BlobGC via curl and JMX
#!/bin/bash
# Bash script to trigger AEM 6.0 Blob GC using curl via JMX
# Author : Jayan Kandathil
# Version : 0.1
# Last updated : May 14, 2015
# Instructions : Copy to CQ/AEM Linux instance's /tmp folder, make necessary changes, enable the execute bit and run
@jayankandathil
jayankandathil / start.sh
Last active November 29, 2015 20:59
CQ 5.6.1 publish start script for 64-bit HotSpot 1.7 JDK on Solaris
#!/bin/bash
#
# This script configures the start information for this server.
#
# The following variables may be used to override the defaults.
# For one-time overrides the variable can be set as part of the command-line; e.g.,
#
# % CQ_PORT=1234 ./start
#
@jayankandathil
jayankandathil / perf_measurement_servlet.java
Last active December 18, 2015 12:19
Sample code snippet showing measurement of actions within a Java servlet and returning the information back to the browser
import java.io.PrintWriter;
import java.text.DecimalFormat;
import javax.servlet.http.HttpServletResponse;
final long lngStart;
final long lngEnd;
final double dblElapsedTime;
// Get timestamp
lngStart = System.currentTimeMillis();
@jayankandathil
jayankandathil / get_cq_page.java
Last active December 18, 2015 17:19
Sample Java servlet code snippet showing how to use Apache HTTPComponents (tested with httpclient-4.2.3.jar and httpcore-4.2.2.jar) to connect to a remote Adobe Experience Manager (CQ) instance and GET a web page for server health check (heartbeat) purposes.
import java.io.IOException;
import java.io.PrintWriter;
import java.net.URI;
import java.net.URISyntaxException;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
@jayankandathil
jayankandathil / jmx.yml
Created June 2, 2016 00:24
New Relic YAML extension to monitor AEM Apache Sling Job Queues (goes in /extensions)
name: Custom JMX
version: 1.0
enabled: true
jmx:
- object_name: "java.lang:type=Threading"
metrics:
- attributes: ThreadCount, PeakThreadCount, DeamonThreadCount, TotalStartedThreadCount
- object_name: "org.apache.sling:type=queues,name=AllQueues"
metrics: