-
Notifications
You must be signed in to change notification settings - Fork 36
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
Spike: Analyze Impact and Alternatives for Reducing Inventory Events #573
Labels
level/task
Task issue
module/agent
module/inventory
Inventory module
spike
Spike
type/enhancement
Enhancement issue
Comments
Basic time analysis
|
Benchmarking and analysis toolsAfter some research a couple of tools were used
example of execution for all scan case:
root@pm-ubuntu24-server:/home/pm-vagrant/workspace/wazuh-agent/build# cat analysis.txt
Flat profile:
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls Ts/call Ts/call name
8.33 0.02 0.02 std::vector<nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void>, std::allocator<nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void> > >* nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void>::create<std::vector<nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void>, std::allocator<nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void> > >, std::vector<nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void>, std::allocator<nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void> > > const&>(std::vector<nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void>, std::allocator<nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void> > > const&)
8.33 0.04 0.02 _init
8.33 0.06 0.02 btreeParseCellPtr
8.33 0.08 0.02 sqlite3RunParser
4.17 0.09 0.01 EVP_DigestFinal_ex
4.17 0.10 0.01 MultiTypeQueue::storedItems(MessageType, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
4.17 0.11 0.01 nlohmann::json_abi_v3_11_3::detail::serializer<nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void> >::dump_escaped(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)
4.17 0.12 0.01 nlohmann::json_abi_v3_11_3::detail::lexer<nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_11_3::detail::iterator_input_adapter<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >::scan_string()
4.17 0.13 0.01 nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void>::dump(int, char, bool, nlohmann::json_abi_v3_11_3::detail::error_handler_t) const
4.17 0.14 0.01 std::locale::id::_M_id() const
4.17 0.15 0.01 std::__basic_file<char>::open(char const*, std::_Ios_Openmode, int)
4.17 0.16 0.01 std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void> >, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void> > >, std::less<void>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void> > > >::_M_get_insert_hint_unique_pos(std::_Rb_tree_const_iterator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void> > >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
4.17 0.17 0.01 cleanup_old_md_data
4.17 0.18 0.01 fe51_sub
4.17 0.19 0.01 gcm_ghash_4bit
4.17 0.20 0.01 lengthFunc
4.17 0.21 0.01 pcache1Fetch
4.17 0.22 0.01 sqlite3SrcListAppend
4.17 0.23 0.01 sqlite3VdbeExec
4.17 0.24 0.01 sqlite3VdbeSetNumCols
% the percentage of the total running time of the
time program used by this function.
cumulative a running sum of the number of seconds accounted
seconds for by this function and those listed above it.
self the number of seconds accounted for by this
seconds function alone. This is the major sort for this
listing.
calls the number of times this function was invoked, if
this function is profiled, else blank.
self the average number of milliseconds spent in this
ms/call function per call, if this function is profiled,
else blank.
total the average number of milliseconds spent in this
ms/call function and its descendents per call, if this
function is profiled, else blank.
name the name of the function. This is the minor sort
for this listing. The index shows the location of
the function in the gprof listing. If the index is
in parenthesis it shows where it would appear in
the gprof listing if it were to be printed.
Copyright (C) 2012-2024 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.
Result of perf report to scan all case
Details
Files |
Update 05/02
|
Basic analysisAdditional analysis made on the same case:
|
Event Volume Analysis
# cat /etc/wazuh-agent/wazuh-agent.yml | grep -A 11 inventory:
inventory:
enabled: true
interval: 60s
scan_on_start: true
hardware: true
system: true
networks: true
packages: true
ports: true
ports_all: true
processes: true
hotfixes: true
Summary of statistics gathered:
|
Event Volume Analysis
Summary of statistics gathered:
|
Closing commentPossible feature improvements
const auto stats { m_interfaceAddress->stats() };
network["tx_packets"] = stats.txPackets;
network["rx_packets"] = stats.rxPackets;
network["tx_bytes"] = stats.txBytes
network["rx_bytes"] = stats.rxBytes
network["tx_errors"] = stats.txErrors
network["rx_errors"] = stats.rxErrors
network["tx_dropped"] = stats.txDropped
network["rx_dropped"] = stats.rxDropped; A cleaner option is to modify dbsync not to check changes: internally this can be done with input["options"]["ignore"].push_back("tx_bytes");
input["options"]["ignore"].push_back("tx_packets");
input["options"]["ignore"].push_back("rx_bytes")
input["options"]["ignore"].push_back("rx_packets")
input["options"]["ignore"].push_back("tx_dropped")
input["options"]["ignore"].push_back("tx_errors")
input["options"]["ignore"].push_back("rx_dropped")
input["options"]["ignore"].push_back("rx_errors") This can generate events with these fields, but won't send a notification after a change. Additional notes:
|
LGTM! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
level/task
Task issue
module/agent
module/inventory
Inventory module
spike
Spike
type/enhancement
Enhancement issue
Objective
Investigate the impact of disabling the inventory of active processes and ports in use, as well as explore potential alternative solutions to reduce the volume of inventory events without affecting key functionalities.
Research Areas
Event Volume Analysis
create/update/delete
events generated by active processes and ports in use under normal agent operation.Performance Impact
Alternative Solutions
Deliverables
Expected Outcome
The results of this spike will guide the final decision on whether to simply disable these inventories or implement a more refined approach to event reduction.
The text was updated successfully, but these errors were encountered: