Since in 3.4, balancer runs on primary of CSRS and the lock document is:
db.locks.findOne( {_id: "balancer"}) { "_id" : "balancer", "state" : 2, "ts" : ObjectId("581178035b3b7dcb772022cd"), "who" : "ConfigServer:Balancer", "process" : "ConfigServer", "when" : ISODate("2016-10-27T03:44:03.007Z"), "why" : "CSRS Balancer" }
The sh.getBalancerHost() method needs to be updated since it still expects the hostname for the mongos:
function (configDB) { if (configDB === undefined) configDB = sh._getConfigDB(); var x = configDB.locks.findOne({_id: "balancer"}); if (x == null) { print( "config.locks collection does not contain balancer lock. be sure you are connected to a mongos"); return ""; } return x.process.match(/[^:]+:[^:]+/)[0]; }