亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
最近訪問(wèn)板塊 發(fā)新帖
查看: 3477 | 回復(fù): 1
打印 上一主題 下一主題

關(guān)于Agent如何動(dòng)態(tài)地取得變量的值。。。(net-snmp) [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2006-02-10 13:41 |只看該作者 |倒序?yàn)g覽
通過(guò)Agent獲取變量的值(小弟寫的是一個(gè)返回cpu利用百分?jǐn)?shù)的函數(shù) void al_share_mem(int * value),\r\n包含在文件rdm-test3.c中,該函數(shù)可動(dòng)態(tài)地返回值)\r\n\r\n然后小弟將MIB文件經(jīng)過(guò)mib2c命令編譯成.c和.h文件,并修改.c文件如下:\r\n/*\r\n * Note: this file originally auto-generated by mib2c using\r\n *        : mib2c.int_watch.conf,v 1.3 2005/05/03 14:38:11 dts12 Exp $\r\n */\r\n \r\n#include <net-snmp/net-snmp-config.h>\r\n#include <net-snmp/net-snmp-includes.h>\r\n#include <net-snmp/agent/net-snmp-agent-includes.h>\r\n#include \"testAgentCpu1.h\"\r\n\r\n/*   我加的部分begin  */\r\n#include \"rdm-test3.c\"    /*  這個(gè)是我自己寫的,將內(nèi)存利用率寫入共享內(nèi)存并返回值 */\r\n/*   我加的部分end    */\r\n \r\nlong    testAgentCpu1 = 1;  /* XXX: set default value */\r\n \r\n/*\r\n * Our initialization routine, called automatically by the agent\r\n * (Note that the function name must match init_FILENAME())\r\n */\r\nvoid\r\ninit_testAgentCpu1(void)\r\n{\r\n \r\n  int i,j,k;\r\n \r\n  static oid testAgentCpu1_oid[] = { 1,3,6,1,4,1,8072,2,4,1,1,1 };\r\n\r\n/*  我加的部分begin  */\r\n  al_share_mem(&testAgentCpu1);        /*  為rdm-test3.c中的函數(shù),通過(guò)讀共享內(nèi)存,\r\n                                           將cpu的利用率百分?jǐn)?shù)賦給testAgentCpu1,\r\n                                           我寫了他的測(cè)試程序,確實(shí)可以動(dòng)態(tài)返回,\r\n                                           每次運(yùn)行返回值都不同  */\r\n/*  我加的部分end   */ \r\n \r\n \r\n  DEBUGMSGTL((\"testAgentCpu1\",\r\n                \"Initializing testAgentCpu1 scalar integer.  Default value = %d\\n\",\r\n                testAgentCpu1));\r\n  netsnmp_register_int_instance(\"testAgentCpu1\",\r\n                                  testAgentCpu1_oid,\r\n                                  OID_LENGTH(testAgentCpu1_oid),\r\n                                  &testAgentCpu1, NULL);\r\n \r\n  DEBUGMSGTL((\"testAgentCpu1\",\r\n              \"Done initalizing testAgentCpu1 module\\n\"));\r\n}//file ended\r\n\r\n將此文件編入Agent后啟動(dòng)snmpd,執(zhí)行snmpget localhost -c public -v 1 testAgentCpu1.0\r\n每次都返回相同的值,郁悶。\r\n\r\n如果重新啟動(dòng)snmpd,則又得到新的值,且又保持不變了。。。。\r\n不知道怎么樣才能獲取到實(shí)時(shí)的值。請(qǐng)指點(diǎn)。

論壇徽章:
0
2 [報(bào)告]
發(fā)表于 2006-02-10 16:15 |只看該作者
問(wèn)題解決了。\r\n不過(guò)用比較笨的方法\r\n就是直接映射共享內(nèi)存的地址\r\n加入兩行程序\r\nshmid=shmget(0x1000,SHMDATASIZE,0660);\r\nshmdata=shmat(shmid,0,0);\r\n\r\n最后將netsnmp_register_int_instance中的&testAgentCpu1替換為shmdata即可\r\n不知道有沒有更好的解決方法\r\n期待中。。
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過(guò)ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP