Showing posts with label google chart api. Show all posts
Showing posts with label google chart api. Show all posts

Thursday, July 24, 2014

GSoC Week 10: Application Indicators - Getting user log in count chart


Since my previous attemp of getting logging in users through a SessionListener failed, this week i started back with two alternatives.

1. As suggested by my mentor Pascal, i tried to use a scheduler task for this. But since the task also doesn't have HTTPSession infomation this was not successful.

2. Created a new UI button to enable user login data tracking. When it is tirggerred the HTTPSession of the servlet request is passed to the Collector thread and logged in user count is retirved and stored into the databse from here onwards.

Below is how it is done.

I added a button to UI to click to enable login indicator. When user clicks this button it starts the LoggedInUsersCountCollectorThread with the session as below.


@RequestMapping(value = "/module/systemmetrics/track", method = RequestMethod.GET)
public void track(HttpServletRequest request)
{
loggedInUsersCountCollectorThread = new LoggedInUsersCountCollectorThread(request.getSession());
Thread loginThread = new Thread(loggedInUsersCountCollectorThread);
loginThread.start();
}


After that i can use the current session and get logged in users from time to time. This is similar to how the OpenMRS Core --> Administration --> Maintenance --> View logged in users section is also getting the users list.

Below is the chart view of the stored data which is calculated every 30 seconds.



Here are the commits i made for the feature within this week. 
  • https://github.com/openmrs/openmrs-module-systemmetrics/commit/e9a36740f2eddf35e6d5e435c13286735aecf0be
Since there is a new JIRA project is created for our project now i created the first feature entry there.
  • https://issues.openmrs.org/browse/SPU-1

Sunday, July 6, 2014

GSoC Week 07 - Ready for the first release !!

This week i mostly worked on getting used memory indicator finalized for the very first 1.0.0 release of OpenMRS-SystemMetrics module. The final agreement for the release between me and my mentors was get the Memory indicator finalized with Service API and the Graph and releasing it out by the next week.

I was able to work on towards this and complete the memory data during this week and covered the tasks below.

1. Modified the per second memory value graph.

2. Added the next graph on per minute memory values for the Used Memory.

3. Added schedulers to delete the data from per second and per minute data tables in the database periodically. The current time duration is per second data will be deleted in every 30 minutes and per minute data will be cleared in every 5 hours to avoid these tables getting flooded. Evetually these values will be make configurable using global properties so users have the freedom of configuring those as they need.

4. Modified the Module home page and provided links to view the charts and tables.

Module Home Page:



Used Memory Charts page:




For the next week i hope to finish the documentation so far, create the JIRA project and create the first video of the System Performance and Utilization Module and release 1.0.0 version of the module.

Once we get the release out the next task would be start on Application indicators and get the data on logged in users statistics and display it in the module.



















Friday, June 27, 2014

GSoC Week 06 - Mid-term Evaluations :)

The good news from GSoC office came today and it said i had passed the mid-term evaluation. :) Few more step to go now ...

This week at the start i had a mail discussion with pascal and we discussed on getting the first release for the System Monitoring module out by the 2nd week of July.

Then it was back to drawing the graph based on memory data. After struggling several times with NVD3 js i finally decided to look for alternatives as it was not easy for me to get the NVD3 based graph working. There were not enough examples, documents on getting this etc. When looking at other available options i found the Google Chart API [1] which was amazing and did my job !!

Google chart API has a rich documentation support and  a good API reference guide which helped me in creating a line chart by retrieving data from the metric value table and populate them as a graph. The syntax was easy to understand. So finally i was able to draw my first graph with real time memory data as shown in the image below. 

This is how the week went so far. Now i am going to work on furnishing the graphs and finalize the current implementation by next week so we can meet up the release deadline right at the time.