'Update stats using SNMP.
If bulk=True, use a bulk request instead of a get request.'

def get_stats_snmp(self, bulk=False, snmp_oid=None):

    snmp_oid = (snmp_oid or {})
    from glances.snmp import GlancesSNMPClient
    clientsnmp = GlancesSNMPClient(host=self.args.client, port=self.args.snmp_port, version=self.args.snmp_version, community=self.args.snmp_community)
    ret = {}
    if bulk:
        snmpresult = clientsnmp.getbulk_by_oid(0, 10, itervalues(*snmp_oid))
        if (len(snmp_oid) == 1):
            for item in snmpresult:
                if iterkeys(item)[0].startswith(itervalues(snmp_oid)[0]):
                    ret[(iterkeys(snmp_oid)[0] + iterkeys(item)[0].split(itervalues(snmp_oid)[0])[1])] = itervalues(item)[0]
        else:
            index = 1
            for item in snmpresult:
                item_stats = {}
                item_key = None
                for key in iterkeys(snmp_oid):
                    oid = ((snmp_oid[key] + '.') + str(index))
                    if (oid in item):
                        if (item_key is None):
                            item_key = item[oid]
                        else:
                            item_stats[key] = item[oid]
                if item_stats:
                    ret[item_key] = item_stats
                index += 1
    else:
        snmpresult = clientsnmp.get_by_oid(itervalues(*snmp_oid))
        for key in iterkeys(snmp_oid):
            ret[key] = snmpresult[snmp_oid[key]]
    return ret
