summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2016-02-08 11:16:39 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2016-02-08 15:05:13 (GMT)
commitc9f6dc168ead762e02db1e27c5bc7c42282c9e50 (patch) (side-by-side diff)
tree8e7cf6487f8c0ee1efada0b592bbff880e438b3d
parentef009c2202de0721f6a56d3b879de66246cf27fd (diff)
downloadvmod-tbf-c9f6dc168ead762e02db1e27c5bc7c42282c9e50.tar.gz
vmod-tbf-c9f6dc168ead762e02db1e27c5bc7c42282c9e50.tar.bz2
Update the docs.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--src/tbf.c4
-rw-r--r--src/vmod-tbf.378
2 files changed, 59 insertions, 23 deletions
diff --git a/src/tbf.c b/src/tbf.c
index 4e00bd8..f906e7c 100644
--- a/src/tbf.c
+++ b/src/tbf.c
@@ -196,7 +196,7 @@ tree_delete_node_unlocked(struct tree *tree, struct node *node)
node->child[CHILD_LEFT]->parent = parent;
} else {
/* Node has both subtrees. Find the largest value in the
- right subtree */
+ left subtree */
struct node *p;
for (p = node->child[CHILD_LEFT]; p->child[CHILD_RIGHT];
p = p->child[CHILD_RIGHT])
@@ -836,7 +836,7 @@ tbf_release_tree(struct tree **t)
static void
-tbf_exit()
+tbf_exit(void)
{
if (tbf_dump_file_name) {
struct tree *t = tbf_get_tree();
diff --git a/src/vmod-tbf.3 b/src/vmod-tbf.3
index 08ffb43..39a60b9 100644
--- a/src/vmod-tbf.3
+++ b/src/vmod-tbf.3
@@ -13,7 +13,7 @@
.\"
.\" You should have received a copy of the GNU General Public License
.\" along with vmod-tbf. If not, see <http://www.gnu.org/licenses/>.
-.TH VMOD-TBF 1 "January 26, 2016" "VMOD-TBF" "User Reference"
+.TH VMOD-TBF 1 "February 8, 2016" "VMOD-TBF" "User Reference"
.SH NAME
vmod-tbf \- token bucket filtering for Varnish
.SH SYNOPSIS
@@ -23,14 +23,22 @@ vmod-tbf \- token bucket filtering for Varnish
.BI "BOOL tbf.check(STRING " key ", STRING " rate ");"
-.BI "VOID tbf.debug(INT " level ");"
-
.BI "VOID tbf.dump(STRING " file ");"
+.BI "VOID tbf.dump_at_exit(STRING " file ");"
+
+.BI "VOID tbf.load(STRING " file ");"
+
.BI "VOID tbf.gc(DURATION " interval ");"
.BI "VOID tbf.set_gc_interval(DURATION " interval ");"
+.BI "VOID tbf.debug(INT " level ");"
+
+.BI "VOID tbf.log_tree(INT " prio ");"
+
+.BI "VOID tbf.log_stats(INT " prio ");"
+
.BI "REAL tbf.getla(INT " sample ");"
.BI "INT tbf.systime();"
@@ -138,36 +146,64 @@ function with the interval as its argument.
.PP
The function
.B tbf.dump
-dumps entire tree to the disk file.
+dumps entire tree to the disk file. The function
+.B tbf.load
+loads the named dump file into the tree.
.PP
The function
-.B tbf.debug
-sets the debug level.
+.B tbf.dump_at_exit
+configures the module to dump the tree before
+.B varnishd
+terminates. Use this to keep the \fBtbf\fR state across
+\fBvarnishd\fR restarts. For example:
+.PP
+.EX
+sub vcl_init {
+ tbf.load("/var/run/tbf.dump");
+ tbf.dump_at_exit("/var/run/tbf.dump");
+}
+.EE
+.SS Debugging
+.TP
+.BI "VOID tbf.debug(INT " level ");"
+Sets the debug verbosity level. Meaningful argument values are
+\fB0\fR (no debugging info) to \fB2\fR (maximum verbosity).
+.TP
+.BI "VOID tbf.log_tree(INT " prio ");"
+Logs the content of the \fBtbf\fR tree to \fBsyslog\fR priority
+\fIprio\fR. Note that this can produce extremely big amounts of info.
+.TP
+.BI "VOID tbf.log_stats(INT " prio ");"
+Logs the tree statistics to \fBsyslog\fR priority \fIprio\fR. The
+following information is logged: total number of nodes in tree, number
+of leaves, shortest, longest and average paths.
.SS Other functions
.PP
Several functions are provided that do not exactly belong to the
TBF algorithm, but which may come useful when implementing rate
control.
-.PP
-The \fBtbf.getla\fR function returns the system load average. Its
-argument identifies the interval for which to compute it: 1, 5 or
-15 minutes.
-.PP
-The \fBtbf.systime\fR function returns the current time of day as the
-number of seconds since the Epoch (1970-01-01 00:00:00 UTC).
-.PP
-The \fBtbf.strftime\fR function formats the \fBtimestamp\fR according
-to the specification in \fBformat\fR. See
+.TP
+.BI "REAL tbf.getla(INT " sample ");"
+Returns the system load average. The argument identifies interval
+for which to compute it: 1, 5 or 15 minutes.
+.TP
+.BI "INT tbf.systime();"
+Returns the current time of day as the number of seconds since the
+Epoch (1970-01-01 00:00:00 UTC).
+.TP
+.BI "STRING tbf.strftime(STRING " format ", INT " timestamp ");"
+Function formats the \fItimestamp\fR according to the specification in
+\fIformat\fR. See
.BR strftime (3),
for a description of available formats. For example, the following
-statements assigns the current year to the \f(CWX\-Year\fR header:
-.PP
+statement assigns the current year to the \f(CWX\-Year\fR header:
+
.EX
set req.http.X-Year = tbf.strftime("%Y", systime());
.EE
-.PP
-The \fBtbf.sleep\fR function suspends execution for a specified amount
-of time.
+.TP
+.BI "VOID tbf.sleep(DURATION " time ");"
+Suspends execution for a specified amount of time.
.\"
.\" The MANCGI variable is set by man.cgi script on Ulysses.
.\" The download.inc file contains the default DOWNLOAD section

Return to:

Send suggestions and report system problems to the System administrator.