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> 50 __rrd_man = rrd_manager;
54 __baseurl_len = strlen(baseurl);
66 if ( strncmp(__baseurl, request->
url().c_str(), __baseurl_len) == 0 ) {
68 std::string subpath = request->
url().substr(__baseurl_len);
75 if (subpath.find(
"/graph/") == 0) {
76 std::string graph_name = subpath.substr(subpath.find_first_not_of(
"/", std::string(
"/graph/").length()));
78 for (g = graphs.begin(); g != graphs.end(); ++g) {
79 if (strcmp((*g)->get_name(), graph_name.c_str()) == 0) {
91 "href=\"/static/css/rrdweb.css\" />\n");
92 *r +=
"<h2>RRD Graphs</h2>\n";
94 std::string subpath = request->
url().substr(__baseurl_len);
97 *r +=
"<table class=\"rrdgrid\">";
98 for (g = graphs.begin(); g != graphs.end(); ++g) {
99 if ((i % 2) == 0) *r +=
" <tr>";
100 r->
append_body(
"<td class=\"%s\"><img src=\"/rrd/graph/%s\" /></td>",
101 ((i % 2) == 0) ?
"left" :
"right",
103 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 const char * what() const
Get primary string.
virtual fawkes::WebReply * process_request(const fawkes::WebRequest *request)
Process a request.
Base class for exceptions in Fawkes.
virtual ~RRDWebRequestProcessor()
Destructor.
Web request meta data carrier.
void append_body(const char *format,...)
Append to body.
const std::string & url() const
Get URL.