public void sendReply_cgibin_nagiosstatus_cgi(MyHTTPServer socket, String cookie) throws Exception
	{
		List<String> reply = new ArrayList<String>();

		addHTTP200(reply, cookie);
		reply.add("<HTML><!-- " + CoffeeSaint.getVersion() + "--><HEAD><meta http-equiv=\"refresh\" content=\"" + config.getSleepTime() + "\"></HEAD><BODY>");
		reply.add("<FONT SIZE=-1>Generated by: " + CoffeeSaint.getVersion() + "</FONT><BR><BR>");

		Calendar rightNow = Calendar.getInstance();

		Object [] result = CoffeeSaint.loadNagiosData(null, -1, null);
		JavNag javNag = (JavNag)result[0];
		if (result[1] != null)
			reply.add("<B>Problem load: " + (String)result[1] + "</B><BR>");
		List<Problem> problems = CoffeeSaint.findProblems(javNag);
		coffeeSaint.learnProblemCount(problems.size());
		coffeeSaint.collectPerformanceData(javNag);
		coffeeSaint.collectLatencyData(javNag);

		if (config.getShowHeader())
		{
			String header = coffeeSaint.getScreenHeader(javNag, rightNow, problems.size() > 0);
			reply.add(header + "<BR>");
		}

		Color bgColor;
		if (problems.size() > 0)
			bgColor = config.getBackgroundColor();
		else
			bgColor = coffeeSaint.predictWithColor(rightNow);

		long maxAge = config.getMaxCheckAge();
		if (maxAge != -1) {
			long currentAge = javNag.findMostRecentCheckAge();
			if (currentAge > maxAge)
				reply.add("<FONT SIZE=+2>WARNING: Nagios has not done anything for the last " + currentAge + " seconds!</FONT><BR><BR>\n");
		}

		reply.add("<TABLE WIDTH=640 HEIGHT=400 TEXT=\"#" + htmlColorString(config.getTextColor()) + "\" BGCOLOR=\"#" + htmlColorString(bgColor) + "\">\n");

		for(Problem currentProblem : problems)
		{
			String stateColor = htmlColorString(coffeeSaint.stateToColor(currentProblem.getCurrent_state(), currentProblem.getHard()));

			String escapeString;
			if (currentProblem.getService() == null)
				escapeString = config.getHostIssue();
			else
				escapeString = config.getServiceIssue();
			Object [] dummy = coffeeSaint.processStringWithEscapes(escapeString, javNag, rightNow, currentProblem, true, true);
			String output = (String)dummy[0];

			reply.add("<TR><TD BGCOLOR=\"#" + stateColor + "\" TEXT=\"#" + htmlColorString(config.getTextColor()) + "\">" + output + "</TD></TR>\n");
		}

		if (problems.size() == 0)
		{
			if (config.getImageUrls().size() >= 1)
				reply.add("<TR VALIGN=CENTER><TD ALIGN=CENTER><IMG SRC=\"/image.jpg\" BORDER=\"0\"></TD></TR>\n");
			else if (config.getNagiosDataSources().size() == 0)
				reply.add("<TR VALIGN=CENTER><TD ALIGN=CENTER>NO NAGIOS SERVERS SELECTED!</TD></TR>\n");
			else
				reply.add("<TR VALIGN=CENTER><TD ALIGN=CENTER>All fine.</TD></TR>\n");
		}

		reply.add("</TABLE>\n");

		reply.add("</BODY>");
		reply.add("</HTML>");

		socket.sendReply(reply);
	}