head_simple_table中的那个table_size怎么确定?

6 views
Skip to first unread message

howe...@gmail.com

unread,
May 26, 2009, 4:24:54 AM5/26/09
to EMS网管开发
head_simple_table中的那个table_size怎么确定?有文档说是通过系统调用得到,不知道是哪个?
另外,网管软件要查询的那些信息(如alarm value等),在agent我如何得到,要自己写函数吗?还是协议已经提供了api?

unsigned char *
var_extensible_disk(vp, name, length, exact, var_len,
write_method)
{
if (header_simple_table
(vp,name,length,exact,var_len,write_method,numdisks)
== MATCH_FAILED)
return(NULL);

[ etc, etc, etc ]

}

Note that the maximum index value parameter does not have to be a
permanently fixed constant. It specifies the maximum valid index at
the time
the request is processed, and a subsequent request may have a
different
maximum.
An example of this can be seen in mibII/sysORTable.c where the table
is held
purely internally to the agent code, including its size (and hence the
maximum valid index). This maximum could also be retrieved via a
system
call, or via a kernel data variable.

sky

unread,
May 26, 2009, 4:31:34 AM5/26/09
to EMS网管开发
网管软件要查询的那些信息(如alarm value等),在agent我如何得到,要自己写函数吗?还是协议已经提供了api?

你要自己定义ALARM的MIB并且实现,都是你做。
SNMP只是一个协议,协议是沟通的语言,说什么做什么还是要你自己说自己做。

howe...@gmail.com

unread,
May 26, 2009, 4:35:40 AM5/26/09
to EMS网管开发
还要定义alarm的mib吗?我已经有rmon的.c了,下面的函数也有了,还要自己定义吗?


/*
* var_alarmTable():
* Handle this table separately from the scalar value case.
* The workings of this are basically the same as for var_alarm
above.
*/
unsigned char *
var_alarmTable(struct variable *vp,
oid *name,
size_t *length,
int exact,
size_t *var_len,
WriteMethod **write_method)
{


/* variables we may use later */
static long long_ret;
static unsigned char string[SPRINT_MAX_LEN];
static oid objid[MAX_OID_LEN];
static struct counter64 c64;


/*
* This assumes that the table is a 'simple' table.
* See the implementation documentation for the meaning of this.
* You will need to provide the correct value for the TABLE_SIZE
parameter
*
* If this table does not meet the requirements for a simple table,
* you will need to provide the replacement code yourself.
* Mib2c is not smart enough to write this for you.
* Again, see the implementation documentation for what is
required.
*/

if (header_simple_table(vp,name,length,exact,var_len,write_method,
1)
== MATCH_FAILED )
return NULL;
/*
if (header_generic(vp,name,length,exact,var_len,write_method)
== MATCH_FAILED )
return NULL;
*/

/*
* this is where we do the value assignments for the mib results.
*/
switch(vp->magic) {


case ALARMINDEX:

long_ret = 0;
return (unsigned char *) &long_ret;

case ALARMINTERVAL:
*write_method = write_alarmInterval;
long_ret = 0;
return (unsigned char *) &long_ret;

case ALARMVARIABLE:
*write_method = write_alarmVariable;
objid[0] = 0;
objid[1] = 0;
*var_len = 2*sizeof(oid);
return (unsigned char *) objid;

case ALARMSAMPLETYPE:
*write_method = write_alarmSampleType;
long_ret = 0;
return (unsigned char *) &long_ret;

case ALARMVALUE:

long_ret = 0;
return (unsigned char *) &long_ret;

case ALARMSTARTUPALARM:
*write_method = write_alarmStartupAlarm;
long_ret = 0;
return (unsigned char *) &long_ret;

case ALARMRISINGTHRESHOLD:
*write_method = write_alarmRisingThreshold;
long_ret = 0;
return (unsigned char *) &long_ret;

case ALARMFALLINGTHRESHOLD:
*write_method = write_alarmFallingThreshold;
long_ret = 0;
return (unsigned char *) &long_ret;

case ALARMRISINGEVENTINDEX:
*write_method = write_alarmRisingEventIndex;
long_ret = 0;
return (unsigned char *) &long_ret;

case ALARMFALLINGEVENTINDEX:
*write_method = write_alarmFallingEventIndex;
long_ret = 0;
return (unsigned char *) &long_ret;

case ALARMOWNER:
*write_method = write_alarmOwner;
*string = 0;
*var_len = strlen(string);
return (unsigned char *) string;

case ALARMSTATUS:
*write_method = write_alarmStatus;
long_ret = 0;
return (unsigned char *) &long_ret;


default:
ERROR_MSG("");
}
return NULL;
> > call, or via a kernel data variable.- Hide quoted text -
>
> - Show quoted text -

Hailong Shu

unread,
May 26, 2009, 4:37:13 AM5/26/09
to ems...@googlegroups.com
我看到的是乱码,别人看的怎么样?

2009/5/26 <howe...@gmail.com>

遜猁隅砱alarm腔mib鎘ˋ扂眒冪衄rmon腔.c賸ㄛ狟醱腔滲杅珩衄賸ㄛ遜猁赻撩隅砱鎘ˋ
> 厙奪璃猁脤戙腔饒虳陓洘ㄗalarm value脹ㄘㄛ婓agent扂睡腕善ㄛ猁赻撩迡滲杅鎘ˋ遜岆衪祜眒冪枑鼎賸apiˋ
>
> 斕猁赻撩隅砱ALARM腔MIB甜妗珋ㄛ飲岆斕酕﹝
> SNMP硐岆珨跺衪祜ㄛ衪祜岆僱籵腔逄晟ㄛ佽妦繫酕妦繫遜岆猁斕赻撩佽赻撩酕﹝
>
> On 5堎26, 狟敁4奀24煦, howema...@gmail.com wrote:
>
>
>
> > head_simple_table笢腔饒跺table_size崋繫隅ˋ衄恅紫佽岆籵徹炵苀覃蚚腕善ㄛ祥眭耋岆闡跺ˋ
> > 鍚俋ㄛ厙奪璃猁脤戙腔饒虳陓洘ㄗalarm value脹ㄘㄛ婓agent扂睡腕善ㄛ猁赻撩迡滲杅鎘ˋ遜岆衪祜眒冪枑鼎賸apiˋ

howe...@gmail.com

unread,
May 26, 2009, 4:41:22 AM5/26/09
to EMS网管开发
不知道为什么是乱码 再来一次了

我是说rmon的.c我已经有了,另外上面那个函数unsigned char *


var_alarmTable(struct variable *vp,
oid *name,
size_t *length,
int exact,
size_t *var_len,
WriteMethod **write_method)
{

也已经有了,还用定义alarm的mib吗?不用了吧应该?


On May 26, 4:37 pm, Hailong Shu <shuhail...@gmail.com> wrote:
> 我看到的是乱码,别人看的怎么样?
>
> 2009/5/26 <howema...@gmail.com>

> > > - Show quoted text -- Hide quoted text -

Reply all
Reply to author
Forward
0 new messages