LiferayPlugin

evernat edited this page Mar 30, 2017 · 11 revisions

Installation

To monitor a Liferay server v6.1 or later, you can install a Liferay javamelody plugin:

  • Download the latest Liferay plugin file from releases
  • Copy the file into the "deploy" directory of your Liferay server and wait a few seconds
  • Liferay automatically deploys the file and removes it from "deploy" That's it!

You can browse the monitoring page at http://<host>:<port>/monitoring. For example, if the server is local: http://localhost:8080/monitoring

Authentication and portal "Administrator" role are required to access this monitoring page.

The Liferay plugin is also published in the Liferay marketplace.

SQL monitoring

Then, if you want to monitor the SQL requests executed by Liferay and the jdbc connections used (since v1.59.1):

  • Configure Liferay to use a JNDI datasource. For example, add a portal-ext.properties file in the directory $TOMCAT_HOME/webapps/ROOT/WEB-INF/classes with the following line :
jdbc.default.jndi.name=jdbc/LiferayPool
  • Add a resource link with a name starting with "jdbc/" in the $TOMCAT_HOME/conf/context.xml file:
<Context>
	...
	<ResourceLink name="jdbc/LiferayPool" global="jdbc/LiferayPool" type="javax.sql.DataSource"/>
	...
</Context>
  • Add a datasource inside GlobalNamingResources of the $TOMCAT_HOME/conf/server.xml file:
...
<!-- If you're using Liferay 6.2 and Tomcat 7 or below ; change maxTotal to maxActive -->
<GlobalNamingResources>
	<!-- Example using the HSQL database -->
	<Resource name="jdbc/LiferayPool" auth="Container" type="javax.sql.DataSource" defaultAutoCommit="false"
		url="jdbc:hsqldb:/opt/liferay/data/hsql/lportal" driverClassName="org.hsqldb.jdbc.JDBCDriver"
		username="SA"
		maxTotal="20" maxIdle="10" maxWait="10000"
	/>

	<!-- Example using the MySQL database -->
	<Resource name="jdbc/LiferayPool" auth="Container" type="javax.sql.DataSource" defaultAutoCommit="false"
		url="jdbc:mysql://localhost:3306/lportal?useUnicode=true&amp;characterEncoding=UTF-8"
		driverClassName="com.mysql.jdbc.Driver"
		username="root" password=""
		maxTotal="20" maxIdle="10" maxWait="10000"
	/>
</GlobalNamingResources>
...

You can look at more parameters for DBCP v2 to configure the datasource when using Tomcat 8 or parameters for DBCP v1 when using Tomcat 7.

And if you have developed a portlet using a database, you can do the same to monitor your SQL requests:

  • Add a resource link with a name starting with "jdbc/" in the $TOMCAT_HOME/conf/context.xml file.
  • Add a datasource inside the GlobalNamingResources of the $TOMCAT_HOME/conf/server.xml file.
  • Use the JNDI datasource in your portlet. For example, in your hibernate.cfg.xml file if you use Hibernate with MySQL :
<property name="hibernate.connection.datasource">java:comp/env/jdbc/MyDataSource</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>

Storage directory

The data files will be stored by default in $TOMCAT_HOME/temp/javamelody/. If you want to use another storage directory, add a "javamelody.storage-directory" system property (in $TOMCAT_HOME/bin/setenv.sh or in $TOMCAT_HOME/conf/catalina.properties). For example:

	... -Djavamelody.storage-directory=/my/path

You can configure other parameters, see Optional parameters.

Weekly, daily or monthly reports by mail

In Liferay, you can also send weekly, daily or monthly reports in pdf format by mail to one or several people. This is explained in the chapter Weekly, daily or monthly reports by mail.

For Liferay, add the following Resource and Parameter lines in the $TOMCAT_HOME/conf/context.xml file:

	...
	<Context ... > 
		...
		<Resource name="mail/JavaMelodySession" auth="Container" type="javax.mail.Session"
			mail.smtp.host="mailhost.foo.bar"
			mail.smtp.user="someLoginIfNeeded"
			mail.from="javamelody@foo.bar"
		/>
		<Parameter name='javamelody.admin-emails' value='admin1@company.com,admin2@company.com' override='false'/>
		<Parameter name='javamelody.mail-session' value='java:comp/env/mail/JavaMelodySession' override='false'/>
		<Parameter name='javamelody.mail-periods' value='day,week,month' override='false'/>
	</Context>
	...

Read Weekly, daily or monthly reports by mail for more parameters if needed.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.