wiki:ManagementPort

Connecting to the management port

Lets say you start Varnish with the shell script:

#!/bin/sh
# file: go.sh

rm -f *.core
date -u
varnishd \
        -T 127.0.0.1:81 \
        -s file,/usr/V,10g \
        -f vg.vcl \
        -p thread_pool_max=1500 \
        -p thread_pools=5 \
        -p listen_depth=512 \
        -p client_http11=on \
        -a 0.0.0.0:80

When you run the script you will see something like:

[root@c5 ~]# ./go.sh
Tue Oct  3 22:32:07 UTC 2006
pclose=0
file /usr/V size 10737418240 bytes (5242880 fs-blocks, 2621440 pages)
Using old SHMFILE
Tue Oct  3 22:32:07 UTC 2006

Then you can connect to the managment port with a command like:

[root@c5 ~]# telnet localhost 81
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

help

200 281
Available commands:
ping [timestamp]
start
stop
stats
vcl.load <configname> <filename>
vcl.inline <configname> <quoted_VCLstring>
vcl.use <configname>
vcl.discard <configname>
vcl.list
param.show [-l] [<param>]
param.set <param> <value>
help [command]
url.purge <regexp>
dump.pool

help start
200 40
start
        Start the Varnish cache process.

For more info on the parameters that you can give on the commandline, type "help command".

For more detailed information refer to:

[root@c5 /]$ man varnishd

and also Stats explained.

The CLI protocol definition

The CLI protocol used on the management/telnet interface is a strict request/response protocol, there are no unsolicited transmissions from the responding end.

Requests are whitespace separated tokens terminated by a newline (NL) character.

Tokens can be quoted with "..." and common backslash escape forms are accepted: (\n), (\r), (\t), (
), (\"), (\%03o) and (\x%02x)

The response consists of a header which can be read as fixed format or ASCII text:

    1-3      %03d      Response code
    4        ' '       Space
    5-12     %8d       Length of body
    13       \n        NL character.

Followed by the number of bytes announced by the header.

The Responsecode is numeric shorthand for the nature of the reaction, with the following values currently defined in include/cli.h:

enum cli_status_e {
        CLIS_SYNTAX     = 100,
        CLIS_UNKNOWN    = 101,
        CLIS_UNIMPL     = 102,
        CLIS_TOOFEW     = 104,
        CLIS_TOOMANY    = 105,
        CLIS_PARAM      = 106,
        CLIS_OK         = 200,
        CLIS_CANT       = 300,
        CLIS_COMMS      = 400,
        CLIS_CLOSE      = 500
};