From 67e19395097e997d31b0b78473811eb8779a99be Mon Sep 17 00:00:00 2001 From: Gonzalo Gallardo <gonzalo.gallardo@windriver.com> Date: Fri, 6 Nov 2020 17:51:33 -0300 Subject: [PATCH] Upload fm-subagent, fm-trap-subagent and armada plugin. Upload fm-subagent and fm-trap-subagent to our snmp armada application integrated with armada plugin. Change-Id: I2c7b3a65f2e97c147068d0c3c41c52e814bb0e2e Story: 2008132 Task: 41227 Signed-off-by: Gonzalo Gallardo <gonzalo.gallardo@windriver.com> --- centos_pkg_dirs | 1 + centos_pkg_dirs_containers | 1 + config | 18 +- python-k8sapp-snmp/centos/build_srpm.data | 3 + .../centos/python-k8sapp-snmp.spec | 61 ++ python-k8sapp-snmp/k8sapp_snmp/.gitignore | 35 + python-k8sapp-snmp/k8sapp_snmp/.stestr.conf | 4 + python-k8sapp-snmp/k8sapp_snmp/LICENSE | 202 ++++ python-k8sapp-snmp/k8sapp_snmp/README.rst | 7 + .../k8sapp_snmp/k8sapp_snmp/__init__.py | 0 .../k8sapp_snmp/armada/__init__.py | 19 + .../k8sapp_snmp/armada/manifest_snmp.py | 35 + .../k8sapp_snmp/common/__init__.py | 0 .../k8sapp_snmp/common/constants.py | 9 + .../k8sapp_snmp/k8sapp_snmp/helm/__init__.py | 0 .../k8sapp_snmp/k8sapp_snmp/helm/snmp.py | 73 ++ .../k8sapp_snmp/k8sapp_snmp/tests/__init__.py | 0 .../k8sapp_snmp/tests/test_plugins.py | 42 + .../k8sapp_snmp/tests/test_snmp.py | 26 + python-k8sapp-snmp/k8sapp_snmp/pylint.rc | 238 +++++ .../k8sapp_snmp/requirements.txt | 2 + python-k8sapp-snmp/k8sapp_snmp/setup.cfg | 42 + python-k8sapp-snmp/k8sapp_snmp/setup.py | 12 + .../k8sapp_snmp/test-requirements.txt | 26 + python-k8sapp-snmp/k8sapp_snmp/tox.ini | 131 +++ .../k8sapp_snmp/upper-constraints.txt | 1 + stx-snmp-helm/centos/docker/Dockerfile | 6 - .../centos/docker/stx-fm-subagent/Dockerfile | 45 + .../centos/docker/stx-fm-subagent/Makefile | 37 + .../docker/stx-fm-subagent/bootstrap.sh | 9 + .../stx-fm-subagent/src/snmpActiveAlarms.c | 266 ++++++ .../stx-fm-subagent/src/snmpAgentPlugin.c | 161 ++++ .../stx-fm-subagent/src/snmpAgentPlugin.h | 69 ++ .../stx-fm-subagent/src/snmpEventLogs.c | 268 ++++++ .../docker/stx-fm-subagent/src/snmpSubAgent.c | 207 ++++ .../docker/stx-fm-trap-subagent/Dockerfile | 26 + .../docker/stx-fm-trap-subagent/Makefile | 40 + .../docker/stx-fm-trap-subagent/bootstrap.sh | 8 + .../src/wrsAlarmMIBSubagent.c | 332 +++++++ .../src/wrsAlarmMIBTrap.c | 897 ++++++++++++++++++ .../src/wrsAlarmMIBTrap.h | 23 + .../centos/docker/stx-snmp/Dockerfile | 12 + .../docker/stx-snmp/mibs/wrsAlarmMib.mib.txt | 818 ++++++++++++++++ .../stx-snmp/mibs/wrsEnterpriseReg.mib.txt | 132 +++ ...-snmp-helm-fm-subagent.stable_docker_image | 3 + ...-helm-fm-trap-subagent.stable_docker_image | 3 + .../stx-snmp-helm-snmp.stable_docker_image | 3 + stx-snmp-helm/centos/stx-snmp-helm.spec | 6 + .../centos/stx-snmp-helm.stable_docker_image | 2 - .../stx-snmp-helm/helm-charts/Makefile | 2 +- .../helm-charts/snmp/snmpd/snmpd.conf | 4 + .../helm-charts/snmp/templates/configmap.yaml | 11 +- .../snmp/templates/deployment.yaml | 22 + .../helm-charts/snmp/templates/service.yaml | 11 +- .../helm-charts/snmp/values.yaml | 15 +- 55 files changed, 4404 insertions(+), 22 deletions(-) create mode 100644 python-k8sapp-snmp/centos/build_srpm.data create mode 100644 python-k8sapp-snmp/centos/python-k8sapp-snmp.spec create mode 100644 python-k8sapp-snmp/k8sapp_snmp/.gitignore create mode 100644 python-k8sapp-snmp/k8sapp_snmp/.stestr.conf create mode 100644 python-k8sapp-snmp/k8sapp_snmp/LICENSE create mode 100644 python-k8sapp-snmp/k8sapp_snmp/README.rst create mode 100644 python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/__init__.py create mode 100644 python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/armada/__init__.py create mode 100644 python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/armada/manifest_snmp.py create mode 100644 python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/common/__init__.py create mode 100644 python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/common/constants.py create mode 100644 python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/helm/__init__.py create mode 100644 python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/helm/snmp.py create mode 100644 python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/tests/__init__.py create mode 100644 python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/tests/test_plugins.py create mode 100644 python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/tests/test_snmp.py create mode 100644 python-k8sapp-snmp/k8sapp_snmp/pylint.rc create mode 100644 python-k8sapp-snmp/k8sapp_snmp/requirements.txt create mode 100644 python-k8sapp-snmp/k8sapp_snmp/setup.cfg create mode 100644 python-k8sapp-snmp/k8sapp_snmp/setup.py create mode 100644 python-k8sapp-snmp/k8sapp_snmp/test-requirements.txt create mode 100644 python-k8sapp-snmp/k8sapp_snmp/tox.ini create mode 100644 python-k8sapp-snmp/k8sapp_snmp/upper-constraints.txt delete mode 100644 stx-snmp-helm/centos/docker/Dockerfile create mode 100644 stx-snmp-helm/centos/docker/stx-fm-subagent/Dockerfile create mode 100644 stx-snmp-helm/centos/docker/stx-fm-subagent/Makefile create mode 100755 stx-snmp-helm/centos/docker/stx-fm-subagent/bootstrap.sh create mode 100644 stx-snmp-helm/centos/docker/stx-fm-subagent/src/snmpActiveAlarms.c create mode 100644 stx-snmp-helm/centos/docker/stx-fm-subagent/src/snmpAgentPlugin.c create mode 100644 stx-snmp-helm/centos/docker/stx-fm-subagent/src/snmpAgentPlugin.h create mode 100644 stx-snmp-helm/centos/docker/stx-fm-subagent/src/snmpEventLogs.c create mode 100644 stx-snmp-helm/centos/docker/stx-fm-subagent/src/snmpSubAgent.c create mode 100644 stx-snmp-helm/centos/docker/stx-fm-trap-subagent/Dockerfile create mode 100644 stx-snmp-helm/centos/docker/stx-fm-trap-subagent/Makefile create mode 100644 stx-snmp-helm/centos/docker/stx-fm-trap-subagent/bootstrap.sh create mode 100644 stx-snmp-helm/centos/docker/stx-fm-trap-subagent/src/wrsAlarmMIBSubagent.c create mode 100644 stx-snmp-helm/centos/docker/stx-fm-trap-subagent/src/wrsAlarmMIBTrap.c create mode 100644 stx-snmp-helm/centos/docker/stx-fm-trap-subagent/src/wrsAlarmMIBTrap.h create mode 100755 stx-snmp-helm/centos/docker/stx-snmp/Dockerfile create mode 100755 stx-snmp-helm/centos/docker/stx-snmp/mibs/wrsAlarmMib.mib.txt create mode 100755 stx-snmp-helm/centos/docker/stx-snmp/mibs/wrsEnterpriseReg.mib.txt create mode 100755 stx-snmp-helm/centos/stx-snmp-helm-fm-subagent.stable_docker_image create mode 100755 stx-snmp-helm/centos/stx-snmp-helm-fm-trap-subagent.stable_docker_image create mode 100755 stx-snmp-helm/centos/stx-snmp-helm-snmp.stable_docker_image delete mode 100644 stx-snmp-helm/centos/stx-snmp-helm.stable_docker_image diff --git a/centos_pkg_dirs b/centos_pkg_dirs index b6438ac..6382f5b 100644 --- a/centos_pkg_dirs +++ b/centos_pkg_dirs @@ -1 +1,2 @@ stx-snmp-helm +python-k8sapp-snmp diff --git a/centos_pkg_dirs_containers b/centos_pkg_dirs_containers index b6438ac..6382f5b 100644 --- a/centos_pkg_dirs_containers +++ b/centos_pkg_dirs_containers @@ -1 +1,2 @@ stx-snmp-helm +python-k8sapp-snmp diff --git a/config b/config index 22bdef2..49414aa 100644 --- a/config +++ b/config @@ -1,12 +1,12 @@ [core] - repositoryformatversion = 0 - filemode = true - bare = false - logallrefupdates = true + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true [remote "origin"] - url = https://review.opendev.org/starlingx/snmp-armada-app.git - fetch = +refs/heads/*:refs/remotes/origin/* + url = https://review.opendev.org/starlingx/snmp-armada-app.git + fetch = +refs/heads/*:refs/remotes/origin/* [branch "master"] - remote = origin - merge = refs/heads/master - rebase = true + remote = origin + merge = refs/heads/master + rebase = true diff --git a/python-k8sapp-snmp/centos/build_srpm.data b/python-k8sapp-snmp/centos/build_srpm.data new file mode 100644 index 0000000..668a862 --- /dev/null +++ b/python-k8sapp-snmp/centos/build_srpm.data @@ -0,0 +1,3 @@ +SRC_DIR="k8sapp_snmp" + +TIS_PATCH_VER=PKG_GITREVCOUNT diff --git a/python-k8sapp-snmp/centos/python-k8sapp-snmp.spec b/python-k8sapp-snmp/centos/python-k8sapp-snmp.spec new file mode 100644 index 0000000..385ee9e --- /dev/null +++ b/python-k8sapp-snmp/centos/python-k8sapp-snmp.spec @@ -0,0 +1,61 @@ +%global app_name snmp +%global pypi_name k8sapp-snmp +%global sname k8sapp_snmp + +Name: python-%{pypi_name} +Version: 1.0 +Release: %{tis_patch_ver}%{?_tis_dist} +Summary: StarlingX sysinv extensions: Snmp + +License: Apache-2.0 +Source0: %{name}-%{version}.tar.gz + +BuildArch: noarch + +BuildRequires: python-setuptools +BuildRequires: python-pbr +BuildRequires: python2-pip +BuildRequires: python2-wheel + +%description +StarlingX sysinv extensions: SNMP K8S app + +%package -n python2-%{pypi_name} +Summary: StarlingX sysinv extensions: SNMP K8S app + +Requires: python-pbr >= 2.0.0 +Requires: sysinv >= 1.0 + +%description -n python2-%{pypi_name} +StarlingX sysinv extensions: SNMP K8S app + +%prep +%setup +# Remove bundled egg-info +rm -rf %{pypi_name}.egg-info + +%build +export PBR_VERSION=%{version} +%{__python2} setup.py build + +%py2_build_wheel + +%install +export PBR_VERSION=%{version}.%{tis_patch_ver} +export SKIP_PIP_INSTALL=1 +%{__python2} setup.py install --skip-build --root %{buildroot} +mkdir -p ${RPM_BUILD_ROOT}/plugins/%{app_name} +install -m 644 dist/*.whl ${RPM_BUILD_ROOT}/plugins/%{app_name}/ + +%files +%{python2_sitelib}/%{sname} +%{python2_sitelib}/%{sname}-*.egg-info + +%package wheels +Summary: %{name} wheels + +%description wheels +Contains python wheels for %{name} + +%files wheels +/plugins/* diff --git a/python-k8sapp-snmp/k8sapp_snmp/.gitignore b/python-k8sapp-snmp/k8sapp_snmp/.gitignore new file mode 100644 index 0000000..78c457c --- /dev/null +++ b/python-k8sapp-snmp/k8sapp_snmp/.gitignore @@ -0,0 +1,35 @@ +# Compiled files +*.py[co] +*.a +*.o +*.so + +# Sphinx +_build +doc/source/api/ + +# Packages/installer info +*.egg +*.egg-info +dist +build +eggs +parts +var +sdist +develop-eggs +.installed.cfg + +# Other +*.DS_Store +.stestr +.testrepository +.tox +.venv +.*.swp +.coverage +bandit.xml +cover +AUTHORS +ChangeLog +*.sqlite diff --git a/python-k8sapp-snmp/k8sapp_snmp/.stestr.conf b/python-k8sapp-snmp/k8sapp_snmp/.stestr.conf new file mode 100644 index 0000000..1a33049 --- /dev/null +++ b/python-k8sapp-snmp/k8sapp_snmp/.stestr.conf @@ -0,0 +1,4 @@ +[DEFAULT] +test_path=./k8sapp_cert_manager/tests +top_dir=./k8sapp_cert_manager +#parallel_class=True diff --git a/python-k8sapp-snmp/k8sapp_snmp/LICENSE b/python-k8sapp-snmp/k8sapp_snmp/LICENSE new file mode 100644 index 0000000..d6e2801 --- /dev/null +++ b/python-k8sapp-snmp/k8sapp_snmp/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2019 Wind River Systems, Inc. + + 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. diff --git a/python-k8sapp-snmp/k8sapp_snmp/README.rst b/python-k8sapp-snmp/k8sapp_snmp/README.rst new file mode 100644 index 0000000..3ad35ee --- /dev/null +++ b/python-k8sapp-snmp/k8sapp_snmp/README.rst @@ -0,0 +1,7 @@ +k8sapp-snmp +=================== + +This project contains StarlingX Kubernetes application specific python plugins +for the snmp. These plugins are required to integrate the oidc +authorization application into the StarlingX application framework and to +support the various StarlingX deployments. diff --git a/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/__init__.py b/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/armada/__init__.py b/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/armada/__init__.py new file mode 100644 index 0000000..5587e5f --- /dev/null +++ b/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/armada/__init__.py @@ -0,0 +1,19 @@ +# +# Copyright (c) 2020 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# + +import yaml + + +class quoted_str(str): + pass + + +# force strings to be single-quoted to avoid interpretation as numeric values +def quoted_presenter(dumper, data): + return dumper.represent_scalar(u'tag:yaml.org,2002:str', data, style="'") + + +yaml.add_representer(quoted_str, quoted_presenter) diff --git a/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/armada/manifest_snmp.py b/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/armada/manifest_snmp.py new file mode 100644 index 0000000..cdcffe9 --- /dev/null +++ b/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/armada/manifest_snmp.py @@ -0,0 +1,35 @@ +# +# Copyright (c) 2020 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# +# All Rights Reserved. +# + +""" System inventory Armada manifest operator.""" + +from sysinv.common import constants +from sysinv.helm import manifest_base as base + +class SnmpArmadaManifestOperator(base.ArmadaManifestOperator): + + APP = constants.HELM_APP_SNMP + ARMADA_MANIFEST = 'armada-manifest' + + def app_lifecycle_actions(self, context, conductor_obj, dbapi, operation, relative_timing): + if operation == constants.APP_APPLY_OP or operation == constants.APP_REMOVE_OP: + if relative_timing == constants.APP_LIFECYCLE_POST: + config_dict = { + "personalities": [constants.CONTROLLER], + "classes": ['platform::fm::runtime'] + } + config_uuid = conductor_obj._config_update_hosts(context, config_dict['personalities']) + conductor_obj._config_apply_runtime_manifest(context, config_uuid, config_dict) + + def platform_mode_manifest_updates(self, dbapi, mode): + """ Update the application manifest based on the platform + + :param dbapi: DB api object + :param mode: mode to control how to apply the application manifest + """ + pass diff --git a/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/common/__init__.py b/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/common/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/common/constants.py b/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/common/constants.py new file mode 100644 index 0000000..1784e26 --- /dev/null +++ b/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/common/constants.py @@ -0,0 +1,9 @@ +# +# Copyright (c) 2020 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# + +# Helm: Supported charts: +# These values match the names in the chart package's Chart.yaml +HELM_CHART_SNMP = 'snmp' diff --git a/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/helm/__init__.py b/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/helm/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/helm/snmp.py b/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/helm/snmp.py new file mode 100644 index 0000000..3d250c4 --- /dev/null +++ b/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/helm/snmp.py @@ -0,0 +1,73 @@ +# +# Copyright (c) 2020 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# + +from k8sapp_snmp.common import constants as app_constants + +from sysinv.common import constants +from sysinv.common import exception + +from sysinv.helm import base +from sysinv.helm import common +from sysinv.puppet import openstack + +from oslo_log import log as logging + + +class SnmpHelm(base.BaseHelm, openstack.OpenstackBasePuppet): + """Class to encapsulate helm operations for the SNMP chart""" + + SUPPORTED_NAMESPACES = base.BaseHelm.SUPPORTED_NAMESPACES + \ + [common.HELM_NS_KUBE_SYSTEM] + SUPPORTED_APP_NAMESPACES = { + constants.HELM_APP_SNMP: + base.BaseHelm.SUPPORTED_NAMESPACES + [common.HELM_NS_KUBE_SYSTEM], + } + + CHART = app_constants.HELM_CHART_SNMP + + SERVICE_NAME = 'snmp' + SERVICE_FM_NAME = 'fm' + SERVICE_FM_PORT = 18002 + + def get_namespaces(self): + return self.SUPPORTED_NAMESPACES + + def get_public_url(self): + return self._format_public_endpoint(self.SERVICE_FM_PORT) + + def get_internal_url(self): + return self._format_private_endpoint(self.SERVICE_FM_PORT) + + def get_admin_url(self): + return self._format_admin_endpoint(self.SERVICE_FM_PORT) + + def get_secure_system_config(self): + config = { + 'fm::database_connection': + self._format_database_connection(self.SERVICE_FM_NAME), + } + + return config + + def get_overrides(self, namespace=None): + + db_url = self.get_secure_system_config()['fm::database_connection'] + + overrides = { + common.HELM_NS_KUBE_SYSTEM: { + 'configmap': { + 'connection': str(db_url) + }, + } + } + + if namespace in self.SUPPORTED_NAMESPACES: + return overrides[namespace] + elif namespace: + raise exception.InvalidHelmNamespace(chart=self.CHART, + namespace=namespace) + else: + return overrides diff --git a/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/tests/__init__.py b/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/tests/test_plugins.py b/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/tests/test_plugins.py new file mode 100644 index 0000000..97fe5bf --- /dev/null +++ b/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/tests/test_plugins.py @@ -0,0 +1,42 @@ +# +# Copyright (c) 2020 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# + +from sysinv.common import constants +from sysinv.tests.db import base as dbbase +from sysinv.tests.helm.test_helm import HelmOperatorTestSuiteMixin + + +class K8SAppSnmpAppMixin(object): + app_name = constants.HELM_APP_SNMP + path_name = app_name + '.tgz' + + def setUp(self): + super(K8SAppSnmpAppMixin, self).setUp() + + +# Test Configuration: +# - Controller +# - IPv6 +# - Ceph Storage +# - snmp app +class K8sAppSnmpControllerTestCase(K8SAppSnmpAppMixin, + dbbase.BaseIPv6Mixin, + dbbase.BaseCephStorageBackendMixin, + HelmOperatorTestSuiteMixin, + dbbase.ControllerHostTestCase): + pass + + +# Test Configuration: +# - AIO +# - IPv4 +# - Ceph Storage +# - snmp app +class K8SAppSnmpAIOTestCase(K8SAppSnmpAppMixin, + dbbase.BaseCephStorageBackendMixin, + HelmOperatorTestSuiteMixin, + dbbase.AIOSimplexHostTestCase): + pass diff --git a/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/tests/test_snmp.py b/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/tests/test_snmp.py new file mode 100644 index 0000000..e078299 --- /dev/null +++ b/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/tests/test_snmp.py @@ -0,0 +1,26 @@ +# Copyright (c) 2020 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# +from k8sapp_snmp.common import constants as app_constants +from k8sapp_snmp.tests import test_plugins + +from sysinv.db import api as dbapi +from sysinv.helm import common + +from sysinv.tests.db import base as dbbase +from sysinv.tests.db import utils as dbutils +from sysinv.tests.helm import base + + +class SnmpTestCase(test_plugins.K8SAppSnmpAppMixin, + base.HelmTestCaseMixin): + + def setUp(self): + super(SnmpTestCase, self).setUp() + self.app = dbutils.create_test_app(name='snmp') + self.dbapi = dbapi.get_instance() + +class SnmpTestCase(SnmpTestCase, dbbase.ProvisionedControllerHostTestCase): + pass + diff --git a/python-k8sapp-snmp/k8sapp_snmp/pylint.rc b/python-k8sapp-snmp/k8sapp_snmp/pylint.rc new file mode 100644 index 0000000..6e869c3 --- /dev/null +++ b/python-k8sapp-snmp/k8sapp_snmp/pylint.rc @@ -0,0 +1,238 @@ +[MASTER] +# Specify a configuration file. +rcfile=pylint.rc + +# Python code to execute, usually for sys.path manipulation such as +# pygtk.require(). +#init-hook= + +# Add files or directories to the blacklist. Should be base names, not paths. +ignore=tests + +# Pickle collected data for later comparisons. +persistent=yes + +# List of plugins (as comma separated values of python modules names) to load, +# usually to register additional checkers. +load-plugins= + +# Use multiple processes to speed up Pylint. +jobs=4 + +# Allow loading of arbitrary C extensions. Extensions are imported into the +# active Python interpreter and may run arbitrary code. +unsafe-load-any-extension=no + +# A comma-separated list of package or module names from where C extensions may +# be loaded. Extensions are loading into the active Python interpreter and may +# run arbitrary code +extension-pkg-whitelist=lxml.etree,greenlet + + + +[MESSAGES CONTROL] +# Enable the message, report, category or checker with the given id(s). You can +# either give multiple identifier separated by comma (,) or put this option +# multiple time. +#enable= + +# Disable the message, report, category or checker with the given id(s). You +# can either give multiple identifier separated by comma (,) or put this option +# multiple time (only on the command line, not in the configuration file where +# it should appear only once). +# See "Messages Control" section of +# https://pylint.readthedocs.io/en/latest/user_guide +# We are disabling (C)onvention +# We are disabling (R)efactor +disable=C, R + +[REPORTS] +# Set the output format. Available formats are text, parseable, colorized, msvs +# (visual studio) and html +output-format=text + +# Put messages in a separate file for each module / package specified on the +# command line instead of printing them on stdout. Reports (if any) will be +# written in a file name "pylint_global.[txt|html]". +files-output=no + +# Tells whether to display a full report or only the messages +reports=yes + +# Python expression which should return a note less than 10 (10 is the highest +# note). You have access to the variables errors warning, statement which +# respectively contain the number of errors / warnings messages and the total +# number of statements analyzed. This is used by the global evaluation report +# (RP0004). +evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) + + +[SIMILARITIES] +# Minimum lines number of a similarity. +min-similarity-lines=4 + +# Ignore comments when computing similarities. +ignore-comments=yes + +# Ignore docstrings when computing similarities. +ignore-docstrings=yes + + +[FORMAT] +# Maximum number of characters on a single line. +max-line-length=85 + +# Maximum number of lines in a module +max-module-lines=1000 + +# String used as indentation unit. This is usually 4 spaces or "\t" (1 tab). +indent-string=' ' + + +[TYPECHECK] +# Tells whether missing members accessed in mixin class should be ignored. A +# mixin class is detected if its name ends with "mixin" (case insensitive). +ignore-mixin-members=yes + +# List of module names for which member attributes should not be checked +# (useful for modules/projects where namespaces are manipulated during runtime +# and thus existing member attributes cannot be deduced by static analysis +ignored-modules=distutils,eventlet.green.subprocess,six,six.moves + +# List of classes names for which member attributes should not be checked +# (useful for classes with attributes dynamically set). +# pylint is confused by sqlalchemy Table, as well as sqlalchemy Enum types +# ie: (unprovisioned, identity) +# LookupDict in requests library confuses pylint +ignored-classes=SQLObject, optparse.Values, thread._local, _thread._local, + Table, unprovisioned, identity, LookupDict + +# List of members which are set dynamically and missed by pylint inference +# system, and so shouldn't trigger E0201 when accessed. Python regular +# expressions are accepted. +generated-members=REQUEST,acl_users,aq_parent + + +[BASIC] +# List of builtins function names that should not be used, separated by a comma +bad-functions=map,filter,apply,input + +# Regular expression which should only match correct module names +module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ + +# Regular expression which should only match correct module level names +const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ + +# Regular expression which should only match correct class names +class-rgx=[A-Z_][a-zA-Z0-9]+$ + +# Regular expression which should only match correct function names +function-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression which should only match correct method names +method-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression which should only match correct instance attribute names +attr-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression which should only match correct argument names +argument-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression which should only match correct variable names +variable-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression which should only match correct list comprehension / +# generator expression variable names +inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ + +# Good variable names which should always be accepted, separated by a comma +good-names=i,j,k,ex,Run,_ + +# Bad variable names which should always be refused, separated by a comma +bad-names=foo,bar,baz,toto,tutu,tata + +# Regular expression which should only match functions or classes name which do +# not require a docstring +no-docstring-rgx=__.*__ + + +[MISCELLANEOUS] +# List of note tags to take in consideration, separated by a comma. +notes=FIXME,XXX,TODO + + +[VARIABLES] +# Tells whether we should check for unused import in __init__ files. +init-import=no + +# A regular expression matching the beginning of the name of dummy variables +# (i.e. not used). +dummy-variables-rgx=_|dummy + +# List of additional names supposed to be defined in builtins. Remember that +# you should avoid to define new builtins when possible. +additional-builtins= + + +[IMPORTS] +# Deprecated modules which should not be used, separated by a comma +deprecated-modules=regsub,string,TERMIOS,Bastion,rexec + +# Create a graph of every (i.e. internal and external) dependencies in the +# given file (report RP0402 must not be disabled) +import-graph= + +# Create a graph of external dependencies in the given file (report RP0402 must +# not be disabled) +ext-import-graph= + +# Create a graph of internal dependencies in the given file (report RP0402 must +# not be disabled) +int-import-graph= + + +[DESIGN] +# Maximum number of arguments for function / method +max-args=5 + +# Argument names that match this expression will be ignored. Default to name +# with leading underscore +ignored-argument-names=_.* + +# Maximum number of locals for function / method body +max-locals=15 + +# Maximum number of return / yield for function / method body +max-returns=6 + +# Maximum number of branch for function / method body +max-branchs=12 + +# Maximum number of statements in function / method body +max-statements=50 + +# Maximum number of parents for a class (see R0901). +max-parents=7 + +# Maximum number of attributes for a class (see R0902). +max-attributes=7 + +# Minimum number of public methods for a class (see R0903). +min-public-methods=2 + +# Maximum number of public methods for a class (see R0904). +max-public-methods=20 + + +[CLASSES] +# List of method names used to declare (i.e. assign) instance attributes. +defining-attr-methods=__init__,__new__,setUp + +# List of valid names for the first argument in a class method. +valid-classmethod-first-arg=cls + + +[EXCEPTIONS] +# Exceptions that will emit a warning when being caught. Defaults to +# "Exception" +overgeneral-exceptions=Exception diff --git a/python-k8sapp-snmp/k8sapp_snmp/requirements.txt b/python-k8sapp-snmp/k8sapp_snmp/requirements.txt new file mode 100644 index 0000000..e71df21 --- /dev/null +++ b/python-k8sapp-snmp/k8sapp_snmp/requirements.txt @@ -0,0 +1,2 @@ +pbr>=2.0.0 +PyYAML==3.10 diff --git a/python-k8sapp-snmp/k8sapp_snmp/setup.cfg b/python-k8sapp-snmp/k8sapp_snmp/setup.cfg new file mode 100644 index 0000000..6d90077 --- /dev/null +++ b/python-k8sapp-snmp/k8sapp_snmp/setup.cfg @@ -0,0 +1,42 @@ +[metadata] +name = k8sapp-snmp +summary = StarlingX sysinv extensions for snmp +long_description = file: README.rst +long_description_content_type = text/x-rst +license = Apache 2.0 +author = StarlingX +author-email = starlingx-discuss@lists.starlingx.io +home-page = https://www.starlingx.io/ +classifier = + Environment :: OpenStack + Intended Audience :: Information Technology + Intended Audience :: System Administrators + License :: OSI Approved :: Apache Software License + Operating System :: POSIX :: Linux + Programming Language :: Python + Programming Language :: Python :: 2 + Programming Language :: Python :: 2.7 + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.4 + Programming Language :: Python :: 3.5 + +[files] +packages = + k8sapp_snmp + +[global] +setup-hooks = + pbr.hooks.setup_hook + +[entry_points] +systemconfig.helm_applications = + snmp = systemconfig.helm_plugins.snmp + +systemconfig.helm_plugins.snmp = + 001_snmp = k8sapp_snmp.helm.snmp:SnmpHelm + +systemconfig.armada.manifest_ops = + snmp = k8sapp_snmp.armada.manifest_snmp:SnmpArmadaManifestOperator + +[wheel] +universal = 1 diff --git a/python-k8sapp-snmp/k8sapp_snmp/setup.py b/python-k8sapp-snmp/k8sapp_snmp/setup.py new file mode 100644 index 0000000..e8729b8 --- /dev/null +++ b/python-k8sapp-snmp/k8sapp_snmp/setup.py @@ -0,0 +1,12 @@ +# +# Copyright (c) 2020 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# + +import setuptools + + +setuptools.setup( + setup_requires=['pbr>=2.0.0'], + pbr=True) diff --git a/python-k8sapp-snmp/k8sapp_snmp/test-requirements.txt b/python-k8sapp-snmp/k8sapp_snmp/test-requirements.txt new file mode 100644 index 0000000..e248a36 --- /dev/null +++ b/python-k8sapp-snmp/k8sapp_snmp/test-requirements.txt @@ -0,0 +1,26 @@ +# The order of packages is significant, because pip processes them in the order +# of appearance. Changing the order has an impact on the overall integration +# process, which may cause wedges in the gate later. +flake8<3.8.0 +pycodestyle<2.6.0 # MIT License +hacking>=1.1.0,<=2.0.0 # Apache-2.0 +coverage>=3.6 +discover +fixtures>=3.0.0 # Apache-2.0/BSD +mock>=2.0.0 # BSD +passlib>=1.7.0 +psycopg2-binary +python-subunit>=0.0.18 +requests-mock>=0.6.0 # Apache-2.0 +sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2 +oslosphinx<2.6.0,>=2.5.0 # Apache-2.0 +oslotest>=3.2.0 # Apache-2.0 +stestr>=1.0.0 # Apache-2.0 +testrepository>=0.0.18 +testtools!=1.2.0,>=0.9.36 +tempest-lib<0.5.0,>=0.4.0 +ipaddr +pytest +pyudev +migrate +markupsafe diff --git a/python-k8sapp-snmp/k8sapp_snmp/tox.ini b/python-k8sapp-snmp/k8sapp_snmp/tox.ini new file mode 100644 index 0000000..fa07dae --- /dev/null +++ b/python-k8sapp-snmp/k8sapp_snmp/tox.ini @@ -0,0 +1,131 @@ +[tox] +envlist = flake8,py27,py36,pylint,bandit +minversion = 1.6 +# skipsdist = True +#,pip-missing-reqs + +# tox does not work if the path to the workdir is too long, so move it to /tmp +toxworkdir = /tmp/{env:USER}_k8ssnmptox +stxdir = {toxinidir}/../../.. +distshare={toxworkdir}/.tox/distshare + +[testenv] +# usedevelop = True +# enabling usedevelop results in py27 develop-inst: +# Exception: Versioning for this project requires either an sdist tarball, +# or access to an upstream git repository. +# Note. site-packages is true and rpm-python must be yum installed on your dev machine. +sitepackages = True + +# tox is silly... these need to be separated by a newline.... +whitelist_externals = bash + find + +install_command = pip install \ + -v -v -v \ + -c{toxinidir}/upper-constraints.txt \ + -c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/openstack/requirements/raw/branch/stable/stein/upper-constraints.txt} \ + {opts} {packages} + +# Note the hash seed is set to 0 until can be tested with a +# random hash seed successfully. +setenv = VIRTUAL_ENV={envdir} + PYTHONHASHSEED=0 + PYTHONDONTWRITEBYTECODE=1 + OS_TEST_PATH=./k8sapp_snmp/tests + LANG=en_US.UTF-8 + LANGUAGE=en_US:en + LC_ALL=C + EVENTS_YAML=./k8sapp_snmp/tests/events_for_testing.yaml + SYSINV_TEST_ENV=True + TOX_WORK_DIR={toxworkdir} + PYLINTHOME={toxworkdir} + +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + -e{[tox]stxdir}/config/sysinv/sysinv/sysinv + -e{[tox]stxdir}/config/tsconfig/tsconfig + -e{[tox]stxdir}/fault/fm-api + -e{[tox]stxdir}/fault/python-fmclient/fmclient + -e{[tox]stxdir}/utilities/ceph/python-cephclient/python-cephclient + -e{[tox]stxdir}/update/cgcs-patch/cgcs-patch + + +commands = + find . -type f -name "*.pyc" -delete + +[flake8] +exclude = build,dist,tools,.eggs +max-line-length=120 + +[testenv:flake8] +basepython = python3 +deps = -r{toxinidir}/test-requirements.txt + flake8-bugbear +commands = + flake8 {posargs} . + +[testenv:py27] +basepython = python2.7 +commands = + {[testenv]commands} + stestr run {posargs} + stestr slowest + +[testenv:py36] +basepython = python3.6 +commands = + {[testenv]commands} + stestr run {posargs} + stestr slowest + +[testenv:pep8] +# testenv:flake8 clone +basepython = {[testenv:flake8]basepython} +deps = {[testenv:flake8]deps} +commands = {[testenv:flake8]commands} + +[testenv:venv] +commands = {posargs} + +[bandit] + +[testenv:bandit] +basepython = python3 +deps = -r{toxinidir}/test-requirements.txt + bandit + +commands = bandit --ini tox.ini -n 5 -r k8sapp_snmp + +[testenv:pylint] +basepython = python2.7 +sitepackages = False + +deps = {[testenv]deps} + pylint +commands = + pylint {posargs} k8sapp_snmp --rcfile=./pylint.rc + +[testenv:cover] +basepython = python2.7 +deps = {[testenv]deps} +setenv = {[testenv]setenv} + PYTHON=coverage run --parallel-mode + +commands = + {[testenv]commands} + coverage erase + stestr run {posargs} + coverage combine + coverage html -d cover + coverage xml -o cover/coverage.xml + coverage report + +[testenv:pip-missing-reqs] +# do not install test-requirements as that will pollute the virtualenv for +# determining missing packages +# this also means that pip-missing-reqs must be installed separately, outside +# of the requirements.txt files +deps = pip_missing_reqs + -rrequirements.txt +commands=pip-missing-reqs -d --ignore-file=/k8sapp_snmp/tests k8sapp_snmp diff --git a/python-k8sapp-snmp/k8sapp_snmp/upper-constraints.txt b/python-k8sapp-snmp/k8sapp_snmp/upper-constraints.txt new file mode 100644 index 0000000..9c30188 --- /dev/null +++ b/python-k8sapp-snmp/k8sapp_snmp/upper-constraints.txt @@ -0,0 +1 @@ +# Override upstream constraints based on StarlingX load diff --git a/stx-snmp-helm/centos/docker/Dockerfile b/stx-snmp-helm/centos/docker/Dockerfile deleted file mode 100644 index e4d0438..0000000 --- a/stx-snmp-helm/centos/docker/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM centos:8 -RUN yum -y update -RUN yum -y install net-snmp - -EXPOSE 161/udp -CMD [ "/usr/sbin/snmpd", "-f"] diff --git a/stx-snmp-helm/centos/docker/stx-fm-subagent/Dockerfile b/stx-snmp-helm/centos/docker/stx-fm-subagent/Dockerfile new file mode 100644 index 0000000..3d5ca8a --- /dev/null +++ b/stx-snmp-helm/centos/docker/stx-fm-subagent/Dockerfile @@ -0,0 +1,45 @@ +ARG BASE +FROM ${BASE} AS stx +RUN yum -y update +RUN yum -y install\ + fm-common \ + fm-common-dev + +FROM centos:7 AS base + +RUN yum -y install\ + net-snmp \ + net-snmp-utils \ + python3-setuptools \ + libpython2.7 \ + python3-devel \ + postgresql + +WORKDIR /home/sub-agent +COPY --from=stx /usr/lib64/libfmcommon.so.1.0 /usr/lib64/ + +RUN ln -s /usr/lib64/libfmcommon.so.1.0 /usr/lib64/libfmcommon.so +RUN ln -s /usr/lib64/libfmcommon.so.1.0 /usr/lib64/libfmcommon.so.1 + +FROM base AS builder +RUN yum -y install\ + net-snmp-libs \ + net-snmp-devel\ + gcc \ + make \ + uuid + +RUN ln -s /usr/lib64/libuuid.so.1.3.0 /usr/lib64/libuuid.so +COPY Makefile . +COPY ./src/* ./src/ +COPY --from=stx /usr/include/fmDbAPI.h /usr/include/ +COPY --from=stx /usr/include/fmAPI.h /usr/include/ +RUN make + + +FROM base AS deployment-env + +COPY --from=builder /home/sub-agent/snmpSubAgent . +COPY bootstrap.sh . +RUN chmod 755 bootstrap.sh +ENTRYPOINT ["./bootstrap.sh"] diff --git a/stx-snmp-helm/centos/docker/stx-fm-subagent/Makefile b/stx-snmp-helm/centos/docker/stx-fm-subagent/Makefile new file mode 100644 index 0000000..e029200 --- /dev/null +++ b/stx-snmp-helm/centos/docker/stx-fm-subagent/Makefile @@ -0,0 +1,37 @@ +# +# SPDX-License-Identifier: Apache-2.0 +# + +MAJOR ?= 1 +MINOR ?= 0 +PATCH ?= 0 +MIBVER ?= 2.0 + +CC=gcc +DEST_DIR ?= / +DATA_DIR ?= /usr/share +LIB_DIR ?= /usr/lib64 +BIN=./bin +SOURCE=./src + +SRCS = $(SOURCE)/snmpSubAgent.c $(SOURCE)/snmpActiveAlarms.c $(SOURCE)/snmpAgentPlugin.c $(SOURCE)/snmpEventLogs.c +OBJS = $(SRCS:.c=.o) +LDLIBS = -L/lib/x86_64-linux-gnu/ -L/usr/lib64 -lfmcommon -lnetsnmp +LDLIBS += -lnetsnmpagent -luuid -lnetsnmpmibs -lnetsnmphelpers + +INCLUDES += -I./ -I/include/net-snmp -I$(SOURCE) -I/usr/include/ +CCFLAGS = -fPIC -g -O2 -Wall -Werror -Wformat -Wformat-security + +TARGET = snmpSubAgent + +.c.o: + $(CC) $(CCFLAGS) $(INCLUDES) -c $< -o $@ + +$(TARGET): $(SRCS) + $(CC) $(CCFLAGS) $(INCLUDES) -o $@ $^ $(LDLIBS) + +clean: + @rm -f $(OBJ) *.o $(TARGET) + +install: + echo "install stage" diff --git a/stx-snmp-helm/centos/docker/stx-fm-subagent/bootstrap.sh b/stx-snmp-helm/centos/docker/stx-fm-subagent/bootstrap.sh new file mode 100755 index 0000000..ac771e6 --- /dev/null +++ b/stx-snmp-helm/centos/docker/stx-fm-subagent/bootstrap.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -u + +# Internal params +RUN_CMD="./snmpSubAgent -f -x tcp:localhost:705" + +# Launch +$RUN_CMD + diff --git a/stx-snmp-helm/centos/docker/stx-fm-subagent/src/snmpActiveAlarms.c b/stx-snmp-helm/centos/docker/stx-fm-subagent/src/snmpActiveAlarms.c new file mode 100644 index 0000000..f03b399 --- /dev/null +++ b/stx-snmp-helm/centos/docker/stx-fm-subagent/src/snmpActiveAlarms.c @@ -0,0 +1,266 @@ +/* +* Copyright (c) 2020 Wind River Systems, Inc. +* +* SPDX-License-Identifier: Apache-2.0 +* +*/ + +#include <stddef.h> +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> +#include <time.h> +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/net-snmp-features.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <fmDbAPI.h> +#include "snmpAgentPlugin.h" + + +netsnmp_feature_require(date_n_time) + +#define MINLOADFREQ 1 /* min reload frequency in seconds */ + +static long Active_Alarm_Count = 0; +static struct activealarm *alarm_list; +static struct activealarm *alarmaddr, savealarm, *savealarmaddr; +static int saveIndex = 0; +static char saveUuid[36]; +static long LastLoad = 0; /* ET in secs at last table load */ +extern long long_return; + + +int Active_Alarm_Get_Count(void); + +static void +Alarm_Scan_Init() +{ + struct timeval et; /* elapsed time */ + struct activealarm **activealarm_ptr; + SFmAlarmQueryT aquery; + size_t i = 0; + + saveIndex = 0; + netsnmp_get_monotonic_clock(&et); + if ( et.tv_sec < LastLoad + MINLOADFREQ ) { + DEBUGMSG(("cgtsAgentPlugin", "Skip reload" )); + alarmaddr = alarm_list; + return; + } + LastLoad = et.tv_sec; + + /* + * free old list: + */ + while (alarm_list) { + struct activealarm *old = alarm_list; + alarm_list = alarm_list->next; + free(old); + } + alarmaddr = 0; + activealarm_ptr = &alarm_list; + + /* + * query active alarm list from DB + */ + if (fm_snmp_util_get_all_alarms(getAlarmSession(), &aquery) != true){ + DEBUGMSG(("cgtsAgentPlugin", "get_all_alarms from db failed\n")); + return; + } + DEBUGMSG(("cgtsAgentPlugin", "get_all_alarms returns %lu alarms\n", aquery.num)); + for (i = 0; i < aquery.num; ++i){ + struct activealarm *almnew; + /*populate alarm_list*/ + almnew = (struct activealarm *) calloc(1, sizeof(struct activealarm)); + if (almnew == NULL) + break; /* alloc error */ + *activealarm_ptr = almnew; + activealarm_ptr = &almnew->next; + memset(&almnew->alarmdata, 0 , sizeof(almnew->alarmdata)); + memcpy(&almnew->alarmdata, aquery.alarm + i, sizeof(almnew->alarmdata)); + } + alarmaddr = alarm_list; + free(aquery.alarm); +} + +static int +Alarm_Scan_NextAlarm(int *Index, + char *Name, + struct activealarm *Aalm) +{ + struct activealarm alm; + while (alarmaddr) { + alm = *alarmaddr; + strlcpy(saveUuid, alm.alarmdata.uuid, sizeof(saveUuid)); + if (Index) + *Index = ++saveIndex; + if (Aalm) + *Aalm = alm; + if (Name) + strcpy(Name, saveUuid); + + savealarm = alm; + savealarmaddr = alarmaddr; + alarmaddr = alm.next; + return 1; + } + return 0; +} + +static int +Alarm_Scan_By_Index(int Index, + char *Name, + struct activealarm *Aalm) +{ + int i; + + DEBUGMSGTL(("cgtsAgentPlugin","Alarm_Scan_By_Index")); + Alarm_Scan_Init(); + while (Alarm_Scan_NextAlarm(&i, Name, Aalm)) { + if (i == Index) + break; + } + if (i != Index) + return (-1); /* Error, doesn't exist */ + return (0); /* DONE */ +} + +static int +header_alarmEntry(struct variable *vp, + oid * name, + size_t * length, + int exact, size_t * var_len, + WriteMethod ** write_method) +{ +#define ALM_ENTRY_NAME_LENGTH 14 + oid newname[MAX_OID_LEN]; + register int index; + int result, count; + + DEBUGMSGTL(("cgtsAgentPlugin", "header_alarmEntry: ")); + DEBUGMSGOID(("cgtsAgentPlugin", name, *length)); + DEBUGMSG(("cgtsAgentPlugin", "exact %d\n", exact)); + + memcpy((char *) newname, (char *) vp->name, + (int) vp->namelen * sizeof(oid)); + /* + * find "next" alarm + */ + count = Active_Alarm_Get_Count(); + DEBUGMSG(("cgtsAgentPlugin", "count %d\n", count)); + for (index = 1; index <= count; index++) { + newname[ALM_ENTRY_NAME_LENGTH] = (oid) index; + result = + snmp_oid_compare(name, *length, newname, + (int) vp->namelen + 1); + if ((exact && (result == 0)) || (!exact && (result < 0))) + break; + } + if (index > count) { + DEBUGMSGTL(("cgtsAgentPlugin", "... index out of range\n")); + return MATCH_FAILED; + } + + memcpy((char *) name, (char *) newname, + ((int) vp->namelen + 1) * sizeof(oid)); + *length = vp->namelen + 1; + *write_method = 0; + *var_len = sizeof(long); /* default to 'long' results */ + + DEBUGMSGTL(("cgtsAgentPlugin", "... get ALM data ")); + DEBUGMSGOID(("cgtsAgentPlugin", name, *length)); + DEBUGMSG(("cgtsAgentPlugin", "\n")); + + DEBUGMSG(("cgtsAgentPlugin","Return index: %d\n", index)); + return index; +} + + +int +Active_Alarm_Get_Count(void) +{ + static time_t scan_time = 0; + time_t time_now = time(NULL); + + if (!Active_Alarm_Count || (time_now > scan_time + 60)) { + scan_time = time_now; + Alarm_Scan_Init(); + Active_Alarm_Count = 0; + while (Alarm_Scan_NextAlarm(NULL, NULL, NULL) != 0) { + Active_Alarm_Count++; + } + } + return (Active_Alarm_Count); +} + +u_char * +var_alarms(struct variable *vp, + oid * name, + size_t * length, + int exact, size_t * var_len, + WriteMethod ** write_method) +{ + static struct activealarm alrm; + static char Name[36]; + char *cp; + int index = 0; + + DEBUGMSGTL(("cgtsAgentPlugin", "var_alarms")); + index = header_alarmEntry(vp, name, length, exact, var_len, write_method); + if (index == MATCH_FAILED) + return NULL; + + Alarm_Scan_By_Index(index, Name, &alrm); + + switch (vp->magic) { + case ALARM_INDEX: + long_return = index; + return (u_char *) & long_return; + case ALARM_UUID: + cp = Name; + *var_len = strlen(cp); + return (u_char *) cp; + case ALARM_ID: + cp = alrm.alarmdata.alarm_id; + *var_len = strlen(cp); + return (u_char *) cp; + case ALARM_INSTANCE_ID: + cp = alrm.alarmdata.entity_instance_id; + *var_len = strlen(cp); + return (u_char *) cp; + case ALARM_TIME:{ + time_t when = alrm.alarmdata.timestamp/SECOND_PER_MICROSECOND; + cp = (char *) date_n_time(&when, var_len ); + return (u_char *) cp; + } + case ALARM_SEVERITY: + long_return = alrm.alarmdata.severity; + return (u_char *) & long_return; + case ALARM_REASONTEXT: + cp = alrm.alarmdata.reason_text; + *var_len = strlen(cp); + return (u_char *) cp; + case ALARM_EVENTTYPE: + long_return = alrm.alarmdata.alarm_type; + return (u_char *) & long_return; + case ALARM_PROBABLECAUSE: + long_return = alrm.alarmdata.probable_cause; + return (u_char *) & long_return; + case ALARM_REPAIRACTION: + cp = alrm.alarmdata.proposed_repair_action; + *var_len = strlen(cp); + return (u_char *) cp; + case ALARM_SERVICEAFFECTING: + long_return = alrm.alarmdata.service_affecting; + return (u_char *) & long_return; + case ALARM_SUPPRESSION: + long_return = alrm.alarmdata.suppression; + return (u_char *) & long_return; + default: + DEBUGMSGTL(("snmpd", "unknown sub-id %d in var_alarms\n", + vp->magic)); + } + return NULL; +} + diff --git a/stx-snmp-helm/centos/docker/stx-fm-subagent/src/snmpAgentPlugin.c b/stx-snmp-helm/centos/docker/stx-fm-subagent/src/snmpAgentPlugin.c new file mode 100644 index 0000000..e20c38a --- /dev/null +++ b/stx-snmp-helm/centos/docker/stx-fm-subagent/src/snmpAgentPlugin.c @@ -0,0 +1,161 @@ +/* +* Copyright (c) 2020 Wind River Systems, Inc. +* +* SPDX-License-Identifier: Apache-2.0 +* +*/ + +#include <stddef.h> +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> +#include <time.h> +#include <stdbool.h> +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/net-snmp-features.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include "snmpAgentPlugin.h" + + +#define CGTS_ALM_TABLE_NAME "wrsAlarmActiveTable" +#define CGTS_EVENT_TABLE_NAME "wrsEventTable" + +#define _UNREGISTER_MIB(var, miboid) \ + do{ \ + size_t varsize = sizeof(struct variable2); \ + struct variable2 *vp; \ + oid myoid[MAX_OID_LEN]; \ + size_t length; \ + int i, result; \ + int numvars = sizeof(var)/varsize; \ + int miboidlen = sizeof(miboid)/sizeof(oid); \ + for (i=0; i < numvars; i++) { \ + vp = (struct variable2 *)((char *)var + varsize * i); \ + memcpy(myoid, miboid, miboidlen * sizeof(oid)); \ + memcpy(myoid+miboidlen, vp->name, vp->namelen * sizeof(oid)); \ + length = miboidlen + vp->namelen; \ + result = unregister_mib(myoid, length); \ + DEBUGMSGOID(("cgtsAgentPlugin", myoid, length)); \ + if (result != MIB_UNREGISTERED_OK) { \ + snmp_log(LOG_ERR, "%s: Unregistering failed:%d\n", \ + __FUNCTION__, result); \ + } else { \ + DEBUGMSGTL(("cgtsAgentPlugin", "Unregistering succeeded\n")); \ + } \ + } \ + }while(0); + + +static TFmAlarmSessionT alm_handle; + +/* + * * the OID we want to register our integer at. This should be the + * * OID node for the entire table. In our case this is the + * * wrsAlarmActiveTable oid definition + */ +oid cgtsAlarmTable_oid[] = + { 1, 3, 6, 1, 4, 1, 731, 1, 1, 1, 1, 1}; + +oid cgtsEventLogTable_oid[] = + { 1, 3, 6, 1, 4, 1, 731, 1, 1, 1, 1, 4}; + + +struct variable2 alarm_variables[] = { + {ALARM_INDEX, ASN_INTEGER, NETSNMP_OLDAPI_RONLY, + var_alarms, 2, {1, 1}}, + {ALARM_UUID, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, + var_alarms, 2, {1, 2}}, + {ALARM_ID, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, + var_alarms, 2, {1, 3}}, + {ALARM_INSTANCE_ID, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, + var_alarms, 2, {1, 4}}, + {ALARM_TIME, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, + var_alarms, 2, {1, 5}}, + {ALARM_SEVERITY, ASN_INTEGER, NETSNMP_OLDAPI_RONLY, + var_alarms, 2, {1, 6}}, + {ALARM_REASONTEXT, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, + var_alarms, 2, {1, 7}}, + {ALARM_EVENTTYPE, ASN_INTEGER, NETSNMP_OLDAPI_RONLY, + var_alarms, 2, {1, 8}}, + {ALARM_PROBABLECAUSE, ASN_INTEGER, NETSNMP_OLDAPI_RONLY, + var_alarms, 2, {1, 9}}, + {ALARM_REPAIRACTION , ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, + var_alarms, 2, {1, 10}}, + {ALARM_SERVICEAFFECTING, ASN_INTEGER, NETSNMP_OLDAPI_RONLY, + var_alarms, 2, {1, 11}}, + {ALARM_SUPPRESSION, ASN_INTEGER, NETSNMP_OLDAPI_RONLY, + var_alarms, 2, {1, 12}}, +}; + +struct variable2 event_log_variables[] = { + {EVENT_INDEX, ASN_INTEGER, NETSNMP_OLDAPI_RONLY, + var_events, 2, {1, 1}}, + {EVENT_UUID, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, + var_events, 2, {1, 2}}, + {EVENT_EVENT_ID, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, + var_events, 2, {1, 3}}, + {EVENT_STATE, ASN_INTEGER, NETSNMP_OLDAPI_RONLY, + var_events, 2, {1, 4}}, + {EVENT_INSTANCE_ID, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, + var_events, 2, {1, 5}}, + {EVENT_TIME, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, + var_events, 2, {1, 6}}, + {EVENT_SEVERITY, ASN_INTEGER, NETSNMP_OLDAPI_RONLY, + var_events, 2, {1, 7}}, + {EVENT_REASONTEXT, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, + var_events, 2, {1, 8}}, + {EVENT_EVENTTYPE, ASN_INTEGER, NETSNMP_OLDAPI_RONLY, + var_events, 2, {1, 9}}, + {EVENT_PROBABLECAUSE, ASN_INTEGER, NETSNMP_OLDAPI_RONLY, + var_events, 2, {1, 10}}, + {EVENT_REPAIRACTION , ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, + var_events, 2, {1, 11}}, + {EVENT_SERVICEAFFECTING, ASN_INTEGER, NETSNMP_OLDAPI_RONLY, + var_events, 2, {1, 12}}, + {EVENT_SUPPRESSION, ASN_INTEGER, NETSNMP_OLDAPI_RONLY, + var_events, 2, {1, 13}}, +}; + + +TFmAlarmSessionT getAlarmSession() +{ + return alm_handle; +} + +/* + * our initialization routine, automatically called by the agent + * (to get called, the function name must match init_FILENAME()) + */ +void +init_snmpAgentPlugin(void) +{ + snmp_log(LOG_INFO,"init_snmpAgentPlugin start\r\n"); + snmp_log(LOG_INFO,"MIB registration: %s\r\n",CGTS_ALM_TABLE_NAME); + REGISTER_MIB(CGTS_ALM_TABLE_NAME, alarm_variables, + variable2, cgtsAlarmTable_oid); + + snmp_log(LOG_INFO,"MIB registration: %s\r\n",CGTS_EVENT_TABLE_NAME); + REGISTER_MIB(CGTS_EVENT_TABLE_NAME, event_log_variables, + variable2, cgtsEventLogTable_oid); + + snmp_log(LOG_INFO,"get alarm database handler\r\n"); + if (fm_snmp_util_create_session(&alm_handle, NULL) != true){ + snmp_log(LOG_ERR,"failed to get alarm database handler\r\n"); + exit(-1); + } + /* + * a debugging statement. Run the agent with -DcgtsAgentPlugin to see + * the output of this debugging statement. + */ + DEBUGMSGTL(("cgtsAgentPlugin", "Done initializing.\n")); +} + +void +deinit_snmpAgentPlugin(void) +{ + snmp_log(LOG_INFO,"deinit_snmpAgentPlugin start\r\n"); + _UNREGISTER_MIB(alarm_variables, cgtsAlarmTable_oid); + _UNREGISTER_MIB(event_log_variables, cgtsEventLogTable_oid); + fm_snmp_util_destroy_session(alm_handle); +} diff --git a/stx-snmp-helm/centos/docker/stx-fm-subagent/src/snmpAgentPlugin.h b/stx-snmp-helm/centos/docker/stx-fm-subagent/src/snmpAgentPlugin.h new file mode 100644 index 0000000..240393f --- /dev/null +++ b/stx-snmp-helm/centos/docker/stx-fm-subagent/src/snmpAgentPlugin.h @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2020 Wind River Systems, Inc. +* +* SPDX-License-Identifier: Apache-2.0 +* +*/ + +#ifndef SNMPAGENTPLUGIN_H +#define SNMPAGENTPLUGIN_H + +#include <fmAPI.h> +#include <fmDbAPI.h> +#include <net-snmp/agent/snmp_vars.h> + +extern FindVarMethod var_alarms; + +extern FindVarMethod var_events; + +/* Active alarm Table */ +#define ALARM_INDEX 1 +#define ALARM_UUID 2 +#define ALARM_ID 3 +#define ALARM_INSTANCE_ID 4 +#define ALARM_TIME 5 +#define ALARM_SEVERITY 6 +#define ALARM_REASONTEXT 7 +#define ALARM_EVENTTYPE 8 +#define ALARM_PROBABLECAUSE 9 +#define ALARM_REPAIRACTION 10 +#define ALARM_SERVICEAFFECTING 11 +#define ALARM_SUPPRESSION 12 + +/* Event Log Table */ +#define EVENT_INDEX 1 +#define EVENT_UUID 2 +#define EVENT_EVENT_ID 3 +#define EVENT_STATE 4 +#define EVENT_INSTANCE_ID 5 +#define EVENT_TIME 6 +#define EVENT_SEVERITY 7 +#define EVENT_REASONTEXT 8 +#define EVENT_EVENTTYPE 9 +#define EVENT_PROBABLECAUSE 10 +#define EVENT_REPAIRACTION 11 +#define EVENT_SERVICEAFFECTING 12 +#define EVENT_SUPPRESSION 13 + + +#define SECOND_PER_MICROSECOND 1000000 + +struct activealarm { + SFmAlarmDataT alarmdata; + struct activealarm *next; +}; + +/* + * function declarations + */ +#ifdef __cplusplus +extern "C" { +#endif +void init_snmpAgentPlugin(void); +void deinit_snmpAgentPlugin(void); +TFmAlarmSessionT getAlarmSession(); +#ifdef __cplusplus +} +#endif + +#endif /* SNMPAGENTPLUGIN_H */ diff --git a/stx-snmp-helm/centos/docker/stx-fm-subagent/src/snmpEventLogs.c b/stx-snmp-helm/centos/docker/stx-fm-subagent/src/snmpEventLogs.c new file mode 100644 index 0000000..aef7701 --- /dev/null +++ b/stx-snmp-helm/centos/docker/stx-fm-subagent/src/snmpEventLogs.c @@ -0,0 +1,268 @@ +/* +* Copyright (c) 2020 Wind River Systems, Inc. +* +* SPDX-License-Identifier: Apache-2.0 +* +*/ + +#include <stddef.h> +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> +#include <time.h> +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/net-snmp-features.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <fmDbAPI.h> +#include "snmpAgentPlugin.h" + + +netsnmp_feature_require(date_n_time) + +#define MINLOADFREQ 2 /* min reload frequency in seconds */ + +static long Event_Log_Count = 0; +static struct activealarm *alarm_list; +static struct activealarm *alarmaddr, savealarm, *savealarmaddr; +static int saveIndex = 0; +static char saveUuid[36]; +static long LastLoad = 0; /* ET in secs at last table load */ +extern long long_return; + + +int Event_Log_Get_Count(void); + +static void +Event_Log_Scan_Init() +{ + struct timeval et; /* elapsed time */ + struct activealarm **activealarm_ptr; + SFmAlarmQueryT aquery; + size_t i = 0; + + saveIndex = 0; + netsnmp_get_monotonic_clock(&et); + if ( et.tv_sec < LastLoad + MINLOADFREQ ) { + DEBUGMSG(("cgtsAgentPlugin", "Skip reload" )); + alarmaddr = alarm_list; + return; + } + LastLoad = et.tv_sec; + + /* + * free old list: + */ + while (alarm_list) { + struct activealarm *old = alarm_list; + alarm_list = alarm_list->next; + free(old); + } + alarmaddr = 0; + activealarm_ptr = &alarm_list; + + /* + * query event log list from DB + */ + if (fm_snmp_util_get_all_event_logs(getAlarmSession(), &aquery) != true){ + DEBUGMSG(("cgtsAgentPlugin", "get_all_event_logs from db failed\n")); + return; + } + DEBUGMSG(("cgtsAgentPlugin", "get_all_event_logs returns %lu logs\n", aquery.num)); + for (i = 0; i < aquery.num; ++i){ + struct activealarm *almnew; + /*populate alarm_list*/ + almnew = (struct activealarm *) calloc(1, sizeof(struct activealarm)); + if (almnew == NULL) + break; /* alloc error */ + *activealarm_ptr = almnew; + activealarm_ptr = &almnew->next; + memset(&almnew->alarmdata, 0 , sizeof(almnew->alarmdata)); + memcpy(&almnew->alarmdata, aquery.alarm + i, sizeof(almnew->alarmdata)); + } + alarmaddr = alarm_list; + free(aquery.alarm); +} + +static int +Event_Log_Scan_NextLog(int *Index, + char *Name, + struct activealarm *Aalm) +{ + struct activealarm alm; + while (alarmaddr) { + alm = *alarmaddr; + strlcpy(saveUuid, alm.alarmdata.uuid, sizeof(saveUuid)); + if (Index) + *Index = ++saveIndex; + if (Aalm) + *Aalm = alm; + if (Name) + strcpy(Name, saveUuid); + + savealarm = alm; + savealarmaddr = alarmaddr; + alarmaddr = alm.next; + return 1; + } + return 0; +} + +static int +Event_Log_Scan_By_Index(int Index, + char *Name, + struct activealarm *Aalm) +{ + int i; + + DEBUGMSGTL(("cgtsAgentPlugin","Event_Log_Scan_By_Index")); + Event_Log_Scan_Init(); + while (Event_Log_Scan_NextLog(&i, Name, Aalm)) { + if (i == Index) + break; + } + if (i != Index) + return (-1); /* Error, doesn't exist */ + return (0); /* DONE */ +} + +static int +header_eventLogEntry(struct variable *vp, + oid * name, + size_t * length, + int exact, size_t * var_len, + WriteMethod ** write_method) +{ +#define ALM_ENTRY_NAME_LENGTH 14 + oid newname[MAX_OID_LEN]; + register int index; + int result, count; + + DEBUGMSGTL(("cgtsAgentPlugin", "header_eventLogEntry: ")); + DEBUGMSGOID(("cgtsAgentPlugin", name, *length)); + DEBUGMSG(("cgtsAgentPlugin", "exact %d\n", exact)); + + memcpy((char *) newname, (char *) vp->name, + (int) vp->namelen * sizeof(oid)); + /* + * find "next" log + */ + count = Event_Log_Get_Count(); + DEBUGMSG(("cgtsAgentPlugin", "count %d\n", count)); + for (index = 1; index <= count; index++) { + newname[ALM_ENTRY_NAME_LENGTH] = (oid) index; + result = + snmp_oid_compare(name, *length, newname, + (int) vp->namelen + 1); + if ((exact && (result == 0)) || (!exact && (result < 0))) + break; + } + if (index > count) { + DEBUGMSGTL(("cgtsAgentPlugin", "... index out of range\n")); + return MATCH_FAILED; + } + + memcpy((char *) name, (char *) newname, + ((int) vp->namelen + 1) * sizeof(oid)); + *length = vp->namelen + 1; + *write_method = 0; + *var_len = sizeof(long); /* default to 'long' results */ + + DEBUGMSGTL(("cgtsAgentPlugin", "... get ALM data ")); + DEBUGMSGOID(("cgtsAgentPlugin", name, *length)); + DEBUGMSG(("cgtsAgentPlugin", "\n")); + + DEBUGMSG(("cgtsAgentPlugin","Return index: %d\n", index)); + return index; +} + +int +Event_Log_Get_Count(void) +{ + static time_t scan_time = 0; + time_t time_now = time(NULL); + + if (!Event_Log_Count || (time_now > scan_time + 60)) { + scan_time = time_now; + Event_Log_Scan_Init(); + Event_Log_Count = 0; + while (Event_Log_Scan_NextLog(NULL, NULL, NULL) != 0) { + Event_Log_Count++; + } + } + return (Event_Log_Count); +} + +u_char * +var_events(struct variable *vp, + oid * name, + size_t * length, + int exact, size_t * var_len, + WriteMethod ** write_method) +{ + static struct activealarm alrm; + static char Name[36]; + char *cp; + int index = 0; + + DEBUGMSGTL(("cgtsAgentPlugin", "var_events")); + index = header_eventLogEntry(vp, name, length, exact, var_len, write_method); + if (index == MATCH_FAILED) + return NULL; + + Event_Log_Scan_By_Index(index, Name, &alrm); + + switch (vp->magic) { + case EVENT_INDEX: + long_return = index; + return (u_char *) & long_return; + case EVENT_UUID: + cp = Name; + *var_len = strlen(cp); + return (u_char *) cp; + case EVENT_EVENT_ID: + cp = alrm.alarmdata.alarm_id; + *var_len = strlen(cp); + return (u_char *) cp; + case EVENT_STATE: + long_return = alrm.alarmdata.alarm_state; + return (u_char *) & long_return; + case EVENT_INSTANCE_ID: + cp = alrm.alarmdata.entity_instance_id; + *var_len = strlen(cp); + return (u_char *) cp; + case EVENT_TIME:{ + time_t when = alrm.alarmdata.timestamp/SECOND_PER_MICROSECOND; + cp = (char *) date_n_time(&when, var_len ); + return (u_char *) cp; + } + case EVENT_SEVERITY: + long_return = alrm.alarmdata.severity; + return (u_char *) & long_return; + case EVENT_REASONTEXT: + cp = alrm.alarmdata.reason_text; + *var_len = strlen(cp); + return (u_char *) cp; + case EVENT_EVENTTYPE: + long_return = alrm.alarmdata.alarm_type; + return (u_char *) & long_return; + case EVENT_PROBABLECAUSE: + long_return = alrm.alarmdata.probable_cause; + return (u_char *) & long_return; + case EVENT_REPAIRACTION: + cp = alrm.alarmdata.proposed_repair_action; + *var_len = strlen(cp); + return (u_char *) cp; + case EVENT_SERVICEAFFECTING: + long_return = alrm.alarmdata.service_affecting; + return (u_char *) & long_return; + case EVENT_SUPPRESSION: + long_return = alrm.alarmdata.suppression; + return (u_char *) & long_return; + default: + DEBUGMSGTL(("snmpd", "unknown sub-id %d in var_events\n", + vp->magic)); + } + return NULL; +} + diff --git a/stx-snmp-helm/centos/docker/stx-fm-subagent/src/snmpSubAgent.c b/stx-snmp-helm/centos/docker/stx-fm-subagent/src/snmpSubAgent.c new file mode 100644 index 0000000..64a1551 --- /dev/null +++ b/stx-snmp-helm/centos/docker/stx-fm-subagent/src/snmpSubAgent.c @@ -0,0 +1,207 @@ +/* +* Copyright (c) 2020 Wind River Systems, Inc. +* +* SPDX-License-Identifier: Apache-2.0 +* +*/ + +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-features.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> + +/* include our parent header */ +#include "snmpAgentPlugin.h" + +#include <signal.h> + +/* + * If compiling within the net-snmp source code, this will trigger the feature + * detection mechansim to ensure the agent_check_and_process() function + * is left available even if --enable-minimialist is turned on. If you + * have configured net-snmp using --enable-minimialist and want to compile + * this code externally to the Net-SNMP code base, then please add + * --with-features="agent_check_and_process enable_stderrlog" to your + * configure line. + */ +netsnmp_feature_require(agent_check_and_process) +netsnmp_feature_require(enable_stderrlog) + +static int keep_running; + +static RETSIGTYPE +stop_server(int a) { + keep_running = 0; +} + +static void usage(void) +{ + printf("usage: wrsAlarmActiveTable [-D<tokens>] [-f] [-L] [-M] [-H] [LISTENING ADDRESSES]\n" + "\t-f Do not fork() from the calling shell.\n" + "\t-DTOKEN[,TOKEN,...]\n" + "\t\tTurn on debugging output for the given TOKEN(s).\n" + "\t\tWithout any tokens specified, it defaults to printing\n" + "\t\tall the tokens (which is equivalent to the keyword 'ALL').\n" + "\t\tYou might want to try ALL for extremely verbose output.\n" + "\t\tNote: You can't put a space between the -D and the TOKENs.\n" + "\t-H\tDisplay a list of configuration file directives\n" + "\t\tunderstood by the agent and then exit.\n" + "\t-M\tRun as a normal SNMP Agent instead of an AgentX sub-agent.\n" + "\t-x ADDRESS\tconnect to master agent at ADDRESS (default /var/agentx/master).\n" + "\t-L\tDo not open a log file; print all messages to stderr.\n"); + exit(0); +} + +int +main (int argc, char **argv) +{ + int agentx_subagent=1; /* change this if you want to be a SNMP master agent */ + /* Defs for arg-handling code: handles setting of policy-related variables */ + int ch; + extern char *optarg; + int dont_fork = 0, use_syslog = 0; + char *agentx_socket = NULL; + + while ((ch = getopt(argc, argv, "D:fHLM-:x:")) != EOF) + switch(ch) + { + case '-': + if (strcasecmp(optarg, "help") == 0) + { + usage(); + } + handle_long_opt(optarg); + break; + case 'D': + debug_register_tokens(optarg); + snmp_set_do_debugging(1); + break; + case 'f': + dont_fork = 1; + break; + case 'H': + netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, + NETSNMP_DS_AGENT_NO_ROOT_ACCESS, 1); + init_agent("wrsAlarmActiveTable"); /* register our .conf handlers */ + init_snmpAgentPlugin(); + init_snmp("wrsAlarmActiveTable"); + fprintf(stderr, "Configuration directives understood:\n"); + read_config_print_usage(" "); + exit(0); + case 'M': + agentx_subagent = 0; + break; + case 'L': + use_syslog = 0; /* use stderr */ + break; + case 'x': + agentx_socket = optarg; + break; + default: + fprintf(stderr,"unknown option %c\n", ch); + usage(); + } + + if (optind < argc) + { + int i; + /* + * There are optional transport addresses on the command line. + */ + DEBUGMSGTL(("snmpd/main", "optind %d, argc %d\n", optind, argc)); + for (i = optind; i < argc; i++) + { + char *c, *astring; + if ((c = netsnmp_ds_get_string(NETSNMP_DS_APPLICATION_ID, + NETSNMP_DS_AGENT_PORTS))) + { + astring = (char*) malloc(strlen(c) + 2 + strlen(argv[i])); + if (astring == NULL) + { + fprintf(stderr, "malloc failure processing argv[%d]\n", i); + exit(1); + } + sprintf(astring, "%s,%s", c, argv[i]); + netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID, + NETSNMP_DS_AGENT_PORTS, astring); + SNMP_FREE(astring); + } + else + { + netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID, + NETSNMP_DS_AGENT_PORTS, argv[i]); + } + } + DEBUGMSGTL(("snmpd/main", "port spec: %s\n", + netsnmp_ds_get_string(NETSNMP_DS_APPLICATION_ID, + NETSNMP_DS_AGENT_PORTS))); + } + + /* we're an agentx subagent? */ + if (agentx_subagent) + { + snmp_log(LOG_INFO,"Make us a agentx client. \r\n"); + /* make us a agentx client. */ + netsnmp_enable_subagent(); + if (NULL != agentx_socket) + { + netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID, + NETSNMP_DS_AGENT_X_SOCKET, agentx_socket); + } + } + + snmp_disable_log(); + if (use_syslog) + snmp_enable_calllog(); + else + snmp_enable_stderrlog(); + + /* daemonize */ + if(!dont_fork) + { + int rc = netsnmp_daemonize(1,!use_syslog); + if(rc) + exit(-1); + } + + /* initialize tcp/ip if necessary */ + SOCK_STARTUP; + + snmp_log(LOG_INFO,"initialize the agent library \r\n"); + /* initialize the agent library */ + init_agent("wrsAlarmActiveTable"); + + snmp_log(LOG_INFO,"init wrsAlarmActiveTable mib code \r\n"); + /* init wrsAlarmActiveTable mib code */ + init_snmpAgentPlugin(); + + snmp_log(LOG_INFO,"Read wrsAlarmActiveTable.conf files\r\n"); + /* read wrsAlarmActiveTable.conf files. */ + init_snmp("wrsAlarmActiveTable"); + + /* If we're going to be a snmp master agent, initial the ports */ + if (!agentx_subagent) + init_master_agent(); /* open the port to listen on (defaults to udp:161) */ + + /* In case we recevie a request to stop (kill -TERM or kill -INT) */ + keep_running = 1; + signal(SIGTERM, stop_server); + signal(SIGINT, stop_server); + snmp_log(LOG_INFO,"Sub Agent Initialized\r\n"); + + /* you're main loop here... */ + while(keep_running) + { + /* if you use select(), see snmp_select_info() in snmp_api(3) */ + /* --- OR --- */ + agent_check_and_process(1); /* 0 == don't block */ + } + + /* at shutdown time */ + snmp_shutdown("wrsAlarmActiveTable"); + deinit_snmpAgentPlugin(); + SOCK_CLEANUP; + + exit(0); +} + diff --git a/stx-snmp-helm/centos/docker/stx-fm-trap-subagent/Dockerfile b/stx-snmp-helm/centos/docker/stx-fm-trap-subagent/Dockerfile new file mode 100644 index 0000000..063df88 --- /dev/null +++ b/stx-snmp-helm/centos/docker/stx-fm-trap-subagent/Dockerfile @@ -0,0 +1,26 @@ +FROM centos:8 AS builder +RUN yum -y update && yum upgrade +RUN yum -y install\ + net-snmp-libs \ + net-snmp-devel \ + make + +RUN dnf -y --enablerepo=PowerTools install json-c-devel +WORKDIR /home/trapagent +COPY src/* ./src/ +COPY Makefile . +RUN make + + +FROM centos:8 +RUN yum -y update && yum upgrade +RUN yum -y install\ + net-snmp \ + net-snmp-utils + +WORKDIR /home/trapagent +COPY --from=builder /home/trapagent/wrsAlarmMIB . +COPY bootstrap.sh . +RUN chmod 755 ./bootstrap.sh +ENTRYPOINT ["./bootstrap.sh"] + diff --git a/stx-snmp-helm/centos/docker/stx-fm-trap-subagent/Makefile b/stx-snmp-helm/centos/docker/stx-fm-trap-subagent/Makefile new file mode 100644 index 0000000..694cb55 --- /dev/null +++ b/stx-snmp-helm/centos/docker/stx-fm-trap-subagent/Makefile @@ -0,0 +1,40 @@ +CC=gcc +PREFIX=wrsAlarmMIB + +NETSNMPCONFIG=net-snmp-config +SOURCE=./src + +# uncomment this if you have GNU make +#NETSNMPCFLAGS := $(shell $(NETSNMPCONFIG) --base-cflags) +#NETSNMPLIBS := $(shell $(NETSNMPCONFIG) --agent-libs) +NETSNMPCFLAGS=`$(NETSNMPCONFIG) --base-cflags` +NETSNMPLIBS=`$(NETSNMPCONFIG) --agent-libs` + +LIBS=$(NETSNMPLIBS) -lpthread -ljson-c + +STRICT_FLAGS = -Wall -Wstrict-prototypes +CFLAGS=-I. $(NETSNMPCFLAGS) $(STRICT_FLAGS) -fPIC + +SRCS = $(SOURCE)/$(PREFIX)Trap.c \ + $(SOURCE)/$(PREFIX)Subagent.c + +OBJS = $(SRCS:.c=.o) + +TARGETS=$(PREFIX) + +.SUFFIXES: +.SUFFIXES: .c .o .deps + + +all: $(TARGETS) + +user: $(USER_OBJS) + +$(TARGETS): $(LIB_DEPS) + +$(PREFIX): $(OBJS) Makefile + $(CC) -o $(PREFIX) $(OBJS) $(LIBS) + +clean: + rm -f $(OBJS) $(TARGETS) + diff --git a/stx-snmp-helm/centos/docker/stx-fm-trap-subagent/bootstrap.sh b/stx-snmp-helm/centos/docker/stx-fm-trap-subagent/bootstrap.sh new file mode 100644 index 0000000..62de88d --- /dev/null +++ b/stx-snmp-helm/centos/docker/stx-fm-trap-subagent/bootstrap.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -u + +# Internal params +RUN_CMD="./wrsAlarmMIB -f -x tcp:localhost:705" + +# Launch +$RUN_CMD diff --git a/stx-snmp-helm/centos/docker/stx-fm-trap-subagent/src/wrsAlarmMIBSubagent.c b/stx-snmp-helm/centos/docker/stx-fm-trap-subagent/src/wrsAlarmMIBSubagent.c new file mode 100644 index 0000000..d6f9306 --- /dev/null +++ b/stx-snmp-helm/centos/docker/stx-fm-trap-subagent/src/wrsAlarmMIBSubagent.c @@ -0,0 +1,332 @@ +/* +* Copyright (c) 2020 Wind River Systems, Inc. +* +* SPDX-License-Identifier: Apache-2.0 +* +*/ + +#include <ctype.h> +#include <errno.h> +#include <inttypes.h> +#include <json-c/json.h> +#include <netdb.h> +#include <pthread.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <unistd.h> + +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-features.h> +#include <net-snmp/net-snmp-includes.h> + +#include <net-snmp/agent/net-snmp-agent-includes.h> + +#include "wrsAlarmMIBTrap.h" + +#define MSG_SIZE 4 +#define TCP_SOCKET_PORT 162 +#define ALARM_CRITICAL "wrsAlarmCritical" +#define ALARM_MAJOR "wrsAlarmMajor" +#define ALARM_MINOR "wrsAlarmMinor" +#define ALARM_WARNING "wrsAlarmWarning" +#define ALARM_MSG "wrsAlarmMessage" +#define ALARM_CLEAR "wrsAlarmClear" +#define ALARM_HIERARCHICAL_CLEAR "wrsAlarmHierarchicalClear" +#define WARM_START "warmStart" + +#define SA struct sockaddr + +/* + * If compiling within the net-snmp source code, this will trigger the feature + * detection mechansim to ensure the agent_check_and_process() function + * is left available even if --enable-minimialist is turned on. If you + * have configured net-snmp using --enable-minimialist and want to compile + * this code externally to the Net-SNMP code base, then please add + * --with-features="agent_check_and_process enable_stderrlog" to your + * configure line. + */ +netsnmp_feature_require(agent_check_and_process) + netsnmp_feature_require(enable_stderrlog) + + static int keep_running; + +static RETSIGTYPE +stop_server(int a) +{ + keep_running = 0; +} + +static void usage(void) +{ + printf("usage: wrsAlarmMIB [-D<tokens>] [-f] [-L] [-M] [-H] [LISTENING ADDRESSES]\n" + "\t-f Do not fork() from the calling shell.\n" + "\t-DTOKEN[,TOKEN,...]\n" + "\t\tTurn on debugging output for the given TOKEN(s).\n" + "\t\tWithout any tokens specified, it defaults to printing\n" + "\t\tall the tokens (which is equivalent to the keyword 'ALL').\n" + "\t\tYou might want to try ALL for extremely verbose output.\n" + "\t\tNote: You can't put a space between the -D and the TOKENs.\n" + "\t-H\tDisplay a list of configuration file directives\n" + "\t\tunderstood by the agent and then exit.\n" + "\t-M\tRun as a normal SNMP Agent instead of an AgentX sub-agent.\n" + "\t-x ADDRESS\tconnect to master agent at ADDRESS (default /var/agentx/master).\n" + "\t-L\tDo not open a log file; print all messages to stderr.\n"); + exit(0); +} +void initSocketServer(void) +{ + int sockfd, connfd, read, bytes_read; + int enable = 1; + int socket_keep_running = 1; + socklen_t len; + struct sockaddr_in servaddr, cli; + const int backlog = 1; + + // socket create and verification + sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + if (sockfd == -1) { + snmp_log(LOG_ERR,"Socket creation failed\n"); + exit(-1); + } + else + snmp_log(LOG_INFO,"Socket successfully created\n"); + + setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int)); + + bzero(&servaddr, sizeof(servaddr)); + + // assign IP, PORT + servaddr.sin_family = AF_INET; + servaddr.sin_addr.s_addr = htonl(INADDR_ANY); + servaddr.sin_port = htons(TCP_SOCKET_PORT); + + // Binding newly created socket to given IP and verification + if ((bind(sockfd, (SA *)&servaddr, sizeof(servaddr))) != 0) { + close(sockfd); + snmp_log(LOG_ERR,"Socket bind failed\n"); + exit(-1); + } + else + snmp_log(LOG_INFO,"Socket successfully binded\n"); + + if ((listen(sockfd, backlog)) != 0) { + snmp_log(LOG_ERR,"Failed to start server socket listen.\n"); + close(sockfd); + exit(-1); + } + else { + snmp_log(LOG_INFO,"Server listening\n"); + } + + len = sizeof(cli); + + while (socket_keep_running) { + connfd = accept(sockfd, (SA *)&cli, &len); + if (connfd < 0) { + snmp_log(LOG_ERR,"Server acccept failed\n"); + close(sockfd); + exit(-1); + } + else + snmp_log(LOG_INFO,"Client socket accepted\n"); + + int length_bytes = 0; + uint32_t length, nlength; + + while (length_bytes < MSG_SIZE) { + read = recv(connfd, ((char *)&nlength) + length_bytes, MSG_SIZE - length_bytes, 0); + if (read == -1) { + snmp_log(LOG_ERR,"Failed to receive message.\n"); + } + length_bytes += read; + } + + length = ntohl(nlength); + char *msg = malloc(length); + bytes_read = recv(connfd, msg, length, 0); + + if (bytes_read == -1) { + snmp_log(LOG_ERR,"Failed to receive message.\n"); + } + + if (bytes_read != length) { + snmp_log(LOG_ERR,"recv: Premature EOF.\n"); + } + + struct json_object *parsed_json = json_tokener_parse(msg); + struct json_object *operation_type; + json_object_object_get_ex(parsed_json, "operation_type", &operation_type); + const char *opt_type = json_object_get_string(operation_type); + + if (strcmp(ALARM_CLEAR, opt_type) == 0) { + + send_wrsAlarmClear_trap(parsed_json); + } + else if (strcmp(ALARM_HIERARCHICAL_CLEAR, opt_type) == 0) { + + send_wrsAlarmHierarchicalClear_trap(parsed_json); + } + else if (strcmp(ALARM_MSG, opt_type) == 0) { + + send_wrsEventMessage_trap(parsed_json); + } + else if (strcmp(ALARM_WARNING, opt_type) == 0) { + + send_wrsAlarmWarning_trap(parsed_json); + } + else if (strcmp(ALARM_MINOR, opt_type) == 0) { + + send_wrsAlarmMinor_trap(parsed_json); + } + else if (strcmp(ALARM_MAJOR, opt_type) == 0) { + + send_wrsAlarmMajor_trap(parsed_json); + } + else if (strcmp(ALARM_CRITICAL, opt_type) == 0) { + + send_wrsAlarmCritical_trap(parsed_json); + } + else if (strcmp(WARM_START, opt_type) == 0) { + + send_wrsWarmStart_trap(); + } + else { + send_wrsAlarmMessage_trap(parsed_json); + } + json_object_put(parsed_json); + free(msg); + } + close(sockfd); +} + +int main(int argc, char **argv) +{ + int agentx_subagent = 1; /* change this if you want to be a SNMP master agent */ + /* Defs for arg-handling code: handles setting of policy-related variables */ + int ch; + extern char *optarg; + int dont_fork = 0, use_syslog = 0; + char *agentx_socket = NULL; + + while ((ch = getopt(argc, argv, "D:fHLM-:x:")) != EOF) + switch (ch) { + case '-': + if (strcasecmp(optarg, "help") == 0) { + usage(); + } + handle_long_opt(optarg); + break; + case 'D': + debug_register_tokens(optarg); + snmp_set_do_debugging(1); + break; + case 'f': + dont_fork = 1; + break; + case 'H': + netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, + NETSNMP_DS_AGENT_NO_ROOT_ACCESS, 1); + init_agent("wrsAlarmMIB"); + init_snmp("wrsAlarmMIB"); + fprintf(stderr, "Configuration directives understood:\n"); + read_config_print_usage(" "); + exit(0); + case 'M': + agentx_subagent = 0; + break; + case 'L': + use_syslog = 0; /* use stderr */ + break; + case 'x': + agentx_socket = optarg; + break; + default: + fprintf(stderr, "unknown option %c\n", ch); + usage(); + } + + if (optind < argc) { + int i; + /* + * There are optional transport addresses on the command line. + */ + DEBUGMSGTL(("snmpd/main", "optind %d, argc %d\n", optind, argc)); + for (i = optind; i < argc; i++) { + char *c, *astring; + if ((c = netsnmp_ds_get_string(NETSNMP_DS_APPLICATION_ID, + NETSNMP_DS_AGENT_PORTS))) { + astring = malloc(strlen(c) + 2 + strlen(argv[i])); + if (astring == NULL) { + fprintf(stderr, "malloc failure processing argv[%d]\n", i); + exit(1); + } + sprintf(astring, "%s,%s", c, argv[i]); + netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID, + NETSNMP_DS_AGENT_PORTS, astring); + SNMP_FREE(astring); + } + else { + netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID, + NETSNMP_DS_AGENT_PORTS, argv[i]); + } + } + DEBUGMSGTL(("snmpd/main", "port spec: %s\n", + netsnmp_ds_get_string(NETSNMP_DS_APPLICATION_ID, + NETSNMP_DS_AGENT_PORTS))); + } + + /* we're an agentx subagent? */ + if (agentx_subagent) { + /* make us a agentx client. */ + netsnmp_enable_subagent(); + if (NULL != agentx_socket) + netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID, + NETSNMP_DS_AGENT_X_SOCKET, agentx_socket); + } + + snmp_disable_log(); + if (use_syslog) + snmp_enable_calllog(); + else + snmp_enable_stderrlog(); + + /* daemonize */ + if (!dont_fork) { + int rc = netsnmp_daemonize(1, !use_syslog); + if (rc) + exit(-1); + } + + /* initialize tcp/ip if necessary */ + SOCK_STARTUP; + + /* initialize the agent library */ + init_agent("wrsAlarmMIB"); + + /* read wrsAlarmMIB.conf files. */ + init_snmp("wrsAlarmMIB"); + + /* If we're going to be a snmp master agent, initial the ports */ + if (!agentx_subagent) + init_master_agent(); /* open the port to listen on (defaults to udp:161) */ + + /* In case we recevie a request to stop (kill -TERM or kill -INT) */ + keep_running = 1; + signal(SIGTERM, stop_server); + signal(SIGINT, stop_server); + initSocketServer(); + while (keep_running) { + /* if you use select(), see snmp_select_info() in snmp_api(3) */ + /* --- OR --- */ + agent_check_and_process(1); /* 0 == don't block */ + } + + /* at shutdown time */ + snmp_shutdown("wrsAlarmMIB"); + SOCK_CLEANUP; + exit(0); +} diff --git a/stx-snmp-helm/centos/docker/stx-fm-trap-subagent/src/wrsAlarmMIBTrap.c b/stx-snmp-helm/centos/docker/stx-fm-trap-subagent/src/wrsAlarmMIBTrap.c new file mode 100644 index 0000000..711d56a --- /dev/null +++ b/stx-snmp-helm/centos/docker/stx-fm-trap-subagent/src/wrsAlarmMIBTrap.c @@ -0,0 +1,897 @@ +/* +* Copyright (c) 2020 Wind River Systems, Inc. +* +* SPDX-License-Identifier: Apache-2.0 +* +*/ + +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> + +#include "wrsAlarmMIBTrap.h" + +#define ALARM_ID "wrsAlarmActiveAlarmId" +#define ALARM_INSTANCE_ID "wrsAlarmActiveEntityInstanceId" +#define ALARM_DATE_TIME "wrsAlarmActiveDateAndTime" +#define ALARM_SEVERITY "wrsAlarmActiveAlarmSeverity" +#define ALARM_REASON_TEXT "wrsAlarmActiveReasonText" +#define ALARM_EVENT_TYPE "wrsAlarmActiveEventType" +#define ALARM_CAUSE "wrsAlarmActiveProbableCause" +#define ALARM_REPAIR_ACTION "wrsAlarmActiveProposedRepairAction" +#define ALARM_SERVICE_AFFECTING "wrsAlarmActiveServiceAffecting" +#define ALARM_SUPPRESSION "wrsAlarmActiveSuppressionAllowed" + +#define EVENT_ID "wrsEventEventId" +#define EVENT_INSTANCE_ID "wrsEventEntityInstanceId" +#define EVENT_DATE_TIME "wrsEventDateAndTime" +#define EVENT_SEVERITY "wrsEventSeverity" +#define EVENT_REASON_TEXT "wrsEventReasonText" +#define EVENT_EVENT_TYPE "wrsEventEventType" +#define EVENT_CAUSE "wrsEventProbableCause" +#define EVENT_SERVICE_AFFECTING "wrsEventServiceAffecting" + +extern const oid snmptrap_oid[]; +extern const size_t snmptrap_oid_len; + +int +send_wrsAlarmCritical_trap( struct json_object *jobj ) +{ + snmp_log(LOG_INFO,"Init send_wrsAlarmCritical_trap\n"); + int exists; + struct json_object *alarmObj; + netsnmp_variable_list *var_list = NULL; + const oid wrsAlarmCritical_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,0,1 }; + const oid wrsAlarmActiveAlarmId_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,3,0}; + const oid wrsAlarmActiveEntityInstanceId_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,4,0}; + const oid wrsAlarmActiveDateAndTime_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,5,0}; + const oid wrsAlarmActiveAlarmSeverity_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,6,0}; + const oid wrsAlarmActiveReasonText_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,7,0}; + const oid wrsAlarmActiveEventType_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,8,0}; + const oid wrsAlarmActiveProbableCause_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,9,0}; + const oid wrsAlarmActiveProposedRepairAction_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,10,0}; + const oid wrsAlarmActiveServiceAffecting_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,11,0}; + const oid wrsAlarmActiveSuppressionAllowed_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,12,0}; + + exists=json_object_object_get_ex(jobj,"alarm",&alarmObj); + if(exists==0) { + snmp_log(LOG_ERR,"Key alarm not found in JSON"); + return SNMP_ERR_BADVALUE; + } + /* + * Set the snmpTrapOid.0 value + */ + snmp_varlist_add_variable(&var_list, + snmptrap_oid, snmptrap_oid_len, + ASN_OBJECT_ID, + wrsAlarmCritical_oid, sizeof(wrsAlarmCritical_oid)); + + + struct json_object *alarmObjField; + if(json_object_object_get_ex(alarmObj,ALARM_ID,&alarmObjField)) { + const char *alarmId = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveAlarmId_oid, OID_LENGTH(wrsAlarmActiveAlarmId_oid), + ASN_OCTET_STR, + alarmId,strlen(alarmId)); + + } + + if(json_object_object_get_ex(alarmObj,ALARM_INSTANCE_ID,&alarmObjField)) { + const char *alarmInstanceId = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveEntityInstanceId_oid, OID_LENGTH(wrsAlarmActiveEntityInstanceId_oid), + ASN_OCTET_STR, + alarmInstanceId, + strlen(alarmInstanceId)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_DATE_TIME,&alarmObjField)) { + const char *alarmDateTime = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveDateAndTime_oid, OID_LENGTH(wrsAlarmActiveDateAndTime_oid), + ASN_OCTET_STR, + alarmDateTime,strlen(alarmDateTime)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_SEVERITY,&alarmObjField)) { + int alarmSeverity = json_object_get_int(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveAlarmSeverity_oid, OID_LENGTH(wrsAlarmActiveAlarmSeverity_oid), + ASN_INTEGER, + &alarmSeverity,sizeof(alarmSeverity)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_REASON_TEXT,&alarmObjField)) { + const char *alarmReasonText = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveDateAndTime_oid, OID_LENGTH(wrsAlarmActiveReasonText_oid), + ASN_OCTET_STR, + alarmReasonText,strlen(alarmReasonText)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_EVENT_TYPE,&alarmObjField)) { + int eventType = json_object_get_int(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveEventType_oid, OID_LENGTH(wrsAlarmActiveEventType_oid), + ASN_INTEGER, + &eventType,sizeof(eventType)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_CAUSE,&alarmObjField)) { + int probableCause = json_object_get_int(json_object_object_get(alarmObj,ALARM_CAUSE)); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveProbableCause_oid, OID_LENGTH(wrsAlarmActiveProbableCause_oid), + ASN_INTEGER, + &probableCause,sizeof(probableCause)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_REPAIR_ACTION,&alarmObjField)) { + const char *proposedRepairAction = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveProposedRepairAction_oid, OID_LENGTH(wrsAlarmActiveProposedRepairAction_oid), + ASN_OCTET_STR, + proposedRepairAction,strlen(proposedRepairAction)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_SERVICE_AFFECTING,&alarmObjField)) { + int serviceAffecting = json_object_get_int(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveServiceAffecting_oid, OID_LENGTH(wrsAlarmActiveServiceAffecting_oid), + ASN_INTEGER, + &serviceAffecting,sizeof(serviceAffecting)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_SUPPRESSION,&alarmObjField)) { + int activeSuppressionAllowed = json_object_get_int(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveSuppressionAllowed_oid, OID_LENGTH(wrsAlarmActiveSuppressionAllowed_oid), + ASN_INTEGER, + &activeSuppressionAllowed,sizeof(activeSuppressionAllowed)); + } + + snmp_log(LOG_INFO,"wrsAlarmCritical trap sent\n"); + send_v2trap( var_list ); + snmp_free_varbind( var_list ); + + return SNMP_ERR_NOERROR; +} +int +send_wrsAlarmMajor_trap( struct json_object *jobj ) +{ + snmp_log(LOG_INFO,"Init send_wrsAlarmMajor_trap\n"); + int exists; + struct json_object *alarmObj; + netsnmp_variable_list *var_list = NULL; + const oid wrsAlarmMajor_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,0,2 }; + const oid wrsAlarmActiveAlarmId_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,3,0}; + const oid wrsAlarmActiveEntityInstanceId_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,4,0}; + const oid wrsAlarmActiveDateAndTime_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,5,0}; + const oid wrsAlarmActiveAlarmSeverity_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,6,0}; + const oid wrsAlarmActiveReasonText_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,7,0}; + const oid wrsAlarmActiveEventType_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,8,0}; + const oid wrsAlarmActiveProbableCause_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,9,0}; + const oid wrsAlarmActiveProposedRepairAction_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,10,0}; + const oid wrsAlarmActiveServiceAffecting_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,11,0}; + const oid wrsAlarmActiveSuppressionAllowed_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,12,0}; + + exists=json_object_object_get_ex(jobj,"alarm",&alarmObj); + if(exists==0) { + snmp_log(LOG_ERR,"Key alarm not found in JSON"); + return SNMP_ERR_BADVALUE; + } + /* + * Set the snmpTrapOid.0 value + */ + snmp_varlist_add_variable(&var_list, + snmptrap_oid, snmptrap_oid_len, + ASN_OBJECT_ID, + wrsAlarmMajor_oid, sizeof(wrsAlarmMajor_oid)); + + + struct json_object *alarmObjField; + if(json_object_object_get_ex(alarmObj,ALARM_ID,&alarmObjField)) { + const char *alarmId = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveAlarmId_oid, OID_LENGTH(wrsAlarmActiveAlarmId_oid), + ASN_OCTET_STR, + alarmId,strlen(alarmId)); + + } + if(json_object_object_get_ex(alarmObj,ALARM_INSTANCE_ID,&alarmObjField)) { + const char *alarmInstanceId = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveEntityInstanceId_oid, OID_LENGTH(wrsAlarmActiveEntityInstanceId_oid), + ASN_OCTET_STR, + alarmInstanceId, + strlen(alarmInstanceId)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_DATE_TIME,&alarmObjField)) { + const char *alarmDateTime = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveDateAndTime_oid, OID_LENGTH(wrsAlarmActiveDateAndTime_oid), + ASN_OCTET_STR, + alarmDateTime,strlen(alarmDateTime)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_SEVERITY,&alarmObjField)) { + int alarmSeverity = json_object_get_int(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveAlarmSeverity_oid, OID_LENGTH(wrsAlarmActiveAlarmSeverity_oid), + ASN_INTEGER, + &alarmSeverity,sizeof(alarmSeverity)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_REASON_TEXT,&alarmObjField)) { + const char *alarmReasonText = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveDateAndTime_oid, OID_LENGTH(wrsAlarmActiveReasonText_oid), + ASN_OCTET_STR, + alarmReasonText,strlen(alarmReasonText)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_EVENT_TYPE,&alarmObjField)) { + int eventType = json_object_get_int(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveEventType_oid, OID_LENGTH(wrsAlarmActiveEventType_oid), + ASN_INTEGER, + &eventType,sizeof(eventType)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_CAUSE,&alarmObjField)) { + int probableCause = json_object_get_int(json_object_object_get(alarmObj,ALARM_CAUSE)); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveProbableCause_oid, OID_LENGTH(wrsAlarmActiveProbableCause_oid), + ASN_INTEGER, + &probableCause,sizeof(probableCause)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_REPAIR_ACTION,&alarmObjField)) { + const char *proposedRepairAction = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveProposedRepairAction_oid, OID_LENGTH(wrsAlarmActiveProposedRepairAction_oid), + ASN_OCTET_STR, + proposedRepairAction,strlen(proposedRepairAction)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_SERVICE_AFFECTING,&alarmObjField)) { + int serviceAffecting = json_object_get_int(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveServiceAffecting_oid, OID_LENGTH(wrsAlarmActiveServiceAffecting_oid), + ASN_INTEGER, + &serviceAffecting,sizeof(serviceAffecting)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_SUPPRESSION,&alarmObjField)) { + int activeSuppressionAllowed = json_object_get_int(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveSuppressionAllowed_oid, OID_LENGTH(wrsAlarmActiveSuppressionAllowed_oid), + ASN_INTEGER, + &activeSuppressionAllowed,sizeof(activeSuppressionAllowed)); + } + + snmp_log(LOG_INFO,"wrsAlarmMajor trap sent\n"); + send_v2trap( var_list ); + snmp_free_varbind( var_list ); + + return SNMP_ERR_NOERROR; +} +int +send_wrsAlarmMinor_trap( struct json_object *jobj ) +{ + snmp_log(LOG_INFO,"Init send_wrsAlarmMinor_trap\n"); + int exists; + struct json_object *alarmObj; + netsnmp_variable_list *var_list = NULL; + const oid wrsAlarmMinor_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,0,3 }; + const oid wrsAlarmActiveAlarmId_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,3,0}; + const oid wrsAlarmActiveEntityInstanceId_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,4,0}; + const oid wrsAlarmActiveDateAndTime_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,5,0}; + const oid wrsAlarmActiveAlarmSeverity_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,6,0}; + const oid wrsAlarmActiveReasonText_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,7,0}; + const oid wrsAlarmActiveEventType_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,8,0}; + const oid wrsAlarmActiveProbableCause_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,9,0}; + const oid wrsAlarmActiveProposedRepairAction_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,10,0}; + const oid wrsAlarmActiveServiceAffecting_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,11,0}; + const oid wrsAlarmActiveSuppressionAllowed_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,12,0}; + + exists=json_object_object_get_ex(jobj,"alarm",&alarmObj); + if(exists==0) { + snmp_log(LOG_ERR,"Key alarm not found in JSON"); + return SNMP_ERR_BADVALUE; + } + /* + * Set the snmpTrapOid.0 value + */ + snmp_varlist_add_variable(&var_list, + snmptrap_oid, snmptrap_oid_len, + ASN_OBJECT_ID, + wrsAlarmMinor_oid, sizeof(wrsAlarmMinor_oid)); + + + struct json_object *alarmObjField; + if(json_object_object_get_ex(alarmObj,ALARM_ID,&alarmObjField)) { + const char *alarmId = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveAlarmId_oid, OID_LENGTH(wrsAlarmActiveAlarmId_oid), + ASN_OCTET_STR, + alarmId,strlen(alarmId)); + + } + + if(json_object_object_get_ex(alarmObj,ALARM_INSTANCE_ID,&alarmObjField)) { + const char *alarmInstanceId = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveEntityInstanceId_oid, OID_LENGTH(wrsAlarmActiveEntityInstanceId_oid), + ASN_OCTET_STR, + alarmInstanceId, + strlen(alarmInstanceId)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_DATE_TIME,&alarmObjField)) { + const char *alarmDateTime = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveDateAndTime_oid, OID_LENGTH(wrsAlarmActiveDateAndTime_oid), + ASN_OCTET_STR, + alarmDateTime,strlen(alarmDateTime)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_SEVERITY,&alarmObjField)) { + int alarmSeverity = json_object_get_int(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveAlarmSeverity_oid, OID_LENGTH(wrsAlarmActiveAlarmSeverity_oid), + ASN_INTEGER, + &alarmSeverity,sizeof(alarmSeverity)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_REASON_TEXT,&alarmObjField)) { + const char *alarmReasonText = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveDateAndTime_oid, OID_LENGTH(wrsAlarmActiveReasonText_oid), + ASN_OCTET_STR, + alarmReasonText,strlen(alarmReasonText)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_EVENT_TYPE,&alarmObjField)) { + int eventType = json_object_get_int(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveEventType_oid, OID_LENGTH(wrsAlarmActiveEventType_oid), + ASN_INTEGER, + &eventType,sizeof(eventType)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_CAUSE,&alarmObjField)) { + int probableCause = json_object_get_int(json_object_object_get(alarmObj,ALARM_CAUSE)); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveProbableCause_oid, OID_LENGTH(wrsAlarmActiveProbableCause_oid), + ASN_INTEGER, + &probableCause,sizeof(probableCause)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_REPAIR_ACTION,&alarmObjField)) { + const char *proposedRepairAction = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveProposedRepairAction_oid, OID_LENGTH(wrsAlarmActiveProposedRepairAction_oid), + ASN_OCTET_STR, + proposedRepairAction,strlen(proposedRepairAction)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_SERVICE_AFFECTING,&alarmObjField)) { + int serviceAffecting = json_object_get_int(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveServiceAffecting_oid, OID_LENGTH(wrsAlarmActiveServiceAffecting_oid), + ASN_INTEGER, + &serviceAffecting,sizeof(serviceAffecting)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_SUPPRESSION,&alarmObjField)) { + int activeSuppressionAllowed = json_object_get_int(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveSuppressionAllowed_oid, OID_LENGTH(wrsAlarmActiveSuppressionAllowed_oid), + ASN_INTEGER, + &activeSuppressionAllowed,sizeof(activeSuppressionAllowed)); + } + + snmp_log(LOG_INFO,"wrsAlarmMinor trap sent\n"); + send_v2trap( var_list ); + snmp_free_varbind( var_list ); + + return SNMP_ERR_NOERROR; +} +int +send_wrsAlarmWarning_trap( struct json_object *jobj ) +{ + snmp_log(LOG_INFO,"Init send_wrsAlarmWarning_trap\n"); + int exists; + struct json_object *alarmObj; + netsnmp_variable_list *var_list = NULL; + const oid wrsAlarmWarning_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,0,4 }; + const oid wrsAlarmActiveAlarmId_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,3,0 }; + const oid wrsAlarmActiveEntityInstanceId_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,4,0}; + const oid wrsAlarmActiveDateAndTime_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,5,0}; + const oid wrsAlarmActiveAlarmSeverity_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,6,0}; + const oid wrsAlarmActiveReasonText_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,7,0}; + const oid wrsAlarmActiveEventType_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,8,0}; + const oid wrsAlarmActiveProbableCause_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,9,0}; + const oid wrsAlarmActiveProposedRepairAction_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,10,0}; + const oid wrsAlarmActiveServiceAffecting_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,11,0}; + const oid wrsAlarmActiveSuppressionAllowed_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,12,0}; + + exists=json_object_object_get_ex(jobj,"alarm",&alarmObj); + if(exists==0) { + snmp_log(LOG_ERR,"Key alarm not found in JSON"); + return SNMP_ERR_BADVALUE; + } + /* + * Set the snmpTrapOid.0 value + */ + snmp_varlist_add_variable(&var_list, + snmptrap_oid, snmptrap_oid_len, + ASN_OBJECT_ID, + wrsAlarmWarning_oid, sizeof(wrsAlarmWarning_oid)); + + + struct json_object *alarmObjField; + if(json_object_object_get_ex(alarmObj,ALARM_ID,&alarmObjField)) { + const char *alarmId = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveAlarmId_oid, OID_LENGTH(wrsAlarmActiveAlarmId_oid), + ASN_OCTET_STR, + alarmId,strlen(alarmId)); + + } + + if(json_object_object_get_ex(alarmObj,ALARM_INSTANCE_ID,&alarmObjField)) { + const char *alarmInstanceId = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveEntityInstanceId_oid, OID_LENGTH(wrsAlarmActiveEntityInstanceId_oid), + ASN_OCTET_STR, + alarmInstanceId, + strlen(alarmInstanceId)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_DATE_TIME,&alarmObjField)) { + const char *alarmDateTime = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveDateAndTime_oid, OID_LENGTH(wrsAlarmActiveDateAndTime_oid), + ASN_OCTET_STR, + alarmDateTime,strlen(alarmDateTime)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_SEVERITY,&alarmObjField)) { + int alarmSeverity = json_object_get_int(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveAlarmSeverity_oid, OID_LENGTH(wrsAlarmActiveAlarmSeverity_oid), + ASN_INTEGER, + &alarmSeverity,sizeof(alarmSeverity)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_REASON_TEXT,&alarmObjField)) { + const char *alarmReasonText = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveDateAndTime_oid, OID_LENGTH(wrsAlarmActiveReasonText_oid), + ASN_OCTET_STR, + alarmReasonText,strlen(alarmReasonText)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_EVENT_TYPE,&alarmObjField)) { + int eventType = json_object_get_int(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveEventType_oid, OID_LENGTH(wrsAlarmActiveEventType_oid), + ASN_INTEGER, + &eventType,sizeof(eventType)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_CAUSE,&alarmObjField)) { + int probableCause = json_object_get_int(json_object_object_get(alarmObj,ALARM_CAUSE)); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveProbableCause_oid, OID_LENGTH(wrsAlarmActiveProbableCause_oid), + ASN_INTEGER, + &probableCause,sizeof(probableCause)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_REPAIR_ACTION,&alarmObjField)) { + const char *proposedRepairAction = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveProposedRepairAction_oid, OID_LENGTH(wrsAlarmActiveProposedRepairAction_oid), + ASN_OCTET_STR, + proposedRepairAction,strlen(proposedRepairAction)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_SERVICE_AFFECTING,&alarmObjField)) { + int serviceAffecting = json_object_get_int(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveServiceAffecting_oid, OID_LENGTH(wrsAlarmActiveServiceAffecting_oid), + ASN_INTEGER, + &serviceAffecting,sizeof(serviceAffecting)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_SUPPRESSION,&alarmObjField)) { + int activeSuppressionAllowed = json_object_get_int(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveSuppressionAllowed_oid, OID_LENGTH(wrsAlarmActiveSuppressionAllowed_oid), + ASN_INTEGER, + &activeSuppressionAllowed,sizeof(activeSuppressionAllowed)); + } + + snmp_log(LOG_INFO,"wrsAlarmWarning trap sent\n"); + send_v2trap( var_list ); + snmp_free_varbind( var_list ); + + return SNMP_ERR_NOERROR; +} +int +send_wrsEventMessage_trap( struct json_object *jobj ) +{ + snmp_log(LOG_INFO,"Init send_wrsEventMessage_trap\n"); + int exists; + struct json_object *alarmObj; + netsnmp_variable_list *var_list = NULL; + + const oid wrsAlarmMessage_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,0,5 }; + const oid wrsAlarmActiveAlarmId_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,3,0}; + const oid wrsAlarmActiveEntityInstanceId_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,4,0}; + const oid wrsAlarmActiveDateAndTime_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,5,0}; + const oid wrsAlarmActiveAlarmSeverity_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,6,0}; + const oid wrsAlarmActiveReasonText_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,7,0}; + const oid wrsAlarmActiveEventType_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,8,0}; + const oid wrsAlarmActiveProbableCause_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,9,0}; + const oid wrsAlarmActiveServiceAffecting_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,11,0}; + + exists=json_object_object_get_ex(jobj,"alarm",&alarmObj); + if(exists==0) { + snmp_log(LOG_ERR,"Key alarm not found in JSON"); + return SNMP_ERR_BADVALUE; + } + /* + * Set the snmpTrapOid.0 value + */ + snmp_varlist_add_variable(&var_list, + snmptrap_oid, snmptrap_oid_len, + ASN_OBJECT_ID, + wrsAlarmMessage_oid, sizeof(wrsAlarmMessage_oid)); + + + json_object *alarmObjField; + if(json_object_object_get_ex(alarmObj,EVENT_ID,&alarmObjField)) { + const char *alarmId = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveAlarmId_oid, OID_LENGTH(wrsAlarmActiveAlarmId_oid), + ASN_OCTET_STR, + alarmId,strlen(alarmId)); + + } + + if(json_object_object_get_ex(alarmObj,EVENT_INSTANCE_ID,&alarmObjField)) { + const char *alarmInstanceId = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveEntityInstanceId_oid, OID_LENGTH(wrsAlarmActiveEntityInstanceId_oid), + ASN_OCTET_STR, + alarmInstanceId, + strlen(alarmInstanceId)); + } + + if(json_object_object_get_ex(alarmObj,EVENT_DATE_TIME,&alarmObjField)) { + const char *alarmDateTime = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveDateAndTime_oid, OID_LENGTH(wrsAlarmActiveDateAndTime_oid), + ASN_OCTET_STR, + alarmDateTime,strlen(alarmDateTime)); + } + + if(json_object_object_get_ex(alarmObj,EVENT_SEVERITY,&alarmObjField)) { + int alarmSeverity = json_object_get_int(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveAlarmSeverity_oid, OID_LENGTH(wrsAlarmActiveAlarmSeverity_oid), + ASN_INTEGER, + &alarmSeverity,sizeof(alarmSeverity)); + } + + if(json_object_object_get_ex(alarmObj,EVENT_REASON_TEXT,&alarmObjField)) { + const char *alarmReasonText = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveDateAndTime_oid, OID_LENGTH(wrsAlarmActiveReasonText_oid), + ASN_OCTET_STR, + alarmReasonText,strlen(alarmReasonText)); + } + + if(json_object_object_get_ex(alarmObj,EVENT_EVENT_TYPE,&alarmObjField)) { + int eventType = json_object_get_int(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveEventType_oid, OID_LENGTH(wrsAlarmActiveEventType_oid), + ASN_INTEGER, + &eventType,sizeof(eventType)); + } + + if(json_object_object_get_ex(alarmObj,EVENT_CAUSE,&alarmObjField)) { + int probableCause = json_object_get_int(json_object_object_get(alarmObj,ALARM_CAUSE)); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveProbableCause_oid, OID_LENGTH(wrsAlarmActiveProbableCause_oid), + ASN_INTEGER, + &probableCause,sizeof(probableCause)); + } + + if(json_object_object_get_ex(alarmObj,EVENT_SERVICE_AFFECTING,&alarmObjField)) { + int serviceAffecting = json_object_get_int(alarmObj); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveServiceAffecting_oid, OID_LENGTH(wrsAlarmActiveServiceAffecting_oid), + ASN_INTEGER, + &serviceAffecting,sizeof(serviceAffecting)); + } + + snmp_log(LOG_INFO,"wrsEvent Message trap sent\n"); + send_v2trap( var_list ); + snmp_free_varbind( var_list ); + + return SNMP_ERR_NOERROR; +} +int +send_wrsAlarmMessage_trap( struct json_object *jobj ) +{ + snmp_log(LOG_INFO,"Init send_wrsAlarmMessage_trap\n"); + int exists; + struct json_object *alarmObj; + netsnmp_variable_list *var_list = NULL; + const oid wrsAlarmMessage_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,0,5 }; + const oid wrsAlarmActiveAlarmId_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,3,0}; + const oid wrsAlarmActiveEntityInstanceId_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,4,0}; + const oid wrsAlarmActiveDateAndTime_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,5,0}; + const oid wrsAlarmActiveAlarmSeverity_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,6,0}; + const oid wrsAlarmActiveReasonText_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,7,0}; + const oid wrsAlarmActiveEventType_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,8,0}; + const oid wrsAlarmActiveProbableCause_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,9,0}; + const oid wrsAlarmActiveProposedRepairAction_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,10,0}; + const oid wrsAlarmActiveServiceAffecting_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,11,0}; + const oid wrsAlarmActiveSuppressionAllowed_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,12,0}; + + + exists=json_object_object_get_ex(jobj,"alarm",&alarmObj); + if(exists==0) { + snmp_log(LOG_ERR,"Key alarm not found in JSON"); + return SNMP_ERR_BADVALUE; + } + /* + * Set the snmpTrapOid.0 value + */ + snmp_varlist_add_variable(&var_list, + snmptrap_oid, snmptrap_oid_len, + ASN_OBJECT_ID, + wrsAlarmMessage_oid, sizeof(wrsAlarmMessage_oid)); + + + json_object *alarmObjField; + if(json_object_object_get_ex(alarmObj,ALARM_ID,&alarmObjField)) { + const char *alarmId = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveAlarmId_oid, OID_LENGTH(wrsAlarmActiveAlarmId_oid), + ASN_OCTET_STR, + alarmId,strlen(alarmId)); + + } + + if(json_object_object_get_ex(alarmObj,ALARM_INSTANCE_ID,&alarmObjField)) { + const char *alarmInstanceId = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveEntityInstanceId_oid, OID_LENGTH(wrsAlarmActiveEntityInstanceId_oid), + ASN_OCTET_STR, + alarmInstanceId, + strlen(alarmInstanceId)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_DATE_TIME,&alarmObjField)) { + const char *alarmDateTime = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveDateAndTime_oid, OID_LENGTH(wrsAlarmActiveDateAndTime_oid), + ASN_OCTET_STR, + alarmDateTime,strlen(alarmDateTime)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_SEVERITY,&alarmObjField)) { + int alarmSeverity = json_object_get_int(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveAlarmSeverity_oid, OID_LENGTH(wrsAlarmActiveAlarmSeverity_oid), + ASN_INTEGER, + &alarmSeverity,sizeof(alarmSeverity)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_REASON_TEXT,&alarmObjField)) { + const char *alarmReasonText = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveDateAndTime_oid, OID_LENGTH(wrsAlarmActiveReasonText_oid), + ASN_OCTET_STR, + alarmReasonText,strlen(alarmReasonText)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_EVENT_TYPE,&alarmObjField)) { + int eventType = json_object_get_int(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveEventType_oid, OID_LENGTH(wrsAlarmActiveEventType_oid), + ASN_INTEGER, + &eventType,sizeof(eventType)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_CAUSE,&alarmObjField)) { + int probableCause = json_object_get_int(json_object_object_get(alarmObj,ALARM_CAUSE)); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveProbableCause_oid, OID_LENGTH(wrsAlarmActiveProbableCause_oid), + ASN_INTEGER, + &probableCause,sizeof(probableCause)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_REPAIR_ACTION,&alarmObjField)) { + const char *proposedRepairAction = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveProposedRepairAction_oid, OID_LENGTH(wrsAlarmActiveProposedRepairAction_oid), + ASN_OCTET_STR, + proposedRepairAction,strlen(proposedRepairAction)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_SERVICE_AFFECTING,&alarmObjField)) { + int serviceAffecting = json_object_get_int(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveServiceAffecting_oid, OID_LENGTH(wrsAlarmActiveServiceAffecting_oid), + ASN_INTEGER, + &serviceAffecting,sizeof(serviceAffecting)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_SUPPRESSION,&alarmObjField)) { + int activeSuppressionAllowed = json_object_get_int(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveSuppressionAllowed_oid, OID_LENGTH(wrsAlarmActiveSuppressionAllowed_oid), + ASN_INTEGER, + &activeSuppressionAllowed,sizeof(activeSuppressionAllowed)); + } + + snmp_log(LOG_INFO,"wrsAlarmMessage trap sent\n"); + send_v2trap( var_list ); + snmp_free_varbind( var_list ); + + return SNMP_ERR_NOERROR; +} +int +send_wrsAlarmClear_trap( struct json_object *jobj ) +{ + snmp_log(LOG_INFO,"Init send_wrsAlarmClear_trap\n"); + int exists; + struct json_object *alarmObj; + netsnmp_variable_list *var_list = NULL; + const oid wrsAlarmClear_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,0,9 }; + const oid wrsAlarmActiveAlarmId_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,3,0 }; + const oid wrsAlarmActiveEntityInstanceId_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,4,0}; + const oid wrsAlarmActiveDateAndTime_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,5,0}; + const oid wrsAlarmActiveReasonText_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,7,0}; + + exists=json_object_object_get_ex(jobj,"alarm",&alarmObj); + if(exists==0) { + snmp_log(LOG_ERR,"Key alarm not found in JSON"); + return SNMP_ERR_BADVALUE; + } + + /* + * Set the snmpTrapOid.0 value + */ + snmp_varlist_add_variable(&var_list, + snmptrap_oid, snmptrap_oid_len, + ASN_OBJECT_ID, + wrsAlarmClear_oid, sizeof(wrsAlarmClear_oid)); + + json_object *alarmObjField; + if(json_object_object_get_ex(alarmObj,ALARM_ID,&alarmObjField)) { + const char *alarmId = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveAlarmId_oid, OID_LENGTH(wrsAlarmActiveAlarmId_oid), + ASN_OCTET_STR, + alarmId,strlen(alarmId)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_INSTANCE_ID,&alarmObjField)) { + const char *alarmInstanceId = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveEntityInstanceId_oid, OID_LENGTH(wrsAlarmActiveEntityInstanceId_oid), + ASN_OCTET_STR, + alarmInstanceId, + strlen(alarmInstanceId)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_DATE_TIME,&alarmObjField)) { + const char *alarmDateTime = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveDateAndTime_oid, OID_LENGTH(wrsAlarmActiveDateAndTime_oid), + ASN_OCTET_STR, + alarmDateTime,strlen(alarmDateTime)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_REASON_TEXT,&alarmObjField)) { + const char *alarmReasonText = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveDateAndTime_oid, OID_LENGTH(wrsAlarmActiveReasonText_oid), + ASN_OCTET_STR, + alarmReasonText,strlen(alarmReasonText)); + } + + snmp_log(LOG_INFO,"wrsAlarmClear trap sent\n"); + send_v2trap( var_list ); + snmp_free_varbind( var_list ); + + return SNMP_ERR_NOERROR; +} +int +send_wrsAlarmHierarchicalClear_trap(struct json_object *jobj ) +{ + snmp_log(LOG_INFO,"Init send_wrsAlarmHierarchical_trap\n"); + struct json_object *alarmObj; + int exists; + netsnmp_variable_list *var_list = NULL; + const oid wrsAlarmHierarchicalClear_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,0,99 }; + const oid wrsAlarmActiveEntityInstanceId_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,4,0}; + const oid wrsAlarmActiveDateAndTime_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,5,0}; + const oid wrsAlarmActiveReasonText_oid[] = { 1,3,6,1,4,1,731,1,1,1,1,1,1,7,0}; + + exists=json_object_object_get_ex(jobj,"alarm",&alarmObj); + if(exists==0) { + snmp_log(LOG_ERR,"Key alarm not found in JSON"); + return SNMP_ERR_BADVALUE; + } + + /* + * Set the snmpTrapOid.0 value + */ + snmp_varlist_add_variable(&var_list, + snmptrap_oid, snmptrap_oid_len, + ASN_OBJECT_ID, + wrsAlarmHierarchicalClear_oid, sizeof(wrsAlarmHierarchicalClear_oid)); + + json_object *alarmObjField; + if(json_object_object_get_ex(alarmObj,ALARM_INSTANCE_ID,&alarmObjField)) { + const char *alarmInstanceId = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveEntityInstanceId_oid, OID_LENGTH(wrsAlarmActiveEntityInstanceId_oid), + ASN_OCTET_STR, + alarmInstanceId, + strlen(alarmInstanceId)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_DATE_TIME,&alarmObjField)) { + const char *alarmDateTime = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveDateAndTime_oid, OID_LENGTH(wrsAlarmActiveDateAndTime_oid), + ASN_OCTET_STR, + alarmDateTime,strlen(alarmDateTime)); + } + + if(json_object_object_get_ex(alarmObj,ALARM_REASON_TEXT,&alarmObjField)) { + const char *alarmReasonText = json_object_get_string(alarmObjField); + snmp_varlist_add_variable(&var_list, + wrsAlarmActiveDateAndTime_oid, OID_LENGTH(wrsAlarmActiveReasonText_oid), + ASN_OCTET_STR, + alarmReasonText,strlen(alarmReasonText)); + } + + snmp_log(LOG_INFO,"wrsHierarchicalClear trap sent\n"); + send_v2trap( var_list ); + snmp_free_varbind( var_list ); + + return SNMP_ERR_NOERROR; +} + +int +send_wrsWarmStart_trap() +{ + snmp_log(LOG_INFO,"Init send_wrsWarmStart_trap\n"); + netsnmp_variable_list *var_list = NULL; + const oid wrsWarmStart_oid[] = {1,3,6,1,6,3,1,1,5,2}; + /* + * Set the snmpTrapOid.0 value + */ + snmp_varlist_add_variable(&var_list, + snmptrap_oid, snmptrap_oid_len, + ASN_OBJECT_ID, + wrsWarmStart_oid, sizeof(wrsWarmStart_oid)); + + snmp_log(LOG_INFO,"wrsWarmStart trap sent\n"); + send_v2trap( var_list ); + snmp_free_varbind( var_list ); + + return SNMP_ERR_NOERROR; +} \ No newline at end of file diff --git a/stx-snmp-helm/centos/docker/stx-fm-trap-subagent/src/wrsAlarmMIBTrap.h b/stx-snmp-helm/centos/docker/stx-fm-trap-subagent/src/wrsAlarmMIBTrap.h new file mode 100644 index 0000000..9b9045f --- /dev/null +++ b/stx-snmp-helm/centos/docker/stx-fm-trap-subagent/src/wrsAlarmMIBTrap.h @@ -0,0 +1,23 @@ +/* +* Copyright (c) 2020 Wind River Systems, Inc. +* +* SPDX-License-Identifier: Apache-2.0 +* +*/ + +#ifndef WRSALARMMIBTRAP_H +#define WRSALARMMIBTRAP_H +#include<json-c/json.h> + +/* function declarations */ +int send_wrsAlarmCritical_trap(struct json_object *); +int send_wrsAlarmMajor_trap(struct json_object *); +int send_wrsAlarmMinor_trap(struct json_object *); +int send_wrsAlarmWarning_trap(struct json_object *); +int send_wrsAlarmMessage_trap(struct json_object *); +int send_wrsEventMessage_trap(struct json_object *); +int send_wrsAlarmClear_trap(struct json_object *); +int send_wrsAlarmHierarchicalClear_trap(struct json_object *); +int send_wrsWarmStart_trap(void); + +#endif /* WRSALARMMIBTRAP_H */ diff --git a/stx-snmp-helm/centos/docker/stx-snmp/Dockerfile b/stx-snmp-helm/centos/docker/stx-snmp/Dockerfile new file mode 100755 index 0000000..cb9328b --- /dev/null +++ b/stx-snmp-helm/centos/docker/stx-snmp/Dockerfile @@ -0,0 +1,12 @@ +FROM centos:8 +RUN yum -y update +RUN yum -y install\ + net-snmp \ + net-snmp-utils \ + net-snmp-libs + +COPY ./mibs/* /usr/share/snmp/mibs/ +EXPOSE 161/udp +EXPOSE 162/udp +EXPOSE 705/tcp +CMD [ "/usr/sbin/snmpd", "-f"] diff --git a/stx-snmp-helm/centos/docker/stx-snmp/mibs/wrsAlarmMib.mib.txt b/stx-snmp-helm/centos/docker/stx-snmp/mibs/wrsAlarmMib.mib.txt new file mode 100755 index 0000000..7c5fb7f --- /dev/null +++ b/stx-snmp-helm/centos/docker/stx-snmp/mibs/wrsAlarmMib.mib.txt @@ -0,0 +1,818 @@ +WRS-ALARM-MIB + +DEFINITIONS ::= BEGIN + + IMPORTS + wrsAlarms, WrsUUID, WrsBoolean FROM WRS-ENTERPRISE-REG-MIB + + NOTIFICATION-GROUP, OBJECT-GROUP, MODULE-COMPLIANCE + FROM SNMPv2-CONF + + DateAndTime, DisplayString, TEXTUAL-CONVENTION + FROM SNMPv2-TC + + MODULE-IDENTITY, OBJECT-IDENTITY, OBJECT-TYPE, NOTIFICATION-TYPE, Unsigned32 + FROM SNMPv2-SMI; + + + wrsAlarmMIB MODULE-IDENTITY + LAST-UPDATED "201703310000Z" + ORGANIZATION "Wind River Systems, Inc." + CONTACT-INFO "Wind River Systems, Inc. + 500 Wind River Way + Alameda, CA 94501, USA + Contact : Wind River Systems Support + E-mail: support@windriver.com + Phone : 510.748.4100" + DESCRIPTION "This module contains objects of the + Titanium Cloud Alarm MIB, + including notifications." + + -- Revision history + REVISION "201703310000Z" + DESCRIPTION "Titanium Cloud Release 4 version, with new Event table and removal of deprecated customer and alarm history tables." + ::= { wrsAlarms 1 } + + wrsAlarmObjects OBJECT IDENTIFIER ::= { wrsAlarmMIB 1 } + wrsAlarmConformance OBJECT IDENTIFIER ::= { wrsAlarmMIB 2 } + wrsAlarmCompliances OBJECT IDENTIFIER ::= { wrsAlarmConformance 1 } + wrsAlarmGroups OBJECT IDENTIFIER ::= { wrsAlarmConformance 2 } + + + -- Textual Conventions + + WrsAlarmSeverity ::= TEXTUAL-CONVENTION + STATUS current + DESCRIPTION "The severity of the alarm." + SYNTAX INTEGER + { + not-applicable (0), + warning (1), + minor (2), + major (3), + critical (4) + } + + WrsAlarmState ::= TEXTUAL-CONVENTION + STATUS current + DESCRIPTION "The state of the alarm." + SYNTAX INTEGER + { + clear (0), + set (1), + log (3) + } + + WrsAlarmId ::= TEXTUAL-CONVENTION + STATUS current + DESCRIPTION "An ID identifying the particular Alarm condition. + Typically used as an index for looking up Alarm details + in a System's Alarm Document. + + This will be a structured ID, in order to allow grouping of + Alarms into general categories and allow specific Alarms to + be independently added and numbered within the group. + + e.g. <Alarm Group ID>.<Alarm Event ID> + where <Alarm Group ID> = 000 - 999 + <Alarm Event ID> = 000 - 999 + + NOTE: the { alarm-id, entity-instance-id } uniquely identifies an ACTIVE Alarm. + e.g. + - an alarm is cleared based on the matching { alarm-id, entity-instance-id }, + - consecutive sets of an alarm with matching { alarm-id, entity-instance-id } + updates the fields of the single ACTIVE Alarm. + E.g. updates severity for example. " + SYNTAX OCTET STRING (SIZE (0..7)) + + WrsAlarmEntityInstanceId ::= TEXTUAL-CONVENTION + DISPLAY-HINT "255a" + STATUS current + DESCRIPTION "This is a textual description of the resource under alarm. + + A '.' separated list of sub-entity-type=instance-value pairs, + representing the containment structure of the overall entity + instance. + + Can be larger than 256 bytes. + + Note that this containment structure will be used for + processing hierarchical clears. + + e.g + system=ironpass1-4 + system=ironpass1-4 . host=compute-0 + system=ironpass1-4 . host=compute-0 . port=eth0 + system=ironpass1-4 . host=compute-0 . disk=/dev/sda + + system=ironpass1-4 . instance=vyatta_rtr_0 + system=ironpass1-4 . stack=vyatta_scaling_rtrs + + NOTE: the { alarm-id, entity-instance-id } uniquely identifies an ACTIVE Alarm. + e.g. + - an alarm is cleared based on the matching { alarm-id, entity-instance-id }, + - consecutive sets of an alarm with matching { alarm-id, entity-instance-id } + updates the fields of the single ACTIVE Alarm. + E.g. updates severity for example." + SYNTAX OCTET STRING + + WrsAlarmText ::= TEXTUAL-CONVENTION + DISPLAY-HINT "255a" + STATUS current + DESCRIPTION "Variable length string to encapsulate alarm or message + information from the entity raising the trap. + Can be larger than 256 bytes." + SYNTAX OCTET STRING + + WrsAlarmProbableCause ::= TEXTUAL-CONVENTION + STATUS current + DESCRIPTION + "ITU-T probable cause values. Duplicate values defined in + X.733 are appended with X733 to ensure syntactic uniqueness. + Probable cause value 0 is reserved for special purposes. + + The Internet Assigned Number Authority (IANA) is responsible + for the assignment of the enumerations in this TC. + IANAItuProbableCause value of 0 is reserved for special + purposes and MUST NOT be assigned. + + Values of IANAItuProbableCause in the range 1 to 1023 are + reserved for causes that correspond to ITU-T probable cause. + + All other requests for new causes will be handled on a + first-come, first served basis and will be assigned + enumeration values starting with 1025. + + Request should come in the form of well-formed + SMI [RFC2578] for enumeration names that are unique and + sufficiently descriptive. + + While some effort will be taken to ensure that new probable + causes do not conceptually duplicate existing probable + causes it is acknowledged that the existence of conceptual + duplicates in the starting probable cause list is an known + industry reality. + + To aid IANA in the administration of probable cause names + and values, the OPS Area Director will appoint one or more + experts to help review requests. + + See http://www.iana.org" + REFERENCE + "ITU Recommendation M.3100, 'Generic Network Information + Model', 1995 + ITU Recommendation X.733, 'Information Technology - Open + Systems Interconnection - System Management: Alarm + Reporting Function', 1992 + ITU Recommendation X.736, 'Information Technology - Open + Systems Interconnection - System Management: Security + Alarm Reporting Function', 1992" + SYNTAX INTEGER + { + not-applicable (0), + -- The following probable causes were defined in M.3100 + adaptor-error (1), + application-subsystem-failure (2), + bandwidth-reduced (3), + call-establishment-error (4), + communication-protocol-error (5), + communication-subsystem-failure (6), + configuration-or-customization-error (7), + congestion (8), + corrupt-data (9), + cpu-cycles-limit-exceeded (10), + dataset-or-modem-error (11), + degraded-signal (12), + dte-dce-interface-error (13), + enclosure-door-open (14), + equipment-malfunction (15), + excessive-vibration (16), + file-error (17), + fire-detected (18), + flood-detected (19), + framing-error (20), + heating-ventilation-cooling-system-problem (21), + humidity-unacceptable (22), + io-device-error (23), + input-device-error (24), + lan-error (25), + leak-detected (26), + local-node-transmission-error (27), + loss-of-frame (28), + loss-of-signal (29), + material-supply-exhausted (30), + multiplexer-problem (31), + out-of-memory (32), + output-device-error (33), + performance-degraded (34), + power-problem (35), + processor-problem (36), + pump-failure (37), + queue-size-exceeded (38), + receive-failure (39), + receiver-failure (40), + remote-node-transmission-error (41), + resource-at-or-nearing-capacity (42), + response-time-excessive (43), + retransmission-rate-excessive (44), + software-error (45), + software-program-abnormally-terminated (46), + software-program-error (47), + storage-capacity-problem (48), + temperature-unacceptable (49), + threshold-crossed (50), + timing-problem (51), + toxic-leak-detected (52), + transmit-failure (53), + transmitter-failure (54), + underlying-resource-unavailable (55), + version-mismatch (56), + duplicate-information (57), + information-missing (58), + information-modification-detected (59), + information-out-of-sequence (60), + unexpected-information (61), + denial-of-service (62), + out-of-service (63), + procedural-error (64), + unspecified-reason (65), + cable-tamper (66), + intrusion-detection (67), + authentication-failure (68), + breach-of-confidentiality (69), + non-repudiation-failure (70), + unauthorized-access-attempt (71), + delayed-information (72), + key-expired (73), + out-of-hours-activity (74) + } + + WrsAlarmEventType ::= TEXTUAL-CONVENTION + STATUS current + DESCRIPTION + "The ITU event Type values. + + The Internet Assigned Number Authority (IANA) is + responsible for the assignment of the enumerations + in this TC. + + Request should come in the form of well-formed + SMI [RFC2578] for enumeration names that are unique + and sufficiently descriptive. + + See http://www.iana.org " + REFERENCE + "ITU Recommendation X.736, 'Information Technology - Open + Systems Interconnection - System Management: Security + Alarm Reporting Function', 1992" + SYNTAX INTEGER + { + other (0), + communicationsAlarm (1), + qualityOfServiceAlarm (2), + processingErrorAlarm (3), + equipmentAlarm (4), + environmentalAlarm (5), + integrityViolation (6), + operationalViolation (7), + physicalViolation (8), + securityServiceOrMechanismViolation (9), + timeDomainViolation (10) + } + + + -- Wind River Systems Active Alarm Table + + wrsAlarmActiveTable OBJECT-TYPE + SYNTAX SEQUENCE OF WrsAlarmActiveEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION "This table contains information about active alarms." + ::= { wrsAlarmObjects 1 } + + wrsAlarmActiveEntry OBJECT-TYPE + SYNTAX WrsAlarmActiveEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION "An active alarm entry" + INDEX { wrsAlarmActiveIndex } + ::= { wrsAlarmActiveTable 1 } + + WrsAlarmActiveEntry ::= SEQUENCE { + wrsAlarmActiveIndex Unsigned32, + wrsAlarmActiveUuid DisplayString, + wrsAlarmActiveAlarmId WrsAlarmId, + wrsAlarmActiveEntityInstanceId WrsAlarmEntityInstanceId, + wrsAlarmActiveDateAndTime DateAndTime, + wrsAlarmActiveAlarmSeverity WrsAlarmSeverity, + wrsAlarmActiveReasonText WrsAlarmText, + wrsAlarmActiveEventType WrsAlarmEventType, + wrsAlarmActiveProbableCause WrsAlarmProbableCause, + wrsAlarmActiveProposedRepairAction WrsAlarmText, + wrsAlarmActiveServiceAffecting WrsBoolean, + wrsAlarmActiveSuppressionAllowed WrsBoolean + } + + wrsAlarmActiveIndex OBJECT-TYPE + SYNTAX Unsigned32 (1..4294967295) + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION "The index of the Active Alarm in the Active Alarm Table." + ::= { wrsAlarmActiveEntry 1 } + + wrsAlarmActiveUuid OBJECT-TYPE + SYNTAX DisplayString + MAX-ACCESS read-only + STATUS current + DESCRIPTION "An ID identifying the active alarm instance in the Active Alarm Table." + ::= { wrsAlarmActiveEntry 2 } + + wrsAlarmActiveAlarmId OBJECT-TYPE + SYNTAX WrsAlarmId + MAX-ACCESS read-only + STATUS current + DESCRIPTION "An ID identifying the particular Alarm condition. + Typically used as an index for looking up Alarm details + in a System's Alarm Document. + + This will be a structured ID, in order to allow grouping of + Alarms into general categories and allow specific Alarms to + be independently added and numbered within the group. + + e.g. <Alarm Group ID>.<Alarm Event ID> + where <Alarm Group ID> = 000 - 999 + <Alarm Event ID> = 000 - 999 + + NOTE: the { alarm-id, entity-instance-id } uniquely identifies an ACTIVE Alarm. + e.g. + - an alarm is cleared based on the matching { alarm-id, entity-instance-id }, + - consecutive sets of an alarm with matching { alarm-id, entity-instance-id } + updates the fields of the single ACTIVE Alarm. + E.g. updates severity for example. " + ::= { wrsAlarmActiveEntry 3 } + + wrsAlarmActiveEntityInstanceId OBJECT-TYPE + SYNTAX WrsAlarmEntityInstanceId + MAX-ACCESS read-only + STATUS current + DESCRIPTION "This is a textual description of the resource under alarm. + + A '.' separated list of sub-entity-type=instance-value pairs, + representing the containment structure of the overall entity + instance. + + Note that this containment structure will be used for + processing hierarchical clears. + + e.g + system=ironpass1-4 + system=ironpass1-4 . host=compute-0 + system=ironpass1-4 . host=compute-0 . port=eth0 + system=ironpass1-4 . host=compute-0 . disk=/dev/sda + + system=ironpass1-4 . instance=vyatta_rtr_0 + system=ironpass1-4 . stack=vyatta_scaling_rtrs + + NOTE: the { alarm-id, entity-instance-id } uniquely identifies an ACTIVE Alarm. + e.g. + - an alarm is cleared based on the matching { alarm-id, entity-instance-id }, + - consecutive sets of an alarm with matching { alarm-id, entity-instance-id } + updates the fields of the single ACTIVE Alarm. + E.g. updates severity for example." + ::= { wrsAlarmActiveEntry 4 } + + wrsAlarmActiveDateAndTime OBJECT-TYPE + SYNTAX DateAndTime + MAX-ACCESS read-only + STATUS current + DESCRIPTION "Provided in this table as a convenience. It is a copy of the Date and Time of the alarm." + ::= { wrsAlarmActiveEntry 5} + + wrsAlarmActiveAlarmSeverity OBJECT-TYPE + SYNTAX WrsAlarmSeverity + MAX-ACCESS read-only + STATUS current + DESCRIPTION "The severity of the alarm." + ::= { wrsAlarmActiveEntry 6} + + wrsAlarmActiveReasonText OBJECT-TYPE + SYNTAX WrsAlarmText + MAX-ACCESS read-only + STATUS current + DESCRIPTION "Represents the per active alarm instance additional text field." + REFERENCE "ITU Recommendation M.3100, 'Generic Network Information Model', 1995 + ITU Recommendation X.733, 'Information Technology - Open + Systems Interconnection - System Management: Alarm Reporting Function', 1992" + ::= { wrsAlarmActiveEntry 7} + + wrsAlarmActiveEventType OBJECT-TYPE + SYNTAX WrsAlarmEventType + MAX-ACCESS read-only + STATUS current + DESCRIPTION "Represents the per active alarm instance event type values." + REFERENCE "ITU Recommendation M.3100, 'Generic Network Information Model', 1995 + ITU Recommendation X.733, 'Information Technology - Open + Systems Interconnection - System Management: Alarm Reporting Function', 1992 + ITU Recommendation X.736, 'Information Technology - Open + Systems Interconnection - System Management: Security + Alarm Reporting Function', 1992" + ::= { wrsAlarmActiveEntry 8 } + + wrsAlarmActiveProbableCause OBJECT-TYPE + SYNTAX WrsAlarmProbableCause + MAX-ACCESS read-only + STATUS current + DESCRIPTION "Per active alarm instance ITU probable cause values." + REFERENCE "ITU Recommendation M.3100, 'Generic Network Information Model', 1995 + ITU Recommendation X.733, 'Information Technology - Open + Systems Interconnection - System Management: Alarm Reporting Function', 1992 + ITU Recommendation X.736, 'Information Technology - Open + Systems Interconnection - System Management: Security + Alarm Reporting Function', 1992" + ::= { wrsAlarmActiveEntry 9 } + + wrsAlarmActiveProposedRepairAction OBJECT-TYPE + SYNTAX WrsAlarmText + MAX-ACCESS read-only + STATUS current + DESCRIPTION "Represents more of the per active alarm instance additional text field." + ::= { wrsAlarmActiveEntry 10} + + wrsAlarmActiveServiceAffecting OBJECT-TYPE + SYNTAX WrsBoolean + MAX-ACCESS read-only + STATUS current + DESCRIPTION "This attribute indicates whether the alarm is service affecting or not." + ::= { wrsAlarmActiveEntry 11 } + + wrsAlarmActiveSuppressionAllowed OBJECT-TYPE + SYNTAX WrsBoolean + MAX-ACCESS read-only + STATUS current + DESCRIPTION "This attribute indicates whether the alarm can be manually suppressed or not." + ::= { wrsAlarmActiveEntry 12 } + + + -- Wind River Event Table + + wrsEventTable OBJECT-TYPE + SYNTAX SEQUENCE OF WrsEventEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION "This table contains information about events." + ::= { wrsAlarmObjects 4 } + + wrsEventEntry OBJECT-TYPE + SYNTAX WrsEventEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION "An event entry" + INDEX { wrsEventIndex } + ::= { wrsEventTable 1 } + + WrsEventEntry ::= SEQUENCE { + wrsEventIndex Unsigned32, + wrsEventUuid DisplayString, + wrsEventEventId WrsAlarmId, + wrsEventState WrsAlarmState, + wrsEventEntityInstanceId WrsAlarmEntityInstanceId, + wrsEventDateAndTime DateAndTime, + wrsEventSeverity WrsAlarmSeverity, + wrsEventReasonText WrsAlarmText, + wrsEventEventType WrsAlarmEventType, + wrsEventProbableCause WrsAlarmProbableCause, + wrsEventProposedRepairAction WrsAlarmText, + wrsEventServiceAffecting WrsBoolean, + wrsEventSuppressionAllowed WrsBoolean + } + + wrsEventIndex OBJECT-TYPE + SYNTAX Unsigned32 (1..4294967295) + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION "The index of the event in the Event Table." + ::= { wrsEventEntry 1 } + + wrsEventUuid OBJECT-TYPE + SYNTAX DisplayString + MAX-ACCESS read-only + STATUS current + DESCRIPTION "An ID identifying the event instance in the Event Table." + ::= { wrsEventEntry 2 } + + wrsEventEventId OBJECT-TYPE + SYNTAX WrsAlarmId + MAX-ACCESS read-only + STATUS current + DESCRIPTION "An ID identifying the particular Event condition. + Typically used as an index for looking up Event details + in a System's Event Document. + + This will be a structured ID, in order to allow grouping of + Events into general categories and allow specific Event to + be independently added and numbered within the group. + + e.g. <Event Group ID>.<Event Event ID> + where <Event Group ID> = 000 - 999 + <Event Event ID> = 000 - 999 " + ::= { wrsEventEntry 3 } + + wrsEventState OBJECT-TYPE + SYNTAX WrsAlarmState + MAX-ACCESS read-only + STATUS current + DESCRIPTION "The state of the event. + + For Customer log events, this field is set to LOG. The attributes that are applicable for a LOG state are: + State, EventId, EntityInstanceId, DateAndTime, Severity, ReasonText, EventType, ProbableCause, ServiceAffecting + + " + ::= { wrsEventEntry 4 } + + wrsEventEntityInstanceId OBJECT-TYPE + SYNTAX WrsAlarmEntityInstanceId + MAX-ACCESS read-only + STATUS current + DESCRIPTION "This is a textual description of the resource under event. + + A '.' separated list of sub-entity-type=instance-value pairs, + representing the containment structure of the overall entity + instance. + + e.g + system=ironpass1-4 + system=ironpass1-4 . host=compute-0 + system=ironpass1-4 . host=compute-0 . port=eth0 + system=ironpass1-4 . host=compute-0 . disk=/dev/sda + + system=ironpass1-4 . instance=vyatta_rtr_0 + system=ironpass1-4 . stack=vyatta_scaling_rtrs" + ::= { wrsEventEntry 5 } + + wrsEventDateAndTime OBJECT-TYPE + SYNTAX DateAndTime + MAX-ACCESS read-only + STATUS current + DESCRIPTION "Provided in this table as a convenience. It is the event last update Date and Time ." + ::= { wrsEventEntry 6 } + + wrsEventSeverity OBJECT-TYPE + SYNTAX WrsAlarmSeverity + MAX-ACCESS read-only + STATUS current + DESCRIPTION "The severity of the Event." + ::= { wrsEventEntry 7 } + + wrsEventReasonText OBJECT-TYPE + SYNTAX WrsAlarmText + MAX-ACCESS read-only + STATUS current + DESCRIPTION "Represents the per Event instance additional text field." + REFERENCE "ITU Recommendation M.3100, 'Generic Network Information Model', 1995 + ITU Recommendation X.733, 'Information Technology - Open + Systems Interconnection - System Management: Alarm Reporting Function', 1992" + ::= { wrsEventEntry 8 } + + wrsEventEventType OBJECT-TYPE + SYNTAX WrsAlarmEventType + MAX-ACCESS read-only + STATUS current + DESCRIPTION "Represents the per Event instance event type values." + REFERENCE "ITU Recommendation M.3100, 'Generic Network Information Model', 1995 + ITU Recommendation X.733, 'Information Technology - Open + Systems Interconnection - System Management: Alarm Reporting Function', 1992 + ITU Recommendation X.736, 'Information Technology - Open + Systems Interconnection - System Management: Security + Alarm Reporting Function', 1992" + ::= { wrsEventEntry 9 } + + wrsEventProbableCause OBJECT-TYPE + SYNTAX WrsAlarmProbableCause + MAX-ACCESS read-only + STATUS current + DESCRIPTION "Per Event instance ITU probable cause values." + REFERENCE "ITU Recommendation M.3100, 'Generic Network Information Model', 1995 + ITU Recommendation X.733, 'Information Technology - Open + Systems Interconnection - System Management: Alarm Reporting Function', 1992 + ITU Recommendation X.736, 'Information Technology - Open + Systems Interconnection - System Management: Security + Alarm Reporting Function', 1992" + ::= { wrsEventEntry 10 } + + wrsEventProposedRepairAction OBJECT-TYPE + SYNTAX WrsAlarmText + MAX-ACCESS read-only + STATUS current + DESCRIPTION "Represents more of the per historical alarm instance additional text field. + Applies to alarms only." + ::= { wrsEventEntry 11} + + wrsEventServiceAffecting OBJECT-TYPE + SYNTAX WrsBoolean + MAX-ACCESS read-only + STATUS current + DESCRIPTION "This attribute indicates whether the Event is service affecting or not." + ::= { wrsEventEntry 12 } + + wrsEventSuppressionAllowed OBJECT-TYPE + SYNTAX WrsBoolean + MAX-ACCESS read-only + STATUS current + DESCRIPTION "This attribute indicates whether the alarm can be manually suppressed or not. + Applies to alarms only." + ::= { wrsEventEntry 13 } + + + -- All notification OIDs would be prefixed with a zero OID to facilitate snmp v1<->v2 conversion + + wrsTrapPrefix OBJECT-IDENTITY + STATUS current + DESCRIPTION "This OID represents the prefix branch for all WIND RIVER ITU Alarm Trap. + The last but one sub identifier in the OID of any Notification must have the value + zero to facilitate v2<-->v1 conversion." + ::= {wrsAlarmObjects 0 } + + +-- Generic Severity-based Traps / Alarms + + wrsAlarmCritical NOTIFICATION-TYPE + OBJECTS { + wrsAlarmActiveAlarmId, + wrsAlarmActiveEntityInstanceId, + wrsAlarmActiveDateAndTime, + wrsAlarmActiveAlarmSeverity, + wrsAlarmActiveReasonText, + wrsAlarmActiveEventType, + wrsAlarmActiveProbableCause, + wrsAlarmActiveProposedRepairAction, + wrsAlarmActiveServiceAffecting, + wrsAlarmActiveSuppressionAllowed + } + STATUS current + DESCRIPTION "This notification indicates that an alarm of 'Critical' severity + has been raised on the system. + The varbinds include details of the alarm." + ::= { wrsTrapPrefix 1 } + + + wrsAlarmMajor NOTIFICATION-TYPE + OBJECTS { + wrsAlarmActiveAlarmId, + wrsAlarmActiveEntityInstanceId, + wrsAlarmActiveDateAndTime, + wrsAlarmActiveAlarmSeverity, + wrsAlarmActiveReasonText, + wrsAlarmActiveEventType, + wrsAlarmActiveProbableCause, + wrsAlarmActiveProposedRepairAction, + wrsAlarmActiveServiceAffecting, + wrsAlarmActiveSuppressionAllowed + } + STATUS current + DESCRIPTION "This notification indicates that an alarm of 'Major' severity + has been raised on the system. + The varbinds include details of the alarm." + ::= { wrsTrapPrefix 2 } + + + wrsAlarmMinor NOTIFICATION-TYPE + OBJECTS { + wrsAlarmActiveAlarmId, + wrsAlarmActiveEntityInstanceId, + wrsAlarmActiveDateAndTime, + wrsAlarmActiveAlarmSeverity, + wrsAlarmActiveReasonText, + wrsAlarmActiveEventType, + wrsAlarmActiveProbableCause, + wrsAlarmActiveProposedRepairAction, + wrsAlarmActiveServiceAffecting, + wrsAlarmActiveSuppressionAllowed + } + STATUS current + DESCRIPTION "This notification indicates that an alarm of 'Minor' severity + has been raised on the system. + The varbinds include details of the alarm." + ::= { wrsTrapPrefix 3 } + + + wrsAlarmWarning NOTIFICATION-TYPE + OBJECTS { + wrsAlarmActiveAlarmId, + wrsAlarmActiveEntityInstanceId, + wrsAlarmActiveDateAndTime, + wrsAlarmActiveAlarmSeverity, + wrsAlarmActiveReasonText, + wrsAlarmActiveEventType, + wrsAlarmActiveProbableCause, + wrsAlarmActiveProposedRepairAction, + wrsAlarmActiveServiceAffecting, + wrsAlarmActiveSuppressionAllowed + } + STATUS current + DESCRIPTION "This notification indicates that an alarm of 'Warning' severity + has been raised on the system. + The varbinds include details of the alarm." + ::= { wrsTrapPrefix 4 } + + + wrsAlarmMessage NOTIFICATION-TYPE + OBJECTS { + wrsAlarmActiveAlarmId, + wrsAlarmActiveEntityInstanceId, + wrsAlarmActiveDateAndTime, + wrsAlarmActiveAlarmSeverity, + wrsAlarmActiveReasonText, + wrsAlarmActiveEventType, + wrsAlarmActiveProbableCause, + wrsAlarmActiveProposedRepairAction, + wrsAlarmActiveServiceAffecting, + wrsAlarmActiveSuppressionAllowed + } + STATUS current + DESCRIPTION "This notification indicates that a stateless message alarm + event has occurred on the system. + The varbinds include details of the alarm. + Note that these events are stored in the Customer Log Table." + ::= { wrsTrapPrefix 5 } + + + wrsAlarmClear NOTIFICATION-TYPE + OBJECTS { + wrsAlarmActiveAlarmId, + wrsAlarmActiveEntityInstanceId, + wrsAlarmActiveDateAndTime, + wrsAlarmActiveReasonText + } + STATUS current + DESCRIPTION "This notification indicates that a previously + reported alarm have been cleared. + The previously reported alarm is identified by the + { AlarmId, EntityInstanceId } tuple." + ::= { wrsTrapPrefix 9 } + + wrsAlarmHierarchicalClear NOTIFICATION-TYPE + OBJECTS { + wrsAlarmActiveEntityInstanceId, + wrsAlarmActiveDateAndTime, + wrsAlarmActiveReasonText + } + STATUS current + DESCRIPTION "This notification indicates that one or more previously + reported alarms have been cleared. + The previously reported alarms are identified by the + EntityInstanceId attribute. + ALL alarms against EntityInstanceId and all of its children + have been cleared." + ::= { wrsTrapPrefix 99 } + + + +-- Notification group definitions + + wrsAlarmNotificationsGroup NOTIFICATION-GROUP + NOTIFICATIONS { + wrsAlarmClear, + wrsAlarmHierarchicalClear, + wrsAlarmMessage, + wrsAlarmWarning, + wrsAlarmMinor, + wrsAlarmMajor, + wrsAlarmCritical + } + STATUS current + DESCRIPTION "Wind River alarm notification group." + ::= { wrsAlarmGroups 1} + + wrsAlarmGroup OBJECT-GROUP + OBJECTS { + wrsAlarmActiveUuid, + wrsAlarmActiveAlarmId, + wrsAlarmActiveEntityInstanceId, + wrsAlarmActiveDateAndTime, + wrsAlarmActiveAlarmSeverity, + wrsAlarmActiveReasonText, + wrsAlarmActiveEventType, + wrsAlarmActiveProbableCause, + wrsAlarmActiveProposedRepairAction, + wrsAlarmActiveServiceAffecting, + wrsAlarmActiveSuppressionAllowed + } + STATUS current + DESCRIPTION "Wind River alarm group." + ::= { wrsAlarmGroups 2} + + + +-- Compliance + + wrsAlarmCompliance MODULE-COMPLIANCE + STATUS current + DESCRIPTION "The compliance statement for entities which implement + the Wind River Alarm MIB." + MODULE -- this module + MANDATORY-GROUPS { wrsAlarmGroup + } + ::= { wrsAlarmCompliances 1} + + +END diff --git a/stx-snmp-helm/centos/docker/stx-snmp/mibs/wrsEnterpriseReg.mib.txt b/stx-snmp-helm/centos/docker/stx-snmp/mibs/wrsEnterpriseReg.mib.txt new file mode 100755 index 0000000..f009cac --- /dev/null +++ b/stx-snmp-helm/centos/docker/stx-snmp/mibs/wrsEnterpriseReg.mib.txt @@ -0,0 +1,132 @@ +------------------------------------------------------------------------------ +-- +-- File : wrsEnterpriseReg.mib +-- Description : Wind River Enterprise Registration Hierarchy MIB +-- Version : 1.2.0 +-- Date : June 2, 2017 +-- OBSOLETES : wrsMasterMib.mib v0.6 (August 29, 2000) +-- +-- Copyright (c) 2014-2017 Wind River Systems, Inc. All Rights Reserved. +-- +-- This module defines the Wind River Systems (WRS) registration hierarchy, +-- +-- The Wind River Systems registration tree is administered with the following +-- hierarchy: +-- iso(1).org(3).dod(6).internet(1).private(4).enterprise(1) +-- .wrs(731) +-- .wrs(731).wrsCommon(1) +-- .wrs(731).wrsCommon(1).wrs<Module>(1-...) ... cont'd in wrsCommon<Module>.mib +-- .wrs(731).wrs<Product>(2-...) ... cont'd in wrs<Product>.mib +-- +-- Reproduction of this document is authorized on condition that this +-- copyright notice is included. This Wind River Enterprise Registration MIB +-- embodies proprietary intellectual property of Wind River Systems (WRS). +-- WRS retains all title and ownership in the specification, including any +-- revisions. +-- +-- It is the intent of WRS to encourage the widespread use of this +-- specification in connection with the management of Wind River products. +-- WRS grants vendors, end-users, and other interested parties a +-- non-exclusive license to use this specification in connection with the +-- management of Wind River products. +-- +-- This specification is supplied "AS IS", and WRS makes no warranty, +-- either express or implied, as to the use, operations, condition, +-- or performance of this specification. +-- +------------------------------------------------------------------------------ + +WRS-ENTERPRISE-REG-MIB DEFINITIONS ::= BEGIN + +IMPORTS + TEXTUAL-CONVENTION FROM SNMPv2-TC + MODULE-IDENTITY, enterprises FROM SNMPv2-SMI; + + wrs MODULE-IDENTITY + LAST-UPDATED "201407100000Z" -- July 10, 2014 + ORGANIZATION "Wind River Systems, Inc." + CONTACT-INFO "Wind River Systems, Inc. + 500 Wind River Way + Alameda, CA 94501, USA + Contact: Wind River Systems Support + E-mail : support@windriver.com + Phone : 510.748.4100" + DESCRIPTION "This module defines the Wind River Systems, Inc. Registration hierarchy." + + -- Revision history + REVISION "201407100000Z" -- July 10, 2014 + DESCRIPTION "Initial Version of MIB." + + ::= { enterprises 731 } + +-- WRS Common Enterprise MIB Modules + wrsCommon OBJECT IDENTIFIER ::= { wrs 1 } + wrsAlarms OBJECT IDENTIFIER ::= { wrsCommon 1 } -- Common WRS Enterprise Alarm MIB + +-- WRS Products +-- tms1_0 OBJECT IDENTIFIER ::= { wrs 1 } Obsolete + tms OBJECT IDENTIFIER ::= { wrs 2 } + wrsTs OBJECT IDENTIFIER ::= { wrs 3 } -- WRS Titanium Cloud specific Enterprise MIBs + + + + + + +--------------------------------------------------------------------------- +-- TMS OID Definitions +-- + +-- TMS Major MIB Categories + idb OBJECT IDENTIFIER ::= { tms 1 } -- IDB MIBs + tmsGeneric OBJECT IDENTIFIER ::= { tms 2 } -- TMS Generic MIBs + oemSwapi OBJECT IDENTIFIER ::= { tms 3 } -- OEM swAPI MIBs + oemProd OBJECT IDENTIFIER ::= { tms 4 } -- OEM Product MIBs + +-- TMS IDB Internal Module MIBs + rmonMib OBJECT IDENTIFIER ::= { idb 1 } +-- garpMib OBJECT IDENTIFIER ::= { idb 2 } SMIv2 +-- stpMib OBJECT IDENTIFIER ::= { idb 3 } SMIv2 + +-- TMS Generic MIBs +-- tmsCommonMib OBJECT IDENTIFIER ::= { tmsGeneric 1 } SMIv2 +-- tmsL3Mib OBJECT IDENTIFIER ::= { tmsGeneric 2 } SMIv2 + +-- OEM swAPI MIBs +-- pmSwapi OBJECT IDENTIFIER ::= { oemSwapi 1 } SMIv2 +-- bcmSwapi OBJECT IDENTIFIER ::= { oemSwapi 2 } SMIv2 +-- pcSwapi OBJECT IDENTIFIER ::= { oemSwapi 3 } SMIv2 + +-- OEM Product MIBs +-- pm3575 OBJECT IDENTIFIER ::= { oemProd 1 } SMIv2 +-- bcm5600 OBJECT IDENTIFIER ::= { oemProd 2 } SMIv2 +-- pcSwitch OBJECT IDENTIFIER ::= { oemProd 3 } SMIv2 + + + +--------------------------------------------------------------------------- +-- General Textual Conventions +-- + +WrsUUID ::= TEXTUAL-CONVENTION + STATUS current + DESCRIPTION "Universally Unique IDentifier; + format is typically XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX , + where X is a hex-digit." + SYNTAX OCTET STRING (SIZE (0..36)) + +WrsBoolean ::= TEXTUAL-CONVENTION + STATUS current + DESCRIPTION "Boolean type." + SYNTAX INTEGER + { + false (0), + true (1) + } + + +-- +-- END of WRS-ENTERPRISE-REG-MIB +-- + +END diff --git a/stx-snmp-helm/centos/stx-snmp-helm-fm-subagent.stable_docker_image b/stx-snmp-helm/centos/stx-snmp-helm-fm-subagent.stable_docker_image new file mode 100755 index 0000000..44d175b --- /dev/null +++ b/stx-snmp-helm/centos/stx-snmp-helm-fm-subagent.stable_docker_image @@ -0,0 +1,3 @@ +BUILDER=docker +LABEL=stx-fm-subagent +DOCKER_CONTEXT=docker/stx-fm-subagent diff --git a/stx-snmp-helm/centos/stx-snmp-helm-fm-trap-subagent.stable_docker_image b/stx-snmp-helm/centos/stx-snmp-helm-fm-trap-subagent.stable_docker_image new file mode 100755 index 0000000..06369da --- /dev/null +++ b/stx-snmp-helm/centos/stx-snmp-helm-fm-trap-subagent.stable_docker_image @@ -0,0 +1,3 @@ +BUILDER=docker +LABEL=stx-fm-trap-subagent +DOCKER_CONTEXT=docker/stx-fm-trap-subagent diff --git a/stx-snmp-helm/centos/stx-snmp-helm-snmp.stable_docker_image b/stx-snmp-helm/centos/stx-snmp-helm-snmp.stable_docker_image new file mode 100755 index 0000000..e26335b --- /dev/null +++ b/stx-snmp-helm/centos/stx-snmp-helm-snmp.stable_docker_image @@ -0,0 +1,3 @@ +BUILDER=docker +LABEL=stx-snmp +DOCKER_CONTEXT=docker/stx-snmp diff --git a/stx-snmp-helm/centos/stx-snmp-helm.spec b/stx-snmp-helm/centos/stx-snmp-helm.spec index f044890..6cbeb8a 100644 --- a/stx-snmp-helm/centos/stx-snmp-helm.spec +++ b/stx-snmp-helm/centos/stx-snmp-helm.spec @@ -25,6 +25,8 @@ Source0: helm-charts-snmp-0-1-0.tar.gz BuildArch: noarch BuildRequires: helm +BuildRequires: python-k8sapp-snmp +BuildRequires: python-k8sapp-snmp-wheels %description StarlingX SNMP Helm Charts @@ -55,6 +57,10 @@ sed -i 's/@APP_NAME@/%{app_name}/g' %{app_staging}/metadata.yaml sed -i 's/@APP_VERSION@/%{version}-%{tis_patch_ver}/g' %{app_staging}/metadata.yaml sed -i 's/@HELM_REPO@/%{helm_repo}/g' %{app_staging}/metadata.yaml +# Copy the plugins: installed in the buildroot +mkdir -p %{app_staging}/plugins +cp /plugins/%{app_name}/*.whl %{app_staging}/plugins + # package it up find . -type f ! -name '*.md5' -print0 | xargs -0 md5sum > checksum.md5 tar -zcf %{_builddir}/%{app_tarball} -C %{app_staging}/ . diff --git a/stx-snmp-helm/centos/stx-snmp-helm.stable_docker_image b/stx-snmp-helm/centos/stx-snmp-helm.stable_docker_image deleted file mode 100644 index b93294a4..0000000 --- a/stx-snmp-helm/centos/stx-snmp-helm.stable_docker_image +++ /dev/null @@ -1,2 +0,0 @@ -BUILDER=docker -LABEL=stx-snmp diff --git a/stx-snmp-helm/stx-snmp-helm/helm-charts/Makefile b/stx-snmp-helm/stx-snmp-helm/helm-charts/Makefile index bf83b0c..e0fa5a6 100644 --- a/stx-snmp-helm/stx-snmp-helm/helm-charts/Makefile +++ b/stx-snmp-helm/stx-snmp-helm/helm-charts/Makefile @@ -1,7 +1,7 @@ # # Copyright 2017 The Openstack-Helm Authors. # -# Copyright (c) 2019 Wind River Systems, Inc. +# Copyright (c) 2020 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # diff --git a/stx-snmp-helm/stx-snmp-helm/helm-charts/snmp/snmpd/snmpd.conf b/stx-snmp-helm/stx-snmp-helm/helm-charts/snmp/snmpd/snmpd.conf index 5a9b3cf..e172f50 100755 --- a/stx-snmp-helm/stx-snmp-helm/helm-charts/snmp/snmpd/snmpd.conf +++ b/stx-snmp-helm/stx-snmp-helm/helm-charts/snmp/snmpd/snmpd.conf @@ -4,4 +4,8 @@ view all included .1 80 agentAddress udp:161 sysObjectID 1.3.6.1.4.1.731.3 sysServices 72 +mibs +ALL +master agentx + +agentXSocket tcp:705 diff --git a/stx-snmp-helm/stx-snmp-helm/helm-charts/snmp/templates/configmap.yaml b/stx-snmp-helm/stx-snmp-helm/helm-charts/snmp/templates/configmap.yaml index 9c33145..5bec78a 100755 --- a/stx-snmp-helm/stx-snmp-helm/helm-charts/snmp/templates/configmap.yaml +++ b/stx-snmp-helm/stx-snmp-helm/helm-charts/snmp/templates/configmap.yaml @@ -4,4 +4,13 @@ metadata: name: {{ .Values.configmap.name_snmpd }} data: {{ (.Files.Glob "snmpd/*").AsConfig | indent 2 }} ---- \ No newline at end of file +{{ .Values.configmap.user_conf | indent 4 }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Values.configmap.name_fm }} +data: + fm.conf: | + sql_connection={{ .Values.configmap.connection }} + diff --git a/stx-snmp-helm/stx-snmp-helm/helm-charts/snmp/templates/deployment.yaml b/stx-snmp-helm/stx-snmp-helm/helm-charts/snmp/templates/deployment.yaml index 3b14789..08e58ce 100755 --- a/stx-snmp-helm/stx-snmp-helm/helm-charts/snmp/templates/deployment.yaml +++ b/stx-snmp-helm/stx-snmp-helm/helm-charts/snmp/templates/deployment.yaml @@ -18,7 +18,11 @@ spec: labels: app.kubernetes.io/name: {{ include "snmp.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} + annotations: + rollme: {{ randAlphaNum 5 | quote }} spec: + imagePullSecrets: + - name: default-registry-key containers: - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" @@ -28,10 +32,28 @@ spec: protocol: UDP - containerPort: 162 protocol: UDP + - containerPort: 705 + protocol: TCP volumeMounts: - name: snmpd-etc-volume mountPath: /etc/snmp + - name: {{ .Values.image.subagent_name }} + image: "{{ .Values.image.repository_subagent }}:{{ .Values.image.tag_subagent }}" + imagePullPolicy: {{ .Values.image.pullPolicy_subagent }} + volumeMounts: + - name: snmpd-fm-volume + mountPath: /etc/fm/ + - name: {{ .Values.image.trap_subagent_name }} + image: "{{ .Values.image.repository_trap_subagent }}:{{ .Values.image.tag_trap_subagent }}" + imagePullPolicy: {{ .Values.image.pullPolicy_trap_subagent }} + ports: + - containerPort: 162 + protocol: TCP + volumes: - name: snmpd-etc-volume configMap: name: {{ .Values.configmap.name_snmpd }} + - name: snmpd-fm-volume + configMap: + name: {{ .Values.configmap.name_fm }} diff --git a/stx-snmp-helm/stx-snmp-helm/helm-charts/snmp/templates/service.yaml b/stx-snmp-helm/stx-snmp-helm/helm-charts/snmp/templates/service.yaml index 6213ffe..6314939 100755 --- a/stx-snmp-helm/stx-snmp-helm/helm-charts/snmp/templates/service.yaml +++ b/stx-snmp-helm/stx-snmp-helm/helm-charts/snmp/templates/service.yaml @@ -10,10 +10,19 @@ metadata: spec: type: {{ .Values.service.type }} ports: - - name: port-1 + - name: port-snmp port: 161 protocol: UDP targetPort: 161 + - name: port-agentx + port: 705 + protocol: TCP + targetPort: 705 + - name: port-trap + port: 162 + protocol: TCP + targetPort: 162 + selector: app.kubernetes.io/name: {{ include "snmp.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/stx-snmp-helm/stx-snmp-helm/helm-charts/snmp/values.yaml b/stx-snmp-helm/stx-snmp-helm/helm-charts/snmp/values.yaml index b1b1fcf..857da97 100755 --- a/stx-snmp-helm/stx-snmp-helm/helm-charts/snmp/values.yaml +++ b/stx-snmp-helm/stx-snmp-helm/helm-charts/snmp/values.yaml @@ -5,15 +5,26 @@ replicaCount: 1 image: - repository: registry.local:9001/local/snmp - tag: 1.0.0 + repository: registry.local:9001/docker.io/starlingx/stx-snmp + tag: stx.5.0-1.0.0 pullPolicy: IfNotPresent + subagent_name: sub-agent + repository_subagent: registry.local:9001/docker.io/starlingx/stx-fm-subagent + tag_subagent: stx.5.0-1.0.0 + pullPolicy_subagent: IfNotPresent + trap_subagent_name: trap-subagent + repository_trap_subagent: registry.local:9001/docker.io/starlingx/stx-fm-trap-subagent + tag_trap_subagent: stx.5.0-1.0.0 + pullPolicy_trap_subagent: IfNotPresent nameOverride: "" fullnameOverride: "" configmap: name_snmpd: snmpd-etc-config + name_fm: snmpd-fm + user_conf: '# User configuration' + connection: '' deployment: master_agent_host: localhost