Skip to content

Commit

Permalink
Merge pull request #4970 from wazuh/enhancement/4890-wazuh-statistics…
Browse files Browse the repository at this point in the history
…-scripts

Enhance StatisticMonitor with API support
  • Loading branch information
davidjiglesias authored Feb 22, 2024
2 parents 73e2c83 + 56c798a commit 2702be3
Show file tree
Hide file tree
Showing 3 changed files with 820 additions and 26 deletions.
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

0 comments on commit 2702be3

Please sign in to comment.