By doing the following aggregation quey:
db.pings.aggreagte(
{"$project": {month: {"$month": "$timestamp"}, machineName: 1, timestamp: 1}},
{"$match":{month: month}},
{"$sort":{"_id":1}},
{"$group":{_id:{machineName: "$machineName", day:{ "$dayOfMonth": "$timestamp"}}, first: {"$min":"$timestamp"}, last: {"$max":"$timestamp"}}}
);