檢視原始碼 snmpa_mib_storage 行為 (snmp v5.18)
SNMP agent mib 儲存的行為模組。
此模組定義 SNMP agent mib 儲存的行為。
mib 儲存由 agent 用來儲存內部與 mib 相關的資訊。mib 儲存模組由多個實體使用,而不僅僅是 mib-server。
符合 snmpa_mib_storage
的模組必須匯出以下函式:
- open/5
- close/1
- read/2
- write/2
- delete/1
- delete/2
- match_object/2
- match_delete/2
- tab2list/1
- info/1
- info/2
- sync/1
- backup/2
它們的語義和確切的簽名將在下面解釋。
摘要
回呼:回呼函式
執行 mib-storage 表格的備份。
關閉 mib-storage 表格。
刪除整個 mib-storage 表格。
從 mib-storage 表格中刪除一筆記錄。
擷取實作相關的 mib-storage 表格資訊。
在 mib-storage 表格中搜尋符合指定模式的記錄,然後將其刪除。刪除的記錄也會被回傳。
在 mib-storage 表格中搜尋符合指定模式的記錄。
建立或開啟 mib 儲存表格。
從 mib-storage 表格讀取一筆記錄。
同步 mib-storage 表格。
以列表形式回傳 mib-storage 表格中的所有記錄。
將一筆記錄寫入 mib-storage 表格。
型別
回呼:回呼函式
-callback backup(TabId :: mib_storage_table_id(), Dir :: file:filename()) -> ok | {error, Reason :: term()}.
執行 mib-storage 表格的備份。
這代表什麼,如果有的話,是取決於實作。
-callback close(TabId :: mib_storage_table_id()) -> term().
關閉 mib-storage 表格。
-callback delete(TabId :: mib_storage_table_id()) -> snmp:void().
刪除整個 mib-storage 表格。
-callback delete(TabId :: mib_storage_table_id(), Key :: term()) -> ok | {error, Reason :: term()}.
從 mib-storage 表格中刪除一筆記錄。
-callback info(TabId :: mib_storage_table_id()) -> Info :: term().
擷取實作相關的 mib-storage 表格資訊。
-callback info(TabId :: mib_storage_table_id(), Item :: atom()) -> Info :: term().
-callback match_delete(TabId :: mib_storage_table_id(), Pattern :: ets:match_pattern()) -> Recs :: [tuple()] | {error, Reason :: term()}.
在 mib-storage 表格中搜尋符合指定模式的記錄,然後將其刪除。刪除的記錄也會被回傳。
-callback match_object(TabId :: mib_storage_table_id(), Pattern :: ets:match_pattern()) -> Recs :: [tuple()] | {error, Reason :: term()}.
在 mib-storage 表格中搜尋符合指定模式的記錄。
-callback open(Name :: atom(), RecName :: atom(), Fields :: mib_storage_fields(), Type :: mib_storage_table_type(), Options :: list()) -> {ok, TabId :: mib_storage_table_id()} | {error, Reason :: term()}.
建立或開啟 mib 儲存表格。
請注意,RecordName
和 Fields
引數可能不會在所有實作中使用(它們實際上僅適用於基於 mnesia 的實作)。
另請注意,Options
引數來自 mib-storage 配置選項的 options
配置選項,並按原樣傳遞。
-callback read(TabId :: mib_storage_table_id(), Key :: term()) -> false | {value, Record :: tuple()}.
從 mib-storage 表格讀取一筆記錄。
-callback sync(TabId :: mib_storage_table_id()) -> snmp:void().
同步 mib-storage 表格。
這代表什麼,如果有的話,是取決於實作。
-callback tab2list(TabId :: mib_storage_table_id()) -> [tuple()].
以列表形式回傳 mib-storage 表格中的所有記錄。
-callback write(TabId :: mib_storage_table_id(), Record :: tuple()) -> ok | {error, Reason :: term()}.
將一筆記錄寫入 mib-storage 表格。