]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Pull request #4325: appid : appid cpu profiler max columns
authorUmang Sharma (umasharm) <umasharm@cisco.com>
Wed, 29 May 2024 21:46:12 +0000 (21:46 +0000)
committerChris Sherwin (chsherwi) <chsherwi@cisco.com>
Wed, 29 May 2024 21:46:12 +0000 (21:46 +0000)
Merge in SNORT/snort3 from ~UMASHARM/snort3:appid_profiler_columns to master

Squashed commit of the following:

commit 27ccc30ed307c0e152794f8d6b3799b2db4ebada
Author: Umang Sharma <umasharm@cisco.com>
Date:   Fri May 24 16:51:14 2024 -0400

    appid: appid cpu profiler max columns

src/network_inspectors/appid/CMakeLists.txt
src/network_inspectors/appid/appid_config.h
src/network_inspectors/appid/appid_cpu_profile_table.cc [moved from src/network_inspectors/appid/app_cpu_profile_table.cc with 80% similarity]
src/network_inspectors/appid/appid_cpu_profile_table.h [moved from src/network_inspectors/appid/app_cpu_profile_table.h with 90% similarity]
src/network_inspectors/appid/appid_discovery.cc
src/network_inspectors/appid/appid_http_event_handler.cc
src/network_inspectors/appid/appid_module.cc
src/network_inspectors/appid/test/appid_api_test.cc

index fc1db4456ad944a590859546602a5ae6934b3907..5706eaaedbf81ec2585089dc0851f99aa58dea5d 100644 (file)
@@ -207,8 +207,8 @@ set ( APPID_SOURCES
     tp_appid_session_api.h
     tp_appid_module_api.h
     tp_appid_module_api.cc
-    app_cpu_profile_table.cc 
-    app_cpu_profile_table.h
+    appid_cpu_profile_table.cc 
+    appid_cpu_profile_table.h
 )
 
 #if (STATIC_INSPECTORS)
index 516e2ac77af5d52b224efa5205d3f98e3d8c1b4a..1a840083a5edef89c34ce2dcb23f0224f134cd8d 100644 (file)
@@ -45,7 +45,7 @@
 #include "detector_plugins/ssh_patterns.h"
 #include "tp_appid_module_api.h"
 #include "utils/sflsq.h"
-#include "app_cpu_profile_table.h"
+#include "appid_cpu_profile_table.h"
 #include "profiler/profiler_defs.h"
 
 #define APP_ID_PORT_ARRAY_SIZE  65536
similarity index 80%
rename from src/network_inspectors/appid/app_cpu_profile_table.cc
rename to src/network_inspectors/appid/appid_cpu_profile_table.cc
index a8e433f31d40f555bf732b6d12593d07116b01bd..c0b4ac6f49a69d4ac4cabdcdbd7c05b0d93c06e2 100644 (file)
 #include <queue>
 
 #include "appid_session.h"
-#include "app_cpu_profile_table.h"
+#include "appid_cpu_profile_table.h"
 
 using namespace snort;
 
-static const char* table_header = "AppId Performance Statistics (all)\n========================================================================================================================\n";
-static const char* columns = " AppId   App Name                             Microsecs        Packets        Avg/Packet       Sessions     Avg/Session \n";
-static const char* partition = "------------------------------------------------------------------------------------------------------------------------\n";
+static const char* table_header = "AppId Performance Statistics (all)\n===========================================================================================================================================================\n";
+static const char* columns = " AppId   App Name                             Usecs        Pkts        AvgUsecs/Pkt       Sessions     AvgUsecs/Sess       MaxPkts/Sess       MaxUsecs/Sess\n";
+static const char* partition = "-----------------------------------------------------------------------------------------------------------------------------------------------------------\n";
 
 static std::string FormatWithCommas(uint64_t value)
 {
@@ -74,9 +74,11 @@ AppidCpuTableDisplayStatus AppidCPUProfilingManager::display_appid_cpu_profiler_
         appid_log(nullptr, TRACE_INFO_LEVEL, columns);
         appid_log(nullptr, TRACE_INFO_LEVEL, partition);
 
-        appid_log(nullptr, TRACE_INFO_LEVEL, " %5d   %-25.25s   %18s   %12s   %15s   %12s    %12s\n",
-                        appid, bucket->second.app_name.c_str(), FormatWithCommas(bucket->second.processing_time).c_str(), FormatWithCommas(bucket->second.processed_packets).c_str(), FormatWithCommas(bucket->second.processing_time/bucket->second.processed_packets).c_str(),
-                                                                                            FormatWithCommas(bucket->second.per_appid_sessions).c_str(), FormatWithCommas(bucket->second.processing_time/bucket->second.per_appid_sessions).c_str());
+        appid_log(nullptr, TRACE_INFO_LEVEL, " %5d   %-25.25s   %14.14s   %9.9s   %17.17s   %12.12s    %14.14s    %15.14s   %17.16s\n",
+                appid, bucket->second.app_name.c_str(), FormatWithCommas(bucket->second.processing_time).c_str(), FormatWithCommas(bucket->second.processed_packets).c_str(), 
+                FormatWithCommas(bucket->second.processing_time/bucket->second.processed_packets).c_str(), FormatWithCommas(bucket->second.per_appid_sessions).c_str(), 
+                FormatWithCommas(bucket->second.processing_time/bucket->second.per_appid_sessions).c_str(), FormatWithCommas(bucket->second.max_processed_pkts_per_session).c_str(), 
+                FormatWithCommas(bucket->second.max_processing_time_per_session).c_str());
     }
     else
     {
@@ -108,9 +110,11 @@ AppidCpuTableDisplayStatus AppidCPUProfilingManager::display_appid_cpu_profiler_
         if (!entry.second.processed_packets or !entry.second.per_appid_sessions)
             continue;
             
-        appid_log(nullptr, TRACE_INFO_LEVEL, " %5d   %-25.25s   %18s   %12s   %15s   %12s    %12s\n",
-                    entry.first, entry.second.app_name.c_str(), FormatWithCommas(entry.second.processing_time).c_str(), FormatWithCommas(entry.second.processed_packets).c_str(), FormatWithCommas(entry.second.processing_time/entry.second.processed_packets).c_str(),
-                                                                               FormatWithCommas(entry.second.per_appid_sessions).c_str(), FormatWithCommas(entry.second.processing_time/entry.second.per_appid_sessions).c_str());
+        appid_log(nullptr, TRACE_INFO_LEVEL, " %5d   %-25.25s   %14.14s   %9.9s   %17.17s   %12.12s    %14.14s    %15.14s   %17.16s\n",
+                entry.first, entry.second.app_name.c_str(), FormatWithCommas(entry.second.processing_time).c_str(), FormatWithCommas(entry.second.processed_packets).c_str(), 
+                FormatWithCommas(entry.second.processing_time/entry.second.processed_packets).c_str(), FormatWithCommas(entry.second.per_appid_sessions).c_str(), 
+                FormatWithCommas(entry.second.processing_time/entry.second.per_appid_sessions).c_str(), FormatWithCommas(entry.second.max_processed_pkts_per_session).c_str(), 
+                FormatWithCommas(entry.second.max_processing_time_per_session).c_str());
     } 
     return DISPLAY_SUCCESS;
 }
@@ -135,6 +139,11 @@ void AppidCPUProfilingManager::insert_appid_cpu_profiler_record(AppId appId, con
         it->second.processing_time += stats.processing_time;
         it->second.processed_packets += stats.processed_packets;
         it->second.per_appid_sessions += 1;
+        if (stats.processed_packets > it->second.max_processed_pkts_per_session)
+            it->second.max_processed_pkts_per_session = stats.processed_packets;
+
+        if (stats.processing_time > it->second.max_processing_time_per_session)
+            it->second.max_processing_time_per_session = stats.processing_time;
     }
 }
 
similarity index 90%
rename from src/network_inspectors/appid/app_cpu_profile_table.h
rename to src/network_inspectors/appid/appid_cpu_profile_table.h
index 49ef0e2b550260c2bce794572202f298fe454a08..5a3f94d116b1806b409da195d904e7511e8e89e1 100644 (file)
@@ -45,9 +45,12 @@ struct AppidCPUProfilerStats {
     uint64_t processing_time    = 0;
     uint64_t processed_packets  = 0;
     uint32_t per_appid_sessions = 0;
-
+    uint64_t max_processing_time_per_session = 0;
+    uint64_t max_processed_pkts_per_session = 0;
+    
     AppidCPUProfilerStats(const char* app_name, uint64_t processing_time, uint64_t processed_packets, uint32_t per_appid_sessions) :
-        app_name(app_name), processing_time(processing_time), processed_packets(processed_packets), per_appid_sessions (per_appid_sessions)
+        app_name(app_name), processing_time(processing_time), processed_packets(processed_packets), per_appid_sessions(per_appid_sessions),
+        max_processing_time_per_session(processing_time), max_processed_pkts_per_session(processed_packets)
     { }
 };
 
index b43e71e234c57c70ce9615c59b8032589c4e2c18..680b6ac2acb91ea6418a0a333ebcab224706baca 100644 (file)
@@ -40,7 +40,7 @@
 #include "appid_http_session.h"
 #include "appid_inspector.h"
 #include "appid_session.h"
-#include "app_cpu_profile_table.h"
+#include "appid_cpu_profile_table.h"
 #include "appid_utils/ip_funcs.h"
 #include "client_plugins/client_discovery.h"
 #include "detector_plugins/detector_dns.h"
index 194af507797b0f6cd84062eb5e0a27a2bb1bd360..e21d532b7c86d2094e3a9354419f742b1ae6bb5b 100644 (file)
@@ -33,7 +33,7 @@
 #include "flow/stream_flow.h"
 
 #include "app_info_table.h"
-#include "app_cpu_profile_table.h"
+#include "appid_cpu_profile_table.h"
 #include "appid_debug.h"
 #include "appid_discovery.h"
 #include "appid_http_session.h"
index ef5b88fffb3a703eb24972c1fcfee31ea3914330..95254848528eb8b763520aaca7eea652bcdd1558 100644 (file)
@@ -50,7 +50,7 @@
 #include "appid_inspector.h"
 #include "appid_peg_counts.h"
 #include "service_state.h"
-#include "app_cpu_profile_table.h"
+#include "appid_cpu_profile_table.h"
 
 using namespace snort;
 using namespace std;
index eec184f3fe6cb2b50419f732cfb703c037802faa..a547d6239fc3843c0032a544797d68086b28badc 100644 (file)
@@ -35,7 +35,7 @@
 #include "appid_http_session.h"
 #include "tp_appid_module_api.h"
 #include "tp_appid_session_api.h"
-#include "app_cpu_profile_table.h"
+#include "appid_cpu_profile_table.h"
 
 #include "appid_mock_definitions.h"
 #include "appid_mock_http_session.h"