<commit_before>doc = " "

from gevent import monkey; monkey.patch_all()
import os
import sys
import socket
import subprocess
import json
import time
import datetime
import platform
import gevent
import ConfigParser

from nodemgr.process_stat import process_stat
from nodemgr.EventManager import EventManager

from pysandesh.sandesh_base import *
from sandesh_common.vns.ttypes import Module, NodeType
from sandesh_common.vns.constants import ModuleNames, NodeTypeNames,\
    Module2NodeType
from subprocess import Popen, PIPE

from analytics.ttypes import \
    NodeStatusUVE, NodeStatus
from analytics.process_info.ttypes import \
    ProcessStatus, ProcessState, ProcessInfo
from analytics.process_info.constants import \
    ProcessStateNames

def usage():
    print doc
    sys.exit(255)

class AnalyticsEventManager(EventManager):
    def __init__(self, rule_file, discovery_server, discovery_port, collector_addr):
        EventManager.__init__(self, rule_file, discovery_server, discovery_port, collector_addr)
        self.node_type = 'contrail-analytics'
        self.module = Module.ANALYTICS_NODE_MGR
        self.module_id =  ModuleNames[self.module]
        self.supervisor_serverurl = "unix:///tmp/supervisord_analytics.sock"
        self.add_current_process(process_stat)
    #end __init__

    def process(self):
        if self.rule_file is '':
            self.rule_file = "/etc/contrail/supervisord_analytics_files/contrail-analytics.rules"
        json_file = open(self.rule_file)
        self.rules_data = json.load(json_file)
        node_type = Module2NodeType[self.module]
        node_type_name = NodeTypeNames[node_type]
        config_file = '/etc/contrail/contrail-analytics-nodemgr.conf'
        Config = self.read_config_data(config_file)
        self.get_collector_list(Config)
        _disc = self.get_discovery_client(Config)
        try:
            from opserver.sandesh.analytics.ttypes import *
            sandesh_pkg_dir = 'opserver.sandesh'
        except:
            from analytics.ttypes import *
            sandesh_pkg_dir = 'analytics'
        sandesh_global.init_generator(self.module_id, socket.gethostname(),
            node_type_name, self.instance_id, self.collector_addr,
            self.module_id, 8104, [sandesh_pkg_dir],_disc)
        sandesh_global.set_logging_params(enable_local_log=True)
        self.sandesh_global = sandesh_global

    def send_process_state_db(self, group_names):
        self.send_process_state_db_base(group_names, ProcessInfo, NodeStatus, NodeStatusUVE)
<commit_msg>Fix incorrect sequence number for NodeStatus UVE in analytics-nodemgr introspect<commit_after>doc = " "

from gevent import monkey; monkey.patch_all()
import os
import sys
import socket
import subprocess
import json
import time
import datetime
import platform
import gevent
import ConfigParser

from nodemgr.process_stat import process_stat
from nodemgr.EventManager import EventManager

from pysandesh.sandesh_base import *
from sandesh_common.vns.ttypes import Module, NodeType
from sandesh_common.vns.constants import ModuleNames, NodeTypeNames,\
    Module2NodeType
from subprocess import Popen, PIPE

from analytics.ttypes import \
    NodeStatusUVE, NodeStatus
from analytics.process_info.ttypes import \
    ProcessStatus, ProcessState, ProcessInfo
from analytics.process_info.constants import \
    ProcessStateNames

def usage():
    print doc
    sys.exit(255)

class AnalyticsEventManager(EventManager):
    def __init__(self, rule_file, discovery_server, discovery_port, collector_addr):
        EventManager.__init__(self, rule_file, discovery_server, discovery_port, collector_addr)
        self.node_type = 'contrail-analytics'
        self.module = Module.ANALYTICS_NODE_MGR
        self.module_id =  ModuleNames[self.module]
        self.supervisor_serverurl = "unix:///tmp/supervisord_analytics.sock"
        self.add_current_process(process_stat)
    #end __init__

    def process(self):
        if self.rule_file is '':
            self.rule_file = "/etc/contrail/supervisord_analytics_files/contrail-analytics.rules"
        json_file = open(self.rule_file)
        self.rules_data = json.load(json_file)
        node_type = Module2NodeType[self.module]
        node_type_name = NodeTypeNames[node_type]
        config_file = '/etc/contrail/contrail-analytics-nodemgr.conf'
        Config = self.read_config_data(config_file)
        self.get_collector_list(Config)
        _disc = self.get_discovery_client(Config)
        sandesh_global.init_generator(self.module_id, socket.gethostname(),
            node_type_name, self.instance_id, self.collector_addr,
            self.module_id, 8104, ['analytics'], _disc)
        sandesh_global.set_logging_params(enable_local_log=True)
        self.sandesh_global = sandesh_global

    def send_process_state_db(self, group_names):
        self.send_process_state_db_base(group_names, ProcessInfo, NodeStatus, NodeStatusUVE)

{'fraction_non_alphanumeric': 0.07366929771301356, 'fraction_numerical': 0.0036429872495446266, 'mean_word_length': 3.888229475766568, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4716277', 'n_tokens_mistral': 1517, 'n_tokens_neox': 1485, 'n_words': 296}