diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-11-09 08:36:11 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-11-09 08:37:11 +0000 |
commit | 910c794ec6d0a364b4aabccf22b715cb45780e83 (patch) | |
tree | 561a9ef6b6a4668102674e1a52b3e7563c57ac61 /src/collectors/python.d.plugin/samba | |
parent | Releasing debian version 1.47.5-1. (diff) | |
download | netdata-910c794ec6d0a364b4aabccf22b715cb45780e83.tar.xz netdata-910c794ec6d0a364b4aabccf22b715cb45780e83.zip |
Merging upstream version 2.0.0 (Closes: #923993, #1042533, #1045145).
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/collectors/python.d.plugin/samba')
l--------- | src/collectors/python.d.plugin/samba/README.md | 1 | ||||
-rw-r--r-- | src/collectors/python.d.plugin/samba/integrations/samba.md | 255 | ||||
-rw-r--r-- | src/collectors/python.d.plugin/samba/metadata.yaml | 205 | ||||
-rw-r--r-- | src/collectors/python.d.plugin/samba/samba.chart.py | 144 | ||||
-rw-r--r-- | src/collectors/python.d.plugin/samba/samba.conf | 60 |
5 files changed, 0 insertions, 665 deletions
diff --git a/src/collectors/python.d.plugin/samba/README.md b/src/collectors/python.d.plugin/samba/README.md deleted file mode 120000 index 3b63bbab..00000000 --- a/src/collectors/python.d.plugin/samba/README.md +++ /dev/null @@ -1 +0,0 @@ -integrations/samba.md
\ No newline at end of file diff --git a/src/collectors/python.d.plugin/samba/integrations/samba.md b/src/collectors/python.d.plugin/samba/integrations/samba.md deleted file mode 100644 index 4d6f8fcc..00000000 --- a/src/collectors/python.d.plugin/samba/integrations/samba.md +++ /dev/null @@ -1,255 +0,0 @@ -<!--startmeta -custom_edit_url: "https://github.com/netdata/netdata/edit/master/src/collectors/python.d.plugin/samba/README.md" -meta_yaml: "https://github.com/netdata/netdata/edit/master/src/collectors/python.d.plugin/samba/metadata.yaml" -sidebar_label: "Samba" -learn_status: "Published" -learn_rel_path: "Collecting Metrics/Storage, Mount Points and Filesystems" -most_popular: False -message: "DO NOT EDIT THIS FILE DIRECTLY, IT IS GENERATED BY THE COLLECTOR'S metadata.yaml FILE" -endmeta--> - -# Samba - - -<img src="https://netdata.cloud/img/samba.svg" width="150"/> - - -Plugin: python.d.plugin -Module: samba - -<img src="https://img.shields.io/badge/maintained%20by-Netdata-%2300ab44" /> - -## Overview - -This collector monitors the performance metrics of Samba file sharing. - -It is using the `smbstatus` command-line tool. - -Executed commands: - -- `sudo -n smbstatus -P` - - -This collector is supported on all platforms. - -This collector only supports collecting metrics from a single instance of this integration. - -`smbstatus` is used, which can only be executed by `root`. It uses `sudo` and assumes that it is configured such that the `netdata` user can execute `smbstatus` as root without a password. - - -### Default Behavior - -#### Auto-Detection - -After all the permissions are satisfied, the `smbstatus -P` binary is executed. - -#### 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 Samba instance - -These metrics refer to the entire monitored application. - -This scope has no labels. - -Metrics: - -| Metric | Dimensions | Unit | -|:------|:----------|:----| -| syscall.rw | sendfile, recvfile | KiB/s | -| smb2.rw | readout, writein, readin, writeout | KiB/s | -| smb2.create_close | create, close | operations/s | -| smb2.get_set_info | getinfo, setinfo | operations/s | -| smb2.find | find | operations/s | -| smb2.notify | notify | operations/s | -| smb2.sm_counters | tcon, negprot, tdis, cancel, logoff, flush, lock, keepalive, break, sessetup | count | - - - -## Alerts - -There are no alerts configured by default for this integration. - - -## Setup - -### Prerequisites - -#### Enable the samba collector - -The `samba` collector is disabled by default. To enable it, use `edit-config` from the Netdata [config directory](/docs/netdata-agent/configuration/README.md), which is typically at `/etc/netdata`, to edit the `python.d.conf` file. - -```bash -cd /etc/netdata # Replace this path with your Netdata config directory, if different -sudo ./edit-config python.d.conf -``` -Change the value of the `samba` setting to `yes`. Save the file and restart the Netdata Agent with `sudo systemctl restart netdata`, or the [appropriate method](/packaging/installer/README.md#maintaining-a-netdata-agent-installation) for your system. - - -#### Permissions and programs - -To run the collector you need: - -- `smbstatus` program -- `sudo` program -- `smbd` must be compiled with profiling enabled -- `smbd` must be started either with the `-P 1` option or inside `smb.conf` using `smbd profiling level` - -The module uses `smbstatus`, which can only be executed by `root`. It uses `sudo` and assumes that it is configured such that the `netdata` user can execute `smbstatus` as root without a password. - -- add to your `/etc/sudoers` file: - - `which smbstatus` shows the full path to the binary. - - ```bash - netdata ALL=(root) NOPASSWD: /path/to/smbstatus - ``` - -- Reset Netdata's systemd unit [CapabilityBoundingSet](https://www.freedesktop.org/software/systemd/man/systemd.exec.html#Capabilities) (Linux distributions with systemd) - - The default CapabilityBoundingSet doesn't allow using `sudo`, and is quite strict in general. Resetting is not optimal, but a next-best solution given the inability to execute `smbstatus` using `sudo`. - - - As the `root` user, do the following: - - ```cmd - mkdir /etc/systemd/system/netdata.service.d - echo -e '[Service]\nCapabilityBoundingSet=~' | tee /etc/systemd/system/netdata.service.d/unset-capability-bounding-set.conf - systemctl daemon-reload - systemctl restart netdata.service - ``` - - - -### Configuration - -#### File - -The configuration file name for this integration is `python.d/samba.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 python.d/samba.conf -``` -#### Options - -There are 2 sections: - -* Global variables -* One or more JOBS that can define multiple different instances to monitor. - -The following options can be defined globally: priority, penalty, autodetection_retry, update_every, but can also be defined per JOB to override the global values. - -Additionally, the following collapsed table contains all the options that can be configured inside a JOB definition. - -Every configuration JOB starts with a `job_name` value which will appear in the dashboard, unless a `name` parameter is specified. - - -<details open><summary>Config options</summary> - -| Name | Description | Default | Required | -|:----|:-----------|:-------|:--------:| -| update_every | Sets the default data collection frequency. | 5 | no | -| priority | Controls the order of charts at the netdata dashboard. | 60000 | no | -| autodetection_retry | Sets the job re-check interval in seconds. | 0 | no | -| penalty | Indicates whether to apply penalty to update_every in case of failures. | yes | no | - -</details> - -#### Examples - -##### Basic - -A basic example configuration. - -<details open><summary>Config</summary> - -```yaml -my_job_name: - name: my_name - update_every: 1 - -``` -</details> - - - -## Troubleshooting - -### Debug Mode - - -To troubleshoot issues with the `samba` collector, run the `python.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 `python.d.plugin` to debug the collector: - - ```bash - ./python.d.plugin samba debug trace - ``` - -### Getting Logs - -If you're encountering problems with the `samba` 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 samba -``` - -#### 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 samba /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 samba -``` - - diff --git a/src/collectors/python.d.plugin/samba/metadata.yaml b/src/collectors/python.d.plugin/samba/metadata.yaml deleted file mode 100644 index 09c04e7d..00000000 --- a/src/collectors/python.d.plugin/samba/metadata.yaml +++ /dev/null @@ -1,205 +0,0 @@ -plugin_name: python.d.plugin -modules: - - meta: - plugin_name: python.d.plugin - module_name: samba - monitored_instance: - name: Samba - link: https://www.samba.org/samba/ - categories: - - data-collection.storage-mount-points-and-filesystems - icon_filename: "samba.svg" - related_resources: - integrations: - list: [] - info_provided_to_referring_integrations: - description: "" - keywords: - - samba - - file sharing - most_popular: false - overview: - data_collection: - metrics_description: "This collector monitors the performance metrics of Samba file sharing." - method_description: | - It is using the `smbstatus` command-line tool. - - Executed commands: - - - `sudo -n smbstatus -P` - supported_platforms: - include: [] - exclude: [] - multi_instance: false - additional_permissions: - description: | - `smbstatus` is used, which can only be executed by `root`. It uses `sudo` and assumes that it is configured such that the `netdata` user can execute `smbstatus` as root without a password. - default_behavior: - auto_detection: - description: "After all the permissions are satisfied, the `smbstatus -P` binary is executed." - limits: - description: "" - performance_impact: - description: "" - setup: - prerequisites: - list: - - title: Enable the samba collector - description: | - The `samba` collector is disabled by default. To enable it, use `edit-config` from the Netdata [config directory](/docs/netdata-agent/configuration/README.md), which is typically at `/etc/netdata`, to edit the `python.d.conf` file. - - ```bash - cd /etc/netdata # Replace this path with your Netdata config directory, if different - sudo ./edit-config python.d.conf - ``` - Change the value of the `samba` setting to `yes`. Save the file and restart the Netdata Agent with `sudo systemctl restart netdata`, or the [appropriate method](/packaging/installer/README.md#maintaining-a-netdata-agent-installation) for your system. - - title: Permissions and programs - description: | - To run the collector you need: - - - `smbstatus` program - - `sudo` program - - `smbd` must be compiled with profiling enabled - - `smbd` must be started either with the `-P 1` option or inside `smb.conf` using `smbd profiling level` - - The module uses `smbstatus`, which can only be executed by `root`. It uses `sudo` and assumes that it is configured such that the `netdata` user can execute `smbstatus` as root without a password. - - - add to your `/etc/sudoers` file: - - `which smbstatus` shows the full path to the binary. - - ```bash - netdata ALL=(root) NOPASSWD: /path/to/smbstatus - ``` - - - Reset Netdata's systemd unit [CapabilityBoundingSet](https://www.freedesktop.org/software/systemd/man/systemd.exec.html#Capabilities) (Linux distributions with systemd) - - The default CapabilityBoundingSet doesn't allow using `sudo`, and is quite strict in general. Resetting is not optimal, but a next-best solution given the inability to execute `smbstatus` using `sudo`. - - - As the `root` user, do the following: - - ```cmd - mkdir /etc/systemd/system/netdata.service.d - echo -e '[Service]\nCapabilityBoundingSet=~' | tee /etc/systemd/system/netdata.service.d/unset-capability-bounding-set.conf - systemctl daemon-reload - systemctl restart netdata.service - ``` - configuration: - file: - name: python.d/samba.conf - options: - description: | - There are 2 sections: - - * Global variables - * One or more JOBS that can define multiple different instances to monitor. - - The following options can be defined globally: priority, penalty, autodetection_retry, update_every, but can also be defined per JOB to override the global values. - - Additionally, the following collapsed table contains all the options that can be configured inside a JOB definition. - - Every configuration JOB starts with a `job_name` value which will appear in the dashboard, unless a `name` parameter is specified. - folding: - title: "Config options" - enabled: true - list: - - name: update_every - description: Sets the default data collection frequency. - default_value: 5 - required: false - - name: priority - description: Controls the order of charts at the netdata dashboard. - default_value: 60000 - required: false - - name: autodetection_retry - description: Sets the job re-check interval in seconds. - default_value: 0 - required: false - - name: penalty - description: Indicates whether to apply penalty to update_every in case of failures. - default_value: yes - required: false - examples: - folding: - enabled: true - title: "Config" - list: - - name: Basic - description: A basic example configuration. - config: | - my_job_name: - name: my_name - update_every: 1 - 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: syscall.rw - description: R/Ws - unit: "KiB/s" - chart_type: area - dimensions: - - name: sendfile - - name: recvfile - - name: smb2.rw - description: R/Ws - unit: "KiB/s" - chart_type: area - dimensions: - - name: readout - - name: writein - - name: readin - - name: writeout - - name: smb2.create_close - description: Create/Close - unit: "operations/s" - chart_type: line - dimensions: - - name: create - - name: close - - name: smb2.get_set_info - description: Info - unit: "operations/s" - chart_type: line - dimensions: - - name: getinfo - - name: setinfo - - name: smb2.find - description: Find - unit: "operations/s" - chart_type: line - dimensions: - - name: find - - name: smb2.notify - description: Notify - unit: "operations/s" - chart_type: line - dimensions: - - name: notify - - name: smb2.sm_counters - description: Lesser Ops - unit: "count" - chart_type: stacked - dimensions: - - name: tcon - - name: negprot - - name: tdis - - name: cancel - - name: logoff - - name: flush - - name: lock - - name: keepalive - - name: break - - name: sessetup diff --git a/src/collectors/python.d.plugin/samba/samba.chart.py b/src/collectors/python.d.plugin/samba/samba.chart.py deleted file mode 100644 index 8eebcd60..00000000 --- a/src/collectors/python.d.plugin/samba/samba.chart.py +++ /dev/null @@ -1,144 +0,0 @@ -# -*- coding: utf-8 -*- -# Description: samba netdata python.d module -# Author: Christopher Cox <chris_cox@endlessnow.com> -# SPDX-License-Identifier: GPL-3.0-or-later -# -# The netdata user needs to be able to be able to sudo the smbstatus program -# without password: -# netdata ALL=(ALL) NOPASSWD: /usr/bin/smbstatus -P -# -# This makes calls to smbstatus -P -# -# This just looks at a couple of values out of syscall, and some from smb2. -# -# The Lesser Ops chart is merely a display of current counter values. They -# didn't seem to change much to me. However, if you notice something changing -# a lot there, bring one or more out into its own chart and make it incremental -# (like find and notify... good examples). - -import re -import os - -from bases.FrameworkServices.ExecutableService import ExecutableService -from bases.collection import find_binary - -disabled_by_default = True - -update_every = 5 - -ORDER = [ - 'syscall_rw', - 'smb2_rw', - 'smb2_create_close', - 'smb2_info', - 'smb2_find', - 'smb2_notify', - 'smb2_sm_count' -] - -CHARTS = { - 'syscall_rw': { - 'options': [None, 'R/Ws', 'KiB/s', 'syscall', 'syscall.rw', 'area'], - 'lines': [ - ['syscall_sendfile_bytes', 'sendfile', 'incremental', 1, 1024], - ['syscall_recvfile_bytes', 'recvfile', 'incremental', -1, 1024] - ] - }, - 'smb2_rw': { - 'options': [None, 'R/Ws', 'KiB/s', 'smb2', 'smb2.rw', 'area'], - 'lines': [ - ['smb2_read_outbytes', 'readout', 'incremental', 1, 1024], - ['smb2_write_inbytes', 'writein', 'incremental', -1, 1024], - ['smb2_read_inbytes', 'readin', 'incremental', 1, 1024], - ['smb2_write_outbytes', 'writeout', 'incremental', -1, 1024] - ] - }, - 'smb2_create_close': { - 'options': [None, 'Create/Close', 'operations/s', 'smb2', 'smb2.create_close', 'line'], - 'lines': [ - ['smb2_create_count', 'create', 'incremental', 1, 1], - ['smb2_close_count', 'close', 'incremental', -1, 1] - ] - }, - 'smb2_info': { - 'options': [None, 'Info', 'operations/s', 'smb2', 'smb2.get_set_info', 'line'], - 'lines': [ - ['smb2_getinfo_count', 'getinfo', 'incremental', 1, 1], - ['smb2_setinfo_count', 'setinfo', 'incremental', -1, 1] - ] - }, - 'smb2_find': { - 'options': [None, 'Find', 'operations/s', 'smb2', 'smb2.find', 'line'], - 'lines': [ - ['smb2_find_count', 'find', 'incremental', 1, 1] - ] - }, - 'smb2_notify': { - 'options': [None, 'Notify', 'operations/s', 'smb2', 'smb2.notify', 'line'], - 'lines': [ - ['smb2_notify_count', 'notify', 'incremental', 1, 1] - ] - }, - 'smb2_sm_count': { - 'options': [None, 'Lesser Ops', 'count', 'smb2', 'smb2.sm_counters', 'stacked'], - 'lines': [ - ['smb2_tcon_count', 'tcon', 'absolute', 1, 1], - ['smb2_negprot_count', 'negprot', 'absolute', 1, 1], - ['smb2_tdis_count', 'tdis', 'absolute', 1, 1], - ['smb2_cancel_count', 'cancel', 'absolute', 1, 1], - ['smb2_logoff_count', 'logoff', 'absolute', 1, 1], - ['smb2_flush_count', 'flush', 'absolute', 1, 1], - ['smb2_lock_count', 'lock', 'absolute', 1, 1], - ['smb2_keepalive_count', 'keepalive', 'absolute', 1, 1], - ['smb2_break_count', 'break', 'absolute', 1, 1], - ['smb2_sessetup_count', 'sessetup', 'absolute', 1, 1] - ] - } -} - -SUDO = 'sudo' -SMBSTATUS = 'smbstatus' - - -class Service(ExecutableService): - def __init__(self, configuration=None, name=None): - ExecutableService.__init__(self, configuration=configuration, name=name) - self.order = ORDER - self.definitions = CHARTS - self.rgx_smb2 = re.compile(r'(smb2_[^:]+|syscall_.*file_bytes):\s+(\d+)') - - def check(self): - smbstatus_binary = find_binary(SMBSTATUS) - if not smbstatus_binary: - self.error("can't locate '{0}' binary".format(SMBSTATUS)) - return False - - if os.getuid() == 0: - self.command = ' '.join([smbstatus_binary, '-P']) - return ExecutableService.check(self) - - sudo_binary = find_binary(SUDO) - if not sudo_binary: - self.error("can't locate '{0}' binary".format(SUDO)) - return False - command = [sudo_binary, '-n', '-l', smbstatus_binary, '-P'] - smbstatus = '{0} -P'.format(smbstatus_binary) - allowed = self._get_raw_data(command=command) - if not (allowed and allowed[0].strip() == smbstatus): - self.error("not allowed to run sudo for command '{0}'".format(smbstatus)) - return False - self.command = ' '.join([sudo_binary, '-n', smbstatus_binary, '-P']) - return ExecutableService.check(self) - - def _get_data(self): - """ - Format data received from shell command - :return: dict - """ - raw_data = self._get_raw_data() - if not raw_data: - return None - - parsed = self.rgx_smb2.findall(' '.join(raw_data)) - - return dict(parsed) or None diff --git a/src/collectors/python.d.plugin/samba/samba.conf b/src/collectors/python.d.plugin/samba/samba.conf deleted file mode 100644 index db15d4e9..00000000 --- a/src/collectors/python.d.plugin/samba/samba.conf +++ /dev/null @@ -1,60 +0,0 @@ -# netdata python.d.plugin configuration for samba -# -# This file is in YaML format. Generally the format is: -# -# name: value -# -# There are 2 sections: -# - global variables -# - one or more JOBS -# -# JOBS allow you to collect values from multiple sources. -# Each source will have its own set of charts. -# -# JOB parameters have to be indented (using spaces only, example below). - -# ---------------------------------------------------------------------- -# Global Variables -# These variables set the defaults for all JOBs, however each JOB -# may define its own, overriding the defaults. - -# update_every sets the default data collection frequency. -# If unset, the python.d.plugin default is used. -update_every: 5 - -# priority controls the order of charts at the netdata dashboard. -# Lower numbers move the charts towards the top of the page. -# If unset, the default for python.d.plugin is used. -# priority: 60000 - -# penalty indicates whether to apply penalty to update_every in case of failures. -# Penalty will increase every 5 failed updates in a row. Maximum penalty is 10 minutes. -# penalty: yes - -# autodetection_retry sets the job re-check interval in seconds. -# The job is not deleted if check fails. -# Attempts to start the job are made once every autodetection_retry. -# This feature is disabled by default. -# autodetection_retry: 0 - -# ---------------------------------------------------------------------- -# JOBS (data collection sources) -# -# The default JOBS share the same *name*. JOBS with the same name -# are mutually exclusive. Only one of them will be allowed running at -# any time. This allows autodetection to try several alternatives and -# pick the one that works. -# -# Any number of jobs is supported. -# -# All python.d.plugin JOBS (for all its modules) support a set of -# predefined parameters. These are: -# -# job_name: -# name: myname # the JOB's name as it will appear at the -# # dashboard (by default is the job_name) -# # JOBs sharing a name are mutually exclusive -# update_every: 1 # the JOB's data collection frequency -# priority: 60000 # the JOB's order on the dashboard -# penalty: yes # the JOB's penalty -# autodetection_retry: 0 # the JOB's re-check interval in seconds
\ No newline at end of file |