aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHansen, Tony (th1395) <th1395@att.com>2021-10-27 00:32:01 +0000
committerHansen, Tony (th1395) <th1395@att.com>2021-11-02 00:30:01 +0000
commit2861c7f08cba6c0cbd5af39aece1ab6c8bc3e368 (patch)
tree1beb52e5587af7ed165ebc88e22eab99d755b9d0
parent7d0c9432f13d83ed19cc07d3a61cc528b3942822 (diff)
send stdout logging to stdout in addition to log files
Change-Id: Icad02afe29e28eef72cc36dd82f0a64810ce9500 Signed-off-by: Hansen, Tony (th1395) <th1395@att.com> Issue-ID: DCAEGEN2-2957 Signed-off-by: Hansen, Tony (th1395) <th1395@att.com>
-rw-r--r--Changelog.md3
-rw-r--r--pom.xml2
-rw-r--r--setup.py2
-rwxr-xr-xsnmptrap/healthcheck.sh6
-rw-r--r--snmptrap/mod/trapd_io.py13
-rwxr-xr-xsnmptrap/snmptrapd.sh37
-rw-r--r--version.properties2
7 files changed, 41 insertions, 24 deletions
diff --git a/Changelog.md b/Changelog.md
index c4a3f50..a6126b5 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
+## [2.0.6] - 2021/10/26
+* Changed [DCAEGEN2-2957] SNMP Trap collector - STDOUT complaince
+
## [2.0.5] - 2021/07/19
* Changed to use version 2.2.1 of pypi onap_dcae_cbs_docker_client
diff --git a/pom.xml b/pom.xml
index 3525b11..8d872f4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,7 +30,7 @@ ECOMP is a trademark and service mark of AT&T Intellectual Property.
<groupId>org.onap.dcaegen2.collectors</groupId>
<artifactId>snmptrap</artifactId>
<name>dcaegen2-collectors-snmptrap</name>
- <version>2.0.5-SNAPSHOT</version>
+ <version>2.0.6-SNAPSHOT</version>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
diff --git a/setup.py b/setup.py
index be7f673..b1fb070 100644
--- a/setup.py
+++ b/setup.py
@@ -28,7 +28,7 @@ from setuptools import setup, find_packages
setup(
name = "snmptrap",
description = "snmp trap receiver for ONAP docker image",
- version = "2.0.5",
+ version = "2.0.6",
packages=find_packages(),
install_requires=[
"pysnmp==4.4.12",
diff --git a/snmptrap/healthcheck.sh b/snmptrap/healthcheck.sh
index 8fe063b..2b6de5d 100755
--- a/snmptrap/healthcheck.sh
+++ b/snmptrap/healthcheck.sh
@@ -1,6 +1,6 @@
-#!/bin/bash
+#!/bin/sh
# ============LICENSE_START=======================================================
-# Copyright (c) 2018-2020 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2018-2021 AT&T Intellectual Property. All rights reserved.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -22,4 +22,4 @@
# health check call.
# run standard status command, exit with results
-/opt/app/snmptrap/bin/snmptrapd.sh status > /dev/null 2>&1
+/opt/app/snmptrap/bin/snmptrapd.sh status
diff --git a/snmptrap/mod/trapd_io.py b/snmptrap/mod/trapd_io.py
index 991bcbd..20b99f9 100644
--- a/snmptrap/mod/trapd_io.py
+++ b/snmptrap/mod/trapd_io.py
@@ -303,6 +303,9 @@ def ecomp_logger(_log_type, _sev, _error_code, _msg):
unused = ""
+ # new requirement to send all logs to stdout
+ log_to_stdout = True
+
# above were various attempts at setting time string found in other
# libs; instead, let's keep it real:
t_out = datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3]
@@ -319,6 +322,8 @@ def ecomp_logger(_log_type, _sev, _error_code, _msg):
% (calling_fx, "snmptrapd", unused, unused, unused, tds.SEV_TYPES[_sev], _error_code, unused, (msg + _msg)))
try:
tds.eelf_error_fd.write('%s|%s\n' % (t_out, str(_out_rec)))
+ if log_to_stdout:
+ print('%s|%s' % (t_out, str(_out_rec)))
except Exception as e:
stdout_logger(str(_out_rec))
@@ -334,6 +339,8 @@ def ecomp_logger(_log_type, _sev, _error_code, _msg):
% (unused, unused, calling_fx, unused, "snmptrapd", unused, unused, unused, unused, unused, unused, unused, tds.SEV_TYPES[_sev], unused, unused, unused, unused, unused, unused, unused, unused, unused, unused, unused, unused, unused, _msg))
try:
tds.eelf_error_fd.write('%s|%s|%s\n' % (t_out, t_out, str(_out_rec)))
+ if log_to_stdout:
+ print('%s|%s|%s' % (t_out, t_out, str(_out_rec)))
except Exception as e:
stdout_logger(str(_out_rec))
elif _log_type == tds.LOG_TYPE_AUDIT:
@@ -344,6 +351,8 @@ def ecomp_logger(_log_type, _sev, _error_code, _msg):
% (calling_fx, "snmptrapd", unused, unused, unused, tds.SEV_TYPES[_sev], _error_code, unused, _msg))
try:
tds.eelf_audit_fd.write('%s|%s\n' % (t_out, str(_out_rec)))
+ if log_to_stdout:
+ print('%s|%s' % (t_out, str(_out_rec)))
except Exception as e:
stdout_logger(str(_out_rec))
elif _log_type == tds.LOG_TYPE_METRICS:
@@ -352,6 +361,8 @@ def ecomp_logger(_log_type, _sev, _error_code, _msg):
% (calling_fx, "snmptrapd", unused, unused, unused, tds.SEV_TYPES[_sev], _error_code, unused, _msg))
try:
tds.eelf_metrics_fd.write('%s|%s\n' % (t_out, str(_out_rec)))
+ if log_to_stdout:
+ print('%s|%s' % (t_out, str(_out_rec)))
except Exception as e:
stdout_logger(str(_out_rec))
@@ -363,6 +374,8 @@ def ecomp_logger(_log_type, _sev, _error_code, _msg):
% (unused, calling_fx, "snmptrapd", unused, unused, unused, tds.SEV_TYPES[_sev], _error_code, unused, _msg))
try:
tds.eelf_debug_fd.write('%s|%s\n' % (t_out, str(_out_rec)))
+ if log_to_stdout:
+ print('%s|%s' % (t_out, str(_out_rec)))
except Exception as e:
stdout_logger(str(_out_rec))
diff --git a/snmptrap/snmptrapd.sh b/snmptrap/snmptrapd.sh
index a10e049..717f660 100755
--- a/snmptrap/snmptrapd.sh
+++ b/snmptrap/snmptrapd.sh
@@ -1,7 +1,8 @@
#!/usr/bin/env bash
+# -*- indent-tabs-mode: nil -*- # vi: set expandtab:
#
# ============LICENSE_START=======================================================
-# Copyright (c) 2017-2020 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2017-2021 AT&T Intellectual Property. All rights reserved.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -104,7 +105,7 @@ exec_cmd=$3
then
mv -f ${stdout_fd} ${stdout_fd}.bak
fi
- ${exec_cmd} >> ${base_dir}/logs/${process_name}.out 2>&1 &
+ ${exec_cmd} 2>&1 | tee -a ${base_dir}/logs/${process_name}.out &
g_return=$?
echo $! > ${pid_file}
else
@@ -115,7 +116,7 @@ exec_cmd=$3
log_msg "${process_name} already running - PID ${pid}"
else
log_msg "PID file present, but no corresponding process. Starting ${process_name}"
- ${exec_cmd} >> ${base_dir}/logs/${process_name}.out 2>&1 &
+ ${exec_cmd} 2>&1 | tee -a ${base_dir}/logs/${process_name}.out &
g_return=$?
echo $! > ${pid_file}
fi
@@ -303,23 +304,23 @@ reload_cfg()
# # # # # # # # # # # # # # #
version()
{
-exit_swt=$1
+ exit_swt=$1
-version_fd=${base_dir}/etc/version.dat
-if [ -f ${version_fd} ]
-then
- version_string=`cat ${version_fd}`
- log_msg "${version_string}"
- ec=0
-else
- log_msg "ERROR: unable to determine version"
- ec=1
-fi
+ version_fd=${base_dir}/etc/version.dat
+ if [ -f ${version_fd} ]
+ then
+ version_string=`cat ${version_fd}`
+ log_msg "${version_string}"
+ ec=0
+ else
+ log_msg "ERROR: unable to determine version"
+ ec=1
+ fi
-if [ "${exit_swt}" == "${exit_after}" ]
-then
- exit ${ec}
-fi
+ if [ "${exit_swt}" = "${exit_after}" ]
+ then
+ exit ${ec}
+ fi
}
diff --git a/version.properties b/version.properties
index 5168625..7b12999 100644
--- a/version.properties
+++ b/version.properties
@@ -1,6 +1,6 @@
major=2
minor=0
-patch=5
+patch=6
base_version=${major}.${minor}.${patch}
release_version=${base_version}
snapshot_version=${base_version}-SNAPSHOT