net-snmp開發教程
目錄
請參閱《TCP-IP詳解卷1》——《第25章SNMP:簡單網路管理協議》
MIBS rfc詳見原始碼目錄下的doc\rfc\smiV2
MIBS總共有三種實體:
1.2.1 scalar:變數,就是一個量(包括整數理、字串型、IPADDRESS等)
snmp認證目前有三個版本:snmpv1、snmpv2、snmpv3
snmpv1(rfc1157)、snmpv2(rfc1901)都是基於密碼字串的認證,且密碼為明文。
snmpv3(rfc2571)認證分為使用USM(基於使用者的安全模式)和VACM(基於檢視的訪問控制模式)。認證的加協議有:MD5、SHA;加密協議有:DES、AES;加密協議用於加密PDU資料。
./configure –help #檢視配置
./configure
make
make install
4.1 snmpd:響應snmp
用法:-f 不呼叫fork,即不進入daemon,如果不用這個引數,則進入daemon模式
-L[efos]日誌輸出到指定的位置
-Le Log messages to the standard error stream.
-Lf FILE
Log messages to the specified file.
-Lo Log messages to the standard output stream.
-Ls FACILITY
Log messages via syslog, using the specified facility
('d' for LOG_DAEMON, 'u' for LOG_USER, or '0'-'7' for
LOG_LOCAL0 through LOG_LOCAL7).
4.4 snmpget、snmpgetnext、snmpwalk:得到請求
4.10 mib2c:用於從mib檔案生成擴充套件模組c程式碼的工具。
-V, --version 顯示命令的版本號
SNMP Version 1 or 2c specific
-c COMMUNITY 設定團體名
SNMP Version 3 specific
-a PROTOCOL 設定認證協議 (MD5|SHA)
-A PASSPHRASE 設定認證協議密碼
-e ENGINE-ID set security engine ID (e.g. 800000020109840301)
-E ENGINE-ID set context engine ID (e.g. 800000020109840301)
-l LEVEL set security level (noAuthNoPriv|authNoPriv|authPriv)
-n CONTEXT set context name (e.g. bridge1)
-u USER-NAME set security name (e.g. bert)
-x PROTOCOL 設定加密協議 (DES|AES)
-X PASSPHRASE 設定加密協議密碼
-Z BOOTS,TIME set destination engine boots/time
例子:
snmpgetnext -v 1 -c public 127.0.0.1 sysUpTime
snmpget –v 3 –a MD5 –A 1235678 –u name 127.0.0.1 oid
用配置工具 snmpconf 進行配置
配置包括三個部分:
###########################################################################
# SECTION: Textual mib parsing
#
# This section controls the textual mib parser. Textual
# mibs are parsed in order to convert OIDs, enumerated
# lists, and ... to and from textual representations
# and numerical representations.
# mibs: Specifies a list of mibs to be searched for and loaded.
# Adding a '+' sign to the front of the argument appends the new
# mib name to the list of mibs already being searched for.
# arguments: [+]mibname[:mibname...]
mibs +/root/test/NET-SNMP-EXAMPLES-MIB.txt
5.2.3 安裝存取控制
###########################################################################
# SECTION: Access Control Setup
#
# This section defines who is allowed to talk to your running
# snmp agent.
# rwcommunity: a SNMPv1/SNMPv2c read-write access community name
# arguments: community [default|hostname|network/bits] [oid]
rwcommunity public 127.0.0.1
rwcommunity public 192.168.0.1
# rwuser: a SNMPv3 read-write user
# arguments: user [noauth|auth|priv] [restriction_oid]
rwuser public #這裡定義使用者名稱和驗證方式,密碼儲存在/var/net-snmp/snmpd.conf中
# rouser: a SNMPv3 read-only user
# arguments: user [noauth|auth|priv] [restriction_oid]
rouser public #這裡定義使用者名稱和驗證方式,密碼儲存在/var/net-snmp/snmpd.conf中,詳見——用net-snmp-config配置V3
###########################################################################
# SECTION: Trap Destinations
#
# Here we define who the agent will send traps to.
# trap2sink: A SNMPv2c trap receiver
# arguments: host [community] [portnum]
trap2sink 127.0.0.1 public 162
trap2sink 192.168.0.1 public 162
###########################################################################
# SECTION: Extending the Agent
#
# You can extend the snmp agent to have it return information
# that you yourself define.
# dlmod: dynamically extend the agent using a shared-object
# arguments: module-name module-path
dlmod notification /data/snmp/test/.libs/ libnetsnmpmibs.so
#authCommunity TYPES COMMUNITY [SOURCE [OID | -v VIEW ]]
authCommunity log,execute,net public
[email protected]:~# net-snmp-config --create-snmpv3-user --help
Usage:
net-snmp-create-v3-user [-ro] [-A authpass] [-X privpass]
[-a MD5|SHA] [-x DES|AES] [username]
[email protected]:~# net-snmp-create-v3-user -ro -A SHA -a public1234 -x DES -X abcdefgmok public
adding the following line to /var/net-snmp/snmpd.conf:
createUser public SHA "public1234" DES abcdefgmok
adding the following line to /usr/local/share/snmp/snmpd.conf:
rouser public
net-snmp-create-v3-user實質上是個指令碼檔案
它實質上是把V3的使用者配置(createUser public SHA "public1234" DES abcdefgmok)加到/var/net-snmp/snmpd.conf檔案中。然後agent從這個檔案中讀取v3的使用者配置資訊。然後生成相應的密碼並儲存在這個檔案中。
SNMP Version 3 引數:
-a PROTOCOL 設定認證協議 (MD5|SHA)
-A PASSPHRASE 設定認證協議密碼
-x PROTOCOL 設定加密協議 (DES|AES)
-X privpass 設定加密協議密碼
執行 snmpd –f –Lo
後臺方式 snmpd
[email protected]:~# snmpget -v 1 -c public 127.0.0.1 UDP-MIB::udpInDatagrams.0
UDP-MIB::udpInDatagrams.0 = Counter32: 7822
如果出現錯誤,請檢查配置是否正確。
8.1 程式邏輯
snmpd代理完成兩個功能:
8.1.1 接收網管發過來的snmp包,並對接收到的snmp包進行解析,校驗後,找到並呼叫相應的處理函式進行處理。
下面是處理snmp包的堆疊:
#0 reachalarmSubscriberTable_handler (handler=0x8159980, reginfo=0x8122b78,
reqinfo=0x817d050, requests=0x817d138) at reachalarmSubscriberTable.c:116
#1 0x008e08e6 in netsnmp_call_handler (requests=0x817d138, reqinfo=0x817d050,
reginfo=0x8122b78, next_handler=0x8159980) at agent_handler.c:526
#2 netsnmp_call_next_handler (current=0x8146088, reginfo=0x8122b78,
reqinfo=0x817d050, requests=0x817d138) at agent_handler.c:640
#3 0x008dab83 in netsnmp_table_iterator_helper_handler (handler=0x8146088,
reginfo=0x8122b78, reqinfo=0x817d050, requests=0x817d138)
at helpers/table_iterator.c:936
#4 0x008e08e6 in netsnmp_call_handler (requests=0x817d138, reqinfo=0x817d050,
reginfo=0x8122b78, next_handler=0x8146088) at agent_handler.c:526
#5 netsnmp_call_next_handler (current=0x813dcf0, reginfo=0x8122b78,
reqinfo=0x817d050, requests=0x817d138) at agent_handler.c:640
#6 0x008d268c in table_helper_handler (handler=0x813dcf0, reginfo=0x8122b78,
reqinfo=0x817d050, requests=0x817d138) at helpers/table.c:712
#7 0x008e0291 in netsnmp_call_handler (requests=0x817d138, reqinfo=0x817d050,
reginfo=0x8122b78, next_handler=0x813dcf0) at agent_handler.c:526
#8 netsnmp_call_handlers (reginfo=0x8122b78, reqinfo=0x817d050,
requests=0x817d138) at agent_handler.c:611
#9 0x008efc4a in handle_var_requests (asp=0x817c738) at snmp_agent.c:2676
#10 0x008f0150 in handle_getnext_loop (asp=0x817c738) at snmp_agent.c:3122
#11 0x008f0b0b in handle_pdu (asp=0x817c738) at snmp_agent.c:3499
#12 0x008f0c98 in netsnmp_handle_request (asp=0x817c738, status=0)
at snmp_agent.c:3278
#13 0x008f16bc in handle_snmp_packet (magic=0x0, pdu=0x8191178,
session=0x817c898, op=<optimized out>, reqid=<optimized out>)
at snmp_agent.c:1987
#14 handle_snmp_packet (op=1, session=0x817c898, reqid=8, pdu=0x8191178,
magic=0x0) at snmp_agent.c:1889
#15 0x003808a6 in _sess_process_packet (sessp=0x817c6c0, sp=0x817c898,
isp=0x817c860, transport=0x817c6d8, opaque=0x817d618, olength=36,
packetptr=0x8180ba0 "0&\002\001", length=40) at snmp_api.c:5400
#16 0x00381d0b in _sess_read (sessp=0x817c6c0, fdset=0xbfd00128)
at snmp_api.c:5829
#17 0x0038250a in snmp_sess_read2 (sessp=0x817c6c0, fdset=0xbfd00128)
at snmp_api.c:5861
#18 0x003825f4 in snmp_read2 (fdset=0xbfd00128) at snmp_api.c:5463
#19 0x0804bcee in receive () at snmpd.c:1315
#20 main (argc=6, argv=0xbfd00414) at snmpd.c:1105
net-snmp可以進行對snmp包處理程式和告警進行擴充套件。
示例程式存放在原始碼目錄:agent\mibgroup\examples下。
示例MIBS檔案:
mibs\NET-SNMP-MIB.txt
mibs\NET-SNMP-EXAMPLES-MIB.txt
用mg-soft builder生成。
mibs\NET-SNMP-EXAMPLES-MIB.txt
export MIBS=ALL
並把MIBS檔案複製到net-snmp安裝目錄的中的mibs目錄下
MIBS ALL #搜尋/usr/share/snmp/mibs下的所有檔案
MIBS +/usr/share/snmp/ NET-SNMP-EXAMPLES-MIB.txt#加入新建立的檔案
[email protected]:~# snmptranslate -TB netSnmpExamples
NET-SNMP-EXAMPLES-MIB::netSnmpExamples
NET-SNMP-EXAMPLES-MIB::netSnmpExampleScalars
NET-SNMP-EXAMPLES-MIB::netSnmpExampleString
NET-SNMP-EXAMPLES-MIB::netSnmpExampleSleeper
解析正確,就說明MIBS檔案配置正確。
8.3.3.1 直接在你想要生成程式碼的目錄下執行下面命令:
mib2c實體名
mib2c會提示你進行操作
[email protected]:~#mib2c netSnmpExamples
writing to -
mib2c has multiple configuration files depending on the type of
code you need to write. You must pick one depending on your need.
You requested mib2c to be run on the following part of the MIB tree:
OID: netSnmpExamples
numeric translation: .1.3.6.1.4.1.8072.2
number of scalars within: 8
number of tables within: 3
number of notifications within: 1
First, do you want to generate code that is compatible with the
ucd-snmp 4.X line of code, or code for the newer Net-SNMP 5.X code
base (which provides a much greater choice of APIs to pick from):
1) ucd-snmp style code
2) Net-SNMP style code
Select your choice :
建議做法是:為每一個實體單獨生成一組檔案。這樣條理比較清楚。
8.3.3.2 如果你清楚模組,可以用下面命令直接指定模板。
mib2c –c 模板檔案實體名
模板檔案位於: /usr/share/snmp/*.conf
實體名:本列中是:netSnmpExamples
注意:模組名不要與已存的的模組名重複,否則會出錯(沒有提示,這就看mib2c先搜尋到哪個MIBS,就應用哪個)。且模組名是大小寫敏感覺的。
執行完後,會生成一組列檔案。
[email protected]:~/test/mib# mib2c netSnmpExampleInteger
writing to -
mib2c has multiple configuration files depending on the type of
code you need to write. You must pick one depending on your need.
You requested mib2c to be run on the following part of the MIB tree:
OID: netSnmpExampleInteger
numeric translation: .1.3.6.1.4.1.8072.2.1.1
number of scalars within: 1
number of tables within: 0
number of notifications within: 0
First, do you want to generate code that is compatible with the
ucd-snmp 4.X line of code, or code for the newer Net-SNMP 5.X code
base (which provides a much greater choice of APIs to pick from):
1) ucd-snmp style code
2) Net-SNMP style code
Select your choice : 2
**********************************************************************
GENERATING CODE FOR SCALAR OBJECTS:
**********************************************************************
It looks like you have some scalars in the mib you requested, so I
will now generate code for them if you wish. You have two choices
for scalar API styles currently. Pick between them, or choose not
to generate any code for the scalars:
1) If you're writing code for some generic scalars
(by hand use: "mib2c -c mib2c.scalar.conf netSnmpExampleInteger")
2) If you want to magically "tie" integer variables to integer
scalars
(by hand use: "mib2c -c mib2c.int_watch.conf netSnmpExampleInteger")
3) Don't generate any code for the scalars
Select your choice: 1
using the mib2c.scalar.conf configuration file to generate your code.
writing to netSnmpExampleInteger.h
writing to netSnmpExampleInteger.c
**********************************************************************
* NOTE WELL: The code generated by mib2c is only a template. *YOU* *
* must fill in the code before it'll work most of the time. In many *
* cases, spots that MUST be edited within the files are marked with *
* /* XXX */ or /* TODO */ comments. *
**********************************************************************
running indent on netSnmpExampleInteger.h
running indent on netSnmpExampleInteger.c
[email protected]:~/test/mib# mib2c netSnmpHostsTable
writing to -
mib2c has multiple configuration files depending on the type of
code you need to write. You must pick one depending on your need.
You requested mib2c to be run on the following part of the MIB tree:
OID: netSnmpHostsTable
numeric translation: .1.3.6.1.4.1.8072.2.2.2
number of scalars within: 0
number of tables within: 1
number of notifications within: 0
First, do you want to generate code that is compatible with the
ucd-snmp 4.X line of code, or code for the newer Net-SNMP 5.X code
base (which provides a much greater choice of APIs to pick from):
1) ucd-snmp style code
2) Net-SNMP style code
Select your choice : 2
**********************************************************************
GENERATING CODE FOR TABLES:
**********************************************************************
The Net-SNMP agent API is extremely extensive and, in fact, lets
each programmer write agent code according to the style that works
best for them based on their experience and their preference. We're
going to ask you a serious of questions that will help mib2c
generate code that best suits *your* needs, as the programmer that
will be responsible for taking the code and further refining it. If
you don't like how the results look, you are always welcome to
re-run mib2c and select a different set of options.
There are essentially two tasks involved in processing requests
for OIDs within a MIB table - firstly identifying the relevant row
of the table for a given request, and then returning (or updating)
the appropriate column value within that row. Many MIB tables model
the state of some external system (the kernel, a device, processes,
etc), and the MIB implementation module (the code we're about to
produce a template for) acts as an interface between this underlying
system and the SNMP side. Other tables hold data internally that is
only available within the agent itself, or at least the master copy
of the data is held within the agent.
There are a number of different code templates that can be used to
implement MIB tables, using various approaches to these two tasks.
There are three basic approaches to identifying the relevant row:
1) Pass the request through to the table-specific code, and
identify the requested row there (for both GET and GETNEXT
requests). This is typically the most efficient way to get
up-to-date information, but relies on suitable
(programmer-provided) code within the MIB handler.
Most importantly, you should be an expert to use this choice.
This will produce code based on the table_dataset handler.
2) Have table-specific code to provide information about which
rows exist in the table (by iterating through them in turn),
but utilise standard helper code to select the appropriate
row for a given request. This is particularly suitable for
tables where the data is naturally stored in a "random" order
(or differently to the MIB table index), or where rows are
frequently added to or removed from the table.
However searching for the requested row is not very efficient,
and performance can be slow - particularly for large tables with
many rows.
3) Hold a locally cached copy of the contents of the table (or at
least a cache of which rows are valid), and utilise standard
helper code to select the appropriate row. This is
significantly faster than the iterator-based approach, but
cached data is inevitably slightly "stale" with respect to the
data from the underlying system being managed. This approach,
since it relies on caching of data, is also results in a larger
memory footprint. It is less appropriate for tables where rows
are frequently added or removed externally to the agent (i.e.,
not via SNMP requests).
This approach can also be used where _all_ use of the table is
via SNMP, and there is no external "underlying system". In
this case, the local cache is the canonical version of the
table.
4) Do not generate code for the tables.
Select the option that best fits your requirements: 2
Having identified the appropriate row for a given request, there are
three basic styles of code for returning (or updating) the requested
column value from within this row:
1) A single handler routine, which contains all the code needed to
handle GET and SET requests for each of the column objects.
The code typically looks like a single function with a large 'case'
statement covering each of the columns.
This will produce code based on the 'iterator' hepler.
2) A set of individual routines, each of which is concerned
with a particular aspect of processing the request.
Each column object within the table has one routine for
retrieving the current value, and another for setting a new one.
This will produce code based on the 'iterate_access' hepler.
3) A (different) set of individual routines, each of which is
smaller and more tightly focused than the code generated by
style 2. The aim here is to reduce the amount of SNMP specific
knowledge required to implement a module, and hide much of the
SNMP terminology and processing within standard generated code
(which can simply be used sight unseen).
This will produce code based on the 'mfd' hepler ('MIB for Dummies').
4) Do not generate code for the tables.
(In all cases, GETNEXT requests are automatically converted
into the equivalent GET request, so the MIB specific code
need only be concerned with GET and SET requests.).
Select the code style you wish to use: 1
The same template code can be generated using
mib2c -c mib2c.iterate.conf netSnmpHostsTable
This framework can work in one of two ways:
1) Hold a local cached copy of some external data
which is then used to service incoming requests.
2) Query the external data directly for each request.
The first is typically more efficient, but results in
slightly "stale" data (depending on the expiration timeout
for the cache) and greater memory usage. The second can
provide more up-to-date information, but at the cost of
higher processing overheads.
Which is more appropriate for your needs?
Select your choice : 1
writing to netSnmpHostsTable.h
writing to netSnmpHostsTable.c
**********************************************************************
* NOTE WELL: The code generated by mib2c is only a template. *YOU* *
* must fill in the code before it'll work most of the time. In many *
* cases, spots that MUST be edited within the files are marked with *
* /* XXX */ or /* TODO */ comments. *
**********************************************************************
running indent on netSnmpHostsTable.h
running indent on netSnmpHostsTable.c
[email protected]:~/test/mib# mib2c netSnmpExampleHeartbeatNotification
writing to -
mib2c has multiple configuration files depending on the type of
code you need to write. You must pick one depending on your need.
You requested mib2c to be run on the following part of the MIB tree:
OID: netSnmpExampleHeartbeatNotification
numeric translation: .1.3.6.1.4.1.8072.2.3.0.1
number of scalars within: 0
number of tables within: 0
number of notifications within: 1
First, do you want to generate code that is compatible with the
ucd-snmp 4.X line of code, or code for the newer Net-SNMP 5.X code
base (which provides a much greater choice of APIs to pick from):
1) ucd-snmp style code
2) Net-SNMP style code
Select your choice : 2
**********************************************************************
GENERATING CODE FOR NOTIFICATIONS:
**********************************************************************
Would you like to generate code for sending notifications from within
the agent?
"y" or "n": y
using mib2c.notify.conf to generate code for sending notifications
writing to netSnmpExampleHeartbeatNotification.h
writing to netSnmpExampleHeartbeatNotification.c
# GENERATING HEADER FILE DEFINITIONS
#
# To generate just a header with a define for each column number in
# your table:
#
# mib2c -c mib2c.column_defines.conf netSnmpExampleHeartbeatNotification
#
# To generate just a header with a define for each enum for any
# column containing enums:
#
# mib2c -c mib2c.column_enums.conf netSnmpExampleHeartbeatNotification
**********************************************************************
* NOTE WELL: The code generated by mib2c is only a template. *YOU* *
* must fill in the code before it'll work most of the time. In many *
* cases, spots that MUST be edited within the files are marked with *
* /* XXX */ or /* TODO */ comments. *
**********************************************************************
running indent on netSnmpExampleHeartbeatNotification.c
running indent on netSnmpExampleHeartbeatNotification.h
scalar實體和table實體其實是一類程式碼,只是處理的複雜度不一樣。
程式碼的核心,就是初始化函式時(程式初始化載入或動態庫載入),向代理(snmpd)註冊了回撥處理函式,當(snmpd)接收到一個snmp請求包時,它會先對包進行校驗,如果校驗不通過,會返回相應的錯誤。如果通過後,它會解析請求包,並把請求包的內容轉換成請求結構(netsnmp_agent_request_info【包含請求包的pdu資訊】,netsnmp_request_info【包含請求包的vb資訊】)。匹配到相關的oid時,就呼叫相應的註冊處理函式並傳入請求結構給處理函式,處理函式只需要根據結構中的內容進行相應的業務處理就可以了。
/** Initializes the netSnmpExampleInteger module */
void
init_netSnmpExampleInteger(void)
{
const oid netSnmpExampleInteger_oid[] = { 1,3,6,1,4,1,8072,2,1,1 };
DEBUGMSGTL(("netSnmpExampleInteger", "Initializing\n"));
netsnmp_register_scalar(
netsnmp_create_handler_registration("netSnmpExampleInteger", handle_netSn
mpExampleInteger,
netSnmpExampleInteger_oid, OID_LENGTH(netSnmpExamp
leInteger_oid),
HANDLER_CAN_RWRITE
));
}
初始函式呼叫netsnmp_create_handler_registration向snmpd註冊netSnmpExampleInteger_oid的處理函式handle_netSnmpExampleInteger。
函式定義:
int
handle_netSnmpExampleInteger(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
當snmpd呼叫它時,便會把相應的snmp包的資訊從這幾個引數中傳進來。其中reqinfo就是snmp請求包被snmpd解析後得到的結構,包含了請求包的會話和pdu資訊;requests:主要包含了 VB 資訊。
/** @struct netsnmp_agent_request_info_s
* The agent transaction request structure
*/
typedef struct netsnmp_agent_request_info_s {
int mode;
/** pdu contains authinfo, eg */
/* netsnmp_pdu *pdu; */
struct netsnmp_agent_session_s *asp; /* may not be needed */
/*
* can be used to pass information on a per-pdu basis from a
* helper to the later handlers
*/
netsnmp_data_list *agent_data;
} netsnmp_agent_request_info;
typedef struct netsnmp_agent_session_s {
int mode;
netsnmp_session *session;
netsnmp_pdu *pdu;
netsnmp_pdu *orig_pdu;
int rw;
int exact;
int status;
int index;
int oldmode;
struct netsnmp_agent_session_s *next;
/*
* new API pointers
*/
netsnmp_agent_request_info *reqinfo;
netsnmp_request_info *requests;
netsnmp_tree_cache *treecache;
netsnmp_variable_list **bulkcache;
int treecache_len; /* length of cache array */
int treecache_num; /* number of current cache entries */
netsnmp_cachemap *cache_store;
int vbcount;
} netsnmp_agent_session;
typedef struct netsnmp_request_info_s {
/**
* variable bindings
*/
netsnmp_variable_list *requestvb;
/**
* can be used to pass information on a per-request basis from a
* helper to the later handlers
*/
netsnmp_data_list *parent_data;
/*
* pointer to the agent_request_info for this request
*/
struct netsnmp_agent_request_info_s *agent_req_info;
/** don't free, reference to (struct tree)->end */
oid *range_end;
size_t range_end_len;
/*
* flags
*/
int delegated;
int processed;
int inclusive;
int status;
/** index in original pdu */
int index;
/** get-bulk */
int repeat;
int orig_repeat;
netsnmp_variable_list *requestvb_start;
/* internal use */
struct netsnmp_request_info_s *next;
struct netsnmp_request_info_s *prev;
struct netsnmp_subtree_s *subtree;
} netsnmp_request_info;
每次處理一個SNMP請求,就呼叫一次註冊函式。從模板生成的檔案,可以很容易看出:通過requests遍歷vb。致於如何處理,你可以用模板生成的方法做,也可以按自己的想法做,你可以把這個看成應用程式的main函式就好了:)
例子可以看net-snmp自帶的示例程式。原始碼目錄\agent\mibgroup\examples\notification.c
目錄
TEST-SNMP-MIB DEFINITIONS ::= BEGIN
IMPORTS
OBJECT-TYPE, NOTIFICATION-TYPE, MODULE-IDENTITY,
Integer32, Counter32, Gauge32, Counter64, Opaque, Ip chan 導入 設置 jna 配置 決定 ptc UNC 番外篇 前言:
以許框架提供的導入配置功能,已經能解決95%以上的導入情況,但有些情況總歸還是得代碼來解決。
本篇介紹與導入相關的代碼。
1、前端追加導入時Post的參數:
var grid = new lis 數據庫 名稱 教程 配置 rdquo net 列名 邏輯 前言:
在面對Excel的各種復雜導入情況中,多表導入是很常見的情景。
今天就來寫一下多表導入是如何配置的。
1、自定義導入模板
怎麽自定義:
其實就是自己新建一個Excel了,把列頭都寫好。
作者:依樂祝 原文地址:https://www.cnblogs.com/yilezhu/p/9891346.html
因為之前一直沒怎麼玩過CentOS,大多數時間都是使用Win10進行開發,然後程式都部署在Window Server2008或者Window Server2012上!因此想嘗試下L
SNMP專案有個需求,就是能夠動態改變net-snmp監聽的埠而不需要重啟裝置。關於這個功能,一開始想的是如果埠變更了,那就直接使用pthread_kill 關閉原來的代理執行緒,然後重新執行執行緒。但是這樣子測試後發現重啟的執行緒會自動導致整個程序退出。
模組框架大致是這 前言:
最新ASP.NET Aries升級到V5.2.0以上之後,之前的樣式和多語言機制,有了重大的升級機制,這篇就簡單介紹一下。
1、控制開關
在配置維護那裡,新增了兩個控制項:
2、如何新增主題
說明:
在Aries下,可以自已新增樣式(這裡系統暫時沒提供其它樣式),然後通過配置 前言:
在面對Excel的各種複雜匯入情況中,多表匯入是很常見的情景。
今天就來寫一下多表匯入是如何配置的。
1、自定義匯入模板
怎麼自定義:
其實就是自己新建一個Excel了,把列頭都寫好。
不過有一些下拉選項,可能自己不好弄,比如使用者角色,是否這些要變成下拉可選操作,自己去資料庫複製 前言:
隨著ASP.NET Aries的普及,剛好也有點閒空,趕緊把Excel匯入功能的教程補上。
Excel匯入功能,分為四篇:單表配置(上)、多表高階配置(中)、配置規則(下)、程式碼編寫(番外篇)。
本篇介紹單表配置功能。
1、配置表頭,把需要匯入的勾打上。
對於格式化的配置(生成Excel模 前言:
以許框架提供的匯入配置功能,已經能解決95%以上的匯入情況,但有些情況總歸還是得程式碼來解決。
本篇介紹與匯入相關的程式碼。
1、前端追加匯入時Post的引數:
var grid = new AR.DataGrid('V_Test', 'Demo_TestA');
//......
前言:
前面兩篇都是大體介紹流程,有一些配置細節,沒有細說,這裡用一篇補上。
1、Excel配置項
起始行索引、列頭跨行數:
對於自定義的Excel匯入模板(有時候模板是由客戶提供,模板的規則很亂)
比如模板裡前面是一些說明,中間是列頭,下面還帶有資料和說明格式。
通過配置起始行索
基於DDD的現代ASP.NET開發框架--ABP系列之2、ABP入門教程
ABP是“ASP.NET Boilerplate Project (ASP.NET樣板專案)”的簡稱。
ASP.NET Boilerplate是一個用最佳實踐和流行技術開發現代WEB應用程式的新起點,它旨在成為一個通用的
轉載請標明出處 原文地址:http://blog.csdn.net/hepeng597/article/details/8782868
花了一兩天時間測試和整理一下。
用net-snmp擴充套件MIB庫,實現方法可歸結為四種:
1)一是靜態庫方式,通過修改配置標頭檔案,
前言:
為了趕進度,週末也寫文了!
前幾篇講完查詢框和工具欄,這節講表格資料相關的操作。
先看一下列表:
接下來我們有很多事情可以做。
1:格式化 - 鍵值的翻譯
對於“啟用”列,已經配置了格式化 #是否,已經可以看到效果了。
對於分類ID列,通常顯示的是分類名稱,而不是
第4章資料庫基礎2:新增自定義資料在這一章中,我們將建立一個新的字典物件,它用來表示我們僱員就職的‘Acme公司‘(呵呵,當然是虛構的一家公司)的部門。這個“部門”字典物件將包含一個表示部門經理的記錄。
轉載請標明出處 原文地址:http://blog.csdn.net/hepeng597/article/details/8782868
花了一兩天時間測試和整理一下。
用net-snmp擴充套件MIB庫,實現方法可歸結為四種:
1)一是靜態庫方式,通
花了一兩天時間測試和整理一下。
用net-snmp擴充套件MIB庫,實現方法可歸結為四種:
1)一是靜態庫方式,通過修改配置標頭檔案,在相應地方包含新引入的mib模組的.c和.h檔案,然後重新編譯庫檔案和擴充套件程式碼;這種方式不夠靈活,每次修改擴 本文將介紹如何在 .NET Core 環境下,藉助 SignalR 在小程式內使用 WebSocket。關於 WebSocket 和 SignalR 的基礎理論知識不在這裡展開,已經有足夠的參考資料,例如參考 SignalR 的官方教程:https://docs.microsoft.com/zh-cn/a 概述
在 《Senparc.Weixin.MP SDK 微信公眾平臺開發教程(六):瞭解MessageHandler》 中我們已經瞭解了 MessageHandler 的執行原理和使用方法,從我設計了這種處理方式到現在已經 6 年多的時間,這是一種非常穩定而且(在如此複雜環境下)相對易於維護的 前提:
最近,有不少同學又問到,Aries裡如何提供WebAPI介面?
針對這個問題,今天給順路寫個教程,其實呢,很簡單的。
方式一:直接用WebService提供介面。
用這種方式,直接新增介面就可以了,Aries只是預設處理了.html字尾的請求。對於WS的asmx字尾是沒有影響的,所以傳統怎麼新 相關推薦
net-snmp開發教程
net-snmp開發過程整理-MIB.txt檔案
ASP.NET Aries 高級開發教程:Excel導入之代碼編寫(番外篇)
ASP.NET Aries 高級開發教程:Excel導入之多表高級導入配置(中)
CentOS開發ASP.NET Core入門教程
SNMP功能開發簡介 四 net-snmp動態監聽自定義埠
ASP.NET Aries 高階開發教程:主題樣式及多語言(標籤化控制)
ASP.NET Aries 高階開發教程:Excel匯入之多表高階匯入配置(中)
ASP.NET Aries 高階開發教程:Excel匯入之單表配置(上)
ASP.NET Aries 高階開發教程:Excel匯入之程式碼編寫(番外篇)
ASP.NET Aries 高階開發教程:Excel匯入配置之規則說明(下)
ABP(現代ASP.NET樣板開發框架)系列之2、ABP入門教程
net-snmp agent開發詳解,非常簡單
ASP.NET Aries 入門開發教程6:列表資料表格的格式化處理及行內編輯
CAD .NET開發 教程(C#)——第四章
net-snmp agent開發詳解
基於net-snmp的代理agent開發詳解
Senparc.Weixin.MP SDK 微信公眾平臺開發教程(二十一):在小程式中使用 WebSocket (.NET Core)
Senparc.Weixin.MP SDK 微信公眾平臺開發教程(二十二):在 .NET Core 2.0/3.0 中使用 MessageHandler 中介軟體
ASP.NET Aries 高階開發教程:如何寫WebAPI介面