Name

sn_app_insights.ParseXmlStats

Description

Logic to take an xml string as input, and parse it to extract the values based on the metric name.

Script

var ParseXmlStats = Class.create();
ParseXmlStats.prototype = {

  initialize: function(nodeStatsXml) {
      this.xmlDoc = new XMLDocument2();
      this.xmlDoc.parseXML(nodeStatsXml);
  },

  parseServletMetrics: function(metricName, interval, aggregator) {
      var path = "/xmlstats/servlet.metrics/" + metricName + "/" + interval;
      var node = this.xmlDoc.getNode(path);
      if (node.toString() == null)
          return '';

      var attributes = node.getAttributes();

      return parseFloat(attributes[aggregator]);
  },

  parseTransactionCount: function() {
      var path = "/xmlstats/servlet.transactions";
      var node = this.xmlDoc.getNode(path);

      return gs.nil(node) ? '' : node.getTextContent();
  },

  parseLoggedInUserCount: function() {
      var path = "/xmlstats/sessionsummary/@logged_in";
      var node = this.xmlDoc.getNode(path);

      return gs.nil(node) ? '' : node.getNodeValue();
  },

  parseSemaphoreStatsByMetric: function(semaphoreName, metricName) {
      var path = "/xmlstats/semaphores[@name='" + semaphoreName + "']/@" + metricName;
      var node = this.xmlDoc.getNode(path);

      return gs.nil(node) ? '' : node.getNodeValue();
  },

  getQueueDepthLimit: function(semaphoreName) {
      var path = "/xmlstats/semaphores[@name='" + semaphoreName + "']/@queue_depth_limit";
      var node = this.xmlDoc.getNode(path);

      return gs.nil(node) ? '' : node.getNodeValue();
  },

  type: 'ParseXmlStats'
};

Sys ID

78a2e53e53b294109d9eddeeff7b12aa

Offical Documentation

Official Docs: