The Msf::PostMixin module already has a sysinfo() method. You can use that. See:
https://github.com/rapid7/metasploit-framework/blob/master/lib/msf/core/post_mixin.rb#L91