23 #include "rrdweb_processor.h"
24 #include <plugins/rrd/aspect/rrd_manager.h>
25 #include <core/threading/scoped_rwlock.h>
26 #include <core/exception.h>
27 #include <webview/page_reply.h>
28 #include <webview/file_reply.h>
29 #include <webview/error_reply.h>
51 __rrd_man = rrd_manager;
55 __baseurl_len = strlen(baseurl);
68 const char *upload_data,
69 size_t *upload_data_size,
72 if ( strncmp(__baseurl, url, __baseurl_len) == 0 ) {
74 std::string subpath = std::string(url).substr(__baseurl_len);
81 if (subpath.find(
"/graph/") == 0) {
82 std::string graph_name = subpath.substr(subpath.find_first_not_of(
"/", std::string(
"/graph/").length()));
84 for (g = graphs.begin(); g != graphs.end(); ++g) {
85 if (strcmp((*g)->get_name(), graph_name.c_str()) == 0) {
97 "href=\"/static/css/rrdweb.css\" />\n");
98 *r +=
"<h2>RRD Graphs</h2>\n";
100 std::string subpath = std::string(url).substr(__baseurl_len);
103 *r +=
"<table class=\"rrdgrid\">";
104 for (g = graphs.begin(); g != graphs.end(); ++g) {
105 if ((i % 2) == 0) *r +=
" <tr>";
106 r->
append_body(
"<td class=\"%s\"><img src=\"/rrd/graph/%s\" /></td>",
107 ((i % 2) == 0) ?
"left" :
"right",
109 if ((i++ % 2) == 1) *r +=
" </tr>\n";
RRDWebRequestProcessor(fawkes::RRDManager *rrd_manager, fawkes::Logger *logger, const char *__baseurl)
Constructor.
Dynamic raw file transfer reply.
Interface for a RRD connection creator.
Fawkes library namespace.
virtual fawkes::WebReply * process_request(const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **session_data)
Process a request.
Abstract web request processor.
virtual const char * what() const
Get primary string.
Base class for exceptions in Fawkes.
virtual ~RRDWebRequestProcessor()
Destructor.
void append_body(const char *format,...)
Append to body.
virtual const RWLockVector< RRDGraphDefinition * > & get_graphs() const =0
Get graphs.