Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance StatisticMonitor with API support #4970

Merged
merged 20 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions deps/wazuh_testing/wazuh_testing/scripts/wazuh_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ def get_script_arguments():
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('-t', '--target', dest='target_list', required=True, type=str, nargs='+', action='store',
help='Type the statistics target to collect separated by whitespace. '
'Targets: agent, logcollector, remote and analysis.')
'Targets: agent, logcollector, remote, analysis_events, analysisd_state and wazuhdb')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could affect other QA process. Did it only affect test_cluster https://github.com/wazuh/wazuh-jenkins/pull/6276/files?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Analysisd by default should it gather it information from the API. We can support deprecated .state data collection only through State class parameter in the constructor

parser.add_argument('-s', '--sleep', dest='sleep_time', type=float, default=5, action='store',
help='Type the time in seconds between each entry.')
parser.add_argument('-d', '--debug', dest='debug', action='store_true', default=False,
help='Enable debug level logging.')
parser.add_argument('--store', dest='store_path', action='store', default=gettempdir(),
help=f"Path to store the CSVs with the data. Default {gettempdir()}.")
parser.add_argument('-a', '--use_api', dest='use_api', type=bool, action='store', default=False,
help="Determine if the API should be used to collect the data. Default False."
"For remoted set to True to get data from API. analysis_events uses API by default.")

return parser.parse_args()

Expand All @@ -51,10 +54,10 @@ def main():
logger.info(f'Started new session: {CURRENT_SESSION}')

for target in options.target_list:
monitor = StatisticMonitor(target=target, time_step=options.sleep_time, dst_dir=options.store_path)
monitor.start()
monitor = StatisticMonitor(target=target, time_step=options.sleep_time, dst_dir=options.store_path, use_api=options.use_api)
MONITOR_LIST.append(monitor)
monitor.start()


if __name__ == '__main__':
main()
main()
Loading
Loading