SOURCES: lighttpd-mod_rrdtool-emptyfile.patch (NEW) - run rrdtool create if...
glen
glen at pld-linux.org
Tue Oct 7 12:59:55 CEST 2008
Author: glen Date: Tue Oct 7 10:59:55 2008 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- run rrdtool create if .rrd file is empty.
see also http://trac.lighttpd.net/trac/ticket/1788
---- Files affected:
SOURCES:
lighttpd-mod_rrdtool-emptyfile.patch (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: SOURCES/lighttpd-mod_rrdtool-emptyfile.patch
diff -u /dev/null SOURCES/lighttpd-mod_rrdtool-emptyfile.patch:1.1
--- /dev/null Tue Oct 7 12:59:56 2008
+++ SOURCES/lighttpd-mod_rrdtool-emptyfile.patch Tue Oct 7 12:59:50 2008
@@ -0,0 +1,101 @@
+--- lighttpd-1.4.20/src/mod_rrdtool.c~ 2008-07-30 22:38:32.000000000 +0300
++++ lighttpd-1.4.20/src/mod_rrdtool.c 2008-10-07 13:27:54.472090759 +0300
+@@ -200,54 +200,58 @@
+ "not a regular file:", s->path_rrd);
+ return HANDLER_ERROR;
+ }
+- } else {
+- int r ;
+- /* create a new one */
++ }
+
+- buffer_copy_string_len(p->cmd, CONST_STR_LEN("create "));
+- buffer_append_string_buffer(p->cmd, s->path_rrd);
+- buffer_append_string_len(p->cmd, CONST_STR_LEN(
+- " --step 60 "
+- "DS:InOctets:ABSOLUTE:600:U:U "
+- "DS:OutOctets:ABSOLUTE:600:U:U "
+- "DS:Requests:ABSOLUTE:600:U:U "
+- "RRA:AVERAGE:0.5:1:600 "
+- "RRA:AVERAGE:0.5:6:700 "
+- "RRA:AVERAGE:0.5:24:775 "
+- "RRA:AVERAGE:0.5:288:797 "
+- "RRA:MAX:0.5:1:600 "
+- "RRA:MAX:0.5:6:700 "
+- "RRA:MAX:0.5:24:775 "
+- "RRA:MAX:0.5:288:797 "
+- "RRA:MIN:0.5:1:600 "
+- "RRA:MIN:0.5:6:700 "
+- "RRA:MIN:0.5:24:775 "
+- "RRA:MIN:0.5:288:797\n"));
++ /* still create DB if it's empty file */
++ if (st.st_size > 0) {
++ return HANDLER_GO_ON;
++ }
+
+- if (-1 == (r = write(p->write_fd, p->cmd->ptr, p->cmd->used - 1))) {
+- log_error_write(srv, __FILE__, __LINE__, "ss",
+- "rrdtool-write: failed", strerror(errno));
++ int r;
++ /* create a new one */
++ buffer_copy_string_len(p->cmd, CONST_STR_LEN("create "));
++ buffer_append_string_buffer(p->cmd, s->path_rrd);
++ buffer_append_string_len(p->cmd, CONST_STR_LEN(
++ " --step 60 "
++ "DS:InOctets:ABSOLUTE:600:U:U "
++ "DS:OutOctets:ABSOLUTE:600:U:U "
++ "DS:Requests:ABSOLUTE:600:U:U "
++ "RRA:AVERAGE:0.5:1:600 "
++ "RRA:AVERAGE:0.5:6:700 "
++ "RRA:AVERAGE:0.5:24:775 "
++ "RRA:AVERAGE:0.5:288:797 "
++ "RRA:MAX:0.5:1:600 "
++ "RRA:MAX:0.5:6:700 "
++ "RRA:MAX:0.5:24:775 "
++ "RRA:MAX:0.5:288:797 "
++ "RRA:MIN:0.5:1:600 "
++ "RRA:MIN:0.5:6:700 "
++ "RRA:MIN:0.5:24:775 "
++ "RRA:MIN:0.5:288:797\n"));
++
++ if (-1 == (r = write(p->write_fd, p->cmd->ptr, p->cmd->used - 1))) {
++ log_error_write(srv, __FILE__, __LINE__, "ss",
++ "rrdtool-write: failed", strerror(errno));
+
+- return HANDLER_ERROR;
+- }
++ return HANDLER_ERROR;
++ }
+
+- buffer_prepare_copy(p->resp, 4096);
+- if (-1 == (r = read(p->read_fd, p->resp->ptr, p->resp->size))) {
+- log_error_write(srv, __FILE__, __LINE__, "ss",
+- "rrdtool-read: failed", strerror(errno));
++ buffer_prepare_copy(p->resp, 4096);
++ if (-1 == (r = read(p->read_fd, p->resp->ptr, p->resp->size))) {
++ log_error_write(srv, __FILE__, __LINE__, "ss",
++ "rrdtool-read: failed", strerror(errno));
+
+- return HANDLER_ERROR;
+- }
++ return HANDLER_ERROR;
++ }
+
+- p->resp->used = r;
++ p->resp->used = r;
+
+- if (p->resp->ptr[0] != 'O' ||
+- p->resp->ptr[1] != 'K') {
+- log_error_write(srv, __FILE__, __LINE__, "sbb",
+- "rrdtool-response:", p->cmd, p->resp);
++ if (p->resp->ptr[0] != 'O' ||
++ p->resp->ptr[1] != 'K') {
++ log_error_write(srv, __FILE__, __LINE__, "sbb",
++ "rrdtool-response:", p->cmd, p->resp);
+
+- return HANDLER_ERROR;
+- }
++ return HANDLER_ERROR;
+ }
+
+ return HANDLER_GO_ON;
================================================================
More information about the pld-cvs-commit
mailing list