summaryrefslogtreecommitdiffstats
path: root/src/go/plugin/go.d/modules/litespeed
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-26 08:15:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-26 08:15:35 +0000
commitf09848204fa5283d21ea43e262ee41aa578e1808 (patch)
treec62385d7adf209fa6a798635954d887f718fb3fb /src/go/plugin/go.d/modules/litespeed
parentReleasing debian version 1.46.3-2. (diff)
downloadnetdata-f09848204fa5283d21ea43e262ee41aa578e1808.tar.xz
netdata-f09848204fa5283d21ea43e262ee41aa578e1808.zip
Merging upstream version 1.47.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/go/plugin/go.d/modules/litespeed')
l---------src/go/plugin/go.d/modules/litespeed/README.md1
-rw-r--r--src/go/plugin/go.d/modules/litespeed/charts.go152
-rw-r--r--src/go/plugin/go.d/modules/litespeed/collect.go119
-rw-r--r--src/go/plugin/go.d/modules/litespeed/config_schema.json37
-rw-r--r--src/go/plugin/go.d/modules/litespeed/integrations/litespeed.md193
-rw-r--r--src/go/plugin/go.d/modules/litespeed/litespeed.go91
-rw-r--r--src/go/plugin/go.d/modules/litespeed/litespeed_test.go164
-rw-r--r--src/go/plugin/go.d/modules/litespeed/metadata.yaml148
-rw-r--r--src/go/plugin/go.d/modules/litespeed/testdata/.rtreport8
-rw-r--r--src/go/plugin/go.d/modules/litespeed/testdata/.rtreport.28
-rw-r--r--src/go/plugin/go.d/modules/litespeed/testdata/config.json4
-rw-r--r--src/go/plugin/go.d/modules/litespeed/testdata/config.yaml2
12 files changed, 927 insertions, 0 deletions
diff --git a/src/go/plugin/go.d/modules/litespeed/README.md b/src/go/plugin/go.d/modules/litespeed/README.md
new file mode 120000
index 00000000..e7418b3d
--- /dev/null
+++ b/src/go/plugin/go.d/modules/litespeed/README.md
@@ -0,0 +1 @@
+integrations/litespeed.md \ No newline at end of file
diff --git a/src/go/plugin/go.d/modules/litespeed/charts.go b/src/go/plugin/go.d/modules/litespeed/charts.go
new file mode 100644
index 00000000..b7309f28
--- /dev/null
+++ b/src/go/plugin/go.d/modules/litespeed/charts.go
@@ -0,0 +1,152 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+package litespeed
+
+import "github.com/netdata/netdata/go/plugins/plugin/go.d/agent/module"
+
+const (
+ prioRequests = module.Priority + iota
+ prioRequestsProcessing
+ prioNetThroughputHttp
+ prioNetThroughputHttps
+ prioConnectionsHttp
+ prioConnectionsHttps
+ prioPublicCacheHits
+ prioPrivateCacheHits
+ prioStaticHits
+)
+
+var charts = module.Charts{
+ requestsChart.Copy(),
+ requestsProcessingChart.Copy(),
+
+ netThroughputHttpChart.Copy(),
+ netThroughputHttpsChart.Copy(),
+
+ connectionsHttpChart.Copy(),
+ connectionsHttpsChart.Copy(),
+
+ publicCacheHitsChart.Copy(),
+ privateCacheHitsChart.Copy(),
+ staticCacheHitsChart.Copy(),
+}
+
+var (
+ requestsChart = module.Chart{
+ ID: "requests",
+ Title: "Requests",
+ Units: "requests/s",
+ Fam: "requests",
+ Ctx: "litespeed.requests",
+ Priority: prioRequests,
+ Dims: module.Dims{
+ {ID: "req_per_sec", Name: "requests", Div: precision},
+ },
+ }
+ requestsProcessingChart = module.Chart{
+ ID: "requests_processing",
+ Title: "Processing requests",
+ Units: "requests",
+ Fam: "requests",
+ Ctx: "litespeed.requests_processing",
+ Priority: prioRequestsProcessing,
+ Dims: module.Dims{
+ {ID: "req_processing", Name: "processing"},
+ },
+ }
+)
+
+var (
+ netThroughputHttpChart = module.Chart{
+ ID: "net_throughput_http",
+ Title: "HTTP throughput",
+ Units: "kilobits/s",
+ Fam: "throughput",
+ Ctx: "litespeed.net_throughput",
+ Type: module.Area,
+ Priority: prioNetThroughputHttp,
+ Dims: module.Dims{
+ {ID: "bps_in", Name: "in"},
+ {ID: "bps_out", Name: "out", Div: -1},
+ },
+ }
+ netThroughputHttpsChart = module.Chart{
+ ID: "net_throughput_https",
+ Title: "HTTPs throughput",
+ Units: "kilobits/s",
+ Fam: "throughput",
+ Ctx: "litespeed.net_ssl_throughput",
+ Type: module.Area,
+ Priority: prioNetThroughputHttps,
+ Dims: module.Dims{
+ {ID: "ssl_bps_in", Name: "in"},
+ {ID: "ssl_bps_out", Name: "out", Div: -1},
+ },
+ }
+)
+
+var (
+ connectionsHttpChart = module.Chart{
+ ID: "connections_http",
+ Title: "HTTP connections",
+ Units: "connections",
+ Fam: "connections",
+ Ctx: "litespeed.connections",
+ Type: module.Stacked,
+ Priority: prioConnectionsHttp,
+ Dims: module.Dims{
+ {ID: "availconn", Name: "free"},
+ {ID: "plainconn", Name: "used"},
+ },
+ }
+ connectionsHttpsChart = module.Chart{
+ ID: "connections_https",
+ Title: "HTTPs connections",
+ Units: "connections",
+ Fam: "connections",
+ Ctx: "litespeed.ssl_connections",
+ Type: module.Stacked,
+ Priority: prioConnectionsHttps,
+ Dims: module.Dims{
+ {ID: "availssl", Name: "free"},
+ {ID: "sslconn", Name: "used"},
+ },
+ }
+)
+
+var (
+ publicCacheHitsChart = module.Chart{
+ ID: "pub_cache_hits",
+ Title: "Public cache hits",
+ Units: "hits/s",
+ Fam: "cache",
+ Ctx: "litespeed.public_cache",
+ Priority: prioPublicCacheHits,
+ Dims: module.Dims{
+ {ID: "pub_cache_hits_per_sec", Name: "hits", Div: precision},
+ },
+ }
+ privateCacheHitsChart = module.Chart{
+ ID: "private_cache_hits",
+ Title: "Private cache hits",
+ Units: "hits/s",
+ Fam: "cache",
+ Ctx: "litespeed.private_cache",
+ Priority: prioPrivateCacheHits,
+ Dims: module.Dims{
+ {ID: "private_cache_hits_per_sec", Name: "hits", Div: precision},
+ },
+ }
+
+ staticCacheHitsChart = module.Chart{
+ ID: "static_hits",
+ Title: "Static hits",
+ Units: "hits/s",
+ Fam: "static",
+ Ctx: "litespeed.static",
+ Priority: prioStaticHits,
+ Dims: module.Dims{
+ {ID: "static_hits_per_sec", Name: "hits", Div: precision},
+ },
+ }
+)
diff --git a/src/go/plugin/go.d/modules/litespeed/collect.go b/src/go/plugin/go.d/modules/litespeed/collect.go
new file mode 100644
index 00000000..a68cf119
--- /dev/null
+++ b/src/go/plugin/go.d/modules/litespeed/collect.go
@@ -0,0 +1,119 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+package litespeed
+
+import (
+ "bufio"
+ "bytes"
+ "errors"
+ "os"
+ "path/filepath"
+ "strconv"
+ "strings"
+)
+
+const precision = 100
+
+func (l *Litespeed) collect() (map[string]int64, error) {
+ if l.checkDir {
+ _, err := os.Stat(l.ReportsDir)
+ if err != nil {
+ return nil, err
+ }
+ l.checkDir = false
+ }
+ reports, err := filepath.Glob(filepath.Join(l.ReportsDir, ".rtreport*"))
+ if err != nil {
+ return nil, err
+ }
+
+ l.Debugf("found %d reports: %v", len(reports), reports)
+
+ if len(reports) == 0 {
+ return nil, errors.New("no reports found")
+ }
+
+ mx := make(map[string]int64)
+
+ for _, report := range reports {
+ if err := l.collectReport(mx, report); err != nil {
+ return nil, err
+ }
+ }
+
+ return mx, nil
+}
+
+func (l *Litespeed) collectReport(mx map[string]int64, filename string) error {
+ bs, err := os.ReadFile(filename)
+ if err != nil {
+ return err
+ }
+
+ sc := bufio.NewScanner(bytes.NewReader(bs))
+
+ var valid bool
+
+ for sc.Scan() {
+ line := sc.Text()
+
+ switch {
+ default:
+ continue
+ case strings.HasPrefix(line, "BPS_IN:"):
+ case strings.HasPrefix(line, "PLAINCONN:"):
+ case strings.HasPrefix(line, "MAXCONN:"):
+ case strings.HasPrefix(line, "REQ_RATE []:"):
+ line = strings.TrimPrefix(line, "REQ_RATE []:")
+ }
+
+ parts := strings.Split(line, ",")
+
+ for _, part := range parts {
+ i := strings.IndexByte(part, ':')
+ if i == -1 {
+ l.Debugf("Skipping metric '%s': missing colon separator", part)
+ continue
+ }
+
+ metric, sVal := strings.TrimSpace(part[:i]), strings.TrimSpace(part[i+1:])
+
+ val, err := strconv.ParseFloat(sVal, 64)
+ if err != nil {
+ l.Debugf("Skipping metric '%s': invalid value", part)
+ continue
+ }
+
+ key := strings.ToLower(metric)
+
+ switch metric {
+ default:
+ continue
+ case "REQ_PER_SEC",
+ "PUB_CACHE_HITS_PER_SEC",
+ "PRIVATE_CACHE_HITS_PER_SEC",
+ "STATIC_HITS_PER_SEC":
+ mx[key] += int64(val * precision)
+ case "BPS_IN",
+ "BPS_OUT",
+ "SSL_BPS_IN",
+ "SSL_BPS_OUT":
+ mx[key] += int64(val) * 8
+ case "REQ_PROCESSING",
+ "PLAINCONN",
+ "AVAILCONN",
+ "SSLCONN",
+ "AVAILSSL":
+ mx[key] += int64(val)
+ }
+ valid = true
+
+ }
+ }
+
+ if !valid {
+ return errors.New("unexpected file: not a litespeed report")
+ }
+
+ return nil
+}
diff --git a/src/go/plugin/go.d/modules/litespeed/config_schema.json b/src/go/plugin/go.d/modules/litespeed/config_schema.json
new file mode 100644
index 00000000..2ec13468
--- /dev/null
+++ b/src/go/plugin/go.d/modules/litespeed/config_schema.json
@@ -0,0 +1,37 @@
+{
+ "jsonSchema": {
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "Litespeed collector configuration.",
+ "type": "object",
+ "properties": {
+ "update_every": {
+ "title": "Update every",
+ "description": "Data collection interval, measured in seconds.",
+ "type": "integer",
+ "minimum": 1,
+ "default": 10
+ },
+ "reports_dir": {
+ "title": "Reports directory",
+ "description": "Directory containing Litespeed's real-time statistics files (`.rtreport`)",
+ "type": "string",
+ "default": "/tmp/lshttpd/"
+ }
+ },
+ "required": [
+ "reports_dir"
+ ],
+ "additionalProperties": false,
+ "patternProperties": {
+ "^name$": {}
+ }
+ },
+ "uiSchema": {
+ "uiOptions": {
+ "fullPage": true
+ },
+ "update_every": {
+ "ui:help": "Data is collected by reading Litespeed's report files, which are updated every 10 seconds. Setting the data collection interval to less than 10 seconds wouldn't provide more recent data."
+ }
+ }
+}
diff --git a/src/go/plugin/go.d/modules/litespeed/integrations/litespeed.md b/src/go/plugin/go.d/modules/litespeed/integrations/litespeed.md
new file mode 100644
index 00000000..96858fda
--- /dev/null
+++ b/src/go/plugin/go.d/modules/litespeed/integrations/litespeed.md
@@ -0,0 +1,193 @@
+<!--startmeta
+custom_edit_url: "https://github.com/netdata/netdata/edit/master/src/go/plugin/go.d/modules/litespeed/README.md"
+meta_yaml: "https://github.com/netdata/netdata/edit/master/src/go/plugin/go.d/modules/litespeed/metadata.yaml"
+sidebar_label: "Litespeed"
+learn_status: "Published"
+learn_rel_path: "Collecting Metrics/Web Servers and Web Proxies"
+most_popular: False
+message: "DO NOT EDIT THIS FILE DIRECTLY, IT IS GENERATED BY THE COLLECTOR'S metadata.yaml FILE"
+endmeta-->
+
+# Litespeed
+
+
+<img src="https://netdata.cloud/img/litespeed.svg" width="150"/>
+
+
+Plugin: go.d.plugin
+Module: litespeed
+
+<img src="https://img.shields.io/badge/maintained%20by-Netdata-%2300ab44" />
+
+## Overview
+
+Examine Litespeed metrics for insights into web server operations. Analyze request rates, response times, and error rates for efficient web service delivery.
+
+The collector uses the statistics under /tmp/lshttpd to gather the metrics.
+
+This collector is supported on all platforms.
+
+This collector only supports collecting metrics from a single instance of this integration.
+
+
+### Default Behavior
+
+#### Auto-Detection
+
+If no configuration is present, the collector will attempt to read files under /tmp/lshttpd/.
+
+#### Limits
+
+The default configuration for this integration does not impose any limits on data collection.
+
+#### Performance Impact
+
+The default configuration for this integration is not expected to impose a significant performance impact on the system.
+
+
+## Metrics
+
+Metrics grouped by *scope*.
+
+The scope defines the instance that the metric belongs to. An instance is uniquely identified by a set of labels.
+
+
+
+### Per Litespeed instance
+
+These metrics refer to the entire monitored application.
+
+This scope has no labels.
+
+Metrics:
+
+| Metric | Dimensions | Unit |
+|:------|:----------|:----|
+| litespeed.requests | requests | requests/s |
+| litespeed.requests_processing | processing | requests |
+| litespeed.net_throughput | in, out | kilobits/s |
+| litespeed.net_ssl_throughput | in, out | kilobits/s |
+| litespeed.connections | free, used | conns |
+| litespeed.ssl_connections | free, used | conns |
+| litespeed.public_cache | hits | hits/s |
+| litespeed.private_cache | hits | hits/s |
+| litespeed.static | hits | hits/s |
+
+
+
+## Alerts
+
+There are no alerts configured by default for this integration.
+
+
+## Setup
+
+### Prerequisites
+
+No action required.
+
+### Configuration
+
+#### File
+
+The configuration file name for this integration is `go.d/litespeed.conf`.
+
+
+You can edit the configuration file using the `edit-config` script from the
+Netdata [config directory](/docs/netdata-agent/configuration/README.md#the-netdata-config-directory).
+
+```bash
+cd /etc/netdata 2>/dev/null || cd /opt/netdata/etc/netdata
+sudo ./edit-config go.d/litespeed.conf
+```
+#### Options
+
+The following options can be defined globally: update_every, autodetection_retry.
+
+
+<details open><summary>Config options</summary>
+
+| Name | Description | Default | Required |
+|:----|:-----------|:-------|:--------:|
+| update_every | Data collection frequency. | 10 | no |
+| autodetection_retry | Sets the job re-check interval in seconds. | 0 | no |
+| reports_dir | Directory containing Litespeed's real-time statistics files. | /tmp/lshttpd/ | no |
+
+</details>
+
+#### Examples
+
+##### Set the path to statistics
+
+Change the path for the litespeed stats files
+
+```yaml
+local:
+ name: 'local'
+ path: '/tmp/lshttpd'
+
+```
+
+
+## Troubleshooting
+
+### Debug Mode
+
+**Important**: Debug mode is not supported for data collection jobs created via the UI using the Dyncfg feature.
+
+To troubleshoot issues with the `litespeed` collector, run the `go.d.plugin` with the debug option enabled. The output
+should give you clues as to why the collector isn't working.
+
+- Navigate to the `plugins.d` directory, usually at `/usr/libexec/netdata/plugins.d/`. If that's not the case on
+ your system, open `netdata.conf` and look for the `plugins` setting under `[directories]`.
+
+ ```bash
+ cd /usr/libexec/netdata/plugins.d/
+ ```
+
+- Switch to the `netdata` user.
+
+ ```bash
+ sudo -u netdata -s
+ ```
+
+- Run the `go.d.plugin` to debug the collector:
+
+ ```bash
+ ./go.d.plugin -d -m litespeed
+ ```
+
+### Getting Logs
+
+If you're encountering problems with the `litespeed` collector, follow these steps to retrieve logs and identify potential issues:
+
+- **Run the command** specific to your system (systemd, non-systemd, or Docker container).
+- **Examine the output** for any warnings or error messages that might indicate issues. These messages should provide clues about the root cause of the problem.
+
+#### System with systemd
+
+Use the following command to view logs generated since the last Netdata service restart:
+
+```bash
+journalctl _SYSTEMD_INVOCATION_ID="$(systemctl show --value --property=InvocationID netdata)" --namespace=netdata --grep litespeed
+```
+
+#### System without systemd
+
+Locate the collector log file, typically at `/var/log/netdata/collector.log`, and use `grep` to filter for collector's name:
+
+```bash
+grep litespeed /var/log/netdata/collector.log
+```
+
+**Note**: This method shows logs from all restarts. Focus on the **latest entries** for troubleshooting current issues.
+
+#### Docker Container
+
+If your Netdata runs in a Docker container named "netdata" (replace if different), use this command:
+
+```bash
+docker logs netdata 2>&1 | grep litespeed
+```
+
+
diff --git a/src/go/plugin/go.d/modules/litespeed/litespeed.go b/src/go/plugin/go.d/modules/litespeed/litespeed.go
new file mode 100644
index 00000000..f57c0eed
--- /dev/null
+++ b/src/go/plugin/go.d/modules/litespeed/litespeed.go
@@ -0,0 +1,91 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+package litespeed
+
+import (
+ _ "embed"
+ "errors"
+
+ "github.com/netdata/netdata/go/plugins/plugin/go.d/agent/module"
+)
+
+//go:embed "config_schema.json"
+var configSchema string
+
+func init() {
+ module.Register("litespeed", module.Creator{
+ JobConfigSchema: configSchema,
+ Defaults: module.Defaults{
+ UpdateEvery: 10, // The .rtreport files are generated per worker, and updated every 10 seconds.
+ },
+ Create: func() module.Module { return New() },
+ Config: func() any { return &Config{} },
+ })
+}
+
+func New() *Litespeed {
+ return &Litespeed{
+ Config: Config{
+ //ReportsDir: "/tmp/lshttpd/",
+ ReportsDir: "/opt/litespeed",
+ },
+ checkDir: true,
+ charts: charts.Copy(),
+ }
+}
+
+type Config struct {
+ UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
+ ReportsDir string `yaml:"reports_dir" json:"reports_dir"`
+}
+
+type Litespeed struct {
+ module.Base
+ Config `yaml:",inline" json:""`
+
+ checkDir bool
+
+ charts *module.Charts
+}
+
+func (l *Litespeed) Configuration() any {
+ return l.Config
+}
+
+func (l *Litespeed) Init() error {
+ if l.ReportsDir == "" {
+ return errors.New("reports_dir is required")
+ }
+ return nil
+}
+
+func (l *Litespeed) Check() error {
+ mx, err := l.collect()
+ if err != nil {
+ l.Error(err)
+ return err
+ }
+
+ if len(mx) == 0 {
+ return errors.New("no metrics collected")
+ }
+
+ return nil
+}
+
+func (l *Litespeed) Charts() *module.Charts {
+ return l.charts
+}
+
+func (l *Litespeed) Collect() map[string]int64 {
+ mx, err := l.collect()
+
+ if err != nil {
+ l.Error(err)
+ return nil
+ }
+
+ return mx
+}
+
+func (l *Litespeed) Cleanup() {}
diff --git a/src/go/plugin/go.d/modules/litespeed/litespeed_test.go b/src/go/plugin/go.d/modules/litespeed/litespeed_test.go
new file mode 100644
index 00000000..576609dc
--- /dev/null
+++ b/src/go/plugin/go.d/modules/litespeed/litespeed_test.go
@@ -0,0 +1,164 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+package litespeed
+
+import (
+ "os"
+ "testing"
+
+ "github.com/netdata/netdata/go/plugins/plugin/go.d/agent/module"
+
+ "github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
+)
+
+var (
+ dataConfigJSON, _ = os.ReadFile("testdata/config.json")
+ dataConfigYAML, _ = os.ReadFile("testdata/config.yaml")
+)
+
+func Test_testDataIsValid(t *testing.T) {
+ for name, data := range map[string][]byte{
+ "dataConfigJSON": dataConfigJSON,
+ "dataConfigYAML": dataConfigYAML,
+ } {
+ require.NotNil(t, data, name)
+ }
+}
+
+func TestLitespeed_ConfigurationSerialize(t *testing.T) {
+ module.TestConfigurationSerialize(t, &Litespeed{}, dataConfigJSON, dataConfigYAML)
+}
+
+func TestLitespeed_Init(t *testing.T) {
+ tests := map[string]struct {
+ wantFail bool
+ config Config
+ }{
+ "success with default": {
+ wantFail: false,
+ config: New().Config,
+ },
+ "fails if reports_dir not set": {
+ wantFail: true,
+ config: Config{
+ ReportsDir: "",
+ },
+ },
+ }
+
+ for name, test := range tests {
+ t.Run(name, func(t *testing.T) {
+ lite := New()
+ lite.Config = test.config
+
+ if test.wantFail {
+ assert.Error(t, lite.Init())
+ } else {
+ assert.NoError(t, lite.Init())
+ }
+ })
+ }
+}
+
+func TestLitespeed_Charts(t *testing.T) {
+ assert.NotNil(t, New().Charts())
+}
+
+func TestLitespeed_Check(t *testing.T) {
+ tests := map[string]struct {
+ prepareLitespeed func() *Litespeed
+ wantFail bool
+ }{
+ "success": {
+ wantFail: false,
+ prepareLitespeed: prepareLitespeedOk,
+ },
+ "fails if reports dir not exist": {
+ wantFail: true,
+ prepareLitespeed: prepareLitespeedDirNotExist,
+ },
+ }
+
+ for name, test := range tests {
+ t.Run(name, func(t *testing.T) {
+ lite := test.prepareLitespeed()
+
+ if test.wantFail {
+ assert.Error(t, lite.Check())
+ } else {
+ assert.NoError(t, lite.Check())
+ }
+ })
+ }
+}
+
+func TestLitespeed_Collect(t *testing.T) {
+ tests := map[string]struct {
+ prepareLitespeed func() *Litespeed
+ wantMetrics map[string]int64
+ }{
+ "success": {
+ prepareLitespeed: prepareLitespeedOk,
+ wantMetrics: map[string]int64{
+ "availconn": 3804,
+ "availssl": 3814,
+ "bps_in": 0,
+ "bps_out": 240,
+ "plainconn": 10,
+ "private_cache_hits_per_sec": 0,
+ "pub_cache_hits_per_sec": 0,
+ "req_per_sec": 1560,
+ "req_processing": 168,
+ "ssl_bps_in": 16,
+ "ssl_bps_out": 3120,
+ "sslconn": 186,
+ "static_hits_per_sec": 760,
+ },
+ },
+ "fails if reports dir not exist": {
+ prepareLitespeed: prepareLitespeedDirNotExist,
+ },
+ }
+
+ for name, test := range tests {
+ t.Run(name, func(t *testing.T) {
+ lite := test.prepareLitespeed()
+
+ mx := lite.Collect()
+
+ assert.Equal(t, test.wantMetrics, mx)
+ if len(test.wantMetrics) > 0 {
+ testMetricsHasAllChartsDims(t, lite, mx)
+ }
+ })
+ }
+}
+
+func testMetricsHasAllChartsDims(t *testing.T, lite *Litespeed, mx map[string]int64) {
+ for _, chart := range *lite.Charts() {
+ if chart.Obsolete {
+ continue
+ }
+ for _, dim := range chart.Dims {
+ _, ok := mx[dim.ID]
+ assert.Truef(t, ok, "collected metrics has no data for dim '%s' chart '%s'", dim.ID, chart.ID)
+ }
+ for _, v := range chart.Vars {
+ _, ok := mx[v.ID]
+ assert.Truef(t, ok, "collected metrics has no data for var '%s' chart '%s'", v.ID, chart.ID)
+ }
+ }
+}
+
+func prepareLitespeedOk() *Litespeed {
+ lite := New()
+ lite.ReportsDir = "testdata"
+ return lite
+}
+
+func prepareLitespeedDirNotExist() *Litespeed {
+ lite := prepareLitespeedOk()
+ lite.ReportsDir += "!"
+ return lite
+}
diff --git a/src/go/plugin/go.d/modules/litespeed/metadata.yaml b/src/go/plugin/go.d/modules/litespeed/metadata.yaml
new file mode 100644
index 00000000..1c795753
--- /dev/null
+++ b/src/go/plugin/go.d/modules/litespeed/metadata.yaml
@@ -0,0 +1,148 @@
+plugin_name: go.d.plugin
+modules:
+ - meta:
+ id: collector-go.d.plugin-litespeed
+ plugin_name: go.d.plugin
+ module_name: litespeed
+ monitored_instance:
+ name: Litespeed
+ link: "https://www.litespeedtech.com/products/litespeed-web-server"
+ categories:
+ - data-collection.web-servers-and-web-proxies
+ icon_filename: "litespeed.svg"
+ related_resources:
+ integrations:
+ list: []
+ info_provided_to_referring_integrations:
+ description: ""
+ keywords:
+ - litespeed
+ - web
+ - server
+ most_popular: false
+ overview:
+ data_collection:
+ metrics_description: "Examine Litespeed metrics for insights into web server operations. Analyze request rates, response times, and error rates for efficient web service delivery."
+ method_description: "The collector uses the statistics under /tmp/lshttpd to gather the metrics."
+ supported_platforms:
+ include: []
+ exclude: []
+ multi_instance: false
+ additional_permissions:
+ description: ""
+ default_behavior:
+ auto_detection:
+ description: "If no configuration is present, the collector will attempt to read files under /tmp/lshttpd/."
+ limits:
+ description: ""
+ performance_impact:
+ description: ""
+ setup:
+ prerequisites:
+ list: []
+ configuration:
+ file:
+ name: go.d/litespeed.conf
+ options:
+ description: |
+ The following options can be defined globally: update_every, autodetection_retry.
+ folding:
+ title: Config options
+ enabled: true
+ list:
+ - name: update_every
+ description: Data collection frequency.
+ default_value: 10
+ required: false
+ - name: autodetection_retry
+ description: Sets the job re-check interval in seconds.
+ default_value: 0
+ required: false
+ - name: reports_dir
+ description: Directory containing Litespeed's real-time statistics files.
+ default_value: "/tmp/lshttpd/"
+ required: false
+ examples:
+ folding:
+ enabled: false
+ title: "Config"
+ list:
+ - name: Set the path to statistics
+ description: Change the path for the litespeed stats files
+ config: |
+ local:
+ name: 'local'
+ path: '/tmp/lshttpd'
+ troubleshooting:
+ problems:
+ list: []
+ alerts: []
+ metrics:
+ folding:
+ title: Metrics
+ enabled: false
+ description: ""
+ availability: []
+ scopes:
+ - name: global
+ description: "These metrics refer to the entire monitored application."
+ labels: []
+ metrics:
+ - name: litespeed.requests
+ description: Requests
+ unit: "requests/s"
+ chart_type: line
+ dimensions:
+ - name: requests
+ - name: litespeed.requests_processing
+ description: Requests In Processing
+ unit: "requests"
+ chart_type: line
+ dimensions:
+ - name: processing
+ - name: litespeed.net_throughput
+ description: Network Throughput HTTP
+ unit: "kilobits/s"
+ chart_type: area
+ dimensions:
+ - name: in
+ - name: out
+ - name: litespeed.net_ssl_throughput
+ description: Network Throughput HTTPS
+ unit: "kilobits/s"
+ chart_type: area
+ dimensions:
+ - name: in
+ - name: out
+ - name: litespeed.connections
+ description: Connections HTTP
+ unit: "conns"
+ chart_type: stacked
+ dimensions:
+ - name: free
+ - name: used
+ - name: litespeed.ssl_connections
+ description: Connections HTTPS
+ unit: "conns"
+ chart_type: stacked
+ dimensions:
+ - name: free
+ - name: used
+ - name: litespeed.public_cache
+ description: Public Cache Hits
+ unit: "hits/s"
+ chart_type: line
+ dimensions:
+ - name: hits
+ - name: litespeed.private_cache
+ description: Private Cache Hits
+ unit: "hits/s"
+ chart_type: line
+ dimensions:
+ - name: hits
+ - name: litespeed.static
+ description: Static Hits
+ unit: "hits/s"
+ chart_type: line
+ dimensions:
+ - name: hits
diff --git a/src/go/plugin/go.d/modules/litespeed/testdata/.rtreport b/src/go/plugin/go.d/modules/litespeed/testdata/.rtreport
new file mode 100644
index 00000000..e262cf3c
--- /dev/null
+++ b/src/go/plugin/go.d/modules/litespeed/testdata/.rtreport
@@ -0,0 +1,8 @@
+VERSION: LiteSpeed Web Server/Enterprise/5.2.7
+UPTIME: 02:31:56
+BPS_IN: 0, BPS_OUT: 15, SSL_BPS_IN: 1, SSL_BPS_OUT: 195
+MAXCONN: 2000, MAXSSL_CONN: 2000, PLAINCONN: 5, AVAILCONN: 1902, IDLECONN: 14, SSLCONN: 93, AVAILSSL: 1907
+REQ_RATE []: REQ_PROCESSING: 84, REQ_PER_SEC: 7.8, TOT_REQS: 92899, PUB_CACHE_HITS_PER_SEC: 0.0, TOTAL_PUB_CACHE_HITS: 9, PRIVATE_CACHE_HITS_PER_SEC: 0.0, TOTAL_PRIVATE_CACHE_HITS: 0, STATIC_HITS_PER_SEC: 3.8, TOTAL_STATIC_HITS: 53244
+REQ_RATE [APVH_149.202.xxx.xxxx:443_example.com]: REQ_PROCESSING: 0, REQ_PER_SEC: 0.0, TOT_REQS: 0, PUB_CACHE_HITS_PER_SEC: 0.0, TOTAL_PUB_CACHE_HITS: 0, PRIVATE_CACHE_HITS_PER_SEC: 0.0, TOTAL_PRIVATE_CACHE_HITS: 0, STATIC_HITS_PER_SEC: 0.0, TOTAL_STATIC_HITS: 0
+EXTAPP [CGI] [] [lscgid]: CMAXCONN: 200, EMAXCONN: 200, POOL_SIZE: 1, INUSE_CONN: 0, IDLE_CONN: 1, WAITQUE_DEPTH: 0, REQ_PER_SEC: 0.0, TOT_REQS: 41
+EXTAPP [Proxy] [] [http://127.0.0.1]: CMAXCONN: 10, EMAXCONN: 10, POOL_SIZE: 1, INUSE_CONN: 0, IDLE_CONN: 1, WAITQUE_DEPTH: 0, REQ_PER_SEC: 0.0, TOT_REQS: 20
diff --git a/src/go/plugin/go.d/modules/litespeed/testdata/.rtreport.2 b/src/go/plugin/go.d/modules/litespeed/testdata/.rtreport.2
new file mode 100644
index 00000000..e262cf3c
--- /dev/null
+++ b/src/go/plugin/go.d/modules/litespeed/testdata/.rtreport.2
@@ -0,0 +1,8 @@
+VERSION: LiteSpeed Web Server/Enterprise/5.2.7
+UPTIME: 02:31:56
+BPS_IN: 0, BPS_OUT: 15, SSL_BPS_IN: 1, SSL_BPS_OUT: 195
+MAXCONN: 2000, MAXSSL_CONN: 2000, PLAINCONN: 5, AVAILCONN: 1902, IDLECONN: 14, SSLCONN: 93, AVAILSSL: 1907
+REQ_RATE []: REQ_PROCESSING: 84, REQ_PER_SEC: 7.8, TOT_REQS: 92899, PUB_CACHE_HITS_PER_SEC: 0.0, TOTAL_PUB_CACHE_HITS: 9, PRIVATE_CACHE_HITS_PER_SEC: 0.0, TOTAL_PRIVATE_CACHE_HITS: 0, STATIC_HITS_PER_SEC: 3.8, TOTAL_STATIC_HITS: 53244
+REQ_RATE [APVH_149.202.xxx.xxxx:443_example.com]: REQ_PROCESSING: 0, REQ_PER_SEC: 0.0, TOT_REQS: 0, PUB_CACHE_HITS_PER_SEC: 0.0, TOTAL_PUB_CACHE_HITS: 0, PRIVATE_CACHE_HITS_PER_SEC: 0.0, TOTAL_PRIVATE_CACHE_HITS: 0, STATIC_HITS_PER_SEC: 0.0, TOTAL_STATIC_HITS: 0
+EXTAPP [CGI] [] [lscgid]: CMAXCONN: 200, EMAXCONN: 200, POOL_SIZE: 1, INUSE_CONN: 0, IDLE_CONN: 1, WAITQUE_DEPTH: 0, REQ_PER_SEC: 0.0, TOT_REQS: 41
+EXTAPP [Proxy] [] [http://127.0.0.1]: CMAXCONN: 10, EMAXCONN: 10, POOL_SIZE: 1, INUSE_CONN: 0, IDLE_CONN: 1, WAITQUE_DEPTH: 0, REQ_PER_SEC: 0.0, TOT_REQS: 20
diff --git a/src/go/plugin/go.d/modules/litespeed/testdata/config.json b/src/go/plugin/go.d/modules/litespeed/testdata/config.json
new file mode 100644
index 00000000..30924549
--- /dev/null
+++ b/src/go/plugin/go.d/modules/litespeed/testdata/config.json
@@ -0,0 +1,4 @@
+{
+ "update_every": 123,
+ "reports_dir": "ok"
+}
diff --git a/src/go/plugin/go.d/modules/litespeed/testdata/config.yaml b/src/go/plugin/go.d/modules/litespeed/testdata/config.yaml
new file mode 100644
index 00000000..03905e5c
--- /dev/null
+++ b/src/go/plugin/go.d/modules/litespeed/testdata/config.yaml
@@ -0,0 +1,2 @@
+update_every: 123
+reports_dir: "ok"