summaryrefslogtreecommitdiffstats
path: root/miss_htbt_service/db_monitoring.py
diff options
context:
space:
mode:
authorVijay Venkatesh Kumar <vv770d@att.com>2023-03-24 22:39:50 +0000
committerVijay Venkatesh Kumar <vv770d@att.com>2023-03-24 22:46:15 +0000
commitf759989a43ddbc8991e45697f0682808716f8d16 (patch)
tree8d8c691380e30cc417798c50d29c4a1cef9f90d1 /miss_htbt_service/db_monitoring.py
parentd2e368fcc6f9aeedec1f036d5b5e3e72e1460b59 (diff)
Fix build job error2.6.1
black check failure https://jenkins.onap.org/view/dcaegen2/job/dcaegen2-services-heartbeat-master-release-version-java-daily/lastBuild/console onap-gerrit-review: -changelog-or-release-file-missing Change-Id: I0e57025285ea90c6e649feae0d2e955064b76083 Signed-off-by: Vijay Venkatesh Kumar <vv770d@att.com> Issue-ID: DCAEGEN2-3366
Diffstat (limited to 'miss_htbt_service/db_monitoring.py')
-rw-r--r--miss_htbt_service/db_monitoring.py27
1 files changed, 11 insertions, 16 deletions
diff --git a/miss_htbt_service/db_monitoring.py b/miss_htbt_service/db_monitoring.py
index 472c356..2b7c056 100644
--- a/miss_htbt_service/db_monitoring.py
+++ b/miss_htbt_service/db_monitoring.py
@@ -156,7 +156,6 @@ def sendControlLoopEvent(
return True
-
def db_monitoring(current_pid, json_file, user_name, password, ip_address, port_num, db_name, sleeptime=20):
while True:
time.sleep(sleeptime)
@@ -169,21 +168,18 @@ def db_monitoring(current_pid, json_file, user_name, password, ip_address, port_
msg = "Json file process error : ", err
_logger.error(msg)
continue
- db_monitoring_singlepass (current_pid, pol_url, user_name, password, ip_address, port_num, db_name)
+ db_monitoring_singlepass(current_pid, pol_url, user_name, password, ip_address, port_num, db_name)
break
-
-def db_monitoring_singlepass (current_pid, pol_url, user_name, password, ip_address, port_num, db_name) :
- hbc_pid, hbc_state, hbc_src_name, hbc_time = db.read_hb_common(
- user_name, password, ip_address, port_num, db_name
- )
+
+
+def db_monitoring_singlepass(current_pid, pol_url, user_name, password, ip_address, port_num, db_name):
+ hbc_pid, hbc_state, hbc_src_name, hbc_time = db.read_hb_common(user_name, password, ip_address, port_num, db_name)
source_name = socket.gethostname()
source_name = source_name + "-" + str(os.getenv("SERVICE_NAME", ""))
-
+
connection_db = pm.postgres_db_open()
cur = connection_db.cursor()
- if (
- int(current_pid) == int(hbc_pid) and source_name == hbc_src_name and hbc_state == "RUNNING"
- ):
+ if int(current_pid) == int(hbc_pid) and source_name == hbc_src_name and hbc_state == "RUNNING":
_logger.info("DBM: Active DB Monitoring Instance")
cur.execute("SELECT event_name FROM vnf_table_1")
vnf_list = [item[0] for item in cur.fetchall()]
@@ -228,7 +224,7 @@ def db_monitoring_singlepass (current_pid, pol_url, user_name, password, ip_addr
epoc_time_sec = row[0][0]
src_name = row[0][1]
cl_flag = row[0][2]
- if (epoc_time - epoc_time_sec) > comparision_time and cl_flag == 0:
+ if (epoc_time - epoc_time_sec) > comparision_time and cl_flag == 0:
sendControlLoopEvent(
"ONSET",
pol_url,
@@ -248,7 +244,7 @@ def db_monitoring_singlepass (current_pid, pol_url, user_name, password, ip_addr
(cl_flag, event_name, (source_name_key + 1)),
)
connection_db.commit()
- elif (epoc_time - epoc_time_sec) < comparision_time and cl_flag == 1:
+ elif (epoc_time - epoc_time_sec) < comparision_time and cl_flag == 1:
sendControlLoopEvent(
"ABATED",
pol_url,
@@ -269,7 +265,7 @@ def db_monitoring_singlepass (current_pid, pol_url, user_name, password, ip_addr
)
connection_db.commit()
- else:
+ else:
msg = "DBM:DB Monitoring is ignored for %s since validity flag is 0" % event_name
_logger.info(msg)
@@ -279,7 +275,7 @@ def db_monitoring_singlepass (current_pid, pol_url, user_name, password, ip_addr
"""
Delete the VNF entry in table1 and delete all the source ids related to vnfs in table2
"""
- else:
+ else:
msg = "DBM:Inactive instance or hb_common state is not RUNNING"
_logger.info(msg)
try:
@@ -293,7 +289,6 @@ def db_monitoring_singlepass (current_pid, pol_url, user_name, password, ip_addr
cur.close()
-
def db_monitoring_wrapper(current_pid, jsfile, number_of_iterations=-1):
get_logger.configure_logger("db_monitoring")
_logger.info("DBM: DBM Process started")