package
0.0.0-20210507151516-45ffd92748f1
Repository: https://github.com/vnnv/smart.git
Documentation: pkg.go.dev

# README

Collector

This is a work in progress project...

collector is a standalone linux application with several built-in commands. It is not tested on iOS or Windows. The aim of this application is to collect data for the installed storage devices (hdd, ssd and nvme) and persist this information in a database. Part of the collected information includes: reallocated sectors count, start_stop_count, information about data written to SSD/NVMe drives, etc. Please check the source code for more information.

Requirements:

1. PostgreSQL database, version 9+ will be ok.
2. To access the hardware the application must be executed with superuser permissions.

Commands:

  1. collector gen-cfg -out <output-file>. gen-cfg generate default configuration file. if -out flag is provided the result is written in the provided file. If file name is empty or -out flag is omitted stdout is used. Example result is :
{
  "dbCfg": {
    "dbHost": "db_host",
    "dbPort": 5432,
    "dbUser": "user",
    "dbPass": "pass",
    "dbName": "smart_collect",
    "dbSchema": "smart",
    "tablePrefix": "smart"
  },
  "driveDbPath": "drivedb.yaml",
  "excludeList": []
}

All options in dbCfg are self-explained. driveDbPath contains full path to "drivedb.yaml" file. See cmd/mkdrivedb. excludeList is a string slice containing devices to be excluded. Values can be device serial number or device path.

After saving this config file and changing the parameters in it, next commands can be used.


  1. collector gen-db -cfg app_config.json -print -create

    -cfg flag points to a valid configuration file

    -print is a boolean flag. Defaults to true. If the flag is true prints DDL to the stdout

    -create is a boolean flag. Defaults to false. If the flag is set to true, try to execute DDLs on the configured database.

This command prepares the database needed for the application


  1. collector scan -cfg app_config.json -save

    -cfg flag points to a valid configuration file

    -save is a boolean flag. Defaults to false. If the flag is set to true, save the collected information in the database.

This command is the main functionality. The application scan all SCSI/SATA and NVMe drives attached to the system and collects various information. If -save flag is enabled the information is saved in the database If save flag is not enabled the information is printed on stdout.