- status - The status of the component, retrieved from the device
- disabled - Should this component be polled?
- ignore - Should this component be alerted on
- error - Error message if in Alert state
The component_prefs table holds custom data in an Attribute/Value format:
```SQL
mysql> select * from component_prefs limit 1;
+----+-----------+-----------+-----------+
| id | component | attribute | value |
+----+-----------+-----------+-----------+
| 4 | 9 | TEST_ATTR | TEST_ATTR |
+----+-----------+-----------+-----------+
2 rows in set (0.00 sec)
```
## <a name="reserved">Reserved Fields</a>
When this data from both the component and component_prefs tables is returned in one single consolidated array, there is the potential for someone to attempt to set an attribute (in the component_prefs) table that is used in the components table.
Because of this all fields of the component table are reserved, they cannot be used as custom attributes, if you update these the module will attempt to write them to the component table, not the component_prefs table.
When a component is no longer needed, it can be deleted.
```php
$COMPONENT->deleteComponent($COMPONENT_ID)
```
This will return True on success or False on failure.
## <a name="update">Editing Components</a>
To edit a component, the procedure is:
1. [Get the Current Components](#get)
2. [Edit the array](#update-edit)
3. [Write the components](#update-write)
### <a name="update-edit">Edit the Array</a>
Once you have a component array from getComponents the first thing to do is extract the components for only the single device you are editing. This is required because the setComponentPrefs function only saves a single device at a time.
If you need to add a new Attribute/Value pair you can:
```php
$ARRAY[COMPONENT_ID]['New Attribute'] = 'Value';
```
If you need to delete a previously set Attribute/Value pair you can:
```php
unset($ARRAY[COMPONENT_ID]['New Attribute']);
```
If you need to edit a previously set Attribute/Value pair you can:
```php
$ARRAY[COMPONENT_ID]['Existing Attribute'] = "New Value";
```
### <a name="update-write">Write the components</a>
To write component changes back to the database simply:
```php
$COMPONENT->setComponentPrefs($DEVICE_ID,$ARRAY)
```
When writing the component array there are several caveats to be aware of, these are:
- $ARRAY must be in the format of a single device ID - `$ARRAY[$COMPONENT_ID][Attribute] = 'Value';` NOT in the multi device format returned by getComponents - $ARRAY[$DEVICE_ID][$COMPONENT_ID][Attribute] = 'Value';`
- You cannot edit the Component ID or the Device ID
- [reserved](#reserved) fields can not be removed
- if a change is found an entry will be written to the eventlog.
## <a name="api">API</a>
Component details are available via the API.
Please see the [API-Docs](http://docs.librenms.org/API/API-Docs/#api-route-25) for details.
If you are creating a poller module which can detect a fault condition simply set STATUS to something other than 0 and ERROR to a message that indicates the problem.