'Write the given command to the Nagios command file'

def _write_command(self, cmd):

    try:
        fp = open(self.cmdfile, 'w')
        fp.write(cmd)
        fp.flush()
        fp.close()
        self.command_results.append(cmd.strip())
    except IOError:
        self.module.fail_json(msg='unable    to    write    to    nagios    command    file', cmdfile=self.cmdfile)
