#ifndef CHECK_NVME_H #define CHECK_NVME_H #include #include #include #include #include #include #include #include #include "auxiliar.h" #define OK 0 #define WARN 1 #define CRIT 2 #define UNKN 3 #define VERSION "1.0" #define SMARTCTL_CMD_ATTRS "/usr/sbin/smartctl -A " #define SMARTCTL_CMD_INFO "/usr/sbin/smartctl -i " #define ROTATION_INFO_STR "Rotation Rate:" #define SSD_DEV_STR "Solid State Device" #define AVAILABLE_SPARE "Available Spare" #define MEDIA_ERRORS "Media and Data Integrity Errors" #define PERCENTAGE_USED "Percentage Used" using namespace std; struct NVMeAttr { string name; int value; int threshold_warn; int threshold_crit; bool optional; bool lower_than; }; typedef struct NVMeAttr NVMeAttr; // Attribute definitions NVMeAttr used = { .name = PERCENTAGE_USED, .value = -1, .threshold_warn = 80, .threshold_crit = 90, .optional = false, .lower_than = false, }; NVMeAttr spare = { .name = AVAILABLE_SPARE, .value = -1, .threshold_warn = 20, .threshold_crit = 10, .optional = false, .lower_than = true, }; NVMeAttr errors = { .name = MEDIA_ERRORS, .value = -1, .threshold_warn = 0, .threshold_crit = 0, .optional = false, .lower_than = false, }; map prepareAttrMap(int driveType); int getNVMeAttrValue(string line); std::string getNVMeAttrName(string line); int run_smartctl_cmd(const string command, const char* disk, string* output); int evalStatus(const char* disk, int driveType, string* status); void printVersion(); void printHelp(bool longVersion); void set_timeout(unsigned int sec); #endif