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 all 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
17 changes: 13 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,21 @@ 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 and wazuhdb')
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('-u', '--use_state_file', action='store_true', default=False,
help="Use state files for analysis and remote operations. "
"When used with 'remote' and 'analysis', data will be collected from state files; "
"otherwise, the API will be used. Default False")
parser.add_argument('-i', '--ip', dest='ip', action='store', default='localhost',
help=f"Specify the IP address for the API. Default is 'localhost'")
parser.add_argument('-p', '--port', dest='port', action='store', default='55000',
help=f"Specify the port for the API. Default is '55000'")

return parser.parse_args()

Expand All @@ -51,10 +59,11 @@ 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_state_file=options.use_state_file, ip=options.ip, port=options.port)
MONITOR_LIST.append(monitor)
monitor.start()


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