Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save asad-albadi/d1c376c2ab0a0172ce8d2b3456be75ee to your computer and use it in GitHub Desktop.
Save asad-albadi/d1c376c2ab0a0172ce8d2b3456be75ee to your computer and use it in GitHub Desktop.

Setting Up Scrutiny Collector Metrics on Windows

Step 1: Create the collector.yaml File

  1. Open PowerShell:

    • Press Win + X and select "Windows PowerShell" or "Windows PowerShell (Admin)".
  2. Navigate to the Desired Directory:

    cd C:\opt\scrutiny\config
    • If the directory does not exist, create it using the mkdir command:
      mkdir -p C:\opt\scrutiny\config
      cd C:\opt\scrutiny\config
  3. Create and Edit the collector.yaml File:

    New-Item -Path . -Name "collector.yaml" -ItemType "file" -Force
    notepad collector.yaml
  4. Paste the Configuration Content:

    • Copy the following configuration content and paste it into the Notepad window that opens:
      # Commented Scrutiny Configuration File
       #
       # The default location for this file is /opt/scrutiny/config/collector.yaml.
       # In some cases to improve clarity default values are specified,
       # uncommented. Other example values are commented out.
       #
       # When this file is parsed by Scrutiny, all configuration file keys are
       # lowercased automatically. As such, Configuration keys are case-insensitive,
       # and should be lowercase in this file to be consistent with usage.
      
      
       ######################################################################
       # Version
       #
       # version specifies the version of this configuration file schema, not
       # the scrutiny binary. There is only 1 version available at the moment
       version: 1
      
       # The host id is a label used for identifying groups of disks running on the same host
       # Primiarly used for hub/spoke deployments (can be left empty if using all-in-one image).
       host:
         id: "SY-WIND"
      
      
       # This block allows you to override/customize the settings for devices detected by
       # Scrutiny via `smartctl --scan`
       # See the "--device=TYPE" section of https://linux.die.net/man/8/smartctl
       # type can be a 'string' or a 'list'
       devices:
       #  # example for forcing device type detection for a single disk
       #  - device: /dev/sda
       #    type: 'sat'
       #
       #  # example for using `-d sat,auto`, notice the square brackets (workaround for #418)
       #  - device: /dev/sda
       #    type: ['sat,auto']
       #
       #  # example to show how to ignore a specific disk/device.
       #  - device: /dev/sda
       #    ignore: true
       #
       #  # examples showing how to force smartctl to detect disks inside a raid array/virtual disk
       #  - device: /dev/bus/0
       #    type:
       #      - megaraid,14
       #      - megaraid,15
       #      - megaraid,18
       #      - megaraid,19
       #      - megaraid,20
       #      - megaraid,21
       #
       #  - device: /dev/twa0
       #    type:
       #      - 3ware,0
       #      - 3ware,1
       #      - 3ware,2
       #      - 3ware,3
       #      - 3ware,4
       #      - 3ware,5
       #
       #  # example to show how to override the smartctl command args (per device), see below for how to override these globally.
       #  - device: /dev/sda
       #    commands:
       #      metrics_info_args: '--info --json -T permissive' # used to determine device unique ID & register device with Scrutiny
       #      metrics_smart_args: '--xall --json -T permissive' # used to retrieve smart data for each device.
      
      
       #log:
       #  file: '' #absolute or relative paths allowed, eg. web.log
       #  level: INFO
       #
       api:
         endpoint: 'http://10.10.12.86:3007'
       #  endpoint: 'http://localhost:8080/custombasepath'
       # if you need to use a custom base path (for a reverse proxy), you can add a suffix to the endpoint.
       #  See docs/TROUBLESHOOTING_REVERSE_PROXY.md for more info,
      
       # example to show how to override the smartctl command args globally
       #commands:
       #  metrics_smartctl_bin: 'smartctl' # change to provide custom `smartctl` binary path, eg. `/usr/sbin/smartctl`
       #  metrics_scan_args: '--scan --json' # used to detect devices
       #  metrics_info_args: '--info --json' # used to determine device unique ID & register device with Scrutiny
       #  metrics_smart_args: '--xall --json' # used to retrieve smart data for each device.
      
      
       ########################################################################################################################
       # FEATURES COMING SOON
       #
       # The following commented out sections are a preview of additional configuration options that will be available soon.
       #
       ########################################################################################################################
      
       #collect:
       #  long:
       #    enable: false
       #    command: ''
       #  short:
       #    enable: false
       #    command: ''
  5. Save and Close:

    • Save the file by clicking "File" -> "Save" in Notepad.
    • Close Notepad.

Step 2: Install smartctl

  1. Download smartctl:

  2. Run the Installer:

    • Execute the installer by running the following command in PowerShell:
      .\smartmontools-7.4-1.win32-setup.exe
  3. Follow the Installation Steps:

    • Follow the on-screen instructions to install smartmontools. Note the installation directory (default is usually C:\Program Files\smartmontools).
  4. Add smartctl to the System Path:

    • Open the Start menu, search for "Environment Variables," and select "Edit the system environment variables."
    • In the System Properties window, click on the "Environment Variables" button.
    • In the Environment Variables window, find the "Path" variable in the "System variables" section and select it, then click "Edit."
    • In the Edit Environment Variable window, click "New" and add the path to the smartctl.exe executable, typically:
      C:\Program Files\smartmontools\bin
      
    • Click "OK" to close all the windows.
  5. Verify the Installation:

    • Open a new command prompt or PowerShell window.
    • Type smartctl --version and press Enter. You should see the version information for smartctl, indicating that it is installed and accessible from the command line.

Step 3: Schedule Scrutiny Collector Metrics Tool to Run Every Hour

  1. Open Task Scheduler:

    • Press Win + R, type taskschd.msc, and press Enter.
  2. Create a New Task:

    • In the Task Scheduler window, click on "Create Basic Task..." in the Actions pane on the right.
    • Give your task a name (e.g., "Scrutiny Collector Metrics") and an optional description, then click "Next".
  3. Set the Trigger:

    • Select "Daily" and click "Next".
    • Set the start date and time to the next hour (e.g., if it's currently 06:45, set it to 07:00), and set the "Recur every" option to 1 day.
    • Click "Next".
  4. Repeat the Task Every Hour:

    • On the next screen, check the "Repeat task every" box and select "1 hour".
    • Set "for a duration of" to "Indefinitely".
    • Click "Next".
  5. Start a Program:

    • Select "Start a program" and click "Next".
    • Click "Browse..." and navigate to the directory where your scrutiny-collector-metrics-windows-amd64.exe is located (e.g., C:\opt\scrutiny\config\scrutiny-collector-metrics-windows-amd64.exe).
    • In the "Add arguments (optional)" field, enter the following arguments to specify the configuration file:
      run --config C:\opt\scrutiny\config\collector.yaml
      
    • Click "Next".
  6. Finish the Task:

    • Review the summary of the task and click "Finish".

Now, the Scrutiny Collector Metrics tool is scheduled to run every hour at the start of the hour. Task Scheduler will handle the execution of the tool according to the specified schedule.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment