2require('dotenv').config();
3const MeshCentralAPI = require('../lib/meshcentral-api');
8async function checkMeshes() {
9 console.log('š Checking MeshCentral device groups...\n');
11 const api = new MeshCentralAPI({
12 url: process.env.MESHCENTRAL_URL,
13 username: process.env.MESHCENTRAL_ADMIN_USER || process.env.MESHCENTRAL_USERNAME,
14 password: process.env.MESHCENTRAL_ADMIN_PASS || process.env.MESHCENTRAL_PASSWORD
19 console.log('š Logging in...');
21 console.log('ā
Logged in successfully\n');
24 console.log('š¦ Fetching device groups...');
25 const meshes = await api.getMeshes();
32 console.log(`\nā
Found ${meshes.length} device group(s):\n`);
34 if (meshes.length === 0) {
35 console.log(' (No device groups found)');
37 meshes.forEach((mesh, index) => {
38 console.log(` ${index + 1}. ${mesh.name || 'Unnamed'}`);
39 console.log(` ID: ${mesh._id}`);
40 console.log(` Type: ${mesh.mtype === 2 ? 'Agent Mesh' : 'Unknown'}`);
46 console.error('ā Error:', error.message);