Skip to content

Timestamp docker #139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct timespec get_ptp_time(char *DEVICE)
clkid = FD_TO_CLOCKID(fd);
if (clock_gettime(clkid, &ts)) {
perror("clock_gettime");
close(fd);
exit(0);
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class influxdb_manager():
def __init__(self):
self.args=None
self.timestampservice= timestampservice()
self.meas_ip = self.timestampservice.get_meas_node_ip()
self.host_name= self.timestampservice.get_hostname()
self.meas_ip = self.timestampservice.get_meas_node_ip_new()
self.host_name= self.timestampservice.get_hostname_new()
self.packet_output_influx_path= self.timestampservice.packet_output_influx_path
self.event_output_influx_path= self.timestampservice.event_output_influx_path
self.packet_influx_download_path = self.timestampservice.packet_influx_download_path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class timestampservice():
def __init__(self):
self.config_file_path="/root/services/timestamp/config_file/timestamp.conf"
self.read_config()
self.hostname= self.get_hostname()
self.meas_node_ip=self.get_meas_node_ip()
self.hostname= self.get_hostname_new()
self.meas_node_ip=self.get_meas_node_ip_new()
self.event_index_name= self.get_event_index_name()
self.packet_index_name= self.get_packet_index_name()

Expand All @@ -42,8 +42,17 @@ def get_hostname(self):
with open(file, "r") as h:
for line in h:
line_no_space= line.strip()
name= line_no_space.rsplit("-",1)[1]
return (name)
host_name= line_no_space.rsplit("-",1)[1]
return (host_name)

# function to adapt to the new format of hostname(Node1)
def get_hostname_new(self):
file="/etc/hostname"
with open(file, "r") as h:
for line in h:
host_name= line.strip()
return (host_name)


def get_meas_node_ip(self):
# Find the line with _meas_node
Expand All @@ -55,6 +64,18 @@ def get_meas_node_ip(self):
meas_ip = line.split()[0]
return (meas_ip)

# function to adpat to mflib meas node hostname change
def get_meas_node_ip_new(self):
# Find the line with meas-node
meas_ip=""
with open("/etc/hosts", "r") as f:
lines = f.readlines()
for line in lines:
if ("meas-node" in line):
meas_ip = line.split()[0]
return (meas_ip)


def get_event_index_name(self):
name= self.hostname
index_name=name+"-event-timestamp"
Expand Down Expand Up @@ -94,7 +115,6 @@ def create_event_elastic_index(self):
print ("create event index succeed")



def create_packet_elastic_index(self):
basic_cmd = f"curl -XPUT 'http://{self.meas_node_ip}:9200/{self.packet_index_name}?include_type_name=true' -H 'Content-Type: application/json' -d'@{self.packet_elastic_index_path}'"
result=os.popen(basic_cmd).read()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,7 @@ def read_ptp_device_name_from_file(self, file):
with open(file, 'r') as f:
for line in f:
name = line.strip()
return (name)



return (name)

def check_elastic_status(self, meas_node_ip):
cmd=f"sudo curl -XGET http://{meas_node_ip}:9200/"
Expand Down Expand Up @@ -193,7 +190,7 @@ def convert_epoch(self, time_ns):

# Get the tcpdump command based on the arguments
def generate_tcpdump_command(self):
command= f"tcpdump -v -j adapter_unsynced --time-stamp-precision nano "
command= f"tcpdump -v -j adapter_unsynced --time-stamp-precision nano --direction in "
name=self.args.name
interface = self.args.interface
interface_cmd = f"-i {interface} "
Expand Down