Skip to content
DataMiner Dojo

More results...

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Search in posts
Search in pages
Search in posts
Search in pages
Log in
Menu
  • Updates & Insights
  • Questions
  • Learning
    • E-learning Courses
    • Tutorials
    • Open Classroom Training
    • Certification
      • DataMiner Fundamentals
      • DataMiner Configurator
      • DataMiner Automation
      • Scripts & Connectors Developer: HTTP Basics
      • Scripts & Connectors Developer: SNMP Basics
      • Visual Overview – Level 1
      • Verify a certificate
    • YouTube Videos
    • Solutions & Use Cases
      • Solutions
      • Use Case Library
    • Agility
      • Learn more about Agile
        • Agile Webspace
        • Everything Agile
          • The Agile Manifesto
          • Best Practices
          • Retro Recipes
        • Methodologies
          • The Scrum Framework
          • Kanban
          • Extreme Programming
        • Roles
          • The Product Owner
          • The Agile Coach
          • The Quality & UX Coach (QX)
      • Book your Agile Fundamentals training
      • Book you Kanban workshop
    • >> Go to DataMiner Docs
  • DevOps
    • About the DevOps Program
    • Sign up for the DevOps Program
    • DataMiner DevOps Support
    • Feature Suggestions
  • Downloads
  • Swag Shop
  • PARTNERS
    • Business Partners
    • Technology Partners
  • Contact
    • Sales, Training & Certification
    • DataMiner Support
    • Global Feedback Survey
  • >> Go to dataminer.services

Remaining licences on Dashboard.

121 views1 day ago
2
Henri Martins [DevOps Advocate]741 4 days ago 0 Comments

Hi.

I want to create a dashboard, indicating:

  • The number of elements by DMA.
  • The number of element licences by DMA but I don't know where to find this data.

Kind regards.

Henri Martins [DevOps Advocate] Answered question 1 day ago

2 Answers

  • Active
  • Voted
  • Newest
  • Oldest
0
Henri Martins [DevOps Advocate]741 Posted 1 day ago 0 Comments

Hi. It seem that in 10.6 releease we could do without SLNET call.

For the moment as I'm not in this release I've resolv all my needs withthis code:

using Skyline.DataMiner.Analytics.GenericInterface;
using Skyline.DataMiner.Net.Messages;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

[GQIMetaData(Name = "DMA Licenses & Elements (SLNet)")] public sealed class DmaLicensesDataSource : IGQIOnInit, IGQIDataSource
{
private GQIDMS _dms; // SLNet via GQI

// --- Types internes ---
private sealed class DmaRow
{
public string Name { get; set; }
public int Id { get; set; }
public int Max { get; set; }
public int Active { get; set; }
public int Present { get; set; }
public int Available => Math.Max(0, Max - Active); // status actuel
public int AvailableTA => Math.Max(0, Max - Present); // status si tout actif
}

private sealed class AgentInfo
{
public int Id { get; set; }
public string Name { get; set; }
}

// --- Colonnes ---
private readonly GQIStringColumn _cName = new GQIStringColumn("Agent");
private readonly GQIIntColumn _cId = new GQIIntColumn("Agent ID");
private readonly GQIIntColumn _cMax = new GQIIntColumn("Licences (MAX)");
private readonly GQIIntColumn _cActive = new GQIIntColumn("Licences (Actives)");
private readonly GQIIntColumn _cPresent = new GQIIntColumn("Éléments (Présents)");
private readonly GQIIntColumn _cAvail = new GQIIntColumn("Licences (Disponibles)");
private readonly GQIIntColumn _cAvailTA = new GQIIntColumn("Licences (Quand tous actifs)");

public OnInitOutputArgs OnInit(OnInitInputArgs args)
{
_dms = args.DMS;
return default;
}

public GQIColumn[] GetColumns() =>
new GQIColumn[] { _cName, _cId, _cMax, _cActive, _cPresent, _cAvail, _cAvailTA };

public GQIPage GetNextPage(GetNextPageInputArgs args)
{
var agents = GetAllAgents(); // Liste des DMAs (Id/Name)
var elementsByDmaId = GetElementsCountPerDma(); // Nombre d’éléments par DMA

var rows = new List<GQIRow>(agents.Count);
foreach (var a in agents)
{
int id = a.Id;
int present = elementsByDmaId.TryGetValue(id, out var cnt) ? cnt : 0;

int max = GetElementsMaxViaLicenses(id);
int active = GetElementsActiveViaActivatedCounters(id);

var cells = new[] {
new GQICell { Value = a.Name },
new GQICell { Value = id },
new GQICell { Value = max },
new GQICell { Value = active },
new GQICell { Value = present },
new GQICell { Value = ( max - active) },
new GQICell { Value = ( max - present) },
};
rows.Add(new GQIRow(cells));
}

return new GQIPage(rows.ToArray());
}

// ----------- SLNet helpers -----------

// Récupère 1 réponse par agent : GetDataMinerInfoResponseMessage
private List<AgentInfo> GetAllAgents()
{
var result = new List<AgentInfo>();
try
{
var responses = _dms.SendMessages(new GetInfoMessage { Type = InfoType.DataMinerInfo });
foreach (var r in responses.OfType<GetDataMinerInfoResponseMessage>())
{
result.Add(new AgentInfo { Id = r.ID, Name = r.AgentName });
}
}
catch { }

return result
.GroupBy(x => x.Id)
.Select(g => new AgentInfo
{
Id = g.Key,
Name = g.Select(x => x.Name).FirstOrDefault(n => !String.IsNullOrWhiteSpace(n)) ?? $"DMA {g.Key}",
})
.ToList();
}

private Dictionary<int, int> GetElementsCountPerDma()
{
var dict = new Dictionary<int, int>();
try
{
var responses = _dms.SendMessages(new GetInfoMessage { Type = InfoType.ElementInfo });
var groups = responses.OfType<ElementInfoEventMessage>()
.GroupBy(e => e.DataMinerID);
foreach (var g in groups)
{
dict[g.Key] = g.Count();
}
}
catch { }
return dict;
}

private int GetElementsMaxViaLicenses(int dmaId)
{
try
{
var resp = (GetLicensesResponseMessage)_dms.SendMessage(
new GetInfoMessage { DataMinerID = dmaId, Type = InfoType.Licenses });

var line = resp?.Licenses?
.FirstOrDefault(s => !String.IsNullOrWhiteSpace(s) &&
s.Trim().StartsWith("ELEMENTS", StringComparison.OrdinalIgnoreCase));

if (!String.IsNullOrEmpty(line))
{
var m = Regex.Match(line, @"ELEMENTS\s*(\d+)", RegexOptions.IgnoreCase);
if (m.Success && Int32.TryParse(m.Groups[1].Value, out var parsed)) return parsed;
}
}
catch { }
return 0;
}

private int GetElementsActiveViaActivatedCounters(int dmaId)
{
try
{
var resp = (GetActivatedLicenseCountersResponseMessage)_dms.SendMessage(
new GetInfoMessage { DataMinerID = dmaId, Type = InfoType.ActivatedLicenseCounters });

var line = resp?.ActivatedLicenseCounters?
.FirstOrDefault(s => !String.IsNullOrWhiteSpace(s) &&
s.Trim().StartsWith("elements", StringComparison.OrdinalIgnoreCase));

if (!String.IsNullOrEmpty(line))
{
var m = Regex.Match(line, @"elements\s*[:=]\s*(\d+)", RegexOptions.IgnoreCase);
if (m.Success && Int32.TryParse(m.Groups[1].Value, out var parsed)) return parsed;

var m2 = Regex.Match(line, @"(\d+)");
if (m2.Success && Int32.TryParse(m2.Value, out var parsed2)) return parsed2;
}
}
catch { }
return 0;
}
}

Henri Martins [DevOps Advocate] Answered question 1 day ago
You are viewing 1 out of 2 answers, click here to view all answers.
Please login to be able to comment or post an answer.

My DevOps rank

DevOps Members get more insights on their profile page.

My user earnings

0 Dojo credits

Spend your credits in our swag shop.

0 Reputation points

Boost your reputation, climb the leaderboard.

Promo banner DataMiner DevOps Professiona Program
DataMiner Integration Studio (DIS)
Empower Katas
Privacy Policy • Terms & Conditions • Contact

© 2026 Skyline Communications. All rights reserved.

DOJO Q&A widget

Can't find what you need?

? Explore the Q&A DataMiner Docs

[ Placeholder content for popup link ] WordPress Download Manager - Best Download Management Plugin