CodeGen_MySQL_Plugin had basic support for status variables (for SHOW STATUS) for quite a while, now it also has basic support for system variables (SHOW [GLOBAL|SESSION] VARIABLES, SET) in the 0.9.2 package version i just released as well 
Currently only simple integer and string variables are supported. Support for ENUM and SET variables and for custom check() and update() functions will probably follow soon though.
A system variable declaration currently looks like this:
<systemvar scope="global" type="str" name="baz" default="foobar" />
<systemvar scope="global" type="int" name="bar" min="23" max="42" default="38" />
<systemvar scope="session" type="int" name="foo" min="23" max="42" default="37" />
The scope, type and name attributes are mandatory, setting a default value is recommended and the min and max attributes for integers are optional.
For global system variables a global variable by the same name is generated in the plugins C++ code which can be accessed directly in the code.
Access to session variables from the plugins C++ code is a bit more tricky, but not much. As session variables are tied to the current connection thread the THDVAR() macro is needed to access them for both assigning and retrieving values:
THDVAR(thd, varname) = 42;
foo = THDVAR(thd, varname);
Note that the actual variable name on the SQL level is not just the one given in the name= attribute but actually a combination of the
plugin and variable names, so a variable named 'foo' in a plugin named 'dummy' will actually show as 'dummy_foo' in
SHOW VARIABLES and needs to be
SET by that name, too.