check_smart.h 1.26 KB
#ifndef CHECK_SMART_H
#define CHECK_SMART_H

#include <iostream>
#include <sstream>
#include <map>

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>

#include <sys/time.h>

#include "auxiliar.h"

#define OK 0
#define WARN 1
#define CRIT 2
#define UNKN 3

#define VERSION "1.3"

#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 REALLOC_SEC_COUNT_ID 5
#define CURRENT_PENDING_SEC_ID 197
#define OFFLINE_UNCORRECT_ID 198
#define WEAR_COUNT_ID 177
#define MEDIA_WEAROUT_INDICATOR 233
#define RUNTIME_BAD_BLOCKS_IDD 183
#define REP_UNCORRECT_ID 187

#define HDD 0
#define SSD 1

using namespace std;

struct SMARTAttr
{
  string name;
  int value;
  int severity;
  bool optional;
}; typedef struct SMARTAttr SMARTAttr;


map<int,SMARTAttr> prepareAttrMap(int driveType);
int getSmartAttrValue(string line);
int getSmartAttrID(string line);
int run_smartctl_cmd(const string command, const char* disk, string* output);
int checkDriveType(const char* disk);
int evalStatus(const char* disk, int driveType, string* status);
void printVersion();
void printHelp(bool longVersion);
void set_timeout(unsigned int sec);

#endif