<commit_before># ------------------------------------------------------------------------------
# This module contains all the features of the category Network, Traffic,
# Operation and Monitoring. This module contains the actual logic built with
# the help of Cloudera Manager API, Generic API and commands.
# -------------------------------------------------------------------------------

# Importing required libraries
from imports import *


class NetworkMonitoringAPI:
    """This Class has functions related to Network, Traffic, Operation and 
    Monitoring category.

    Has functions which fetch different network, monitoring, etc metrics from 
    Hadoop cluster like bandwidth, ingress, egress, disk speed, monitoring 
    tools, etc.

    Args:
        inputs (dict): Contains user input attributes
    """

    def __init__(self, inputs):
        """Initialize inputs"""

        self.inputs = inputs
        self.version = inputs["version"]
        self.cloudera_manager_host_ip = inputs["cloudera_manager_host_ip"]
        self.cloudera_manager_port = inputs["cloudera_manager_port"]
        self.cloudera_manager_username = inputs["cloudera_manager_username"]
        self.cloudera_manager_password = inputs["cloudera_manager_password"]
        self.cluster_name = inputs["cluster_name"]
        self.logger = inputs["logger"]
        self.config_path = inputs["config_path"]
        self.ssl = inputs["ssl"]
        if self.ssl:
            self.http = "https"
        else:
            self.http = "http"
        self.start_date = inputs["start_date"]
        self.end_date = inputs["end_date"]

    def max_bandwidth(self):
        """Get maximum bandwidth of cluster.

        Returns:
            max_bandwidth (str): maximum bandwidth.
        """

        try:
            subprocess.Popen(
                "awk '/MaxBandwidth/  {print $2}' /etc/vnstat.conf > MaxBandwidth.csv",
                shell=True,
                stdout=subprocess.PIPE,
                encoding="utf-8",
            ).wait(10)
            maxbandwidth_df = pd.read_csv("MaxBandwidth.csv", delimiter="\n")
            subprocess.Popen(
                "rm ./MaxBandwidth.csv",
                shell=True,
                stdout=subprocess.PIPE,
                encoding="utf-8",
            ).wait(10)
            max_bandwidth = str(maxbandwidth_df["MaxBandwidth"][0])
            self.logger.info("max_bandwidth successful")<commit_msg>change in maxbandwidth function in networkmonitoring file<commit_after># ------------------------------------------------------------------------------
# This module contains all the features of the category Network, Traffic,
# Operation and Monitoring. This module contains the actual logic built with
# the help of Cloudera Manager API, Generic API and commands.
# -------------------------------------------------------------------------------

# Importing required libraries
from imports import *


class NetworkMonitoringAPI:
    """This Class has functions related to Network, Traffic, Operation and 
    Monitoring category.

    Has functions which fetch different network, monitoring, etc metrics from 
    Hadoop cluster like bandwidth, ingress, egress, disk speed, monitoring 
    tools, etc.

    Args:
        inputs (dict): Contains user input attributes
    """

    def __init__(self, inputs):
        """Initialize inputs"""

        self.inputs = inputs
        self.version = inputs["version"]
        self.cloudera_manager_host_ip = inputs["cloudera_manager_host_ip"]
        self.cloudera_manager_port = inputs["cloudera_manager_port"]
        self.cloudera_manager_username = inputs["cloudera_manager_username"]
        self.cloudera_manager_password = inputs["<PASSWORD>"]
        self.cluster_name = inputs["cluster_name"]
        self.logger = inputs["logger"]
        self.config_path = inputs["config_path"]
        self.ssl = inputs["ssl"]
        if self.ssl:
            self.http = "https"
        else:
            self.http = "http"
        self.start_date = inputs["start_date"]
        self.end_date = inputs["end_date"]

    def max_bandwidth(self):
        """Get maximum bandwidth of cluster.

        Returns:
            max_bandwidth (str): maximum bandwidth.
        """

        try:
            max_bandwidth = subprocess.Popen("awk '/MaxBandwidth/  {print $2}' /etc/vnstat.conf",shell=True,stdout=subprocess.PIPE,encoding="utf-8")
            max_bandwidth.wait(10)
            max_bandwidth, err = max_bandwidth.communicate()
            self.logger.info("max_bandwidth successful")
{'fraction_non_alphanumeric': 0.15765272607838843, 'fraction_numerical': 0.0026275454346398074, 'mean_word_length': 2.0514362057448228, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, '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': '2556429', 'n_tokens_mistral': 1203, 'n_tokens_neox': 1152, 'n_words': 302}