Expand my Community achievements bar.

SOLVED

How to check since when AEM author/publisher instance is running?

Avatar

Level 2

I am new to AEM development.

I have use-case to check since how long AEM author/publish instance is up and running. Can you suggest how can I achieve this through Java/jsp?

Thanks,

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

I am not sure if there is a function to get the directory. However, you can access the logs by just using the "crx-quickstart" when using the file path. For example: 

InputStream in = new FileInputStream(new File("crx-quickstart/logs/stdout.log"));

Here is an example component you could use to display the log file:

<%@include file="/libs/foundation/global.jsp"%> <%@page session="false" %> <%@ page import="java.util.*, java.io.*"%> <body> <% InputStream in = new FileInputStream(new File("crx-quickstart/logs/stdout.log")); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); StringBuilder out2 = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { out.append(line); } System.out.println(out2.toString());   //Prints the string content read from input stream reader.close(); %> </body>

If you make a component with this code, and add it to a page, it should output the file. It will be one big block of text, but the example should work.

View solution in original post

6 Replies

Avatar

Level 10

You can use JMX to get the uptime. This [1] should help you on how to read JMX properties

[1] http://docs.adobe.com/docs/en/cq/5-6-1/developing/jmx-integration.html

Avatar

Former Community Member

In order to check how long the the AEM author/publish instance has been up and running, you could use the stdout.txt log file that is located in your crx-quickstart folder under logs.

This log file records what time your instance of AEM started and what time it shuts down, and is refreshed every time the instance is started. You can read more about the log files here: http://docs.adobe.com/docs/en/cq/5-6/howto/logsaudits.html.

In order to achieve this through Java/jsp, you would need to read in the file, and search it for the following line - "Quickstart startup at (date goes here)".

Avatar

Level 2

You could also use JMX?

 

{   "Name": "Uptime",   "Value": "108473218",   "MBeanAttributeInfo": {   "Description": "Uptime",   "Readable": true,   "Writable": false,   "Is": false,   "Type": "long" }

Avatar

Level 2

swesto01 wrote...

In order to check how long the the AEM author/publish instance has been up and running, you could use the stdout.txt log file that is located in your crx-quickstart folder under logs.

This log file records what time your instance of AEM started and what time it shuts down, and is refreshed every time the instance is started. You can read more about the log files here: http://docs.adobe.com/docs/en/cq/5-6/howto/logsaudits.html.

In order to achieve this through Java/jsp, you would need to read in the file, and search it for the following line - "Quickstart startup at (date goes here)".

 

Thanks for your reply. 

How do I get base path of AEM Installation [to parse stdout.logs]? Different server will have different installation directory for AEM/CQ. Is there some function to get cq-installation-dir?

Thanks,

Avatar

Correct answer by
Former Community Member

I am not sure if there is a function to get the directory. However, you can access the logs by just using the "crx-quickstart" when using the file path. For example: 

InputStream in = new FileInputStream(new File("crx-quickstart/logs/stdout.log"));

Here is an example component you could use to display the log file:

<%@include file="/libs/foundation/global.jsp"%> <%@page session="false" %> <%@ page import="java.util.*, java.io.*"%> <body> <% InputStream in = new FileInputStream(new File("crx-quickstart/logs/stdout.log")); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); StringBuilder out2 = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { out.append(line); } System.out.println(out2.toString());   //Prints the string content read from input stream reader.close(); %> </body>

If you make a component with this code, and add it to a page, it should output the file. It will be one big block of text, but the example should work.

Avatar

Level 2

Thanks a lot! I can read stdout.log by using these relative path.

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----