如何使用collectd的DBI插件从本地sqlite数据库收集数据

时间:2018-05-01 08:09:31

标签: sqlite dbi collectd calibre

我试图从calibre库中收集一些统计信息,这些库将元数据存储在sqlite数据库中。我试图使用collectd dbi plugin,但我无法找到使其打开数据库的正确选项。

我尝试的所有选项都出现以下错误:

collectd[1214]: dbi plugin: cdbi_connect_database (calibre): dbi_conn_connect failed: dbi_conn_error failed with status -3

这里是collectd配置的相关部分:

LoadPlugin dbi

<Plugin dbi>
  <Query "books">
    Statement "SELECT COUNT(*) AS value FROM books"
    <Result>
      Type "gauge"
      InstancePrefix "calibre_books"
      ValuesFrom "value"
    </Result>
  </Query>
  <Query "languages">
    Statement "SELECT COUNT(*) AS value FROM languages"
    <Result>
      Type "gauge"
      InstancePrefix "calibre_languages"
      ValuesFrom "value"
    </Result>
  </Query>
  <Query "series">
    Statement "SELECT COUNT(*) AS value FROM series"
    <Result>
      Type "gauge"
      InstancePrefix "calibre_series"
      ValuesFrom "value"
    </Result>
  </Query>
  <Query "tags">
    Statement "SELECT COUNT(*) AS value FROM tags"
    <Result>
      Type "gauge"
      InstancePrefix "calibre_tags"
      ValuesFrom "value"
    </Result>
  </Query>
  <Database "calibre">
    Driver "sqlite3"
#    DriverOption "path" "/books/metadata.db"
    DriverOption "dbname" "/books/metadata.db"
#    SelectDB "calibre"
    Query "books"
    Query "languages"
    Query "series"
    Query "tags"
  </Database>
</Plugin>

1 个答案:

答案 0 :(得分:0)

仅作记录:添加DriverOption“ sqlite3_dbdir”“ / dir”