import { XMLParser } from 'fast-xml-parser'; import { ConfigFile } from "./models"; /** * breakdown qkview xml stats, convert to json and analyze key stats */ export default class XmlStats { xmlParser: XMLParser; /** * line 1. xml header * typically: * this does not change */ xmlHeaderRx: RegExp; /** * line 2. qkproc version * example: * key off this version if/when qkproc structure changes */ qkProcVersionRx: RegExp; /** * list of stats to get from xml files * - currenly only stat_module.xml + mcp_module.xml * * --- update the rx tree to mimic the file->stats structure, use this tree to get the stats we want * so we can just update this tree to add files/stats in the future */ rx: { 'stat_module.xml': string[]; 'mcp_module.xml': string[]; }; /** * top N virtual servers to get stats for * * set to 10000 to get all virtual servers with stats */ topN: number; weights: { vs: { pktsIn: number; bytsIn: number; pktsOut: number; bytsOut: number; maxConns: number; totConns: number; curConns: number; }; }; /** * main stats object */ xmlStats: any; /** * stats object for virtual servers */ stats: any; stat_gtm_wideip_stat: RegExpMatchArray; mcp_gtm_wideip_stat: RegExpMatchArray; constructor(); /** * Crunch the xml stats file pulling the stats defined in this.statsToGet * Then parse the stats into json for further processing * * @param file { fileName: string, size: number, content: string } * */ load(file: ConfigFile): Promise; /** * processes the json stats from the converted xml files */ crunch(): Promise; asmStats(): Promise; ruleStats(): Promise; /** * Get the topN gtm wideips by requests * source: stat_module.xml for now */ gslbStats(): Promise; /** * collects vs stats and ranks them by the topN * * source: mcp_module.xml for now */ private topMcpVs; /** * convert wip_type to string that means something * @param type * @returns * @deprecated test function/idea for initial development */ private enumGtmWipType; } export type xmlStats = { 'mcp_module.xml'?: { "Qkproc": { "admin_ip": unknown; "system_information": unknown; "cert_status_object": unknown; "system_module": unknown; "tmm_stat": unknown; "traffic_group": unknown; "virtual_address": unknown; "virtual_address_stat": unknown; "virtual_server": unknown; "virtual_server_stat": unknown; "interface": unknown; "interface_stat": unknown; "pool": unknown; "pool_member": unknown; "pool_member_metadata": unknown; "pool_member_stat": unknown; "pool_stat": unknown; "profile_dns_stat": unknown; "profile_http_stat": unknown; "profile_tcp_stat": unknown; "rule_stat": unknown; }; }; }; export type VsStatsSlim = { name: string; pkts_in: number; bytes_in: number; pkts_out: number; bytes_out: number; max_conns: number; tot_conns: number; cur_conns: number; };