Blame view

check_smart/check_smart.h 1.26 KB
Imanol-Mikel Barba Sabariego authored
1
2
3
4
5
#ifndef CHECK_SMART_H
#define CHECK_SMART_H

#include <iostream>
#include <sstream>
6
#include <map>
Imanol-Mikel Barba Sabariego authored
7
8

#include <stdio.h>
9
10
#include <string.h>
#include <stdlib.h>
Imanol-Mikel Barba Sabariego authored
11
12
13
14
#include <unistd.h>

#include <sys/time.h>
Imanol-Mikel Barba Sabariego authored
15
#include "auxiliar.h"
Imanol-Mikel Barba Sabariego authored
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#define OK 0
#define WARN 1
#define CRIT 2
#define UNKN 3

#define VERSION "1.2"

#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
34
#define MEDIA_WEAROUT_INDICATOR 233
35
36
37
38
39
#define RUNTIME_BAD_BLOCKS_IDD 183
#define REP_UNCORRECT_ID 187

#define HDD 0
#define SSD 1
Imanol-Mikel Barba Sabariego authored
40
41
42

using namespace std;
43
44
45
46
47
struct SMARTAttr
{
  string name;
  int value;
  int severity;
48
  bool optional;
49
50
51
52
53
54
55
56
57
}; 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);
Imanol-Mikel Barba Sabariego authored
58
59
void printVersion();
void printHelp(bool longVersion);
60
void set_timeout(unsigned int sec);
Imanol-Mikel Barba Sabariego authored
61
62

#endif