38 Commits

Author SHA1 Message Date
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
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
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
Adrian Czarnecki
92ac626c9b Python3: Make monasca-setup compatible with py35
Change-Id: Ieb4039e5af8d876218ce9b20d6f293c3dff989a9
2018-07-03 15:08:58 +02:00
Adrian Czarnecki
96f08da015 fix tox python3 overrides
We want to default to running all tox environments under python 3, so
set the basepython value in each environment.

We do not want to specify a minor version number, because we do not
want to have to update the file every time we upgrade python.

We do not want to set the override once in testenv, because that
breaks the more specific versions used in default environments like
py35 and py36.

Change-Id: I12967d5f5e707efe2b271b28bc7ea4b40e7f1c15
2018-07-02 09:41:20 +02:00
Jui Chandwaskar
82200d9401 Fix log rotation in monasca agent
Observed AttributeError in forwarder and collector logs due to
missing import of logging module handlers.

Added missing import and removed module level import.

Task:15058
Story: 2001941
Change-Id: I62b03bb550c8b01ce9ea5bb4ba49a2ac00763d68
2018-04-30 11:26:15 +02:00
Jui Chandwaskar
2b2b5719c7 Fix type error in monasca agent
Observed TypeError in forwarder and collector logs while
executing monasca agent. Due to which monasca agent failed
to start.

Added line continuation character to fix the error.

Change-Id: Ibaf148ca6cf7b9cb73ceabacccf7aa519897af72
Task: 14449
Story: 2001922
2018-04-27 09:00:34 +02:00
Jui Chandwaskar
c983708637 Add Apache License
Added Apache 2.0 License for missed files

Change-Id: I72217d3cf0089434a9bbe1e5dfd57224a803704e
Signed-off-by: Jui Chandwaskar <jchandwaskar@op5.com>
2018-04-14 11:50:07 +00:00
Jui Chandwaskar
f837eee559 Update pep8 checks
* set the maximum line length to 100
* cleaned up the codes for pep8

Depends-On: https://review.openstack.org/560844
Change-Id: Id548b78b673cce869ef8291bdb6b4f1367b383ed
Signed-off-by: Jui Chandwaskar <jchandwaskar@op5.com>
2018-04-12 11:05:01 +00:00
kaiokassiano
0c49ed4a8e Remove deprecated io_loop argument
The argument io_loop on the ioloop.PeriodicCallback constructor is
deprecated in newer tornado versions, so we can just remove it.

Since we are using tornado<=4.5.2 on stable/pike, we can correctly set
master's version to tornado>=4.5.3.

Story: 2001489
Task: 6218

Change-Id: Id621d5b609e1bf4eac3a3dd4aff44436dd012b87
2018-01-29 13:33:54 -03:00
Tomasz Trębski
e099d074da Fix broken help commands for monasca-*
Call for:

* monasca-collector -h
* monasca-forwader -h
* monasca-statsd -h

was broken, as described in [1].

Commits removes usage of deprecated optparse in favor
of argparse.

Ref:
[1] https://storyboard.openstack.org/#!/story/2000995

Story: 2000998
Task: 4180
Change-Id: I8879f1f11a2502c180407c93e13d22451f6f2fa2
2017-05-15 06:53:00 +00:00
Jenkins
e04f5df4ad Merge "Configurable logrotate in agent" 2017-05-04 13:17:14 +00:00
Michael Worley
730b77a637 Configurable logrotate in agent
Story: 2000997
Task: 4179

Change-Id: I2e38b1f0a94209c4d38b50e192b35a141b582424
2017-05-02 13:25:10 -07:00
Kaiyan Sheng
22ac6a1e60 Rollup network metrics and disk io metrics
In cadvisor and kubernetes plugin network metrics are reported
by individual network interface and disk io metrics are by each
device. Instead of getting seperate metrics for each interface
or device, the roll up results among all are more useful.

Change-Id: I483a7f458ce05de2572d8dfe70e5943eae572f3b
2017-04-19 09:06:20 -06:00
Claudiu Belu
fcdad06ab2 Properly get the conf.d folder
Currently, it only loads the conf.d folder based on
the statically defined default config file location.

It should take into account the config-file argument
passed.

The Config object already has a get_confd_path method
which does this, and it should be used instead.

Partially-Implements: blueprint add-windows-support

Change-Id: I406b1773920d0b546956452da5003b3f27de8bc0
2016-10-11 19:42:04 +03:00
Claudiu Belu
5c616b2afa Adds config-file arg option
Currently, the configurations are being loaded from a
statically defined file (/etc/monasca/agent/agent.yaml).

Adds CLI arg option for the configuration file (--config-file).
Also added this argument to the forwarder's tornado options, in
order to avoid exception due to unrecognised argument.

Co-Authored-By: Craig Bryant <craig.bryant@hpe.com>

Partially-Implements: blueprint add-windows-support

Change-Id: I400fdb3db6562a7171ecadcb27ee63ae4eaf8006
2016-10-11 19:41:04 +03:00
zhangyanxian
db00b7bc9f Fix a typo in util.py
TrivialFix

Change-Id: I2fe1bacd21582fb70bb6534408558119fbff3e5b
2016-09-21 02:06:07 +00:00
Michael James Hoppal
8b4ed96fa7 Rework Vertica plugin
Adding the metrics to monitor resource pools, resources
and projections per a node.

Metrics for Vertica are now:

vertica.connection_status
vertica.node_status
vertica.projection.ros_count
vertica.projection.tuple_mover_mergeouts
vertica.projection.tuple_mover_moveouts
vertica.projection.wos_used_bytes
vertica.resource.disk_space_rejections
vertica.resource.pool.memory_inuse_kb
vertica.resource.pool.memory_size_actual_kb
vertica.resource.pool.rejection_count
vertica.resource.pool.running_query_count
vertica.resource.request_queue_depth
vertica.resource.resource_rejections
vertica.resource.wos_used_bytes

Change-Id: I6e30d524ca77f900f231b9a626bfa853e31dbeb1
2016-06-06 14:46:27 -06:00
Michael James Hoppal
ff5e9c7d7c Refactor agent
Remove windows related code as we do not support running on
windows

Remove the idea of check status as it was added code and complexity
that we did not gain much from.

Remove some functions at the AgentCheck level that either added another
layer of complexity that we did not get any functionality from or functions
that we didnt use like events

Change-Id: I4b6bc4f9d38e6b4f4fe5c632f885b84aaff7fd08
2016-04-13 16:50:44 -06:00
cindy oneill
cb1334271a New Vertica plugin
The vertica plugin will watch vertica processes
(create process.pid_count metrics for vertica
processes) and create vertica.db.connection_status
metrics.  A vertica.db.connection_status with
value=1 can indicate that the DB on a host
is not healthy.

Change-Id: I03dddec6adaa3f428fdabb5e24e884be1adb3dab
2016-02-27 08:44:21 -07:00
Ryan Brandt
3a08640e06 Change order of dimension override
Change to instance overrides plugin which overrides agent config

Change-Id: I54f9353969ae16fcba3757198016d37b226ef5fc
2016-02-09 13:38:48 -07:00
Kaiyan Sheng
85c24f10c3 Restart collector in agent every 24 hours
Restart the collector every 24 hours by default will
prevent the collection time growing over 15 seconds

Change-Id: I8e26ba703d13adaa685e397e9dbec749b2ed843d
2016-02-05 14:24:53 -07:00
Michael James Hoppal
b2211aa0eb Add HPE copyright
Change-Id: I46efbc9be90a8415e60f3db76656e7db3d7bcb54
2016-02-02 10:34:10 -07:00
Kaiyan Sheng
dc16d7b0ef Display collection time for each check
Add collection time in millisecond for each check in log file (DEBUG).
If the collection time for a single check is larger than the threshold value
for warning (5second as default), a warning message will be created in log file.

Change-Id: Ieb4949fbdd6b3db79de13b52abe2a367afceaa9e
2016-01-14 09:25:49 -07:00
David Schroeder
24d170fbb5 Allow config file 'instances' to be empty
This change allows slightly more lenient processing of Agent config
files, where 'instances' is still required in the .yaml file, but may
be an empty list.

An example of where this is necessary is the libvirt plugin, where
it is unreasonable to have all VMs enumerated as 'instances' in the
.yaml file, but are instead provided by the hypervisor.

The libvirt plugin itself needed a minor modification to work with
empty instances.  These changes are necessitated by the monasca-setup
change https://review.openstack.org/239815

Change-Id: Idc67df9e5d9195f65fe16b9d67478e1de8e61eb3
2015-10-29 17:21:02 -06:00
Michael James Hoppal
977b07a29c Remove watchdog from the agent
The watchdog is causing problems by restarting the agent
even if it does not need to. Also we are not gaining
anything by running it. In result we are removing
watchdog completely from the agent.

Change-Id: I45b80e28d81749c98dff7273d7756e10db23da70
2015-08-25 08:07:08 -06:00
Joe Keen
1ded0b7b1c Fixing flake8 errors now that tox is working again
Change-Id: Id34991711c57f20922f003928008143032723af3
2015-07-30 14:47:02 -06:00
Gary Hessler
f9fd9c5a30 Converted the agent config file to yaml to match the plugin config files
Converted the config file to yaml and updated the config processing logic to match.
Cleaned up some deprecated config item processing.

Change-Id: I8c5d9ad841b22d20825608ac9f2c82d8011b04f0
2015-03-02 18:36:15 -07:00
Gary Hessler
b1de7db1f5 Removing subprocess call from system metrics classes
Changed the IO, Disk and Network classes to not use a subprocess.
They now use psutil to get the metrics.  Also, changed the linux
system metrics classes to subclass the AgentCheck class instead
of the old-style Check class.  Added additional configuration
and changed monasca-setup to support that. Fixed some Python
2.6 incompatible string formatting issues.

Change-Id: I1f8b65bf48e48e2c598aa4950c194fbae2f9e337
2015-02-25 10:58:43 -07:00
gary-hessler
51b4f9b221 Update all plugins to handle dimensions correctly
Updated the plugin code to handle the dimensions from the agent config,
the plugin config and dimensions defined in the code correctly.
Also removed the old-style plugin configuration code from several of
the plugins and added a command-line option to monasca-setup to pass
the log_level if desired instead of hard-coding it in the config.
This will make it easier to test in debug mode. Fixed an issue
with the Swift detection plugin.

Change-Id: I679457e5e1f302b0cdc87b0f0f799a42a9fa0ba4
2015-02-13 16:36:46 -07:00
Michael James Hoppal
a8929debda Modifications to accommodate for python 2.6
Change-Id: If959b8a9c7073cbbc97a9712945754116f026c5c
2015-02-06 11:18:09 -07:00
gary-hessler
5e20bac393 Fixing monasca-agent check and check_all
The command-line debugging tools "monasca-collector check check_name_here"
and "monasca-collector check_all" were hanging on the multi-threaded
ServicesCheck based agent checks.  Added calls to stop the thread pool
after the checks ran.  Removed duplicate code.

Change-Id: Iac033beafc1c055de13eba855819a881629ad55d
2015-02-04 18:18:05 -07:00
Tim Kuhlman
19cd1c053e Remove emit_time from the collector and put it into the forwarder.
Fixed the service dimension for api checks on various openstack services
so that it matches that of the other service checks, allowing for it to
be grouped together.

Modified the config so a config in the working dir can be used this is
helpful for testing. Additionally I fixed up few tests and removed
some no longer used, there is a lot of work with test left unfinished

Change-Id: Ic5b127db41c174735f1436bb511f00e271274cb0
2015-02-04 14:54:00 -07:00
gary-hessler
39ade0e4dd Rewrote config processing to simplify logic.
Reorganized and created classes for the methods in config.py.
Added more sections to the agent config file.
Moved a lot of functions out of config.py that were more
utility-like to util.py.

Change-Id: I19fc709fb165895382099b49fd9c83991ca1183d
2015-01-28 10:04:49 -07:00
gary-hessler
92c064ff28 Updated dimension processing for service and component
The dimension handling was incorrect.  It now follows this order of precedence:
1) Dimensions defined in a plugin config file
2) Dimensions that are defined in the agent config file
3) Dimensions that are defaults in a particular plugin

Also, updated imports to meet the OpenStack standards.

Change-Id: I99d82f2b534ca7b3bea8a147c83404505177e15e
2015-01-22 10:04:43 -07:00
gary-hessler
34d82d455e Renaming agent packages to reflect monasca
Renamed monagent package to monasca_agent and monsetup package to monasca_setup.
Also, renamed the monstatsd agent package to statsd to more closely match the internal
collector and forwarder packages.

Change-Id: I0649ae4341fe325007e2a8d37161d330e4c95d72
2014-12-19 09:22:03 -07:00