2022-01-11
2022-01-11 12:15:01 by Henrik Grubbström (Grubba) <grubba@grubba.org>
-
4b1299817718a7fa6a5b29c91e74a92cbbcbe045
(42 lines)
(+42/-0)
[
Show
| Annotate
]
Branch: 4b1299817718a7fa6a5b29c91e74a92cbbcbe045
ABS: Report the process list for the embedded MySQL/MariaDB on ABS.
Fixes [REP-368].
3831: Inside #if undefined(__NT__)
};
}
}
+ catch {
+ Sql.Sql db = connect_to_my_mysql(0, "mysql");
+ array(mapping(string:string)) db_procs;
+ if (catch {
+ // MySQL 8.0 and later.
+ db_procs = db->query("SELECT * FROM performance_schema.processlist");
+ }) {
+ // Fall-back to old syntax.
+ db_procs = db->query("SHOW FULL PROCESSLIST");
+ }
+ if (db_procs && sizeof(db_procs)) {
+ report_debug("MySQL process list:\n");
+ foreach(db_procs, mapping(string:string) row) {
+ // NB: The case for the field names has changed
+ // between the old and new syntax.
+ string db_id = row->ID || row->Id;
+ string db_user = row->USER || row->User;
+ string db_host = row->HOST || row->Host;
+ string db_db = row->DB || row->db;
+ string db_cmd = row->COMMAND || row->Command;
+ string db_state = row->STATE || row->State;
+ int db_time = (int)(row->TIME || row->Time);
+ string db_info = row->INFO || row->Info;
-
+ string db_url = "";
+ if (db_user) db_url = db_user + "@";
+ if (db_host) db_url += db_host;
+ if (db_db) db_url += "://" + db_db;
+ if (db_url == "") db_url = "internal";
+ report_debug(" %s(%s): %s(%s) %dms\n",
+ db_id || "NULL", db_url,
+ db_cmd || "", db_state || "NULL",
+ db_time);
+ if (db_info) {
+ report_debug(" %s(%s): %s\n",
+ db_id || "NULL", db_url,
+ db_info);
+ }
+ }
+ }
+ };
+
unregister_roxen_perror_output(abs_buf->add);
if (has_value(query("abs_email"), "@")) {
report_debug("\nAttempting to send ABS report via email to %s.\n",