Teamspeak 3 Statistics
Visualise Teamspeak 3 virtual server data provided by collectd
# About

This dashboard relies graphite-carbon, collectd, and a collectd plugin, to gather and collate Teamspeak 3 Server statistics. The collectd plugin, written in python, will provide collectd with data from each virtual server instance.

This plugin can be found at [https://github.com/martindines/collectd_ts3](https://github.com/martindines/collectd_ts3)

Shoutout to [thannaske](https://grafana.com/orgs/thannaske) for heavily inspiring the presentation of this data. Check out his [Teamspeak 3 Metrics (InfluxDB)](https://grafana.com/dashboards/3020) dashboard
## Configure graphite-carbon

Graphite Carbon is used to aggregate data from collectd. To enable aggregation, a schema must be specified, commonly defined in `/etc/carbon/storage-schemas.conf`:

```
[collectd]
pattern = ^collectd.*
retentions = 10s:1d,1m:7d,10m:1y
```


## Configure collectd

Configure collectd to execute the Python plugin using the following configuration, commonly defined in ` /etc/collectd/collectd.conf`, replacing placeholders with your server values

```
LoadPlugin python
<Plugin python>
  ModulePath "SCRIPT_PATH"
  LogTraces true
  Interactive false
  Import collectd_ts3
  <Module collectd_ts3>
      Host "TEAMSPEAK3_SERVER_QUERY_HOST"
      Port "TEAMSPEAK3_SERVER_QUERY_PORT"
      Username "TEAMSPEAK3_SERVER_QUERY_USERNAME"
      Password "TEAMSPEAK3_SERVER_QUERY_PASSWORD"
  </Module>
</Plugin>
```


|Placeholder|Value|Example|
|---|---|---|
|SCRIPT_PATH|Path to directory containing collectd_ts3.py|/opt/collectd/|
|TEAMSPEAK3_SERVER_QUERY_HOST|Teamspeak 3 Server Query Host|127.0.0.1|
|TEAMSPEAK3_SERVER_QUERY_PORT|Teamspeak 3 Server Query Port|10011|
|TEAMSPEAK3_SERVER_QUERY_USERNAME|Teamspeak 3 Server Query Username|serveradmin|
|TEAMSPEAK3_SERVER_QUERY_PASSWORD|Teamspeak 3 Server Query Password||


{
  "__inputs": [
    {
      "name": "DS_GRAPHITE",
      "label": "Graphite",
      "description": "",
      "type": "datasource",
      "pluginId": "graphite",
      "pluginName": "Graphite"
    }
  ],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "5.0.3"
    },
    {
      "type": "panel",
      "id": "graph",
      "name": "Graph",
      "version": "5.0.0"
    },
    {
      "type": "datasource",
      "id": "graphite",
      "name": "Graphite",
      "version": "5.0.0"
    },
    {
      "type": "panel",
      "id": "singlestat",
      "name": "Singlestat",
      "version": "5.0.0"
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "gnetId": 5276,
  "graphTooltip": 1,
  "id": null,
  "iteration": 1522196001004,
  "links": [],
  "panels": [
    {
      "cacheTimeout": null,
      "colorBackground": false,
      "colorValue": false,
      "colors": [
        "#299c46",
        "rgba(237, 129, 40, 0.89)",
        "#d44a3a"
      ],
      "datasource": "${DS_GRAPHITE}",
      "decimals": 0,
      "format": "none",
      "gauge": {
        "maxValue": 100,
        "minValue": 0,
        "show": false,
        "thresholdLabels": false,
        "thresholdMarkers": true
      },
      "gridPos": {
        "h": 3,
        "w": 3,
        "x": 0,
        "y": 0
      },
      "id": 5,
      "interval": null,
      "links": [],
      "mappingType": 1,
      "mappingTypes": [
        {
          "name": "value to text",
          "value": 1
        },
        {
          "name": "range to text",
          "value": 2
        }
      ],
      "maxDataPoints": 100,
      "nullPointMode": "connected",
      "nullText": null,
      "postfix": "",
      "postfixFontSize": "50%",
      "prefix": "",
      "prefixFontSize": "50%",
      "rangeMaps": [
        {
          "from": "null",
          "text": "N/A",
          "to": "null"
        }
      ],
      "repeat": null,
      "sparkline": {
        "fillColor": "rgba(31, 118, 189, 0.18)",
        "full": false,
        "lineColor": "rgb(31, 120, 193)",
        "show": true
      },
      "tableColumn": "",
      "targets": [
        {
          "refCount": 0,
          "refId": "A",
          "target": "collectd.$Server.ts3-$ID.gauge-virtualserver_voiceclientsonline"
        }
      ],
      "thresholds": "",
      "title": "Voice Clients Online",
      "transparent": false,
      "type": "singlestat",
      "valueFontSize": "110%",
      "valueMaps": [
        {
          "op": "=",
          "text": "N/A",
          "value": "null"
        }
      ],
      "valueName": "current"
    },
    {
      "cacheTimeout": null,
      "colorBackground": false,
      "colorValue": false,
      "colors": [
        "#299c46",
        "rgba(237, 129, 40, 0.89)",
        "#d44a3a"
      ],
      "datasource": "${DS_GRAPHITE}",
      "format": "none",
      "gauge": {
        "maxValue": 100,
        "minValue": 0,
        "show": false,
        "thresholdLabels": false,
        "thresholdMarkers": true
      },
      "gridPos": {
        "h": 3,
        "w": 3,
        "x": 3,
        "y": 0
      },
      "id": 4,
      "interval": null,
      "links": [],
      "mappingType": 1,
      "mappingTypes": [
        {
          "name": "value to text",
          "value": 1
        },
        {
          "name": "range to text",
          "value": 2
        }
      ],
      "maxDataPoints": 100,
      "nullPointMode": "connected",
      "nullText": null,
      "postfix": "",
      "postfixFontSize": "50%",
      "prefix": "",
      "prefixFontSize": "50%",
      "rangeMaps": [
        {
          "from": "null",
          "text": "N/A",
          "to": "null"
        }
      ],
      "sparkline": {
        "fillColor": "rgba(31, 118, 189, 0.18)",
        "full": false,
        "lineColor": "rgb(31, 120, 193)",
        "show": false
      },
      "tableColumn": "",
      "targets": [
        {
          "refId": "A",
          "target": "collectd.$Server.ts3-$ID.gauge-virtualserver_maxclients"
        }
      ],
      "thresholds": "",
      "title": "Maximum Clients",
      "type": "singlestat",
      "valueFontSize": "110%",
      "valueMaps": [
        {
          "op": "=",
          "text": "N/A",
          "value": "null"
        }
      ],
      "valueName": "current"
    },
    {
      "cacheTimeout": null,
      "colorBackground": false,
      "colorValue": true,
      "colors": [
        "#299c46",
        "rgba(237, 129, 40, 0.89)",
        "#d44a3a"
      ],
      "datasource": "${DS_GRAPHITE}",
      "format": "none",
      "gauge": {
        "maxValue": 100,
        "minValue": 0,
        "show": false,
        "thresholdLabels": false,
        "thresholdMarkers": true
      },
      "gridPos": {
        "h": 3,
        "w": 3,
        "x": 6,
        "y": 0
      },
      "id": 7,
      "interval": null,
      "links": [],
      "mappingType": 1,
      "mappingTypes": [
        {
          "name": "value to text",
          "value": 1
        },
        {
          "name": "range to text",
          "value": 2
        }
      ],
      "maxDataPoints": 100,
      "nullPointMode": "connected",
      "nullText": null,
      "postfix": "",
      "postfixFontSize": "50%",
      "prefix": "",
      "prefixFontSize": "50%",
      "rangeMaps": [
        {
          "from": "null",
          "text": "N/A",
          "to": "null"
        }
      ],
      "sparkline": {
        "fillColor": "rgba(31, 118, 189, 0.18)",
        "full": false,
        "lineColor": "rgb(31, 120, 193)",
        "show": false
      },
      "tableColumn": "",
      "targets": [
        {
          "refId": "A",
          "target": "collectd.$Server.ts3-$ID.gauge-virtualserver_status"
        }
      ],
      "thresholds": "1.5",
      "title": "Server Status",
      "type": "singlestat",
      "valueFontSize": "80%",
      "valueMaps": [
        {
          "op": "=",
          "text": "Online",
          "value": "1"
        },
        {
          "op": "=",
          "text": "Offline",
          "value": "2"
        }
      ],
      "valueName": "avg"
    },
    {
      "cacheTimeout": null,
      "colorBackground": false,
      "colorValue": false,
      "colors": [
        "#299c46",
        "rgba(237, 129, 40, 0.89)",
        "#d44a3a"
      ],
      "datasource": "${DS_GRAPHITE}",
      "decimals": 0,
      "format": "dtdurations",
      "gauge": {
        "maxValue": 100,
        "minValue": 0,
        "show": false,
        "thresholdLabels": false,
        "thresholdMarkers": true
      },
      "gridPos": {
        "h": 3,
        "w": 3,
        "x": 9,
        "y": 0
      },
      "id": 9,
      "interval": null,
      "links": [],
      "mappingType": 1,
      "mappingTypes": [
        {
          "name": "value to text",
          "value": 1
        },
        {
          "name": "range to text",
          "value": 2
        }
      ],
      "maxDataPoints": 100,
      "nullPointMode": "connected",
      "nullText": null,
      "postfix": "",
      "postfixFontSize": "50%",
      "prefix": "",
      "prefixFontSize": "50%",
      "rangeMaps": [
        {
          "from": "null",
          "text": "N/A",
          "to": "null"
        }
      ],
      "sparkline": {
        "fillColor": "rgba(31, 118, 189, 0.18)",
        "full": false,
        "lineColor": "rgb(31, 120, 193)",
        "show": false
      },
      "tableColumn": "",
      "targets": [
        {
          "refId": "A",
          "target": "collectd.$Server.ts3-$ID.gauge-virtualserver_uptime"
        }
      ],
      "thresholds": "",
      "title": "Server Uptime",
      "type": "singlestat",
      "valueFontSize": "80%",
      "valueMaps": [
        {
          "op": "=",
          "text": "N/A",
          "value": "null"
        }
      ],
      "valueName": "current"
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_GRAPHITE}",
      "fill": 1,
      "gridPos": {
        "h": 6,
        "w": 12,
        "x": 12,
        "y": 0
      },
      "id": 15,
      "legend": {
        "alignAsTable": true,
        "avg": true,
        "current": true,
        "max": true,
        "min": true,
        "show": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [
        {
          "alias": "Client Average RTT",
          "fill": 0,
          "yaxis": 2
        }
      ],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "refCount": 0,
          "refId": "B",
          "target": "alias(keepLastValue(collectd.$Server.ts3-$ID.gauge-virtualserver_total_packetloss_speech, 0), 'Speech')",
          "textEditor": false
        },
        {
          "refCount": 0,
          "refId": "E",
          "target": "alias(keepLastValue(collectd.$Server.ts3-$ID.gauge-virtualserver_total_packetloss_keepalive, 0), 'Keepalive')",
          "textEditor": false
        },
        {
          "refCount": 0,
          "refId": "F",
          "target": "alias(keepLastValue(collectd.$Server.ts3-$ID.gauge-virtualserver_total_packetloss_control, 0), 'Control')",
          "textEditor": false
        },
        {
          "refCount": 0,
          "refId": "A",
          "target": "alias(keepLastValue(collectd.$Server.ts3-$ID.gauge-virtualserver_total_packetloss_total, 0), 'Overall')",
          "textEditor": false
        },
        {
          "refCount": 0,
          "refId": "G",
          "target": "alias(keepLastValue(collectd.$Server.ts3-$ID.gauge-virtualserver_total_ping, 100), 'Client Average RTT')",
          "textEditor": false
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeShift": null,
      "title": "Average Packetloss by Type",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "transparent": false,
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "decimals": null,
          "format": "percent",
          "label": "Packetloss",
          "logBase": 1,
          "max": null,
          "min": "0",
          "show": true
        },
        {
          "format": "ms",
          "label": "Average Ping",
          "logBase": 1,
          "max": null,
          "min": "0",
          "show": true
        }
      ]
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_GRAPHITE}",
      "fill": 0,
      "gridPos": {
        "h": 10,
        "w": 12,
        "x": 0,
        "y": 3
      },
      "id": 2,
      "legend": {
        "alignAsTable": true,
        "avg": true,
        "current": true,
        "hideEmpty": false,
        "hideZero": false,
        "max": true,
        "min": true,
        "rightSide": false,
        "show": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "percentage": false,
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "repeat": null,
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "refCount": 0,
          "refId": "C",
          "target": "alias(keepLastValue(collectd.$Server.ts3-$ID.gauge-virtualserver_voiceclientsonline, 100), 'Voice Clients')"
        },
        {
          "refCount": 0,
          "refId": "B",
          "target": "alias(keepLastValue(collectd.$Server.ts3-$ID.gauge-virtualserver_queryclientsonline, 100), 'Query Clients')",
          "textEditor": false
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeShift": null,
      "title": "Users Online",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "transparent": false,
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "decimals": 0,
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": false
        }
      ]
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_GRAPHITE}",
      "fill": 1,
      "gridPos": {
        "h": 13,
        "w": 12,
        "x": 12,
        "y": 6
      },
      "id": 16,
      "legend": {
        "alignAsTable": true,
        "avg": true,
        "current": true,
        "max": true,
        "min": true,
        "show": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [
        {
          "alias": "/Ingress/i",
          "stack": "A"
        },
        {
          "alias": "/Egress/i",
          "stack": "B",
          "transform": "negative-Y"
        }
      ],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "refCount": 0,
          "refId": "B",
          "target": "alias(summarize(derivative(keepLastValue(collectd.$Server.ts3-$ID.gauge-connection_bytes_received_speech)), '10s', 'sum'), 'Speech (Ingress)')",
          "textEditor": false
        },
        {
          "refCount": 0,
          "refId": "E",
          "target": "alias(summarize(derivative(keepLastValue(collectd.$Server.ts3-$ID.gauge-connection_bytes_received_keepalive, 0)), '10s', 'sum'), 'Keepalive (Ingress)')",
          "textEditor": false
        },
        {
          "refCount": 0,
          "refId": "F",
          "target": "alias(summarize(derivative(keepLastValue(collectd.$Server.ts3-$ID.gauge-connection_bytes_received_control, 0)), '10s', 'sum'), 'Control (Ingress)')",
          "textEditor": false
        },
        {
          "refCount": 0,
          "refId": "A",
          "target": "alias(summarize(derivative(keepLastValue(collectd.$Server.ts3-$ID.gauge-connection_bytes_sent_speech, 0)), '10s', 'sum'), 'Speech (Egress)')",
          "textEditor": false
        },
        {
          "refCount": 0,
          "refId": "G",
          "target": "alias(summarize(derivative(keepLastValue(collectd.$Server.ts3-$ID.gauge-connection_bytes_sent_keepalive, 0)), '10s', 'sum'), 'Keepalive (Egress)')",
          "textEditor": false
        },
        {
          "refCount": 0,
          "refId": "H",
          "target": "alias(summarize(derivative(keepLastValue(collectd.$Server.ts3-$ID.gauge-connection_bytes_sent_control, 0)), '10s', 'sum'), 'Control (Egress)')",
          "textEditor": false
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeShift": null,
      "title": "Traffic Usage by Type",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "transparent": false,
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "decimals": null,
          "format": "decbytes",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": false
        }
      ]
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_GRAPHITE}",
      "fill": 1,
      "gridPos": {
        "h": 6,
        "w": 12,
        "x": 0,
        "y": 13
      },
      "id": 13,
      "legend": {
        "alignAsTable": true,
        "avg": true,
        "current": true,
        "max": true,
        "min": true,
        "show": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [
        {
          "alias": "Outgoing Traffic",
          "transform": "negative-Y"
        }
      ],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "hide": false,
          "refCount": 0,
          "refId": "A",
          "target": "alias(summarize(derivative(keepLastValue(collectd.$Server.ts3-$ID.gauge-connection_bytes_received_total, 0)), '10s', 'sum'), 'Incoming Traffic')",
          "textEditor": false
        },
        {
          "refCount": 0,
          "refId": "B",
          "target": "alias(summarize(derivative(keepLastValue(collectd.$Server.ts3-$ID.gauge-connection_bytes_sent_total, 0)), '10s', 'sum'), 'Outgoing Traffic')",
          "textEditor": false
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeShift": null,
      "title": "Overall Traffic Usage",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "decbytes",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": false
        }
      ]
    }
  ],
  "refresh": "5m",
  "schemaVersion": 16,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": [
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_GRAPHITE}",
        "hide": 0,
        "includeAll": false,
        "label": null,
        "multi": false,
        "name": "Server",
        "options": [],
        "query": "collectd.*",
        "refresh": 1,
        "regex": "",
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_GRAPHITE}",
        "hide": 0,
        "includeAll": false,
        "label": null,
        "multi": false,
        "name": "ID",
        "options": [],
        "query": "collectd.$Server.ts3-*",
        "refresh": 1,
        "regex": "/ts3-(\\d+?)/",
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      }
    ]
  },
  "time": {
    "from": "now-3h",
    "to": "now"
  },
  "timepicker": {
    "refresh_intervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ],
    "time_options": [
      "5m",
      "15m",
      "1h",
      "6h",
      "12h",
      "24h",
      "2d",
      "7d",
      "30d"
    ]
  },
  "timezone": "",
  "title": "Teamspeak 3 Statistics",
  "uid": "VFPJ-skiz",
  "version": 1,
  "description": "Visualise Teamspeak 3 virtual server data provided by collectd"
}