Commit 0512efed authored by jithu.tagore's avatar jithu.tagore

Update infra_as_service_monitor.py

parent cb7794a3
......@@ -190,9 +190,7 @@ def docker_container():
except docker.errors.NotFound as exc:
print(f"Check container name!\n{exc.explanation}")
else:
if container.attrs["State"]["Status"] == "restarting" or container.attrs["State"]["Status"] == \
"exited":
container_restart.append(container)
if container.attrs["State"]["Status"] == "restarting" or container.attrs["State"]["Status"] == "exited":
end = container.attrs["State"]["FinishedAt"]
start_date = dateutil.parser.isoparse(end)
end_date = datetime.datetime.now(tz=datetime.timezone.utc)
......@@ -202,6 +200,7 @@ def docker_container():
if container_id not in df["Services"].values:
df.loc[len(df.index)] = [container_id, datetime.datetime.now(), 0]
df.to_csv("check_time.csv")
container_restart.append(container_id)
else:
found = list(df[df['Services'] == container_id]["Time"])
timer = datetime.datetime.now() - found[0]
......@@ -211,6 +210,7 @@ def docker_container():
df.loc[df['Services'] == container_id, "Ago"] = 0
df.loc[df['Services'] == container_id, "Time"] = datetime.datetime.now()
df.to_csv("check_time.csv")
container_restart.append(container_id)
else:
df.loc[df['Services'] == container_id, "Ago"] = str(timer)
df.to_csv("check_time.csv")
......@@ -270,6 +270,8 @@ def docker_container():
if container_id not in df["Services"].values:
df.loc[len(df.index)] = [container_id,datetime.datetime.now(),0]
df.to_csv("check_time.csv")
container_restart.append(each)
else:
found = list(df[df['Services']==container_id]["Time"])
timer=datetime.datetime.now()-found[0]
......@@ -649,6 +651,7 @@ if __name__ == '__main__':
df.loc[len(df.index)] = [container_id, datetime.datetime.now(), 0]
Ram_send_mail=1
df.to_csv("check_time.csv")
send_mail = True
else:
found = list(df[df['Services'] == container_id]["Time"])
timer = datetime.datetime.now() - found[0]
......@@ -677,6 +680,7 @@ if __name__ == '__main__':
if container_id not in df["Services"].values:
df.loc[len(df.index)] = [container_id, datetime.datetime.now(), 0]
df.to_csv("check_time.csv")
send_mail = True
else:
found = list(df[df['Services'] == container_id]["Time"])
timer = datetime.datetime.now() - found[0]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment