<%
/********************************************************************************
FileName	:egSysDashBoard.jsp
Purpose		:This is created for System tab in Monitor Dashboard
Created by	:Simeon.D
Created on	:05/03/2009
GUI Changed by	:Vijay\Jaiwin
**********************************************************************************/
%>

<%@ taglib prefix="egui" uri="../WEB-INF/eg-taglib.tld" %>
<%@ include file = "EgMonitorTracker.jsp"%>
<%@ page import="java.util.*"%>
<%@ page import="java.text.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="com.eg.EgInstallInfo" %>
<%@ page import="egurkha.*"%>
<%@ page import="egurkha.reporter.ErInfo"%>
<%@ page import="egurkha.reporter.ErTimePlotsBean"%>
<%@ page import = "egurkha.reporter.ErUtils"%>
<%@ page import="com.eg.IniFile"%>
<%@ page import = "com.eg.EgURLEncoder"%>
<%@ page import = "com.eg.EgMappingInfo"%>
<%@ page import = "com.eg.EgDateInfo"%>
<%@ page import = "com.eg.EgSpecsInfo"%>
<%@ page import="com.eg.EgDbInfo"%>
<%@ page import="com.eg.EgTablesInfo"%>
<%@ page import="com.eg.EgMemInfo"%>
<%@ page import="com.egurkha.util.StringUtils"%>
<%@ page import="com.egurkha.util.DateTimeTokenizer"%>
<%@ page import="com.egurkha.Health"%>
<%@ page import="com.egurkha.State"%>
<%@ page import = "com.egurkha.EgMeasureGraphExt" %>
<%@ page import="com.egurkha.monitor.*"%>
<%@ page import = "com.eg.EgDbAdapterTypeUI" %>
<%@ page import = "egurkha.EgDbAdapterUI" %>
<%@page import="egurkha.reporter.ErUtils"%>
<%@ page import="com.objectplanet.chart.*"%>
<%@ page import="egurkha.reporter.uptime.*" %>
<%@ page import="java.util.*"%>
<%@ page import="net.sf.json.*"%>
<%@ page language="java" contentType="application/json;charset=UTF-8" pageEncoding="UTF-8" %>
<%
	response.setHeader("Cache-Control","no-store");
	response.setHeader("Pragma","no-cache");
	response.setDateHeader("Expires", -1);
%>
<%
try
{
	if(EgInstallInfo.isSuperManager)
	{
		String currentSession = session.getId();
		String hostname = request.getParameter("hostName");
		//System.out.println("egSysDashboardJSON.jsp hostname " + hostname);
		if(hostname != null && !hostname.trim().equalsIgnoreCase("null"))
		{
			if(hostname.indexOf(":")>-1)
			{
				hostname = hostname.substring(0,hostname.indexOf(":"));
			}
			//System.out.println("egSysDashboardJSON.jsp host " + hostname);
			ArrayList managerIds = EgElementInfo.getInstance().getManagerIDs("component",hostname);
			//System.out.println("egSysDashboardJSON.jsp managerIds " + managerIds);
			if(managerIds != null && !managerIds.isEmpty())
			{
				SmSessionData smsData = new SmSessionData(currentSession,managerIds);
				EgThreadLocal egtl = new EgThreadLocal();
				egtl.set(smsData);
			}
		}
	}
//	System.out.println("QueryString---sysDash----->"+ErUtils.prepareQueryString(request.getParameterMap()));
	JSONObject rootJson=new JSONObject();
	JSONObject screenLabels = new JSONObject();
	JSONObject selectedValues = new JSONObject();
	JSONObject hiddens = new JSONObject();
	
	String compType=request.getParameter("compType");
	String s_iniFile_dir=EgInstallInfo.getInstallDir()+"/manager/config/";
	String dashboardIni = "eg_serverdashboard.ini";

	EgTablesInfo tablesInfo=new EgTablesInfo("manager");
	EgSpecsInfo specsInfo = new EgSpecsInfo("manager");

	EgMappingInfo mappingInfo1=new EgMappingInfo(trackerLanguage);
	EgMeasureGraphExt measureGraphInfo = new EgMeasureGraphExt();
	DateTimeTokenizer dtd = new DateTimeTokenizer();
	EgServerDashboardModel  egDashboard=null;
	boolean aggregateServerDahboard = false;
	if(compType!=null && compType.startsWith("Agg_"))
	{
		aggregateServerDahboard = true;
		egDashboard=new  EgServerDashboardModel(true);
		dashboardIni = "eg_aggregateserverdashboard.ini";
	}
	else
	{
		egDashboard=new  EgServerDashboardModel();
	}
	IniFile iniObj=new IniFile(s_iniFile_dir+dashboardIni);
	EgFusionChartUtil fusionChart=new EgFusionChartUtil(trackerLanguage);


	String subject="System_Dashboard_Metrics";
	String compName=request.getParameter("hostName");
	String s_specificsubject=iniObj.getValue("CommonDashboardConfiguration",compType);
	boolean isfromSuper = session.getAttribute("fromSuper") != null && session.getAttribute("fromSuper").toString().equalsIgnoreCase("yes");
	boolean isSpecificSubject=(s_specificsubject!=null && s_specificsubject.equalsIgnoreCase("yes"));
	if(isSpecificSubject)
	{
		subject=compType;
	}

	egDashboard.setSubject(subject);

	boolean ddEnabled = EgMemInfo.ddEnabled;
	boolean noGraphsFound=true;
	String siteName=request.getParameter("site");
	String componentState=egDashboard.getServerState(compName,compType,siteName);

	String tab=request.getParameter("tab");
	String subsystem=request.getParameter("subsystem");
	String graphType=request.getParameter("graphType");

	SimpleDateFormat sf=new SimpleDateFormat("MM/dd/yyyy");
	SimpleDateFormat  dateFormatWithTime=new SimpleDateFormat("dd/MM/yyyy HH:mm");

	java.util.Date endDate=new java.util.Date();
	java.util.Date startDate=new java.util.Date(endDate.getTime()-(60*60*1000));

	EgDbInfo dbInfo=new EgDbInfo("manager");
	EgServerDashboardMGraphModel measureGraph=new EgServerDashboardMGraphModel();
	VmSummaryView view = new VmSummaryView();

	String hostName="";
	String portNo="";
	String startTime="";
	String endTime="";
	String startHour="";
	String endHour="";
	String startDateTime="";
	String endDateTime="";

	String test="";
	String measure="";
	String info="";
	String status="";
	String sid="";

	startTime=request.getParameter("starttime");
	endTime=request.getParameter("endtime");
	startHour=request.getParameter("starthr");
	endHour=request.getParameter("endhr");
	String timelineFormat=request.getParameter("format");
	String showGraph=request.getParameter("showGraph");
	String graphTimeline=request.getParameter("time_line");
	if(showGraph==null)
	{
		showGraph="DDgraph";
	}

	String eventCriticalPageUrl ="";
	String eventMajorPageUrl ="";
	String eventMinorPageUrl ="";
	if(compName!=null && !compName.equals(""))
	{
		StringTokenizer st=new StringTokenizer(compName,":");
		if(st.hasMoreTokens())
			hostName=st.nextToken();

		if(st.hasMoreTokens())
			portNo=st.nextToken();

		if(st.hasMoreTokens())
			sid=st.nextToken();
	}

	try
	{
		if ( !StringUtils.isNull( startTime ) && startTime.equals("")) {
			java.util.Date startDateFormat = sf.parse(startTime);
			startTime=sf.format(startDateFormat);	
		}
		else
		{
			startTime=sf.format(startDate);
		}
		if ( !StringUtils.isNull( endTime ) && endTime.equals("") ) {
			java.util.Date endDateFormat = sf.parse(endTime);
			endTime=sf.format(endDateFormat);
		}
		else
		{
			endTime=sf.format(endDate);
		}
		startDateTime=dateFormatWithTime.format(startDate);
		endDateTime=dateFormatWithTime.format(endDate);
	}
	catch(Exception ex)
	{
		ex.printStackTrace();
	}

	boolean isSubjectFound=false;
	List subjects=Arrays.asList(iniObj.getSubjects());
	ArrayList enabledTests=specsInfo.getEnabledTests(compType,false);

	if(subjects.contains(subject))
		isSubjectFound=true;

	String dashboardHistoryGraphType="SummaryAtGlance";
	
	if(isSubjectFound)
	{
		rootJson.put("METRICS","TRUE");
		String EventAnalysistimeline=iniObj.getValue("Default_HistoricalEvents_Duration","duration");
		String actualTimeline=EventAnalysistimeline;
		if(EventAnalysistimeline!=null && EventAnalysistimeline.indexOf(" ")!=-1)
		{
			String eventTimeDuration=EventAnalysistimeline.substring(0,EventAnalysistimeline.indexOf(" "));
			String eventTimePeriod=EventAnalysistimeline.substring(EventAnalysistimeline.indexOf(" ")+1,EventAnalysistimeline.length());			eventTimePeriod=eventTimePeriod.substring(0,1).toUpperCase()+eventTimePeriod.substring(1,eventTimePeriod.length());
			EventAnalysistimeline=eventTimeDuration+" "+eventTimePeriod;
		}
		MonitorDAOFactory monitorDaoFactory = MonitorDAOFactory.getInstance();
		ErUtils erutils=new ErUtils();
		
		EgServerDashBoardDAO dashboardDAO=monitorDaoFactory.getServerDashBoardDAO();
		dashboardDAO.setDashboardType("system");
		ErInfo erInfo=new ErInfo();
		EgDateInfo egDate=new EgDateInfo();

		Hashtable alarmCount=new Hashtable();
		Hashtable alarmDetails=new Hashtable();

		Hashtable events=new Hashtable();

		alarmCount=egDashboard.getAlarmCount(compName,compType,"System");
		egDashboard.setAllAlarmDetails();
		session.setAttribute("DashboardModelObject",egDashboard);
		alarmDetails=egDashboard.getAlarmDetails();
		events=egDashboard.getEventsForServer(compName,compType,"System");

		int eventsCount=0;
		if(events!=null)
		{
			Integer countObj=(Integer)events.get("Count");
			if(countObj!=null)
				eventsCount=countObj.intValue();
		}

		String systemOverviewValues="";
		systemOverviewValues=iniObj.getValue(subject,"System_"+subsystem);
		boolean isSubsystemHasComparisonGraphs=false;
		boolean isOverview=subsystem!=null  && subsystem.equalsIgnoreCase("overview");

		String subsystemsWithComparisonGraphs=iniObj.getValue(subject,"System_subsystems_Comparison");
		StringTokenizer stksubSystems=new StringTokenizer(subsystemsWithComparisonGraphs,",");

		while(stksubSystems.hasMoreTokens())
		{
			if(subsystem!=null && subsystem.equals(stksubSystems.nextToken()))
			{
				isSubsystemHasComparisonGraphs=true;
				break;
			}
		}
	
		if(isOverview && (graphType==null) || (graphType!=null && (graphType.equals("null") || graphType.equals(""))))
		{
			dashboardHistoryGraphType="SummaryAtGlance";
		}
		else if(!isOverview && (graphType==null) || (graphType!=null && (graphType.equals("null") || graphType.equals(""))))
		{
			if(isSubsystemHasComparisonGraphs)
			{
				dashboardHistoryGraphType="DDgraph";
			}
			else
			{
				dashboardHistoryGraphType="measureGraph";
			}
		}
		else
		{
			dashboardHistoryGraphType=graphType;
			if(graphTimeline==null || graphTimeline.equalsIgnoreCase("null") || graphTimeline.equals(""))
			{
				graphTimeline=iniObj.getValue("Default_MeasureGraph_Duration","duration");;
			}
		}

		String ua = request.getHeader( "User-Agent" );
		boolean isFirefox2 = ( ua != null && ua.indexOf( "Firefox/2" ) != -1 );
		boolean isFirefox3 = ( ua != null && ua.indexOf( "Firefox/3" ) != -1 );
		boolean isMSIE = ( ua != null && ua.indexOf( "MSIE" ) != -1 );
		boolean isChrome = ( ua != null && ua.indexOf( "Chrome/" ) != -1 );

		String SummaryDivWidth="740px";
		String graphDivDisplay="";
		String graphDivWidth="961px";
		String tabDivWidth="961px";

		//out.print(isFirefox3);

		if (isMSIE)
		{
			SummaryDivWidth="740px";
			graphDivDisplay="block";
			graphDivWidth="958px";
			tabDivWidth="958px";
		}
		else if(isFirefox3)
		{
			SummaryDivWidth="738px";
			graphDivDisplay="block";
			graphDivWidth="956px";
			tabDivWidth="958px";
		}
		else if(isFirefox2)
		{
			SummaryDivWidth="738px";
			graphDivDisplay="table-row";
			graphDivWidth="956px";
			tabDivWidth="956px";
		}
		else if(isChrome)
		{
			SummaryDivWidth="740px";
			graphDivDisplay="block";
			graphDivWidth="958px";
			tabDivWidth="960px";
		}
		if(tab!=null && tab.equalsIgnoreCase("system"))
		{
			rootJson.put("Tests","TRUE");
			screenLabels.put("subsystemTitle", mappingInfo.getTextDescription("monitor.dashboard.Subsystem"));
			JSONArray subsystemArr = new JSONArray();
			
			String systemSubsystems=iniObj.getValue(subject,"System_subsystems");
			StringTokenizer subsystemTokens=new StringTokenizer(systemSubsystems,":");
			JSONObject combObj=new JSONObject();
			while(subsystemTokens.hasMoreTokens())
			{	
				JSONObject subsystemObj = new JSONObject();
				String token=subsystemTokens.nextToken();
				subsystemObj.put("valueField", token);
				subsystemObj.put("displayField", mappingInfo.getTextDescription("monitor.dashboard."+token));
				subsystemArr.add(subsystemObj);
				if(subsystem!=null && token!=null && subsystem.equalsIgnoreCase(token))
				{
					selectedValues.put("subsystemSelected", subsystem);
				}
				
				
			}
			rootJson.put("subsystemCombo", subsystemArr);
		
		if(subsystem!=null && subsystem.equalsIgnoreCase("overview"))
		{
			rootJson.put("SUBSYSTEM", "OVERVIEW");
			JSONObject overviewObj = new JSONObject();
			overviewObj.put("alertTitle", mappingInfo.getTextDescription("monitor.dashboard.Current System Alerts"));
			int openproblems=0;
			Integer   critical=(Integer)alarmCount.get("HIGH");
			Integer   major=(Integer)alarmCount.get("INTERMEDIATE");
			Integer   minor=(Integer)alarmCount.get("LOW");
			if(alarmCount!=null && alarmCount.size()>0 && (critical.intValue()+major.intValue()+minor.intValue())>0)
			{
				JSONObject alertObj = new JSONObject();
				String criticalDesc=(String)alarmDetails.get("HIGH");
				String majorDesc=(String)alarmDetails.get("INTERMEDIATE");
				String minorDesc=(String)alarmDetails.get("LOW");
				openproblems=critical.intValue()+major.intValue()+minor.intValue();
				alertObj.put("OPEN_ALERT_TITLE", mappingInfo.getTextDescription("monitor.dashboard.Open Alerts"));
				alertObj.put("DISTRIBUTION_TITLE", mappingInfo.getTextDescription("monitor.dashboard.Distribution"));
				alertObj.put("OPEN_ALERTS", openproblems);
				if(critical!=null && critical.intValue()>0)
				{
					
					alertObj.put("DISTRIBUTION_CRITICAL_VALUE", String.valueOf(critical.intValue()));
					alertObj.put("DISTRIBUTION_CRITICAL_DESC", criticalDesc);
					JSONObject linkObj = new JSONObject();
					linkObj.put("METHOD_NAME", "showAlert");
					linkObj.put("PARAMS", "event|"+criticalDesc+"|"+critical.intValue()+"HIGH");
					alertObj.put("DISTRIBUTION_CRITICAL_LINK", linkObj);
				}
				else
				{	
					alertObj.put("DISTRIBUTION_CRITICAL_VALUE", String.valueOf(critical.intValue()));
				}

				if(major!=null && major.intValue()>0)
				{
					alertObj.put("DISTRIBUTION_MAJOR_VALUE", String.valueOf(major.intValue()));
					alertObj.put("DISTRIBUTION_MAJOR_DESC", majorDesc);
					JSONObject linkObj = new JSONObject();
					linkObj.put("METHOD_NAME", "showAlert");
					linkObj.put("PARAMS", "event|"+majorDesc+"|"+major.intValue()+"INTERMEDIATE");
					alertObj.put("DISTRIBUTION_MAJOR_LINK", linkObj);
				}
				else
				{
					alertObj.put("DISTRIBUTION_MAJOR_VALUE", String.valueOf(major.intValue()));
				}

				if(minor!=null && minor.intValue()>0)
				{
					alertObj.put("DISTRIBUTION_MINOR_VALUE", String.valueOf(minor.intValue()));
					alertObj.put("DISTRIBUTION_MINOR_DESC", minorDesc);
					JSONObject linkObj = new JSONObject();
					linkObj.put("METHOD_NAME", "showAlert");
					linkObj.put("PARAMS", "event|"+minorDesc+"|"+minor.intValue()+"LOW");
					alertObj.put("DISTRIBUTION_MINOR_LINK", linkObj);
				}
				else
				{
					alertObj.put("DISTRIBUTION_MINOR_VALUE", String.valueOf(minor.intValue()));
				}
				overviewObj.put("ALERTS", alertObj);
			}
			else
			{
				overviewObj.put("ALERTS", "-");
				overviewObj.put("NO_ALERTS", mappingInfo.getTextDescription("monitor.dashboard.No alarms found")+"!");
			}
			String dateDiff="";
			String test_name="UptimeTest";
			if(aggregateServerDahboard)
			{
				test_name="UptimeTest_ag";
			}

			if(isSpecificSubject)
			{
				test_name=iniObj.getValue("DASHBOARD_UPTIME_TESTS",subject);
				if(test_name==null || (test_name!=null && test_name.equals("")))
				{
					if(aggregateServerDahboard)
					{
						test_name="UptimeTest_ag";
					}
					else
					{
						test_name="UptimeTest";
					}
				}
			}
		
			String measure_name="Total_uptime";
			String in_info="+";
			String msmtHost="";
			measure_name=dbInfo.getColumnForMeasure(test_name,measure_name);
			Vector msmtHostsForTest=dashboardDAO.getMsmtHost(hostName,compType,test_name,portNo);
			if(msmtHostsForTest!=null &&  msmtHostsForTest.size()>0)
				msmtHost=(String)msmtHostsForTest.get(0);

			String tmpCmpName = compName;
			if(compName!=null && compName.endsWith(":NULL"))
			{
				tmpCmpName = compName.substring(0,compName.indexOf(":NULL"));
			}		
			boolean isExcludedTest = egDashboard.isExcludedComponentForTest(compType,tmpCmpName,test_name);
			String currentValue=dashboardDAO.getCurrentMeasure(hostName,portNo,in_info,test_name,measure_name,msmtHost);
			if(enabledTests!=null && enabledTests.contains(test_name) && !isExcludedTest  && currentValue!=null && !currentValue.trim().equals(""))
			{
				long minites=0;
				int secounds=0;
				if(currentValue!=null && currentValue.indexOf(".")>0)
				{
					minites=Long.parseLong(currentValue.substring(0,currentValue.indexOf(".")));
					if(currentValue.substring(currentValue.indexOf(".")+1).length()>2)
					secounds=Integer.parseInt(currentValue.substring(currentValue.indexOf(".")+1,currentValue.indexOf(".")+3));
					else
					secounds=Integer.parseInt(currentValue.substring(currentValue.indexOf(".")+1));
				}
				else
				{
					minites=Long.parseLong(currentValue);
				}
				long valueInSecound=(minites*60)+secounds;
				dateDiff=egDashboard.getDateDifferenceString(valueInSecound);
				if(dateDiff==null || dateDiff.trim().equals(""))
				dateDiff="-";
				overviewObj.put("DATE_DIFF", dateDiff);
			}
			else if(dateDiff.trim().equals(""))
			{
				dateDiff="-";
				overviewObj.put("DATE_DIFF", dateDiff);
			}
			overviewObj.put("SYSTEM_UPTIME", mappingInfo.getTextDescription("monitor.dashboard.System Uptime"));
			JSONObject eventsObj = new JSONObject();	
			eventsObj.put("eventsTitle", mappingInfo.getTextDescription("monitor.dashboard.History of Events During the Last")+" "+mappingInfo.getTextDescription("monitor.common."+EventAnalysistimeline));
			if(eventsCount!=0)
			{
				ErUtils erUtils=new ErUtils();
				double criticalEvtCount=0.0;
				double majorEvtCount=0.0;
				double minorEvtCount=0.0;
				Integer   criticalEvents=null;
				Integer majorEvents=null;
				Integer  minorEvents=null;
				ArrayList al=new ArrayList();
				criticalEvents=(Integer)events.get("HIGH");
				majorEvents=(Integer)events.get("INTERMEDIATE");
				minorEvents=(Integer)events.get("LOW");
				al.add(criticalEvents.toString());
				al.add(majorEvents.toString());
				al.add(minorEvents.toString());
				criticalEvtCount=criticalEvents.doubleValue();
				majorEvtCount=majorEvents.doubleValue();
				minorEvtCount=minorEvents.doubleValue();
				String max=erUtils.getMaximum(al);
				double[] Hsevalues=new double[]{criticalEvtCount,majorEvtCount,minorEvtCount};
				
				eventsObj.put("criticalEvtCount",criticalEvtCount);
				eventsObj.put("majorEvtCount",majorEvtCount);
				eventsObj.put("minorEvtCount",minorEvtCount);

				String HistoricalEventsGraphURL="/final/servlet/com.egurkha.monitor.EgEventChart?hostName="+compName+"&compType="+compType+"&module=System&width=220&height=88&imgdate="+new java.util.Date();

				eventCriticalPageUrl = response.encodeURL("/final/monitor/EgAlarmHistoryView.jsp?")+"newAlarms=true&compTypeList="+compType+"&compNameList="+EgURLEncoder.encode(compName,"UTF-8")+"&glduration=0&duration=0&timeselect=seconds&eg_timeline="+actualTimeline+"&eventsPerPage=All&arrangeAlarms=-1&fromDashBoard=true&selectedLayer="+tab+"&tab="+tab+"&dashboardcomptype="+compType+"&dashboardcompname="+EgURLEncoder.encode(compName,"UTF-8")+"&state=HIGH";
				eventMajorPageUrl = response.encodeURL("/final/monitor/EgAlarmHistoryView.jsp?")+"newAlarms=true&compTypeList="+compType+"&compNameList="+EgURLEncoder.encode(compName,"UTF-8")+"&glduration=0&duration=0&timeselect=seconds&eg_timeline="+actualTimeline+"&eventsPerPage=All&arrangeAlarms=-1&fromDashBoard=true&selectedLayer="+tab+"&tab="+tab+"&dashboardcomptype="+compType+"&dashboardcompname="+EgURLEncoder.encode(compName,"UTF-8")+"&state=INTERMEDIATE";
				eventMinorPageUrl = response.encodeURL("/final/monitor/EgAlarmHistoryView.jsp?")+"newAlarms=true&compTypeList="+compType+"&compNameList="+EgURLEncoder.encode(compName,"UTF-8")+"&glduration=0&duration=0&timeselect=seconds&eg_timeline="+actualTimeline+"&eventsPerPage=All&arrangeAlarms=-1&fromDashBoard=true&selectedLayer="+tab+"&tab="+tab+"&dashboardcomptype="+compType+"&dashboardcompname="+EgURLEncoder.encode(compName,"UTF-8")+"&state=LOW";

				Vector eventChartAttribute=new Vector();

				eventChartAttribute.add("majorTMNumber='6'");
				eventChartAttribute.add("majorTMHeight='10'");
				eventChartAttribute.add("majorTMColor='ffffff'");
				eventChartAttribute.add("minorTMColor='D5D5D5'");
				eventChartAttribute.add("minorTMHeight='5'");
				eventChartAttribute.add("minorTMNumber='5'");
				eventChartAttribute.add("majorTMThickness='2'");
				eventChartAttribute.add("palette='2'");
				eventChartAttribute.add("showValues='1'");
				eventChartAttribute.add("showYAxisValues='0'");
				eventChartAttribute.add("decimals='0'");
				eventChartAttribute.add("formatNumberScale='0'");
				eventChartAttribute.add("useRoundEdges='1'");
				eventChartAttribute.add("exportEnabled='0'");
				eventChartAttribute.add("showExportDialog='1'");
				eventChartAttribute.add("exportAction='save'");
				eventChartAttribute.add("exportTargetWindow='1'");
				eventChartAttribute.add("showShadow='1'");
				eventChartAttribute.add("showToolTipShadow='1'");
				eventChartAttribute.add("chartLeftMargin='8'");
				eventChartAttribute.add("chartRightMargin='20'");
				eventChartAttribute.add("chartTopMargin='3'");
				eventChartAttribute.add("chartBottomMargin='8'");
				eventChartAttribute.add("bgColor='99CCFF,FFFFFF'");
				eventChartAttribute.add("bgAlpha='0,0'");
				eventChartAttribute.add("outCnvBaseFontColor='ffffff'");
				eventChartAttribute.add("canvasLeftMargin='17'");
				eventChartAttribute.add("canvasRightMargin='7'");
				eventChartAttribute.add("canvasTopMargin='5'");
				eventChartAttribute.add("canvasBottomMargin='7'");
				eventChartAttribute.add("showBorder='0'");

				//String historyXMLData=fusionChart.getXMLforEventHistory(compName,compType,tab,eventChartAttribute);
				String smUrl = null;
				if(isfromSuper)
				{
					smUrl = (String)session.getAttribute("Super_Manager_Url");
				}
				String timeline=iniObj.getValue("Default_HistoricalEvents_Duration","duration");
				if(timeline==null || timeline.trim().equals(""))
					timeline="24 hours";

				String historyXMLData=fusionChart.getXMLforEventHistory(compName,compType,tab,timeline,"",eventChartAttribute,isfromSuper,smUrl,"eventUrl1","eventUrl2","eventUrl3");
				eventsObj.put("SWF_PATH", "/final/FusionCharts/swf/Bar2D.swf");
				eventsObj.put("XML_DATA", historyXMLData);
				eventsObj.put("monitor.dashboard.Total Events", mappingInfo.getTextDescription("monitor.dashboard.Total Events"));
				eventsObj.put("TOTAL_EVENTS", ((Integer)events.get("Count")).toString());

				eventsObj.put("monitor.dashboard.Avg Duration", mappingInfo.getTextDescription("monitor.dashboard.Avg Duration"));
				eventsObj.put("AVG_DURATION", (String)events.get("AvgDuration"));

				eventsObj.put("monitor.dashboard.Avg Duration", mappingInfo.getTextDescription("monitor.dashboard.Avg Duration"));
				eventsObj.put("AVG_DURATION", (String)events.get("AvgDuration"));

				eventsObj.put("monitor.dashboard.Max Duration", mappingInfo.getTextDescription("monitor.dashboard.Max Duration"));
				eventsObj.put("MAX_DURATION", (String)events.get("MaxDuration"));
				overviewObj.put("EVENTS",eventsObj);
			}
			else
			{
				overviewObj.put("eventsTitle", mappingInfo.getTextDescription("monitor.dashboard.History of Events During the Last")+" "+mappingInfo.getTextDescription("monitor.common."+EventAnalysistimeline));
				overviewObj.put("EVENTS","-");
				overviewObj.put("NO_EVENTS",mappingInfo.getTextDescription("monitor.dashboard.No events found")+"!");
			}
			
			overviewObj.put("eventUrl1", eventCriticalPageUrl);
			overviewObj.put("eventUrl2", eventMajorPageUrl);
			overviewObj.put("eventUrl3", eventMinorPageUrl);
			rootJson.put("OVERVIEW", overviewObj);
		}
		else
		{
			rootJson.put("SUBSYSTEM", subsystem);
			String url="egSummary.jsp?hostName="+EgURLEncoder.encode(compName,"UTF-8")+"&compType="+compType+"&subsystem="+subsystem+"&subject="+subject;
			//url
		}
		rootJson.put("selectedGraphType","System_"+dashboardHistoryGraphType);
		String urlString="egDashboardGraphTimeline.jsp?showGraph="+dashboardHistoryGraphType+"&subsystem="+subsystem+"&tab=System&graphTimeline="+graphTimeline+"&starttime="+startTime+"&endtime="+endTime+"&starthr="+startHour+"&endhr="+endHour+"&format="+timelineFormat+"&subject="+subject;
		//urlString
		String StringUrl="/final/monitor/egDashboardGraphTimeline.jsp?showGraph="+dashboardHistoryGraphType+"&subsystem="+subsystem+"&tab=System&graphTimeline="+graphTimeline+"&starttime="+startTime+"&endtime="+endTime+"&starthr="+startHour+"&endhr="+endHour+"&format="+timelineFormat+"&subject="+subject+"&compType="+compType+"&graphType="+graphType;
		rootJson.put("TAB_URL", StringUrl);
		if(isOverview  && (dashboardHistoryGraphType!=null && dashboardHistoryGraphType.equalsIgnoreCase("SummaryAtGlance")))
		{
			String url="/final/monitor/egDashboardOverviewJSON.jsp?hostName="+compName+"&compType="+compType+"&subject="+subject+"&tab=System";
			rootJson.put("INNER_TAB_URL", url);
		}
		else
		{	
			rootJson.put("SUBSYSTEM",subsystem);
			String url="/final/monitor/egDashboardHistoryJSON.jsp?tab=System&subsystem="+subsystem+"&hostName="+compName+"&compType="+compType+"&graphType="+dashboardHistoryGraphType+"&subject="+subject+"&time_line="+graphTimeline+"&starttime="+startTime+"&endtime="+endTime+"&starthr="+startHour+"&endhr="+endHour+"&format="+timelineFormat+"&showGraph="+dashboardHistoryGraphType;
			rootJson.put("INNER_TAB_URL", url);
		}
	}
		else{
			rootJson.put("Tests","FALSE");			
		}
}
	else
	{
		rootJson.put("METRICS","FALSE");
		rootJson.put("NO_METRICS",mappingInfo.getTextDescription("monitor.dashboar.No Metrics Configured"));
	}
	rootJson.put("selectedValues", selectedValues);
	rootJson.put("screenLabels", screenLabels);
	rootJson.put("hiddens", hiddens);
	out.println(rootJson.toString());
//	System.out.println("System dashboard------->"+rootJson);
}
catch(Throwable ex)
{
	ex.printStackTrace();
}
%>