I have written a Glassfish Monitor (using shell scripting, PHP and MySQL), to help myself to monitor the Glassfish Application server’s resource usage as well as the server resource usage.
The setup of this monitor is very simple, just unzip the file and copy the files to some folder say /root/server_monitor folder.
After copying, run the setup_glassfish_monitor.sh script as root user using the command:
# sh setup_glassfish_monitor.sh
The script will ask for Glassfish admin username and password.
The setup script adds a cron job, which is scheduled to run every 15 minutes and to collect the server statistics and add it to some centralized MySQL database server.
Types of Monitoring:
The tool can do the following types of monitoring:
We can configure the following parameters in the tool:
1) Change the CPU/RAM utilization % threshold for receiving alerts. Default value is 90%.
2) Change the frequency at which the alert will be sent to the receivers.
Note: The script will run every 5 minutes but if we set $alert_sent_every parameter to 30, then if some issue is detected, then immediately alert will be sent to the receivers but if the issue persists then the next alert will go only after $alert_sent_every minutes i.e. after 30 minues, not every 5 minutes.
3) Set the alert receivers by editing $mail_ids parameter. Multiple recipients separated by ; (semicolon) .
4) Change the DB server settings in this file, these settings are for storing the server status to the centralized server for reporting/analysis.
Latest Monitoring data in web browser
We can monitor the server status from our web browser.
After we open the reporting link for this tool, we have to select the server which we want to monitor, so using this tool we can keep an eye on all the Glassfish servers from a single web page.
If you select Auto Refresh On, and click save then after every Refresh Interval minutes, the latest monitored data will be loaded in the browser automatically and previous loaded data will be pushed towards the bottom of the browser.
In the below screenshot we can see that our auto refreshed data is loaded in the browser, now we can see and compare the latest data with the previously collected data.
After selecting a server we can see some new links, this links provide quick overview of few monitoring entities:
We can see monitoring data for last 3 hours, (12 monitoring collections, 12x15 Minutes = 3 Hours status)
To create a report you have to
2) CPU Usage Report
Using this report we can see the CPU usage of the server over a period of time. This will help to estimate the load on the server. Here also we can find the % of CPU used by Glassfish out of the whole server CPU usage.
4) Glassfish Heap Usage Report:
Here we can find the JVM heap usages. Here we can see the free available space in the heap, allocated heap size and usage %. This may help us to size the heap correctly.
This is a small tool but can be very handy.
My next plan is to write a heap sizing advisor (sizing different heap areas Eden Space, two Survivor Spaces and the OldGen space), but all depends on how much free time Almighty will provide me .