diff options
Diffstat (limited to 'veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance')
10 files changed, 917 insertions, 0 deletions
diff --git a/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance/Main.java b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance/Main.java new file mode 100644 index 0000000..83f97e1 --- /dev/null +++ b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance/Main.java @@ -0,0 +1,64 @@ +package evel_javalibrary.att.com.loadbalance; +/**************************************************************************//** + * @file + * Sample Test Agent for EVEL library + * + * This file implements the Sample Agent which is intended to provide a + * simple wrapper around the complexity of AT&T's Vendor Event Listener API so + * that VNFs can use it without worrying about details of the API transport. + * It also shows how events can be formatted with data for POST + * + * License + * ------- + * Unless otherwise specified, all software contained herein is + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *****************************************************************************/ + +import org.apache.log4j.Level; + +import evel_javalibrary.att.com.AgentMain; +//import evel_javalibrary.att.com.MeasureData; +//import evel_javalibrary.att.com.heartBeatData; + + + + + +public class Main { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + try { + AgentMain.evel_initialize("http://127.0.0.1", 30000, + null,null, + "will", + "pill", + null, null, null, + Level.TRACE); + }catch(Exception e) { + e.printStackTrace(); + return; + } + MeasureData mdataThread = new MeasureData(); + mdataThread.start(); + + heartBeatData hbDataThread = new heartBeatData(); + hbDataThread.start(); + + faultData flDataThread = new faultData(); + flDataThread.start(); + + } + +} + diff --git a/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance/MeasureData.java b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance/MeasureData.java new file mode 100644 index 0000000..38c517a --- /dev/null +++ b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance/MeasureData.java @@ -0,0 +1,375 @@ +package evel_javalibrary.att.com.loadbalance; +/**************************************************************************//** + * @file + * Measurement class + * + * This file implements the Measurement Event class which is intended to provide a + * simple wrapper around the complexity of AT&T's Vendor Event Listener API so + * that VNFs can use it to send CPU, Memory, Disk Measurements to Collector. + * + * License + * ------- + * Unless otherwise specified, all software contained herein is + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *****************************************************************************/ + + +import java.io.BufferedReader; +import java.io.File; +import java.io.InputStreamReader; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import org.apache.log4j.Level; + +import evel_javalibrary.att.com.AgentMain; +import evel_javalibrary.att.com.EvelBatch; +import evel_javalibrary.att.com.EvelScalingMeasurement; + +public class MeasureData extends Thread{ + static HashMap<String, String> hm = new HashMap<>(); + static HashMap<String, String> vpp_metrics = new HashMap<>(); + + static HashMap<String, String> common_meas = new HashMap<>(); + + + static int bytes_in_this_round; + static int bytes_out_this_round; + static int packets_in_this_round; + static int packets_out_this_round; + + static int gm_event_id = 1; + static String event_id1 = "mvfs"; + static String event_id = "00000000"; + static String event_id2=null; + + static int request_rate = 0; + + static long epoch_start = 0; + + static String linkStart = ""; + static int linkCount; + + + Long start_epoch_microsec = 0L; + Long last_epoch_microsec = 0L; + + //public static void main(String[] args) { + public void run() { + // TODO Auto-generated method stub + //read_config_file(); + read_meas_traffic(); + read_common_config_file(); + read_meas_config_file(); + + HashMap<String, String> intFaceMap = read_interface_config_file(); + int numOfInterfaces = 0; + if( !intFaceMap.isEmpty() ) + numOfInterfaces = intFaceMap.size(); + if( numOfInterfaces <= 0) { + System.out.println("ERROR : Didn't find interfacess in config file, exiting thread"); + return; + } + + System.out.println("MAP values: " + hm.values()); + + HashMap last_metrics = read_vpp_metrics(linkStart); + try { + Thread.sleep(Integer.parseInt(common_meas.get("measurementInterval"))); + }catch(Exception e) {} + + + while(true) { + //request_rate = rand()%10000; + request_rate =2; + EvelBatch ebt = new EvelBatch(); + event_id2 = event_id1+ event_id+(gm_event_id++); + EvelScalingMeasurement eveMeas = new EvelScalingMeasurement( Double.parseDouble(common_meas.get("measurementInterval")) , + common_meas.get("eventName"), + event_id2); + + for( String vNic : intFaceMap.keySet() ) { + //System.out.println("INFO:: getting vpp metrics for vNic "+vNic); + + HashMap current_metrics = read_vpp_metrics(vNic); + if( current_metrics.size() !=4 ) { + System.out.println("ERROR:: Did't get vpp metrics for vNic "+vNic); + continue; + } + + if (Integer.parseInt((String) current_metrics.get("bytes_in")) + - Integer.parseInt((String) last_metrics.get("bytes_in")) > 0) { + bytes_in_this_round = Integer.parseInt((String) current_metrics.get("bytes_in")) + - Integer.parseInt((String) last_metrics.get("bytes_in")); + } else { + bytes_in_this_round = 0; + } + + if (Integer.parseInt((String) current_metrics.get("bytes_out")) + - Integer.parseInt((String) last_metrics.get("bytes_out")) > 0) { + bytes_out_this_round = Integer.parseInt((String) current_metrics.get("bytes_out")) + - Integer.parseInt((String) last_metrics.get("bytes_out")); + } else { + bytes_out_this_round = 0; + } + + if (Integer.parseInt((String) current_metrics.get("packets_in")) + - Integer.parseInt((String) last_metrics.get("packets_in")) > 0) { + packets_in_this_round = Integer.parseInt((String) current_metrics.get("packets_in")) + - Integer.parseInt((String) last_metrics.get("packets_in")); + } else { + packets_in_this_round = 0; + } + + if (Integer.parseInt((String) current_metrics.get("packets_out")) + - Integer.parseInt((String) last_metrics.get("packets_out")) > 0) { + packets_out_this_round = Integer.parseInt((String) current_metrics.get("packets_out")) + - Integer.parseInt((String) last_metrics.get("packets_out")); + } else { + packets_out_this_round = 0; + } + + event_id2 = event_id1+ (gm_event_id++); + /* EvelScalingMeasurement eveMeas = new EvelScalingMeasurement( Double.parseDouble(hm.get("measurementInterval")) , + hm.get("eventName"), + event_id2); */ + + + EvelScalingMeasurement.MEASUREMENT_NIC_PERFORMANCE vNicPerf = eveMeas.evel_measurement_new_vnic_performance(vNic, "true"); + eveMeas.evel_meas_vnic_performance_add(vNicPerf ); + + if( hm.get("eventType")!=null) { + + start_epoch_microsec = last_epoch_microsec; + last_epoch_microsec = System.nanoTime()/1000; + + eveMeas.evel_last_epoch_set(start_epoch_microsec); + eveMeas.evel_start_epoch_set(last_epoch_microsec); + + + eveMeas.evel_measurement_type_set( hm.get("eventType").toString()); + eveMeas.evel_measurement_request_rate_set(request_rate ); + eveMeas.evel_vnic_performance_rx_total_pkt_delta_set(vNicPerf, packets_in_this_round); + eveMeas.evel_vnic_performance_tx_total_pkt_delta_set(vNicPerf, packets_out_this_round); + eveMeas.evel_vnic_performance_rx_octets_delta_set( vNicPerf, bytes_in_this_round); + eveMeas.evel_vnic_performance_tx_octets_delta_set( vNicPerf, bytes_out_this_round); + + eveMeas.evel_nfcnamingcode_set(hm.get("nfcNamingCode").toString()); + eveMeas.evel_nfnamingcode_set(hm.get("nfNamingCode").toString()); + eveMeas.evel_reporting_entity_name_set(hm.get("reportingEntityName").toString()); + eveMeas.evel_reporting_entity_id_set(hm.get("reportingEntityId").toString()); + eveMeas.evel_nfVendorName_set(hm.get("nfVendorName").toString()); + eveMeas.evel_header_set_sourceid(true,hm.get("sourceId").toString()); + + eveMeas.evel_header_set_source_name(hm.get("sourceName").toString()); + eveMeas.evel_timeZoneOffset_set(hm.get("timeZoneOffset").toString()); + + + + + } + + + try { + Thread.sleep(Integer.parseInt(common_meas.get("measurementInterval"))); + }catch(Exception e) {} + last_metrics = current_metrics; + } + + //ebt.addEvent(eveMeas); + AgentMain.evel_post_event(eveMeas); + System.out.println(" Event sent"); + + } + + } + + + + + public static HashMap<String, String> read_vpp_metrics(String linkStart) { + Process p; + + String s=""; + HashMap<String, String> vpp_metrics_map = new HashMap<>(); + String params[] = {"-f3", "-f11", "-f4", "-f12"}; + try { + Runtime rt = Runtime.getRuntime(); + for(int i=0;i<4;i++) { + String[] command = {"/bin/sh", "-c", "cat /proc/net/dev | grep \""+linkStart+"\" | tr -s \' \' | cut -d\' \' "+params[i]+""}; + Process child = rt.exec(command); + + BufferedReader reader = new BufferedReader(new InputStreamReader( + child.getInputStream())); + + while ((s= reader.readLine()) != null) { + String[] res = s.split(" "); + if( i==0) + vpp_metrics_map.put("bytes_in", res[0]); + if( i==1) + vpp_metrics_map.put("packets_in", res[0]); + if( i==2) + vpp_metrics_map.put("bytes_out", res[0]); + if( i==3) + vpp_metrics_map.put("packets_out", res[0]); + + } + } + + } catch (Exception e) { + e.printStackTrace(); + } + return vpp_metrics_map; + } + + + + public static HashMap<String, String> read_common_config_file() { + + List<String> list = new ArrayList<String>(); + + + hm.put("eventType", ""); + hm.put("nfcNamingCode", ""); + hm.put("nfNamingCode", ""); + hm.put("nfVendorName", ""); + hm.put("reportingEntityId", ""); + hm.put("reportingEntityName", ""); + hm.put("sourceId", ""); + hm.put("sourceName", ""); + hm.put("timeZoneOffset", ""); + + + + System.out.println("KEYS: " + hm.keySet().size()); + System.out.println("VALUES: " + hm.values()); + + try { + // File file = new File("/home/ves/users/admin/temp/fw_common_config.txt"); + File file = new File("./src/main/java/evel_javalibrary/att/com/loadbalance/fw_common_config.txt"); + list = Files.readAllLines(file.toPath(), Charset.defaultCharset()); + for (String lineSplit : list) { + String[] res = lineSplit.split(" "); + hm.put(res[0], res[1]); + System.out.println("File reading after split ---" + res[0]); + System.out.println("File reading after split second---" + res[1]); + } + } catch (Exception ex) { + ex.printStackTrace(); + } + System.out.println("KEYS: " + hm.keySet().size()); + System.out.println("VALUES: " + hm.values()); + return hm; + } + + + + public static HashMap<String, String> read_interface_config_file() { + + List<String> list = new ArrayList<String>(); + HashMap<String, String> interface_config = new HashMap<>(); + //interface_config.put("lo", ""); + + + System.out.println("KEYS: " + interface_config.keySet().size()); + System.out.println("VALUES: " + interface_config.values()); + + try { + //File file = new File("/home/ves/users/admin/temp/fw_interface_config.txt"); + File file = new File("./src/main/java/evel_javalibrary/att/com/loadbalance/fw_interface_config.txt"); + list = Files.readAllLines(file.toPath(), Charset.defaultCharset()); + for (String lineSplit : list) { + String[] res = lineSplit.split(" "); + interface_config.put(res[0], res[1]); + } + + linkStart = (String)interface_config.keySet().toArray()[1]; + linkCount = interface_config.keySet().size(); + + + + } catch (Exception ex) { + ex.printStackTrace(); + } + + return interface_config; + } + + + + + + + + public static HashMap<String, String> read_meas_config_file() { + + List<String> list = new ArrayList<String>(); + + common_meas.put("eventName", "Measurement_vFirewall-AT&T_nicPerformance"); + common_meas.put("measurementInterval", ""); + + System.out.println("KEYS: " + common_meas.keySet().size()); + System.out.println("VALUES: " + common_meas.values()); + + try { + //File file = new File("/home/ves/users/admin/temp/fw_meas_config.txt"); + File file = new File("./src/main/java/evel_javalibrary/att/com/loadbalance/fw_meas_config.txt"); + list = Files.readAllLines(file.toPath(), Charset.defaultCharset()); + for (String lineSplit : list) { + String[] res = lineSplit.split(" "); + common_meas.put(res[0], res[1]); + } + } catch (Exception ex) { + ex.printStackTrace(); + } + System.out.println("KEYS: " + common_meas.keySet().size()); + System.out.println("VALUES: " + common_meas.values()); + return common_meas; + } + + + + + + public static HashMap<String, String> read_meas_traffic() { + Process p; + List<String> vpp_params = new ArrayList(); + String s=""; + // HashMap<String, String> vpp_metrics_map = new HashMap<>(); + String params[] = {"-f3", "-f11", "-f4", "-f12"}; + try { +// System.out.println("***********inside read_vpp_metrics"); +// String command = "cat /proc/net/dev | grep \"Receive\" | tr -s \' \' | cut -d\' \' -f3"; + //{"-f3", "-f11", "-f4", "-f12"}; +// String command = "cat /proc/net/dev | grep \""+vnic+"\" "; + for(int i=0;i<4;i++) { + String[] command = {"/bin/sh", "-c", "docker logs vHello | grep -c"}; +// System.out.println("**COMMAND***: "+command); + Process child = Runtime.getRuntime().exec(command); + + BufferedReader reader = new BufferedReader(new InputStreamReader( + child.getInputStream())); + + while ((s= reader.readLine()) != null) { + vpp_params.add(s); + System.out.println("VPP meas_traffic:----" + s); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return vpp_metrics; + } +} diff --git a/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance/faultData.java b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance/faultData.java new file mode 100644 index 0000000..5400ba3 --- /dev/null +++ b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance/faultData.java @@ -0,0 +1,286 @@ +package evel_javalibrary.att.com.loadbalance; +/**************************************************************************//** + * @file + * Evel Fault Event class extends EvelHeader class + * + * This file implements the Evel Fault Event class which is intended to provide a + * simple wrapper around the complexity of AT&T's Vendor Event Listener API so + * that VNFs can use it to send Fault events. + * + * License + * ------- + * Unless otherwise specified, all software contained herein is + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *****************************************************************************/ + +import java.io.File; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import evel_javalibrary.att.com.AgentMain; +import evel_javalibrary.att.com.EvelBatch; +import evel_javalibrary.att.com.EvelFault; +import evel_javalibrary.att.com.EvelFault.EVEL_SEVERITIES; +import evel_javalibrary.att.com.EvelFault.EVEL_SOURCE_TYPES; +import evel_javalibrary.att.com.EvelFault.EVEL_VF_STATUSES; +import evel_javalibrary.att.com.EvelHeader; +import evel_javalibrary.att.com.EvelHeader.PRIORITIES; + + + +public class faultData extends Thread{ + + static HashMap<String, String> fault_config = new HashMap<>(); + static HashMap<String, String> interface_config = new HashMap<>(); + + static HashMap<String, String> hm = new HashMap<>(); + + static String linkStart = ""; + static int linkCount; + + + static int gm_event_id = 1; + static String event_id1 = "fault"; + static String event_id = "00000000"; + static String event_id2=null; + + + static int bytes_in; + static int bytes_out; + static int packets_in; + static int packets_out; + + + static int falut_raised =0; + + + public void run() { + + String alarmCondition = "linkDown"; + String specificProblem = "Transmit-Receive issue"; + + Long start_epoch_microsec = 0L; + Long last_epoch_microsec = 0L; + + + MeasureData mdataThread = new MeasureData(); + hm = mdataThread.read_common_config_file(); + + read_fault_config_file(); + HashMap<String, String> intFaceMapFault = mdataThread.read_interface_config_file(); + int numOfInterfacesFalut = 0; + if( !intFaceMapFault.isEmpty() ) + numOfInterfacesFalut = intFaceMapFault.size(); + if( numOfInterfacesFalut <= 0) { + System.out.println("ERROR : Didn't find interfacess in config file, exiting thread"); + return; + } + + + HashMap falut_last_metrics = mdataThread.read_vpp_metrics(linkStart); + + while(true) { + //request_rate = rand()%10000; + //request_rate =2; + EvelBatch ebt = new EvelBatch(); + event_id2 = event_id1+ event_id+(gm_event_id++); +// EvelScalingMeasurement eveMeas = new EvelScalingMeasurement( Double.parseDouble(common_meas.get("measurementInterval")) , +// common_meas.get("eventName"), +// event_id2); + + EvelHeader header = new EvelHeader("", ""); + + + //EvelFault eveFalt = new EvelFault(fault_config.get("eventName"), event_id2, alarmCondition, specificProblem,EVEL_PRIORITY_MEDIUM, EVEL_SEVERITY_MAJOR,EVEL_SOURCE_HOST,EVEL_VF_STATUS_IDLE); + + EvelFault eveFalt = new EvelFault(fault_config.get("eventName"),event_id2, alarmCondition, specificProblem, + EvelHeader.PRIORITIES.EVEL_PRIORITY_HIGH, + EVEL_SEVERITIES.EVEL_SEVERITY_MAJOR, + EVEL_SOURCE_TYPES.EVEL_SOURCE_CARD, + EVEL_VF_STATUSES.EVEL_VF_STATUS_ACTIVE); + + + + //EvelFault eveFalt = new EvelFault(fault_config.get("eventName"), event_id2, alarmCondition,specificProblem,1,1,3,1); + // EvelFault eveFalt = new EvelFault("eventName", "event_id2", "alarmCondition","specificProblem",1,1,3,1); + // EvelFault eveFalt = new EvelFault(fault_config.get("eventName"), event_id2, alarmCondition,specificProblem,1,1,3,1); + + for( String falut : intFaceMapFault.keySet() ) { + + HashMap falut_current_metrics = mdataThread.read_vpp_metrics(falut); + if( falut_current_metrics.size() !=4 ) { + System.out.println("ERROR:: Did't get vpp metrics for vNic "+falut); + continue; + } + + if (Integer.parseInt((String) falut_current_metrics.get("bytes_in")) + - Integer.parseInt((String) falut_last_metrics.get("bytes_in")) > 0) { + bytes_in = Integer.parseInt((String) falut_current_metrics.get("bytes_in")) + - Integer.parseInt((String) falut_last_metrics.get("bytes_in")); + } else { + bytes_in = 0; + } + + if (Integer.parseInt((String) falut_current_metrics.get("bytes_out")) + - Integer.parseInt((String) falut_last_metrics.get("bytes_out")) > 0) { + bytes_out = Integer.parseInt((String) falut_current_metrics.get("bytes_out")) + - Integer.parseInt((String) falut_last_metrics.get("bytes_out")); + } else { + bytes_out = 0; + } + + if (Integer.parseInt((String) falut_current_metrics.get("packets_in")) + - Integer.parseInt((String) falut_last_metrics.get("packets_in")) > 0) { + packets_in = Integer.parseInt((String) falut_current_metrics.get("packets_in")) + - Integer.parseInt((String) falut_last_metrics.get("packets_in")); + } else { + packets_in = 0; + } + + if (Integer.parseInt((String) falut_current_metrics.get("packets_out")) + - Integer.parseInt((String) falut_last_metrics.get("packets_out")) > 0) { + packets_out = Integer.parseInt((String) falut_current_metrics.get("packets_out")) + - Integer.parseInt((String) falut_last_metrics.get("packets_out")); + } else { + packets_out = 0; + } + + + + if((bytes_in < Integer.parseInt((String)fault_config.get("lowWaterMark")) || bytes_out < Integer.parseInt((String)fault_config.get("lowWaterMark")) || + packets_in < Integer.parseInt((String)fault_config.get("lowWaterMark")) || packets_out < Integer.parseInt((String)fault_config.get("lowWaterMark"))) && falut_raised == 0){ + + event_id2 = event_id1+ (gm_event_id++); + + if(eveFalt != null) { + + falut_raised =1; + eveFalt.evel_fault_interface_set(linkStart); + + if( hm.get("eventType")!=null) { + eveFalt.evel_fault_type_set(hm.get("eventType")); + + start_epoch_microsec = last_epoch_microsec; + last_epoch_microsec = System.nanoTime()/1000; + + eveFalt.evel_last_epoch_set(start_epoch_microsec); + eveFalt.evel_start_epoch_set(last_epoch_microsec); + + eveFalt.evel_fault_category_set("link"); + eveFalt.evel_fault_interface_set("My Interface"); + eveFalt.evel_nfcnamingcode_set(hm.get("nfcNamingCode").toString()); + eveFalt.evel_nfnamingcode_set(hm.get("nfNamingCode").toString()); + eveFalt.evel_reporting_entity_name_set(hm.get("reportingEntityName").toString()); + eveFalt.evel_reporting_entity_id_set(hm.get("reportingEntityId").toString()); + eveFalt.evel_nfVendorName_set(hm.get("nfVendorName").toString()); + eveFalt.evel_header_set_sourceid(true,hm.get("sourceId").toString()); + + eveFalt.evel_header_set_source_name(hm.get("sourceName").toString()); + eveFalt.evel_timeZoneOffset_set(hm.get("timeZoneOffset").toString()); + + } + + } + + }else if((bytes_in > Integer.parseInt((String)fault_config.get("lowWaterMark")) && bytes_out > Integer.parseInt((String)fault_config.get("lowWaterMark")) && + packets_in > Integer.parseInt((String)fault_config.get("lowWaterMark")) && packets_out > Integer.parseInt((String)fault_config.get("lowWaterMark"))) && falut_raised == 1) { + + + + event_id2 = event_id1+ (gm_event_id++); +// EvelHeader header = new EvelHeader("", ""); +// EvelFault eveFalt = new EvelFault(fault_config.get("eventName"), event_id2, "linkDown", "Transmit-Receive issue", header.priority, eveFalt.event_severity,eveFalt.event_source_type,eveFalt.vf_status); + + if(eveFalt != null) { + falut_raised =1; + + eveFalt.evel_fault_interface_set(linkStart); + System.out.println("Event type is "+hm.get("eventType") ); + if( hm.get("eventType")!=null) { + eveFalt.evel_fault_type_set(hm.get("eventType")); + + eveFalt.evel_fault_category_set("link"); + eveFalt.evel_nfcnamingcode_set(hm.get("nfcNamingCode").toString()); + eveFalt.evel_nfnamingcode_set(hm.get("nfNamingCode").toString()); + eveFalt.evel_reporting_entity_name_set(hm.get("reportingEntityName").toString()); + eveFalt.evel_reporting_entity_id_set(hm.get("reportingEntityId").toString()); + eveFalt.evel_nfVendorName_set(hm.get("nfVendorName").toString()); + eveFalt.evel_header_set_sourceid(true,hm.get("sourceId").toString()); + + eveFalt.evel_header_set_source_name(hm.get("sourceName").toString()); + eveFalt.evel_timeZoneOffset_set(hm.get("timeZoneOffset").toString()); + + } + + } + + + + } + + + try { + Thread.sleep(1000); + }catch(Exception e) {} + } + // ebt.addEvent(eveFalt); + AgentMain.evel_post_event(eveFalt); + System.out.println(" Event sent"); + + } + + + } + + + + + + + public static HashMap<String, String> read_fault_config_file() { + + List<String> list = new ArrayList<String>(); + + List<String> list_interface = new ArrayList<String>(); + + fault_config.put("eventName", ""); + fault_config.put("faultCheckInterval", ""); + fault_config.put("lowWaterMark", ""); + + //interface_config.put("lo", ""); + + try { + // File file = new File("/home/ves/users/admin/temp/fw_flt_config.txt"); + File file = new File("./src/main/java/evel_javalibrary/att/com/loadbalance/fw_flt_config.txt"); + System.out.println("File path is..."+ file); + list = Files.readAllLines(file.toPath(), Charset.defaultCharset()); + for (String lineSplit : list) { + String[] res = lineSplit.split(" "); + fault_config.put(res[0], res[1]); + } + + + } catch (Exception ex) { + ex.printStackTrace(); + } + System.out.println("KEYS:fault_config " + fault_config.keySet().size()); + System.out.println("VALUES:fault_config " + fault_config.values()); + return fault_config; + } + + + +} diff --git a/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance/fw_common_config.txt b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance/fw_common_config.txt new file mode 100644 index 0000000..e40b5b3 --- /dev/null +++ b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance/fw_common_config.txt @@ -0,0 +1,9 @@ +eventType platform +nfcNamingCode ssc +nfNamingCode scfx +nfVendorName AT&T +reportingEntityId cc305d54-75b4-431b-adb2-eb6b9e541234 +reportingEntityName ibcx0001vm002oam001 +sourceId de305d54-75b4-431b-adb2-eb6b9e546014 +sourceName scfx0001vm002cap001 +timeZoneOffset UTC-05:30 diff --git a/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance/fw_config.txt b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance/fw_config.txt new file mode 100644 index 0000000..f730d6f --- /dev/null +++ b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance/fw_config.txt @@ -0,0 +1,10 @@ +eventName Measurement_vFirewall-AT&T_nicPerformance +eventType platform +nfcNamingCode ssc +nfNamingCode scfx +nfVendorName AT&T +reportingEntityId cc305d54-75b4-431b-adb2-eb6b9e541234 +reportingEntityName ibcx0001vm002oam001 +sourceId de305d54-75b4-431b-adb2-eb6b9e546014 +timeZoneOffset UTC-05:30 +measurementInterval 30 diff --git a/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance/fw_flt_config.txt b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance/fw_flt_config.txt new file mode 100644 index 0000000..4b660ea --- /dev/null +++ b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance/fw_flt_config.txt @@ -0,0 +1,3 @@ +eventName Fault_vFirewall-AT&T_linkDownError +faultCheckInterval 30 +lowWaterMark 100 diff --git a/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance/fw_hb_config.txt b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance/fw_hb_config.txt new file mode 100644 index 0000000..c288120 --- /dev/null +++ b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance/fw_hb_config.txt @@ -0,0 +1,2 @@ +eventName Heartbeat_vFirewall-AT&T_heartbeat +heartbeatInterval 20 diff --git a/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance/fw_interface_config.txt b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance/fw_interface_config.txt new file mode 100644 index 0000000..46c3777 --- /dev/null +++ b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance/fw_interface_config.txt @@ -0,0 +1,13 @@ +lo DNS1_RSLOTPORT_VLAN_CLASSTYPE +bond0 DNS2_RSLOTPORT_VLAN_CLASSTYPE +bond0.4020 DNS3_RSLOTPORT_VLAN_CLASSTYPE +bond0.4020.4020 DNS4_RSLOTPORT_VLAN_CLASSTYPE +bond0.4021 DNS5_RSLOTPORT_VLAN_CLASSTYPE +bond0.4021.4021 DNS6_RSLOTPORT_VLAN_CLASSTYPE +ens3 DNS7_RSLOTPORT_VLAN_CLASSTYPE +ens4 DNS8_RSLOTPORT_VLAN_CLASSTYPE +ens5 DNS9_RSLOTPORT_VLAN_CLASSTYPE +ens6 DNSa_RSLOTPORT_VLAN_CLASSTYPE +ens7 DNSb_RSLOTPORT_VLAN_CLASSTYPE +docker0 DNSb_RSLOTPORT_VLAN_CLASSTYPE +enp0s3 DNSb_RSLOTPORT_VLAN_CLASSTYPE diff --git a/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance/fw_meas_config.txt b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance/fw_meas_config.txt new file mode 100644 index 0000000..7fac2f7 --- /dev/null +++ b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance/fw_meas_config.txt @@ -0,0 +1,2 @@ +eventName Measurement_vFirewall-AT&T_nicPerformance +measurementInterval 30 diff --git a/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance/heartBeatData.java b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance/heartBeatData.java new file mode 100644 index 0000000..9da7521 --- /dev/null +++ b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/loadbalance/heartBeatData.java @@ -0,0 +1,153 @@ +package evel_javalibrary.att.com.loadbalance; +/**************************************************************************//** + * @file + * Heartbeat field class + * + * This file implements the Heartbeat Event class which is intended to provide a + * simple wrapper around the complexity of AT&T's Vendor Event Listener API so + * that VNFs can use it to send Agent status. + * + * License + * ------- + * Unless otherwise specified, all software contained herein is + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *****************************************************************************/ + +import java.io.File; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import javax.json.Json; +import javax.json.JsonArray; +import javax.json.JsonArrayBuilder; +import javax.json.JsonObject; +import javax.json.JsonObjectBuilder; + +import evel_javalibrary.att.com.AgentMain; +import evel_javalibrary.att.com.EvelBatch; +import evel_javalibrary.att.com.EvelHeartbeatField; + +public class heartBeatData extends Thread{ + + static HashMap<String, String> hm = new HashMap<>(); + static HashMap<String, String> hb_config = new HashMap<>(); + static int gm_event_id = 1; + static String event_id1 = "mvfs"; + static String event_id2=null; + + + public void run() { + + Long start_epoch_microsec = 0L; + Long last_epoch_microsec = 0L; + + MeasureData mdataThread = new MeasureData(); + hm = mdataThread.read_common_config_file(); + read_hb_config_file(); + + while(true) { + event_id2 = event_id1+ (gm_event_id++); + + + EvelHeartbeatField evelHb = new EvelHeartbeatField(Integer.parseInt(hb_config.get("heartbeatInterval")) , + hb_config.get("eventName"), + event_id2); + + if( hm.get("eventType")!=null) { + + start_epoch_microsec = last_epoch_microsec; + last_epoch_microsec = System.nanoTime()/1000; + + evelHb.evel_last_epoch_set(start_epoch_microsec); + evelHb.evel_start_epoch_set(last_epoch_microsec); + + evelHb.evel_header_type_set(hm.get("eventType").toString()); + evelHb.evel_nfcnamingcode_set(hm.get("nfcNamingCode").toString()); + evelHb.evel_nfnamingcode_set(hm.get("nfNamingCode").toString()); + evelHb.evel_reporting_entity_name_set(hm.get("reportingEntityName").toString()); + evelHb.evel_reporting_entity_id_set(hm.get("reportingEntityId").toString()); + evelHb.evel_nfVendorName_set(hm.get("nfVendorName").toString()); + evelHb.evel_header_set_sourceid(true,hm.get("sourceId").toString()); + evelHb.evel_header_set_source_name(hm.get("sourceName").toString()); + + evelHb.evel_timeZoneOffset_set(hm.get("timeZoneOffset").toString()); + + + JsonObject obj = Json.createObjectBuilder() + .add( "heartbeatFields",evelHeartbeatFieldObject() + ).build(); + + EvelBatch ebt = new EvelBatch(); + //ebt.addEvent(evelHb); + + + System.out.println(" Event sent..."+ obj.asJsonObject()); + System.out.println("Event sent...###########"); + AgentMain.evel_post_event(evelHb); + System.out.println(" Event sent..."); + } + + try { + Thread.sleep(1000); + }catch(Exception e) { + + } + } + } + + + JsonObjectBuilder evelHeartbeatFieldObject() + { + String version = "3.0"; + JsonObjectBuilder evelHeatbeat = Json.createObjectBuilder() + .add("heartbeatInterval", hb_config.get("heartbeatInterval")); + evelHeatbeat.add( "heartbeatFieldsVersion", version); + return evelHeatbeat; + } + + + public static HashMap<String, String> read_hb_config_file() { + + List<String> list = new ArrayList<String>(); + + hb_config.put("eventName", ""); + hb_config.put("heartbeatInterval", ""); + + + System.out.println("KEYS: " + hb_config.keySet().size()); + System.out.println("VALUES: " + hb_config.values()); + + try { + //File file = new File("/home/ves/users/admin/temp/fw_hb_config.txt"); + File file = new File("./src/main/java/evel_javalibrary/att/com/loadbalance/fw_hb_config.txt"); + list = Files.readAllLines(file.toPath(), Charset.defaultCharset()); + for (String lineSplit : list) { + String[] res = lineSplit.split(" "); + hb_config.put(res[0], res[1]); +// System.out.println("File reading after split ---" + res[0]); +// System.out.println("File reading after split second---" + res[1]); + } + } catch (Exception ex) { + ex.printStackTrace(); + } + System.out.println("KEYS:hb_config " + hb_config.keySet().size()); + System.out.println("VALUES:hb_config " + hb_config.values()); + return hb_config; + } + + + + +} |