> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/adapters/o/ocs-inventory-db-adapter.md).

# OCS Inventory DB Adapter

OCS Inventory is an open-source IT asset discovery and inventory tool. This adapter connects to its MySQL database and reads a view or a custom query that you define, and adds the rows to the device inventory.

## Use cases

* **Find OCS devices that no other source reports.**

```
Adapters = ocs-inventory-db-adapter AND NOT Adapters = active-directory
```

* **Review the OCS inventory.** Use it to compare agent-based inventory with your other sources.

```
Adapters = ocs-inventory-db-adapter
```

## Before you begin

### Network

| Source              | Destination                               | Port                  | Protocol |
| ------------------- | ----------------------------------------- | --------------------- | -------- |
| OctoXLabs connector | OCS Inventory MySQL server (IP parameter) | 3306 (Port parameter) | MySQL    |

### Required permissions

| Scope or role                      | Permission | Needed for                            |
| ---------------------------------- | ---------- | ------------------------------------- |
| Database user, on the OCS database | SELECT     | Reading the view or running the query |

## Create credentials in OCS Inventory

{% stepper %}
{% step %}

### Open the user settings

In your MySQL management tool, go to **Management**, then **Users and Privileges**, and select the user to grant permissions to.
{% endstep %}

{% step %}

### Grant SELECT

Click **Schema Privileges**, then **Add Entry**, select the database and click **OK**. Check **SELECT** under **Object Rights** and click **Apply**.
{% endstep %}

{% step %}

### Log in once

Log in to the database with this user once to avoid an error.
{% endstep %}
{% endstepper %}

## Connection parameters

| Parameter     | Required    | Type    | Default  | Description                                                                          |
| ------------- | ----------- | ------- | -------- | ------------------------------------------------------------------------------------ |
| IP            | Yes         | String  | None     | Address of the MySQL server.                                                         |
| Port          | No          | Integer | 3306     | MySQL port.                                                                          |
| Domain        | No          | String  | None     | Domain FQDN.                                                                         |
| Database      | Yes         | String  | None     | Name of the database.                                                                |
| Username      | Yes         | String  | None     | Database user.                                                                       |
| Password      | Yes         | String  | None     | Password of the user.                                                                |
| View Name     | Conditional | String  | None     | View to query. Required if you give no Custom Query.                                 |
| Custom Query  | No          | SQL     | None     | Custom SQL query. When set, it is used instead of the view.                          |
| Primary Field | No          | String  | Hostname | Column of the view used as the device hostname. Not used when a Custom Query is set. |
| Query Timeout | No          | Integer | 60       | Maximum seconds for a query.                                                         |

## Troubleshooting

| Error message                                        | Cause                                      | Fix                                  |
| ---------------------------------------------------- | ------------------------------------------ | ------------------------------------ |
| It is mandatory to enter either custom query or view | Neither View Name nor Custom Query is set. | Enter a view name or a custom query. |

## Change history

{% hint style="info" %}
Available starting from version 5.5.0.
{% endhint %}
