Commit Graph

596 Commits

Author SHA1 Message Date
Hasan Acar 7c42c56f1f fix: Making the gates happy
Change-Id: Iddf3469f07486f2c58b46ea993547eecd6df3382
2024-04-16 11:51:48 +00:00
Jan Zerebecki dbb766218e Remove JMSAppender.class to avoid CVE-2021-4104,
CVE-2022-23302, CVE-2022-23305, and CVE-2022-23307.

Though it does not contain a vulnerable configuration of log4j, to avoid
needing to prove that and false positives of security scanners, this
commit is the result of running the following commands:

zip -q -d monasca_agent/collector/checks/libs/jmxfetch-0.3.0-jar-with-dependencies.jar org/apache/logging/log4j/core/lookup/JndiLookup.class org/apache/log4j/net/JMSAppender.class org/apache/log4j/jdbc/JDBCAppender.class org/apache/log4j/net/JMSSink.class org/apache/log4j/chainsaw"*"
unzip monasca_agent/collector/checks/libs/jmxterm-1.0-DATADOG-uber.jar WORLDS-INF/lib/log4j.jar
zip -q -d WORLDS-INF/lib/log4j.jar org/apache/logging/log4j/core/lookup/JndiLookup.class org/apache/log4j/net/JMSAppender.class org/apache/log4j/jdbc/JDBCAppender.class org/apache/log4j/net/JMSSink.class org/apache/log4j/chainsaw"*"
zip monasca_agent/collector/checks/libs/jmxterm-1.0-DATADOG-uber.jar WORLDS-INF/lib/log4j.jar

Change-Id: Id47ba9397e7fef1ac8622abb2a1691a260f4bc9c
2022-01-27 09:05:15 +00:00
Zuul 170afab952 Merge "Revert "Replace fnmatch with oslo.utils.fnmatch"" 2021-07-13 13:22:13 +00:00
Takashi Kajinami ad45a1bb77 Revert "Replace fnmatch with oslo.utils.fnmatch"
This reverts commit 9ff337881b.

Reason for revert:
The oslo_utils.fnmatch module was added to solve an issue in py2.7 but
it is no longer required because py2.7 is no longer supported.
The module was deprecated since oslo.utils 4.9.1[1] and the stdlib's
fnmatch module should be used instead.

[1] 4c893c92f551c9dd2a7cfbe7ae8171ad8139df0b

Change-Id: I84c0d2b2705e34b9853d42d03a398ecbe4f95330
2021-07-06 12:25:27 +00:00
kpdev f6d1170b9b vmware: Use oslo.vmware's get_moref_value()
With switching the SOAP library backing oslo.vmware [1], the internal
representation of ManagedObjectReference's attributes changes. To be able
to make the switch without interruption, we introduced helper functions
in oslo.vmware. This commit uses one of those - get_moref_value()
- to make the access to the "value" attribute compatible with both
backing libraries.

[1] https://specs.openstack.org/openstack/oslo-specs/specs/victoria/oslo-vmware-soap-library-switch.html

Change-Id: I50f0aa5d8865323515d15d1c1c5f10683bbac090
2021-06-15 15:14:44 +00:00
Martin Chacon Piza 679f09a3a8 Fix PY3 issue
- In PY3 the output of subprocess.Popen is a type bytes, but
strip() method requires a type str.

Story: 2008017
Task: 40669

Change-Id: I297c30044df9a94baa645a1a27de10bb49038440
2021-06-10 16:25:06 +02:00
Pierre Riteau 478a438654 Fix typo in log message
Change-Id: I4d6801b2d162b2acd00d0cf07aee109ebe652718
2021-06-09 09:49:31 +00:00
Adrian Czarnecki 4047310277 Fix small issue in dokcer plugin.
Change-Id: I7dda293fde999407a1bca7684b2ee777bfc7eddf
2021-03-24 08:12:33 -07:00
Zuul abc8f5982e Merge "Use importlib to take place of imp module" 2020-11-23 23:45:21 +00:00
Zuul 39131405ad Merge "Remove six" 2020-11-13 17:07:14 +00:00
likui c84e98d6b6 Remove six
Replace the following items with Python 3 style code.

- six.PY2
- six.add_metaclass
- six.string_types
- six.text_type
- six.moves
- six.StringIO
- six.wraps
- six.integer_types

Story: 2008305
Task: 41191

Change-Id: I68710421b69d4049c9e990451da491dc14251fb5
2020-11-13 16:16:58 +01:00
Yanos Angelopoulos 085f64578f Set 'libvirt_type' and 'libvirt_uri' options in the 'libvirt' plugin to be defined in conf.d/libvirt.yaml
The 'libvirt_type' and 'libvirt_uri' options are currently set by oslo configuration library.
However, in 'monasca_agent/collector/virt/libvirt/inspector.py' file these options cannot be
provided by a configuration file. Changing this to retrieve both options from
'conf.d/libvirt.yaml' file.

Change-Id: I1918fda471e951f42db0d302e371108b664e936c
2020-11-11 02:40:33 +02:00
gugug 8bf8c8b006 Use importlib to take place of imp module
The imp module is deprecated[1] since version 3.4, use importlib to
instead

[1]: https://docs.python.org/3/library/imp.html

Change-Id: I10f2c8c165aebddc8fd39601a0a23231ff89cdf7
2020-08-30 23:10:04 +08:00
bandorf 79dd8cad21 Convert byte-stream to 'utf-8'
Change-Id: Id0a2140ceca38e3baf0de9d28d392e6b8929d26a
Story: 2007977
Task: 40599
2020-08-10 12:28:09 +00:00
Hervé Beraud 0d16b32190 Stop to use the __future__ module.
The __future__ module [1] was used in this context to ensure compatibility
between python 2 and python 3.

We previously dropped the support of python 2.7 [2] and now we only support
python 3 so we don't need to continue to use this module and the imports
listed below.

Imports commonly used and their related PEPs:
- `division` is related to PEP 238 [3]
- `print_function` is related to PEP 3105 [4]
- `unicode_literals` is related to PEP 3112 [5]
- `with_statement` is related to PEP 343 [6]
- `absolute_import` is related to PEP 328 [7]

[1] https://docs.python.org/3/library/__future__.html
[2] https://governance.openstack.org/tc/goals/selected/ussuri/drop-py27.html
[3] https://www.python.org/dev/peps/pep-0238
[4] https://www.python.org/dev/peps/pep-3105
[5] https://www.python.org/dev/peps/pep-3112
[6] https://www.python.org/dev/peps/pep-0343
[7] https://www.python.org/dev/peps/pep-0328

Change-Id: I2471123ec7f3ea0b872f5054d6160bcd88a104b0
2020-06-04 13:05:21 +02:00
Zuul 183e1bab8b Merge "Improve error handling in method that creates Monasca client" 2020-05-28 12:52:20 +00:00
Adrian Czarnecki a44befb061 Improve error handling in method that creates Monasca client
Add error handler that prevent crash of forwarded
when agent is not able to connect to keystone

Story: 2007674
Task: 39781
Change-Id: If6366e5b94f9cbe3f21ce9dbeb26d28e3a36ae88
2020-05-26 16:19:48 -07:00
Doug Szumski a2400fcf12 Fix parsing of StatsD metrics with Py3
When running with Py3 we compare a byte string to a unicode string
when parsing StatsD metrics. This patch adds some unit tests to
reproduce the bug and decodes the bytestring to make the existing
comparisons valid under Py3. When backporting to Train we can use
Oslo encodeutils. Clearly we could have more unit tests, but
this makes a start.

Change-Id: I6341f96f5c186428d2d829cabf618a6f84f40ce2
Story: 2007684
Task: 39796
2020-05-22 21:08:28 +01:00
Witek Bedyk 1f24f46332 Fix flake8 errors
Change-Id: Idb1c1fbe9484b118ec6fe20b7176e173c83694a1
2020-05-14 12:11:56 +02:00
KeithMnemonic 674cefe1e7 Add debug output for libvirt ping checks
This patch adds some extra debug options to the ping check. It writes
the STDOUT of ping subprocess to a temporary file which can be logged in
the debug log level.

Change-Id: Ife9a1d409a8326fb9ff07b1b04508cd11f899d10
2020-05-08 14:14:22 +00:00
Andreas Jaeger cedadccc6f Update hacking for Python3
The repo is Python 3 now, so update hacking to version 3.0 which
supports Python 3.

Fix problems found.

Update local hacking checks for new flake8.

Change-Id: I6396403d0a62f5403fc5b7fb04b6ce790c332c84
2020-03-31 06:49:33 +00:00
Darragh O'Reilly 1caaf4423a Close db connection in mysql check
Mysql log gets an "Aborted connection" warning every 30sec
because the connection is not being closed properly.

Story: 2007233
Task: 38509
Change-Id: Ied6c19f8f7ac9b81f61b84efa2f6c7a8e40c3056
2020-01-30 12:32:16 +00:00
Zuul ebd42eb5de Merge "Add Infiniband metrics plugin" 2020-01-16 08:25:26 +00:00
Doug Szumski e4aba27933 Add Infiniband metrics plugin
This plugin adds initial support for gathering Infiniband counters.

Story: 2007044
Task: 37859
Change-Id: Id04c34bd9aabd61ccd4ce22b30e515e4ca627561
2020-01-14 11:33:03 +00:00
Zuul 8af052695b Merge "Add support for gathering Slab memory usage" 2020-01-13 18:00:27 +00:00
Doug Szumski 0a4abd532e Add support for gathering Slab memory usage
This is useful, for example when monitoring Slab memory leaks. To support
gathering this metric a minimum version of psutil 5.4.4 is required
(released on Apr 13th 2018).

Story: 2006815
Task: 37375
Change-Id: Ibe8def9e2a7c967a34236889aa03b287065abcdc
2019-12-19 15:23:24 +00:00
Stig Telfer 3406f8243c Ceph plugin updates for Luminous
Since the Luminous release of Ceph, the plugin no longer exports metrics
such as object storage daemon stats, placement groups and pool stats.
Check for the installed version of the Ceph command and parse results
according to version.

Include test data for Jewel and Luminous Ceph clusters.

Story: 2005032
Task: 29515

Change-Id: I0aef0db25f49545c715b07880edd57135e3beafe
Co-Authored-By: Bharat Kunwar <bharat@stackhpc.com>
Co-Authored-By: Doug Szumski <doug@stackhpc.com>
2019-12-18 10:59:08 +00:00
Guang Yee e1d73c4b5d add X.509 certificate check plugin
Currently we don't have any capability to monitor the internal TLS/SSL
certificates. i.e. SSL certificates used by MySQL for replication, RabbitMQ for
distribution, etc. The cert_check plugin is not adequate for this purpose
becaue it can only check on certficates over HTTPS endpoints. Furthermore,
checking on these internal certificates over the network is cumbersome
because the agent plugin would have to speak specific protocols.

This patch adds a cert_file_check plugin to detect the certificate expiry
(in days from now) for the given X.509 certificate file in PEM format.
Similar to cert_check plugin, this plugin will a metric
'cert_file.cert_expire_days' which contains the number of days from now the
given certificate will be expired. If the certificate has already expired,
this will be a negative number.

Change-Id: Id95cc7115823f972e234417223ab5906b57447cc
Story: 2006753
2019-11-13 08:35:54 -08:00
Zuul 4b70995282 Merge "Change Elasticsearch urls to fix failing metrics retrieval" 2019-10-28 11:16:53 +00:00
Matthew Oliver 833e5946fe Add swift_handoffs check plugin to monasca
A powerful metric to watch for a swift cluster is the
number of handoff partitions on a drive on a storage node.

A build up of handoff nodes on a particular server could
indicate a disk problem somewhere in the cluster. A bottleneck
somewhere. Or better, when would be a good time to rebalance
the ring (as you'd want to do it when existing backend data
movement is at a minimum.

So it turns out to be a great visualisation of the health of
a cluster.

That's what this check plugin does. Each instance check takes
the following values:

  ring: <path to a Swift ring file>
  devices: <path to the directory of mountpoints>
  granularity: <either server or device>

To be able to determine primary vs handoff partitions on a drive
the swift ring needs to be consulted. If a storage node stores
more then 1 ring, and an instance would be defined for each.

You give swift a bunch of disks. These disks are placed in what
swift calls the 'devices' location. That is a directory where a
mount point for each mounted swift drive is located.

Finally, you can decide on the granularity, which defaults to
`server` if not defined. Only 2 metrics are created from this
check:

  swift.partitions.primary_count
  swift.partitions.handoff_count

But with the hostname dimension a ring dimension will also be set.
Allowing the graphing of the handoff vs partitions of each ring.
When the granularity is set to device, then an additional
dimension to the metric is added, the device name (the name of
the devices mount point). This allows the graphing and monitoring
of each device in a server if a finer granularity is required.

Because we need to consult the Swift ring there is a runtime
requirement on the Python Swift module being installed. But
this isn't required for the unit tests. Making it a runtime
dependency means when the check is loaded it'll log an error
and then exit if it can't import the swift module.

This is the second of two Swift check plugins I've been working on.
For more details see my blog post[1]

[1] - https://oliver.net.au/?p=358

Change-Id: Ie91add9af39f2ab0e5b575390c0c6355563c0bfc
2019-10-18 17:16:14 +02:00
Matthew Oliver 0d929d01a8 Add swift_recon check plugin to monasca
Swift outputs alot of statsd metrics that you can point directly
at monasca-agents. However there is another swift endpoint,
recon, that is used to gather more metrics.

The Swift recon (or reconnaissance) API is an endpoint each of the
storage node servers make available via a REST API. This API can
either be hit manually or via the swift-recon tool.

This patch adds a check plugin that hits the recon REST API and
and send metrics to monasca.

This is the first of two Swift check plugins I'm working on.
For more details see my blog post[1]

[1] - https://oliver.net.au/?p=358

Change-Id: I503d74936f6f37fb261c1592845968319695475a
2019-10-09 19:06:08 +02:00
Arseni Lipinski 833cee2413 Change Elasticsearch urls to fix failing metrics retrieval
The change concerns Elasticsearch 7.3+. The change was made
due to internal changes in Elastisearch, as compared to the
version we're using now.

Story: 2006376
Task: 36167

Change-Id: Ia60e6173ba28433c6b020998157456f3e2bcc184
2019-09-24 11:36:23 +00:00
Dobroslaw Zybort 7f36745b69 Fix python 3 compatibility in statsd
Change-Id: I7e0ba155e209960edee7df3b4c7d248896cf3d5b
2019-09-24 09:26:51 +02:00
Andreas Jaeger ea9f2ebc15 Update api-ref location
The api documentation is now published on docs.openstack.org instead
of developer.openstack.org. Update all links that are changed to the
new location.

Note that redirects will be set up as well but let's point now to the
new location.

For details, see:
http://lists.openstack.org/pipermail/openstack-discuss/2019-July/007828.html

Change-Id: I744e2f029df54410394341e60a46b56658e4175c
2019-07-30 19:51:03 +02:00
Pierre Riteau 7dca05326d Add missing space to log statement
Change-Id: I1ea64ce2217776658e8139aa041e4e217985dfbb
2019-07-22 18:55:07 +02:00
Zuul ebc8eb843e Merge "Enable unit tests for py36" 2019-07-22 15:03:24 +00:00
Joseph Davis 623a4db21f Enable unit tests for py36
Even though there was a py36 test enabled in the gate, the tox.ini
configuration was not actually invoking the unit tests.  This
change sets up the environment to allow tests to run.

As a result, a number of Python3 errors are uncovered and fixed.

Notably:
  Python 3 does not have contextlib.nested, so reformatting using ,
  file() is not in Python 3, so use io.open() instead
  Use six.assertCountEqual(self, in tests

safe_decode:
  subprocess.check_output returns in byte encoding, while default text
type str. safe_decode does the right thing by making sure string are not
bytes in python2 and python3

No ascci encoding:
 python3 defaults to UTF-8 encoding, which is merely an extension to
ascii (default for python2).

test_json_plugin.py:
 the file being opened in binary(wb) mode so python is expecting the
string in bytes.

Some of the refactoring should be revisited after we drop Python 2
support.

Change-Id: I62b46a2509c39201ca015ca7c269b2ea70c376c8
Story: 2005047
Task: 29547
2019-07-18 16:08:09 +02:00
akhiljain23 3404a6df72 Update hacking version to 1.1.x
This commit updates hacking version in test-requirements
and fixes some related pep8 issues

Also ignores false positive bandit test
B105: hardcoded_password_string,
B106: hardcoded_password_funcarg
based on variable or argument names.
For more info refer [1][2]

[1] https://bandit.readthedocs.io/en/latest/plugins/b105_hardcoded_password_string.html
[2] https://bandit.readthedocs.io/en/latest/plugins/b106_hardcoded_password_funcarg.html

Change-Id: If779ebad11926594961577e0744093a8ba691610
Story: 2004930
Task: 29314
2019-06-26 12:49:13 +05:30
Adrian Czarnecki 62d1412223 Fix python3 compatibility
Change-Id: I1b3e4ffa2317e824be8454c5549669bbed8952e3
2018-12-18 12:29:59 +01:00
Zuul 301d2871d0 Merge "Improve metric error handling" 2018-11-20 13:15:22 +00:00
Joseph Davis f2e1f03fc8 Improve metric error handling
flush() should not produce a metric if value is None (causes
exception in monasca-api).
Fix the exception message in flush() to use the correct data
structure.

Change-Id: I62d31270db9e70f16d2a38a73856009c52c098e6
Story: 2004276
Task: 27825
2018-11-06 12:49:18 -08:00
Chuck Short b8bb2ff4c3 Add python36 support
Use the six library to get monasca-agent to work with
python2.7 and python3.

Story: 2004148
Task: 27621

Change-Id: I0de315967dd5a745741fda0c53ce8cc85cda8cc5
Signed-off-by: Chuck Short <chucks@redhat.com>
2018-10-25 09:09:53 -04:00
Zuul 5ff06e027f Merge "Enable the system metrics in Docker environment" 2018-08-24 06:37:21 +00:00
Lukasz Zajaczkowski f23ceda96b Enable the system metrics in Docker environment
Story: 2003093
Task: 23185
Change-Id: I9700a6fcb650fbcf983f2a4f145b430876f12429
2018-08-22 10:12:38 +02:00
Doug Szumski 902ab5dd90 Use six library to import python queue
Due to the queue module being renamed in Python 3 we need to support
both the new and the old name whilst people are still using Python 2.

Story: 2003130
Task: 23251
Change-Id: I9075183e199530f1953c2cd988ec28b3d0580257
2018-07-30 09:36:05 +01:00
Adrian Czarnecki 7b150fa352 Make forwarder and collector compatible with py35
Change-Id: Ia269ec000caec80cea2ca201012f65520efb046d
2018-07-17 13:31:48 +02:00
Tuan Do Anh 3712e124a6 Trivial fix typo of description
Corrected the typo of description in check.py

Change-Id: Id78880f8a41a820974fef3d673f3b86564bb5f7b
2018-07-10 11:29:02 +07:00
Zuul 17332007e3 Merge "Enable the process plugin in Docker environment" 2018-07-09 11:16:07 +00:00
Lukasz Zajaczkowski 029127aa42 Enable the process plugin in Docker environment
Change-Id: I860a960f900fcb89ce4c7ddb096f9c37cba9c4c9
Story: 2002783
Task: 22667
2018-07-09 10:57:33 +02:00
Adrian Czarnecki 92ac626c9b Python3: Make monasca-setup compatible with py35
Change-Id: Ieb4039e5af8d876218ce9b20d6f293c3dff989a9
2018-07-03 15:08:58 +02:00