<commit_before># node-raidar: a Node.js NetGear RAIDar library

`node-raidar` is a simple to use NetGear RAIDar implementation for Node.js.



## Installing

### NPM

```
npm install --save raidar
```

### Yarn

```
yarn add raidar
```



## Examples

### One shot

``` js
// require lib
var raidar = require('raidar')

// request devices
raidar.request(function (err, devices) {

  // handle error
  if (err) console.error(err)

  // do something useful
  else console.log('ReadyNAS devices found:', devices.length)

})
```

### Events

``` js
// require lib
var raidar = require('raidar')

// listen for all devices
raidar.on('device', function (device) {

  // do something cool
  console.log('Reponse from', device.hostname())

})

// handle all errors
raidar.on('error', function (err) {

  // log error
  console.error(err)

})

// listen single device by IP
raidar.on('192.168.1.10', function (device) { ... })

// listen single device by hostname
raidar.on('nas-acme', function (device) { ... })

// listen single device by MAC address
raidar.on('aa:bb:cc:dd:ee:ff', function (device) { ... })

// perform request
raidar.request()
```



## ReadyNAS (device) class

Representation of a ReadyNAS device.

### Device info APIs

#### mac() : {String}

Get device MAC address.

#### hostname() : {String}

Get device hostname.

#### ip() : {String}

Get device IP.

#### serial() : {String}

Get device serial number.

#### version() : {String}

Get loaded firmware version.

### Disks info APIs

#### diskCount() : {Number}

Get number of loaded disks.

#### diskInfo({Number} index, {String} [attribute='status']) : {String|Number}

Get info of a particular disk.

| Attribute   | Return type | Description               |
| ----------- | ----------- | ------------------------- |
| status      | {String}    | 'ok', 'warn', 'dead' or ? |
| channel     | {Number}    | HDD channel               |
| model       | {String}    | HDD model                 |
| celsius     | {Number}    | temperature in celsius    |
| fahrenheit  | {Number}    | temperature in fahrenheit |

### Volumes info APIs

#### volumeCount() : {Number}

Get number of configured volumes.

#### volumeInfo({Number} index, {String} [attribute='status']) : {String|Number}

Get info of a particular volume.

| Attribute | Return type | Description               |
| --------- | ----------- | ------------------------- |
| status    | {String}    | 'ok', 'warn', 'dead' or ? |
| level     | {String}    | RAID level                |
| message   | {String}    | Status description        |
| size      | {Number}    | Volume size in bytes      |
| used      | {Number}    | Used space in bytes       |
| free      | {Number}    | Free space in bytes       |

### Other APIs

#### getEntities() : {Array}

Get all device entities.

#### getEntity({String} entity, {Number} [index]) : {Object}

Get entity data.

#### getEntityAttribute({String} entity, {Number} [index], {String} attribute) : {*}

Get single entity attribute.
<commit_msg>removed wrong status<commit_after># node-raidar: a Node.js NetGear RAIDar library

`node-raidar` is a simple to use NetGear RAIDar implementation for Node.js.



## Installing

### NPM

```
npm install --save raidar
```

### Yarn

```
yarn add raidar
```



## Examples

### One shot

``` js
// require lib
var raidar = require('raidar')

// request devices
raidar.request(function (err, devices) {

  // handle error
  if (err) console.error(err)

  // do something useful
  else console.log('ReadyNAS devices found:', devices.length)

})
```

### Events

``` js
// require lib
var raidar = require('raidar')

// listen for all devices
raidar.on('device', function (device) {

  // do something cool
  console.log('Reponse from', device.hostname())

})

// handle all errors
raidar.on('error', function (err) {

  // log error
  console.error(err)

})

// listen single device by IP
raidar.on('192.168.1.10', function (device) { ... })

// listen single device by hostname
raidar.on('nas-acme', function (device) { ... })

// listen single device by MAC address
raidar.on('aa:bb:cc:dd:ee:ff', function (device) { ... })

// perform request
raidar.request()
```



## ReadyNAS (device) class

Representation of a ReadyNAS device.

### Device info APIs

#### mac() : {String}

Get device MAC address.

#### hostname() : {String}

Get device hostname.

#### ip() : {String}

Get device IP.

#### serial() : {String}

Get device serial number.

#### version() : {String}

Get loaded firmware version.

### Disks info APIs

#### diskCount() : {Number}

Get number of loaded disks.

#### diskInfo({Number} index, {String} [attribute='status']) : {String|Number}

Get info of a particular disk.

| Attribute   | Return type | Description               |
| ----------- | ----------- | ------------------------- |
| status      | {String}    | 'ok', 'warn', 'dead' or ? |
| channel     | {Number}    | HDD channel               |
| model       | {String}    | HDD model                 |
| celsius     | {Number}    | temperature in celsius    |
| fahrenheit  | {Number}    | temperature in fahrenheit |

### Volumes info APIs

#### volumeCount() : {Number}

Get number of configured volumes.

#### volumeInfo({Number} index, {String} [attribute='status']) : {String|Number}

Get info of a particular volume.

| Attribute | Return type | Description           |
| --------- | ----------- | --------------------- |
| status    | {String}    | 'ok', 'warn' or ?     |
| level     | {String}    | RAID level            |
| message   | {String}    | Status description    |
| size      | {Number}    | Volume size in bytes  |
| used      | {Number}    | Used space in bytes   |
| free      | {Number}    | Free space in bytes   |

### Other APIs

#### getEntities() : {Array}

Get all device entities.

#### getEntity({String} entity, {Number} [index]) : {Object}

Get entity data.

#### getEntityAttribute({String} entity, {Number} [index], {String} attribute) : {*}

Get single entity attribute.

{'fraction_non_alphanumeric': 0.18659329664832416, 'fraction_numerical': 0.0030015007503751876, 'mean_word_length': 2.5873205741626792, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5463328', 'n_tokens_mistral': 1902, 'n_tokens_neox': 1831, 'n_words': 567}