Skip to content

Instantly share code, notes, and snippets.

@brianschmitt
Last active May 1, 2026 00:35
Show Gist options
  • Select an option

  • Save brianschmitt/6321422fe7c315675a84d87f2bf66861 to your computer and use it in GitHub Desktop.

Select an option

Save brianschmitt/6321422fe7c315675a84d87f2bf66861 to your computer and use it in GitHub Desktop.
UDM Scripts
mongo --quiet localhost:27117/ace --eval '
var oldest = db.event.find().sort({time:1}).limit(1).toArray()[0];
var newest = db.event.find().sort({time:-1}).limit(1).toArray()[0];
print("Oldest: " + oldest.datetime);
print("Newest: " + newest.datetime);
'
mongo localhost:27117/ace --eval 'db.event.deleteMany({})'
mongo --quiet localhost:27117/ace --eval '
var devices = {};
var names = {};
// Build MAC → name map
db.user.find({}, { mac: 1, name: 1, hostname: 1 }).forEach(function(u) {
names[u.mac] = u.name || u.hostname || "unknown";
});
// Build radio usage
db.event.find(
{ key: "EVT_WU_Connected" },
{ user: 1, radio: 1, ssid: 1 }
).forEach(function(d) {
if (!devices[d.user]) {
devices[d.user] = { radios: {}, ssids: {} };
}
devices[d.user].radios[d.radio] = true;
devices[d.user].ssids[d.ssid] = true;
});
// Output
for (var mac in devices) {
if (devices[mac].radios["ng"] && devices[mac].radios["na"]) {
print(
(names[mac] || "unknown") + " | " +
mac + " | BOTH BANDS | SSIDs=" +
Object.keys(devices[mac].ssids).join(",")
);
}
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment