- 浏览: 982402 次
- 性别:
- 来自: 广州
最新评论
-
qingchuwudi:
有用,非常感谢!
erlang进程的优先级 -
zfjdiamond:
你好 这条命令 在那里输入??
你们有yum 我有LuaRocks -
simsunny22:
这个是在linux下运行的吧,在window下怎么运行escr ...
escript的高级特性 -
mozhenghua:
http://www.erlang.org/doc/apps/ ...
mnesia 分布协调的几个细节 -
fxltsbl:
A new record of 108000 HTTP req ...
Haproxy 1.4-dev2: barrier of 100k HTTP req/s crossed
原文地址: http://www.drxyzzy.org/mnesia-snmp/index.html
手册写的巨明白
Contents
Introduction
Define a Mnesia Table
Create the MIB File
Create the .funcs File
Compile the MIB for OTP
Create sys.config and .conf Files
Create MIB Header for Mnesia
Create Data Directory for Mnesia
Create Erlang Program
Start OTP with Mnesia and SNMP agent
Access the Table from net-snmp
References
Introduction
We occasionally make mnesia data readable via SNMP. Here's a cookbook summary of the process. Certainly the Ericsson guide listed in the references should be consulted - this page merely gives extensive detail for a sample case.
Complete directions are given for creating a sample table, configuring the MIB, relating the two, and accessing the table from a net-snmp client.
Limitations of this tutorial.
SNMP versions 1&2, but not 3, are used.
SMIv1 is used to write the MIB.
The SNMP agent listens on non-privileged port 9161, instead of 161.
Code was compiled and executed using FreeBSD-5.0, OTP-R9B1, and Net-SNMP-5.0.8_1.
Define a Mnesia Table
For this example, use a table for several servers which handle telephone calls. Each row contains the server name, plus two counters - the number of inbound calls and the number of outbound calls. Here's an .hrl file defining the record type:
serverTable.hrl.
Create the MIB File
This example places the monitored data in the SNMP OID tree under iso.org.dod.internet.private.enterprises. Filename must end with ".mib". We use a fictional enterprise name of "bazmatic" with enterprise number 99999. See references below if you need an official enterprise number. Server names will be read-only from SNMP. Call counters will be writable from SNMP.
SAMPLE-MIB.mib.
Create the .funcs File
Since default mnesia functions are used, this step could probably be omitted if RowStatus were used.
SAMPLE-MIB.funcs.
Compile the MIB for OTP
Shell command for compiling the MIB.
/usr/home/xxx/otp-snmp>erl
Erlang (BEAM) emulator version 5.2.3.3 [source] [hipe] [threads:0]
Eshell V5.2.3.3 (abort with ^G)
1> snmp:c("SAMPLE-MIB", [{db, mnesia}]).
{ok,"./SAMPLE-MIB.bin"}
Result is binary file SAMPLE-MIB.bin.
Create sys.config and .conf Files
Continuing the previous erl session:
2> snmp:config().
Simple SNMP configuration tool (v3.0)
----------------------------------------------
Note: Non-trivial configurations still has to be done manually.
IP addresses may be entered as dront.ericsson.se (UNIX only) or 123.12.13.23
1. System name (sysName standard variable) [xxx's agent]sample agent
2. Engine ID (snmpEngineID standard variable)[xxx's engine]sample engine
3. The UDP port the agent listens to. (standard 161) [4000]9161
4. IP address for the agent (only used as id
when sending traps) []127.0.0.1
5. IP address for the manager (only this manager will have access
to the agent, traps are sent to this one) []127.0.0.1
6. To what UDP port at the manager should traps
be sent (standard 162)? [5000]9162
7. What SNMP version should be used (1,2,3,1&2,1&2&3,2&3)? [3]1&2
8. Do you want a none- minimum- or semi-secure configuration?
Note that if you chose v1 or v2, you won't get any security for these
requests (none, minimum, semi) [minimum]
9. Where is the configuration directory (absolute)? [/usr/home/xxx/otp-snmp]
10. Current configuration files will now be overwritten. Ok [y]/n?y
------------------------
Info: 1. SecurityName "initial" has noAuthNoPriv read access and authenticated write access to the "restricted" subtree.
2. SecurityName "all-rights" has noAuthNoPriv read/write access to the "internet" subtree.
3. Standard traps are sent to the manager.
4. Community "public" is mapped to security name "initial".
5. Community "all-rights" is mapped to security name "all-rights".
The following files were written: agent.conf, community.conf,
standard.conf, target_addr.conf, target_params.conf,
notify.conf vacm.conf, sys.config
------------------------
ok
Result is the following files: agent.conf, community.conf, context.conf, notify.conf, standard.conf, sys.config, target_addr.conf, target_params.conf, vacm.conf.
Create MIB Header for Mnesia
3> snmp:mib_to_hrl("SAMPLE-MIB").
"SAMPLE-MIB.hrl" written.
ok
Result is file SAMPLE-MIB.hrl.
Create Data Directory for Mnesia
Will use non-volatile storage (disc_copies) for convenience. Designate a directory on disk where the table will be stored.
mkdir /tmp/db
Create Erlang Program
Here is a tiny Erlang module with functions to create the table in Mnesia, get and set values in the table, and start the snmp agent.
snmp_sample.erl.
Start OTP with Mnesia and SNMP agent
Here is the transcript of an Erlang shell session starting things up:
erl -mnesia dir '"/tmp/db"' -config ./sys -name sample
(sample@xyz.com)1> c(snmp_sample).
{ok,snmp_sample}
(sample@xyz.com)2> mnesia:create_schema([node()]).
ok
(sample@xyz.com)3> mnesia:start().
ok
(sample@xyz.com)4> snmp_sample:create_table().
{atomic,ok}
(sample@xyz.com)5> snmp_sample:set_counts("srv01",3,44).
ok
(sample@xyz.com)6> snmp_sample:get_counts().
[[{serverTable,"srv01",3,44}]]
(sample@xyz.com)7> snmp_sample:init_snmp().
<0.140.0>
(sample@xyz.com)8> snmp_mgr:g([[1,3,6,1,2,1,1,1,0]]).
ok
* Got PDU: v1, CommunityName = "public"
Response, Request Id:112362370
(sample@xyz.com)9> snmp_mgr:gn([[1,3,6,1,4,1,99999,1]]).
ok
* Got PDU: v1, CommunityName = "public"
Response, Request Id:38817076
[name,5,115,114,118,48,49] = "srv01"
(sample@xyz.com)10>
Access the Table from net-snmp
Here is an example of a Bourne shell script reading and setting counter values.
First, the script:
# snmpops.sh
# Point MIBDIRS at directory containing the MIB for this example.
MIBDIRS=+/home/xxx/otp-snmp
MIBS=+SAMPLE-MIB
export MIBDIRS MIBS
snmpwalk -Ob -Cc -v 1 -c public localhost:9161 \
.iso.org.dod.internet.private.enterprises.bazmatic
snmpget -Os -v 1 -c public localhost:9161 \
.iso.org.dod.internet.private.enterprises.bazmatic.serverTable.serverEntry.callsIn.5.115.114.118.48.49
snmpset -Os -v 1 -c all-rights localhost:9161 \
.iso.org.dod.internet.private.enterprises.bazmatic.serverTable.serverEntry.callsIn.5.115.114.118.48.49 = 22
snmpget -Os -v 1 -c public localhost:9161 \
.iso.org.dod.internet.private.enterprises.bazmatic.serverTable.serverEntry.callsIn.5.115.114.118.48.49
Then, the results:
SAMPLE-MIB::name.5.115.114.118.48.49 = STRING: "srv01"
SAMPLE-MIB::callsIn.5.115.114.118.48.49 = INTEGER: 3
SAMPLE-MIB::callsOut.5.115.114.118.48.49 = INTEGER: 44
callsIn."srv01" = INTEGER: 3
callsIn."srv01" = INTEGER: 22
callsIn."srv01" = INTEGER: 22
References
Application for Private Enterprise Number
Erlang/OTP SNMP User's Guide See Chapter 6 - Implementation Example
Standard Names for Versions of the SNMP Protocol
revised Jul 22, 2003 - Hal Snyder & Josh Snyder
手册写的巨明白
Contents
Introduction
Define a Mnesia Table
Create the MIB File
Create the .funcs File
Compile the MIB for OTP
Create sys.config and .conf Files
Create MIB Header for Mnesia
Create Data Directory for Mnesia
Create Erlang Program
Start OTP with Mnesia and SNMP agent
Access the Table from net-snmp
References
Introduction
We occasionally make mnesia data readable via SNMP. Here's a cookbook summary of the process. Certainly the Ericsson guide listed in the references should be consulted - this page merely gives extensive detail for a sample case.
Complete directions are given for creating a sample table, configuring the MIB, relating the two, and accessing the table from a net-snmp client.
Limitations of this tutorial.
SNMP versions 1&2, but not 3, are used.
SMIv1 is used to write the MIB.
The SNMP agent listens on non-privileged port 9161, instead of 161.
Code was compiled and executed using FreeBSD-5.0, OTP-R9B1, and Net-SNMP-5.0.8_1.
Define a Mnesia Table
For this example, use a table for several servers which handle telephone calls. Each row contains the server name, plus two counters - the number of inbound calls and the number of outbound calls. Here's an .hrl file defining the record type:
serverTable.hrl.
Create the MIB File
This example places the monitored data in the SNMP OID tree under iso.org.dod.internet.private.enterprises. Filename must end with ".mib". We use a fictional enterprise name of "bazmatic" with enterprise number 99999. See references below if you need an official enterprise number. Server names will be read-only from SNMP. Call counters will be writable from SNMP.
SAMPLE-MIB.mib.
Create the .funcs File
Since default mnesia functions are used, this step could probably be omitted if RowStatus were used.
SAMPLE-MIB.funcs.
Compile the MIB for OTP
Shell command for compiling the MIB.
/usr/home/xxx/otp-snmp>erl
Erlang (BEAM) emulator version 5.2.3.3 [source] [hipe] [threads:0]
Eshell V5.2.3.3 (abort with ^G)
1> snmp:c("SAMPLE-MIB", [{db, mnesia}]).
{ok,"./SAMPLE-MIB.bin"}
Result is binary file SAMPLE-MIB.bin.
Create sys.config and .conf Files
Continuing the previous erl session:
2> snmp:config().
Simple SNMP configuration tool (v3.0)
----------------------------------------------
Note: Non-trivial configurations still has to be done manually.
IP addresses may be entered as dront.ericsson.se (UNIX only) or 123.12.13.23
1. System name (sysName standard variable) [xxx's agent]sample agent
2. Engine ID (snmpEngineID standard variable)[xxx's engine]sample engine
3. The UDP port the agent listens to. (standard 161) [4000]9161
4. IP address for the agent (only used as id
when sending traps) []127.0.0.1
5. IP address for the manager (only this manager will have access
to the agent, traps are sent to this one) []127.0.0.1
6. To what UDP port at the manager should traps
be sent (standard 162)? [5000]9162
7. What SNMP version should be used (1,2,3,1&2,1&2&3,2&3)? [3]1&2
8. Do you want a none- minimum- or semi-secure configuration?
Note that if you chose v1 or v2, you won't get any security for these
requests (none, minimum, semi) [minimum]
9. Where is the configuration directory (absolute)? [/usr/home/xxx/otp-snmp]
10. Current configuration files will now be overwritten. Ok [y]/n?y
------------------------
Info: 1. SecurityName "initial" has noAuthNoPriv read access and authenticated write access to the "restricted" subtree.
2. SecurityName "all-rights" has noAuthNoPriv read/write access to the "internet" subtree.
3. Standard traps are sent to the manager.
4. Community "public" is mapped to security name "initial".
5. Community "all-rights" is mapped to security name "all-rights".
The following files were written: agent.conf, community.conf,
standard.conf, target_addr.conf, target_params.conf,
notify.conf vacm.conf, sys.config
------------------------
ok
Result is the following files: agent.conf, community.conf, context.conf, notify.conf, standard.conf, sys.config, target_addr.conf, target_params.conf, vacm.conf.
Create MIB Header for Mnesia
3> snmp:mib_to_hrl("SAMPLE-MIB").
"SAMPLE-MIB.hrl" written.
ok
Result is file SAMPLE-MIB.hrl.
Create Data Directory for Mnesia
Will use non-volatile storage (disc_copies) for convenience. Designate a directory on disk where the table will be stored.
mkdir /tmp/db
Create Erlang Program
Here is a tiny Erlang module with functions to create the table in Mnesia, get and set values in the table, and start the snmp agent.
snmp_sample.erl.
Start OTP with Mnesia and SNMP agent
Here is the transcript of an Erlang shell session starting things up:
erl -mnesia dir '"/tmp/db"' -config ./sys -name sample
(sample@xyz.com)1> c(snmp_sample).
{ok,snmp_sample}
(sample@xyz.com)2> mnesia:create_schema([node()]).
ok
(sample@xyz.com)3> mnesia:start().
ok
(sample@xyz.com)4> snmp_sample:create_table().
{atomic,ok}
(sample@xyz.com)5> snmp_sample:set_counts("srv01",3,44).
ok
(sample@xyz.com)6> snmp_sample:get_counts().
[[{serverTable,"srv01",3,44}]]
(sample@xyz.com)7> snmp_sample:init_snmp().
<0.140.0>
(sample@xyz.com)8> snmp_mgr:g([[1,3,6,1,2,1,1,1,0]]).
ok
* Got PDU: v1, CommunityName = "public"
Response, Request Id:112362370
(sample@xyz.com)9> snmp_mgr:gn([[1,3,6,1,4,1,99999,1]]).
ok
* Got PDU: v1, CommunityName = "public"
Response, Request Id:38817076
[name,5,115,114,118,48,49] = "srv01"
(sample@xyz.com)10>
Access the Table from net-snmp
Here is an example of a Bourne shell script reading and setting counter values.
First, the script:
# snmpops.sh
# Point MIBDIRS at directory containing the MIB for this example.
MIBDIRS=+/home/xxx/otp-snmp
MIBS=+SAMPLE-MIB
export MIBDIRS MIBS
snmpwalk -Ob -Cc -v 1 -c public localhost:9161 \
.iso.org.dod.internet.private.enterprises.bazmatic
snmpget -Os -v 1 -c public localhost:9161 \
.iso.org.dod.internet.private.enterprises.bazmatic.serverTable.serverEntry.callsIn.5.115.114.118.48.49
snmpset -Os -v 1 -c all-rights localhost:9161 \
.iso.org.dod.internet.private.enterprises.bazmatic.serverTable.serverEntry.callsIn.5.115.114.118.48.49 = 22
snmpget -Os -v 1 -c public localhost:9161 \
.iso.org.dod.internet.private.enterprises.bazmatic.serverTable.serverEntry.callsIn.5.115.114.118.48.49
Then, the results:
SAMPLE-MIB::name.5.115.114.118.48.49 = STRING: "srv01"
SAMPLE-MIB::callsIn.5.115.114.118.48.49 = INTEGER: 3
SAMPLE-MIB::callsOut.5.115.114.118.48.49 = INTEGER: 44
callsIn."srv01" = INTEGER: 3
callsIn."srv01" = INTEGER: 22
callsIn."srv01" = INTEGER: 22
References
Application for Private Enterprise Number
Erlang/OTP SNMP User's Guide See Chapter 6 - Implementation Example
Standard Names for Versions of the SNMP Protocol
revised Jul 22, 2003 - Hal Snyder & Josh Snyder
发表评论
-
OTP R14A今天发布了
2010-06-17 14:36 2677以下是这次发布的亮点,没有太大的性能改进, 主要是修理了很多B ... -
R14A实现了EEP31,添加了binary模块
2010-05-21 15:15 3030Erlang的binary数据结构非常强大,而且偏向底层,在作 ... -
如何查看节点的可用句柄数目和已用句柄数
2010-04-08 03:31 4814很多同学在使用erlang的过程中, 碰到了很奇怪的问题, 后 ... -
获取Erlang系统信息的代码片段
2010-04-06 21:49 3475从lib/megaco/src/tcp/megaco_tcp_ ... -
iolist跟list有什么区别?
2010-04-06 20:30 6529看到erlang-china.org上有个 ... -
erlang:send_after和erlang:start_timer的使用解释
2010-04-06 18:31 8386前段时间arksea 同学提出这个问题, 因为文档里面写的很不 ... -
Latest news from the Erlang/OTP team at Ericsson 2010
2010-04-05 19:23 2013参考Talk http://www.erlang-factor ... -
对try 异常 运行的疑问,为什么出现两种结果
2010-04-05 19:22 2842郎咸武<langxianzhe@163.com> ... -
Erlang ERTS Async基础设施
2010-03-19 00:03 2517其实Erts的Async做的很不错的, 相当的完备, 性能又高 ... -
CloudI 0.0.9 Released, A Cloud as an Interface
2010-03-09 22:32 2476基于Erlang的云平台 看了下代码 质量还是不错的 完成了不 ... -
Memory matters - even in Erlang (再次说明了了解内存如何工作的必要性)
2010-03-09 20:26 3439原文地址:http://www.lshift.net/blog ... -
Some simple examples of using Erlang’s XPath implementation
2010-03-08 23:30 2050原文地址 http://www.lshift.net/blog ... -
lcnt 环境搭建
2010-02-26 16:19 2614抄书:otp_doc_html_R13B04/lib/tool ... -
Erlang强大的代码重构工具 tidier
2010-02-25 16:22 2486Jan 29, 2010 We are very happy ... -
[Feb 24 2010] Erlang/OTP R13B04 has been released
2010-02-25 00:31 1387Erlang/OTP R13B04 has been rele ... -
R13B04 Installation
2010-01-28 10:28 1390R13B04后erlang的源码编译为了考虑移植性,就改变了编 ... -
Running tests
2010-01-19 14:51 1486R13B03以后 OTP的模块加入了大量的测试模块,这些模块都 ... -
R13B04在细化Binary heap
2010-01-14 15:11 1508从github otp的更新日志可以清楚的看到otp R13B ... -
R13B03 binary vheap有助减少binary内存压力
2009-11-29 16:07 1668R13B03 binary vheap有助减少binary内存 ... -
erl_nif 扩展erlang的另外一种方法
2009-11-26 01:02 3218我们知道扩展erl有2种方法, driver和port. 这2 ...
相关推荐
为了解决这个问题,Mnesia 提供了表分片(table fragmentation)的功能。通过使用 Linear Hashing 算法,Mnesia 可以将大表分散存储在多个节点上,从而提高表的可扩展性和性能。 在分析 Mnesia 表分片的过程和算法...
session, specify a Mnesia database directory, initialize a database schema, start Mnesia, and create tables. Initial prototyping of record definitions is also discussed. • Build a Mnesia Database ...
8.附录.A:Mnesia.错误信息 8.1.Mnesia.中的错误 9.附录.B:备份回调函数接口 9.1.Mnesia.备份回调行为 10.附录.C:作业存取回调接口 10.1.Mnnesia.存取回调行为 11.附录.D:分片表哈希回调接口 11.1....
8 附录 A : Mnesia 错误信息 . . .. . . 75 8.1 Mnesia 中的错误 . . . . .. . 75 9 附录 B :备份回调函数接口 . . .. . .. . . .. . 76 9.1 Mnesia 备份回调行为 . . .. . . . .. . 76 10 附录 C :作业存取...
B站视频地址: 做了文字校验,已经成功上线,有兴趣的小伙伴可以扫码体验:可以微信搜索:失忆备忘录一、失忆的由来之所以开发这款软件,是因为在那段时间事情很多,但是经常忘记。虽然市面上类似的功能很多,我之前...
AMNESIA是一个基于Erlang编程语言的开源库,专门设计用于简化与关系数据库管理系统(RDBMS)的交互。Erlang以其并发处理、容错性和高效性能在分布式系统领域备受推崇,而AMNESIA则进一步扩展了Erlang的功能,使...
Api-Social-Amnesia.zip,忘记过去。社交健忘症确保你的社交媒体帐户只显示你最近的历史,而不是5年前“那个阶段”的帖子。,一个api可以被认为是多个软件设备之间通信的指导手册。例如,api可用于web应用程序之间的...
《Mnesia用户手册》是专为理解和操作Erlang编程语言中的Mnesia数据库管理系统而编写的详尽指南。Mnesia是Erlang OTP (Open Telephony Platform) 库中的一个核心组件,它是一个强大的分布式数据库系统,特别适用于...
除此之外,Mnesia支持与SNMP(简单网络管理协议)的结合,使得可以监控和管理网络设备。 Mnesia的错误信息处理、备份回调函数接口、作业访问回调接口和分片表哈希回调接口分别在附录中进行了详细说明,这些都是使用...
- **数据模型**:Mnesia 支持两种主要的数据模型:*正交表(Table)* 和 *活动数据表(Active Data Table, ADT)*。正交表用于存储静态数据,而ADT则用于动态数据,支持实时更新和查询。 - **启动 Mnesia**:启动...
语言:English (United States) 遗忘的延伸 Chrome失忆症是一个Chrome扩展程序,可让您有选择地不记得自己的任何浏览历史记录。...有关更多信息,请访问https://github.com/DanielBok/chrome-amnesia。
### Mnesia数据库:Erlang中的分布式数据库管理系统 #### 引言 Mnesia,作为Erlang编程语言的一部分,是一款由爱立信公司开发的分布式数据库管理系统(DBMS)。自1997年以来,Mnesia一直是Open Telecom Platform...
失忆症是一种提醒,允许您定义警报,贴纸(贴子)以提醒您一些重要的内容以及有关所需内容的注释。 可以将警报编程为在给定时间显示,可以在桌面上放置贴纸以随时查看。
"Amnesia"是一个可能与计算机安全或数据丢失相关的主题,暗示了系统或用户可能遭遇了某种形式的记忆丧失,即数据无法访问或丢失的情况。在IT领域,这种情况通常涉及到磁盘故障、病毒攻击、误操作或者软件错误。"Post...