Note that since most database commands can only be sent to the primary of a replica set, the command() method does not obey the Database’s read_preference, but you can pass an explicit read preference to the method:
>>> db.command('dbstats', read_preference=ReadPreference.NEAREST)
{...}
In [1]: import pymongo
In [2]: import urllib
In [3]: mongo_host = 'mongos-hxvm-001'
In [4]: mongodb_user = 'superuser'
In [5]: mongodb_pwd = 'xxxxxxxx'
In [6]: username = urllib.quote_plus(mongodb_user)
In [7]: password = urllib.quote_plus(mongodb_pwd)
In [8]: uri = 'mongodb://' + username + ':' + password + '@' + mongo_host + '/admin?authMechanism=MONGODB-CR'
In [9]: client = pymongo.MongoClient(uri)
In [10]: client
Out[10]: MongoClient('mongos-hxvm-001', 27017)
In [11]: client.read_preference
Out[11]: Primary()
In [12]: db = client.afumigatus_cb_v3
In [13]: from pymongo import ReadPreference
In [14]: db.command('dbstats', read_preference=ReadPreference.PRIMARY)['storageSize']
Out[14]: 30728192
In [15]: db.command('dbstats', read_preference=ReadPreference.SECONDARY)['storageSize']
Out[15]: 30728192