Skip to content

Commit

Permalink
snmp: borrow dummy plugin as a start point
Browse files Browse the repository at this point in the history
Add: ChatGPT in_snmp

Add: snmp get with fix request

Add: snmp with log recorder

Add: print value by sprint_realloc_by_type

Fix: refine code.

Add: walk get values

TMP

Signed-off-by: k402xxxcenxxx <[email protected]>
  • Loading branch information
k402xxxcenxxx committed Dec 15, 2024
1 parent 362ca1f commit cf8b9ff
Show file tree
Hide file tree
Showing 8 changed files with 590 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ include(GNUInstallDirs)
include(ExternalProject)
include(cmake/FindJournald.cmake)
include(cmake/FindMonkey.cmake)
include(cmake/FindNetsnmp.cmake)
include(cmake/macros.cmake)
include(cmake/platform_feature_checks.cmake)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/sanitizers-cmake/cmake" ${CMAKE_MODULE_PATH})
Expand Down
73 changes: 73 additions & 0 deletions cmake/FindNetsnmp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# - Find Net-SNMP
#
# -*- cmake -*-
#
# Find the Net-SNMP module
#
# NETSNMP_INCLUDE_DIR - where to find Net-SNMP.h, etc.
# NETSNMP_LIBRARIES - List of libraries when using Net-SNMP.
# NETSNMP_FOUND - True if Net-SNMP found.

IF (NETSNMP_INCLUDE_DIR)
# Already in cache, be silent
SET(NETSNMP_FIND_QUIETLY TRUE)
ENDIF (NETSNMP_INCLUDE_DIR)

FIND_PATH(NETSNMP_INCLUDE_DIR snmp.h
/usr/include/net-snmp/library
)

SET(NETSNMP_NAMES netsnmp)
FIND_LIBRARY(NETSNMP_LIBRARY
NAMES ${NETSNMP_NAMES}
PATHS /usr/lib /usr/local/lib
)

SET(NETSNMPAGENT_NAMES netsnmpagent)
FIND_LIBRARY(NETSNMPAGENT_LIBRARY
NAMES ${NETSNMPAGENT_NAMES}
PATHS /usr/lib /usr/local/lib
)

SET(NETSNMPHELPERS_NAMES netsnmphelpers)
FIND_LIBRARY(NETSNMPHELPERS_LIBRARY
NAMES ${NETSNMPHELPERS_NAMES}
PATHS /usr/lib /usr/local/lib
)

SET(NETSNMPMIBS_NAMES netsnmpmibs)
FIND_LIBRARY(NETSNMPMIBS_LIBRARY
NAMES ${NETSNMPMIBS_NAMES}
PATHS /usr/lib /usr/local/lib
)

SET(NETSNMPTRAPD_NAMES netsnmptrapd)
FIND_LIBRARY(NETSNMPTRAPD_LIBRARY
NAMES ${NETSNMPTRAPD_NAMES}
PATHS /usr/lib /usr/local/lib
)

SET(NETSNMP_LIBRARIES
${NETSNMP_LIBRARY}
${NETSNMPAGENT_LIBRARY}
${NETSNMPHELPERS_LIBRARY}
${NETSNMPMIBS_LIBRARY}
# ${NETSNMPTRAPD_LIBRARY}
)


INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(NETSNMP
DEFAULT_MSG
NETSNMP_INCLUDE_DIR
NETSNMP_LIBRARIES
)

MARK_AS_ADVANCED(
NETSNMP_LIBRARY
NETSNMPAGENT_LIBRARY
NETSNMPHELPERS_LIBRARY
NETSNMPMIBS_LIBRARY
NETSNMPTRAPD_LIBRARY
NETSNMP_INCLUDE_DIR
)
1 change: 1 addition & 0 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ REGISTER_IN_PLUGIN("in_prometheus_scrape")
REGISTER_IN_PLUGIN("in_emitter")
REGISTER_IN_PLUGIN("in_tail")
REGISTER_IN_PLUGIN("in_dummy")
REGISTER_IN_PLUGIN("in_snmp")
REGISTER_IN_PLUGIN("in_head")
REGISTER_IN_PLUGIN("in_health")
REGISTER_IN_PLUGIN("in_http")
Expand Down
8 changes: 8 additions & 0 deletions plugins/in_snmp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set(NETSNMP_LIBRARIES ${NETSNMP_LIBRARY})
set(NETSNMP_INCLUDE_DIRS ${NETSNMP_INCLUDE_DIR})

set(src
in_snmp.c)

FLB_PLUGIN(in_snmp "${src}" "")
target_link_libraries(flb-plugin-in_snmp ${NETSNMP_LIBRARIES})
Loading

0 comments on commit cf8b9ff

Please sign in to comment.