Skip to content

plugin_mysql

Alejandro Mora edited this page Mar 9, 2026 · 1 revision

MySQL plugin

This plugin allows execute SQL queries into a MySQL server. MySQL is a multithreaded, multi-user, SQL (Structured Query Language) relational database server (RDBS).

Currently, MySQL plugin only supports retrieving the server status, retrieving the first row/column of a query and the number of rows returned by a query.


Functions

MySQL::count(query) return the number of rows returned by
MySQL::query(query) return a string containing the first value of the row.
MySQL::status() return a string containing the current server status: Uptime in seconds, number of running threads, questions, reloads, and open tables.

Configuration example

Plugin MySQL {
        server 'www.myserver.foo'
        port 3306
        user 'admin'
        password 'topsecret'
        database 'shop'
}

If server entry is missing, localhost will be assumed.<br> If port entry is missing, MySQL default's one will be used.<br> If user entry is missing, LCD4Linux unix owner will be assumed.<br> If password entry is missing, empty password will be used.<br> database entry is required.


Widget examples

Widget CustomersOnline {
        class 'Text'
        expression MySQL::count('SELECT DISTINCT ip_address FROM whos_online')
        width 2
        align 'R'
        update 30000
}
Widget NewOrders {
        class 'Text'
        expression MySQL::query('SELECT id FROM orders WHERE status = 1')
        width 14
        align 'R'
        prefix 'New Orders:'
        update 30000
}
Widget MySqlLastOnline {
        class 'Text'
        expression MySQL::query('SELECT ip_address FROM whos_online order by timestamp DESC limit 1')
        width 10
        align 'R'
        update 3000
}

Clone this wiki locally