@@ -30,14 +30,15 @@ type MySQLProcesses []*MySQLProcess
30
30
31
31
// MySQLProcess represents the data returned from SHOW PROCESS LIST.
32
32
type MySQLProcess struct {
33
- ID int64 `json:"id"`
34
- User string `json:"user"`
35
- Host string `json:"host"`
36
- DB NullString `json:"db"`
37
- Cmd string `json:"command"`
38
- Time int64 `json:"time"`
39
- State string `json:"state"`
40
- Info NullString `json:"info"`
33
+ ID int64 `json:"id"`
34
+ User string `json:"user"`
35
+ Host string `json:"host"`
36
+ DB NullString `json:"db"`
37
+ Cmd string `json:"command"`
38
+ Time int64 `json:"time"`
39
+ State string `json:"state"`
40
+ Info NullString `json:"info"`
41
+ Progress float64 `json:"progress"` // mariadb
41
42
}
42
43
43
44
type NullString struct {
@@ -137,8 +138,15 @@ func scanMySQLProcessList(ctx context.Context, dbase *sql.DB) (MySQLProcesses, e
137
138
138
139
for rows .Next () {
139
140
var pid MySQLProcess
140
- // for each row, scan the result into our tag composite object
141
- err := rows .Scan (& pid .ID , & pid .User , & pid .Host , & pid .DB , & pid .Cmd , & pid .Time , & pid .State , & pid .Info )
141
+ // for each row, scan the result into our tag composite object.
142
+ if cols , _ := rows .Columns (); len (cols ) == 8 {
143
+ // mysql only has 8 columns
144
+ err = rows .Scan (& pid .ID , & pid .User , & pid .Host , & pid .DB , & pid .Cmd , & pid .Time , & pid .State , & pid .Info )
145
+ } else {
146
+ // mariadb returns 9 columns (adds progress).
147
+ err = rows .Scan (& pid .ID , & pid .User , & pid .Host , & pid .DB , & pid .Cmd , & pid .Time , & pid .State , & pid .Info , & pid .Progress )
148
+ }
149
+
142
150
if err != nil {
143
151
mnd .Apps .Add ("MySQL&&Errors" , 1 )
144
152
return nil , fmt .Errorf ("scanning process rows: %w" , err )
0 commit comments