Count queries printed to the Glassfish logs. This basically:
- Takes the last 'n' lines from the glassfish log file, marked by a logging statement in Java
- Writes the lines to a file
- Runs them though the python collections.Counter.
Tested on python 2.7.
- Open the
persistence.xmlfile - Add this line to the end of the ````` list:
<property name="eclipselink.logging.level.sql" value="FINE"/>- Example:
<properties>
<!--property name="toplink.logging.level" value="FINE"/-->
<property name="eclipselink.weaving" value="false"/>
<property name="eclipselink.ddl-generation" value="create-tables"/>
<property name="eclipselink.cache.shared.default" value="false"/>
<!-- The following property allows primary keys of 0 -->
<property name="eclipselink.id-validation" value="NULL"/>
<property name="eclipselink.logging.level.sql" value="FINE"/>
</properties>- Add delimiters to the pages you would like to check.
- Example:
- Edit the
DatasetPage.java - Add this line to the top of your
init(...)method:
- Edit the
System.out.println("_YE_OLDE_QUERY_COUNTER_");- Copy the file
scripts/settings_template.jsontoscripts/settings.json - Update
scripts/settings.jsonwith the path to your Glassfish log file - Example:
{ "GLASSFISH_LOG_FILE_PATH" : "/Users/rp/Documents/iqss-git/glassfish4.1/glassfish/domains/domain1/logs/server.log" }- Go to the page you would like to check: e.g.
http://localhost:8080/dataset.xhtml?id=3&versionId=15- The log should contain SQL statements from the page load
- Run the python script, with the name of an output file:
> cd 'glassfish-query-counter/scripts'
> python count_queries.py dataset-page-check
- This does the following:
- Creates a text file in:
query_lists/dataset-page-check.txt(the ".txt" is appended automatically) - Creates a .csv file with query counts:
query_counts/dataset-page-check.csv - Prints output to the terminal
- Creates a text file in: