ParamsBean params = new ParamsBean(req, getHostsList()); if(params.getValue("sync") != null) { configthread.run(); } else {
@Override public String toString() { StringBuilder parambuff = new StringBuilder(); Map<String, Object> args = new HashMap<String, Object>(); addFilterArgs(args); addPeriodArgs(args, true); addMinMaxArgs(args); parambuff.append('&'); if(id != 0) parambuff.append("id=").append(id).append('&'); if(gid != 0) parambuff.append("gid=").append(gid).append('&'); for(Map.Entry<String, Object> param: args.entrySet()) { String key = param.getKey(); Object value = param.getValue(); if(value != null && !"".equals(value)) { parambuff.append(key); parambuff.append('='); parambuff.append(value); parambuff.append('&'); } else if(value == null) { parambuff.append(key); parambuff.append('&'); } } // Remove the extra & parambuff.deleteCharAt(parambuff.length() - 1); return parambuff.toString(); }
public jrds.Graph getGraph(JrdsServlet caller) { jrds.Graph g = null; if(gid != null) g = hostlist.getRenderer().getGraph(gid); if(g == null) { logger.debug("graph cache miss"); jrds.GraphNode node = getGraphNode(caller); if(node != null) { g = node.getGraph(); configureGraph(g); } } return g; }
private void doGraph(GraphNode gn, Renderer r, ParamsBean params, JrdsJSONWriter w) throws IOException { jrds.Graph graph = gn.getGraph(); if (graph == null) { return; } params.configureGraph(graph); Map<String, Object> imgProps = new HashMap<String, Object>(); r.render(graph); Probe<?, ?> p = gn.getProbe(); imgProps.put("probename", p.getName()); imgProps.put("qualifiedname", graph.getQualifiedName()); Dimension d = graph.getDimension(); if(d != null) { imgProps.put("height", d.height); imgProps.put("width", d.width); } imgProps.put("graph", params.doArgsMap(graph, true)); imgProps.put("history", params.doArgsMap(graph, false)); imgProps.put("probe", params.doArgsMap(p, true)); imgProps.put("graphnode", params.doArgsMap(gn, true)); doTree(w, graph.getQualifiedName(), gn.hashCode(), "graph", null, imgProps); }
try { w.object(); doVariable(w, "pid", params.getValue("pid")); doVariable(w, "id", params.getValue("id")); doVariable(w, "gid", params.getValue("gid")); doVariable(w, "sort", params.getValue("sort")); String pathString = params.getValue("path"); if(pathString != null && !"".equals(pathString)) { doVariable(w, "path", new JSONArray(pathString)); String choiceType = params.getChoiceType(); String choiceValue = params.getChoiceValue(); if(choiceType != null && choiceValue != null) doVariable(w, choiceType, choiceValue); doVariable(w, "min", params.getMinStr()); doVariable(w, "max", params.getMaxStr()); doVariable(w, "dsName", params.getValue("dsName")); doVariable(w, "begin", params.getBegin()); doVariable(w, "end", params.getEnd()); doVariable(w, "autoperiod", params.getScale());
@Override public boolean generate(JrdsJSONWriter w, HostsList root, ParamsBean params) throws IOException { if(ParamsBean.TABCHOICE.equals(params.getChoiceType())) { Tab tab = params.getTab(); logger.debug(jrds.Util.delayedFormatString("Tab specified: %s", params.getChoiceValue())); if(tab == null) return false; } else if(ParamsBean.HOSTCHOICE.equals(params.getChoiceType())) { GraphTree tree = params.getTree(); logger.debug(jrds.Util.delayedFormatString("Host specified: %s", params.getChoiceValue())); if(tree == null) return false; return evaluateTree(params, w, root, tree); } else if(ParamsBean.TREECHOICE.equals(params.getChoiceType())) { GraphTree tree = params.getTree(); logger.debug(jrds.Util.delayedFormatString("Tree specified: %s", params.getChoiceValue())); if(tree == null) return false; return evaluateTree(params, w, root, tree); } else if(ParamsBean.FILTERCHOICE.equals(params.getChoiceType())) { Filter filter = params.getFilter(); logger.debug(jrds.Util.delayedFormatString("Filter specified: %s", params.getChoiceValue())); if(filter == null) return false;
HostsList hl = getHostsList(); ParamsBean p = new ParamsBean(req, hl, "host", "graphname"); cache = false; jrds.Graph graph = p.getGraph(this); jrds.GraphNode node = hl.getGraphById(p.getId()); int wh = graph.getDimension().height; int rh = graph.getRrdGraph().getRrdGraphInfo().getHeight();
ParamsBean params = new ParamsBean(req, hl, "host", "probe", "dsname", "period", "cf"); long period = jrds.Util.parseStringNumber(params.getValue("period"), new Long(hl.getStep())); String cfName = params.getValue("cf"); if(cfName == null || cfName.trim().isEmpty()) cfName = "AVERAGE"; Probe<?, ?> p = params.getProbe(); if (p == null) { res.sendError(HttpServletResponse.SC_BAD_REQUEST, "No matching probe"); String ds = params.getValue("dsname");
ParamsBean p = new ParamsBean(req, hl, "host", "graphname"); Graph graph = p.getGraph(this);
protected ParamsBean getParamsBean(HttpServletRequest request, String... restPath) { return new ParamsBean(request, getHostsList(), restPath); }
public String makeObjectUrl(String file, Object o, boolean timeAbsolute) { Map<String, Object> args = doArgsMap(o, timeAbsolute); logger.trace(jrds.Util.delayedFormatString("Params string:%s ", args)); // We build the Url StringBuilder urlBuffer = new StringBuilder(); urlBuffer.append(contextPath); if(!contextPath.endsWith("/")) { urlBuffer.append('/'); } urlBuffer.append(file).append("?"); for(Map.Entry<String, Object> e: args.entrySet()) { try { urlBuffer.append(e.getKey()).append("=").append(URLEncoder.encode(e.getValue().toString(), "UTF-8")).append("&"); } catch (UnsupportedEncodingException e1) { } } urlBuffer.deleteCharAt(urlBuffer.length() - 1); return urlBuffer.toString(); }
HostsList hl = getHostsList(); ParamsBean params = new ParamsBean(req, hl); if(!allowed(params, getPropertiesManager().adminACL, req, res)) return;
addPeriodArgs(args, timeAbsolute); addMinMaxArgs(args); if(o instanceof jrds.FilterHost) { args.put("host", ((jrds.Filter) o).getName()); args.put("pid", o.hashCode()); } else { addFilterArgs(args); args.put("id", o.hashCode());
/** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse * response) */ protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { ParamsBean params = new ParamsBean(req, getHostsList(), "command", "arg"); String command = params.getValue("command"); if(command == null || "".equals(command)) { command = req.getServletPath().substring(1); } logger.debug(Util.delayedFormatString("Command found: %s", command)); if(!allowed(params, getPropertiesManager().adminACL, req, res)) return; if("reload".equalsIgnoreCase(command)) { ServletContext ctxt = getServletContext(); // only one reload allowed to run, just ignore synchronous reload if(ReloadHostList.reloading.tryAcquire()) { reload(ctxt); } res.sendRedirect(req.getContextPath() + "/"); } else if("pause".equalsIgnoreCase(command)) { ServletContext ctxt = getServletContext(); pause(ctxt, params.getValue("arg")); res.sendRedirect(req.getContextPath() + "/"); } }
ParamsBean params = new ParamsBean(req, hl); if(!allowed(params, ACL.ALLOWEDACL, req, res)) { return; if(params.getValue("json") != null) { JrdsJSONWriter writer = new JrdsJSONWriter(res); try {