-
Notifications
You must be signed in to change notification settings - Fork 32
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
davidjiglesias
merged 20 commits into
4.8.0
from
enhancement/4890-wazuh-statistics-scripts
Feb 22, 2024
Merged
Changes from 9 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
a404dee
add params to wazuh_statistics
Deblintrake09 197f6e5
add api support to statistic.py
Deblintrake09 cc403ec
move statistic headers to file
Deblintrake09 3712d7c
add wazuhdb header
Deblintrake09 a1d4008
add missing headers
Deblintrake09 3486a9f
add wazuhdb parsing
Deblintrake09 2ac54a6
change remoted parameter to remote
Deblintrake09 e128396
fix target argument documentation
Deblintrake09 b0ce46f
enhance documentation
Deblintrake09 8128e8a
add port and ip for API
Deblintrake09 135c652
add port and IP for API
Deblintrake09 15d80c8
fix documentation
Deblintrake09 0da9d00
replace use_api parameter for use_state_file
Deblintrake09 17aac75
fix file naming
Deblintrake09 68a79c1
fix undo name change
Deblintrake09 a9192a5
enhance wazuh-statistic docu
Deblintrake09 a1d0448
add wait for complete_to_api endpoint
Deblintrake09 b48cd5b
remove unnecesary checks
Deblintrake09 edac452
fix typo
Deblintrake09 56c798a
fix query typo
Deblintrake09 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() | ||
|
||
|
@@ -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() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?