Conky: Add new module for SMART monitoring

Created on 29 May 2017  路  3Comments  路  Source: brndnmtthws/conky

I'm thinking about creating a new module for SMART disk monitoring. As far as I can tell, there are three options to implement this:

  • calling smartctl (smartmontools)
  • interfacing libatasmart
  • interfacing udisks using DBUS communications

I'd prefer to use libatasmart as this would add native support with only a single additional dependency.

Does anyone know if it is possible to use libatasmart without root privileges?

enhancement

Most helpful comment

@fonic OMFG. I can't wait to see this implemented. :scream:

All 3 comments

libatasmart

#include <stdio.h>
#include <string.h>
#include <errno.h>

#include <atasmart.h>

int main(void) {
  uint64_t mkelvin = 0;
  const char *device = "/dev/sda";
  SkDisk *d = NULL;

  if (-1 == (sk_disk_open(device, &d))) {
    fprintf(stderr, "Failed to open disk %s: %s\n", device, strerror(errno));
    return 1;
  }

  if (-1 == (sk_disk_smart_read_data(d))) {
    fprintf(stderr, "Failed to read SMART data: %s\n", strerror(errno));
    goto finish;
  }

  if (-1 == (sk_disk_smart_get_temperature(d, &mkelvin))) {
    fprintf(stderr, "Failed to get temperature: %s\n", strerror(errno));
    goto finish;
  }

  printf("%llu\n", (unsigned long long)mkelvin);

finish:
  if (NULL != d) {
    sk_disk_free(d);
  }
  return 0;
}

smartmontools are cross-platform available and the *BSD flavours would benefit from it too.

Those like me that do not use init systemd will be forced to install additional dependencies.

Does anyone know if it is possible to use libatasmart without root privileges?

visudo

computer_name ALL=NOPASSWD:/usr/bin/program_name

@fonic OMFG. I can't wait to see this implemented. :scream:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  4Comments

akorop picture akorop  路  3Comments

zero77 picture zero77  路  3Comments

zero77 picture zero77  路  3Comments

Microcrap picture Microcrap  路  4Comments