Difference between revisions of "AgentLite-Node.js"
Eric.liang (talk | contribs) |
Eric.liang (talk | contribs) |
||
| (15 intermediate revisions by the same user not shown) | |||
| Line 5: | Line 5: | ||
#<span style="font-size:medium;">Net-Protocol ( ./lib/WISECore3.3.js)",</span> | #<span style="font-size:medium;">Net-Protocol ( ./lib/WISECore3.3.js)",</span> | ||
#<span style="font-size:medium;">main program ( AgentLite3.3.js) </span> | #<span style="font-size:medium;">main program ( AgentLite3.3.js) </span> | ||
| − | #<span style="font-size:medium;">plugin module ( ./module/plugin_temp.js). <span style="color:#FF0000;"> | + | #<span style="font-size:medium;">plugin module ( ./module/plugin_temp.js). <span style="color:#FF0000;">Developer need to implement your application in this plugin.js.</span></span> |
[[File:AgentLite-Node-js.jpg|800x500px|AgentLite-Node-js.jpg]] | [[File:AgentLite-Node-js.jpg|800x500px|AgentLite-Node-js.jpg]] | ||
| Line 15: | Line 15: | ||
== Sofware Components of AgentLite-Node.js == | == Sofware Components of AgentLite-Node.js == | ||
| − | [[File:AgentLite-Node.js-SW-Stack.jpg|center|800x400px]] | + | [[File:AgentLite-Node.js-SW-Stack.jpg|center|800x400px|AgentLite-Node.js-SW-Stack.jpg]] |
== Configure == | == Configure == | ||
| Line 166: | Line 166: | ||
|} | |} | ||
</div> | </div> | ||
| − | |||
== AdvDataMgt == | == AdvDataMgt == | ||
| Line 188: | Line 187: | ||
=== Function === | === Function === | ||
| + | |||
| + | {| border="1" cellspacing="1" cellpadding="1" style="width: 840px;" | ||
| + | |- | ||
| + | | style="width: 50px;" | '''Item''' | ||
| + | | style="width: 316px;" | '''Function''' | ||
| + | | style="width: 455px;" | '''Description''' | ||
| + | |- | ||
| + | | style="width: 50px; text-align: center;" | 1 | ||
| + | | style="width: 316px;" | '''bool initialize ( strName, jInfo )''' | ||
| + | | style="width: 455px;" | To initialize the AdvDataMgt<br/> | ||
| + | |- | ||
| + | | style="width: 50px; text-align: center;" | 2 | ||
| + | | style="width: 316px;" | '''bool addSensor( strPath, jsSensor, strKey )'''<br/> | ||
| + | | style="width: 455px;" | Add a sensor data by path.<br/> | ||
| + | |- | ||
| + | | style="width: 50px; text-align: center;" | 3 | ||
| + | | style="width: 316px;" | '''bool ''removeSensorbyPath''( strPath )'''<br/> | ||
| + | | style="width: 455px;" | Remove a sensor by path<br/> | ||
| + | |- | ||
| + | | style="width: 50px; text-align: center;" | 4 | ||
| + | | style="width: 316px;" | '''bool removeSensorbyKey''( ''strKey )'''<br/> | ||
| + | | style="width: 455px;" | Remove a sensor by key<br/> | ||
| + | |- | ||
| + | | style="width: 50px; text-align: center;" | 5 | ||
| + | | style="width: 316px;" | '''bool removeGroup( strPath )''' | ||
| + | | style="width: 455px;" | Remove a JSON Goup | ||
| + | |- | ||
| + | | style="width: 50px; text-align: center;" | 6 | ||
| + | | style="width: 316px;" | '''var getCapability ()'''<br/> | ||
| + | | style="width: 455px;" | Get capability.<br/> | ||
| + | |- | ||
| + | | style="width: 50px; text-align: center;" | 7 | ||
| + | | style="width: 316px;" | '''bool updatebyPath( strPath, value )'''<br/> | ||
| + | | style="width: 455px;" | Update value by path<br/> | ||
| + | |- | ||
| + | | style="width: 50px; text-align: center;" | 8 | ||
| + | | style="width: 316px;" | '''bool updatebyKey( strKey, value )'''<br/> | ||
| + | | style="width: 455px;" | Update value by key<br/> | ||
| + | |- | ||
| + | | style="width: 50px; text-align: center;" | 9 | ||
| + | | style="width: 316px;" | '''var getSenseorbyPath( strPath )'''<br/> | ||
| + | | style="width: 455px;" | Get sensor value by path | ||
| + | |- | ||
| + | | style="width: 50px; text-align: center;" | 10 | ||
| + | | style="width: 316px;" | '''var getSenseorbyKey( strKey )'''<br/> | ||
| + | | style="width: 455px;" | Get sensor value by key<br/> | ||
| + | |- | ||
| + | | style="width: 50px; text-align: center;" | 11 | ||
| + | | style="width: 316px;" | '''var queryKeybyPath( strPath )'''<br/> | ||
| + | | style="width: 455px;" | Query key by path | ||
| + | |- | ||
| + | | style="width: 50px; text-align: center;" | 12 | ||
| + | | style="width: 316px;" | '''var getAllPath( outRet [ ] )'''<br/> | ||
| + | | style="width: 455px;" | Get all of paths | ||
| + | |- | ||
| + | | style="width: 50px; text-align: center;" | 13 | ||
| + | | style="width: 316px;" | '''var getAllKey( outRet [ ] )'''<br/> | ||
| + | | style="width: 455px;" | Get all of keys | ||
| + | |- | ||
| + | | style="width: 50px; text-align: center;" | 14 | ||
| + | | style="width: 316px;" | '''var getValuebyKey ( strKey )''' | ||
| + | | style="width: 455px;" | Get value only by key | ||
| + | |- | ||
| + | | style="width: 50px; text-align: center;" | 15 | ||
| + | | style="width: 316px;" | '''var getAllLatestValues()''' | ||
| + | | style="width: 455px;" | Get all latest sensor data values only | ||
| + | |- | ||
| + | | style="width: 50px; text-align: center;" | 16 | ||
| + | | style="width: 316px;" | '''bool getUpdatedValues( outRet{}, strPath )''' | ||
| + | | style="width: 455px;" | Get latest update sensor data values, strPath = null (All), by JSON group | ||
| + | |- | ||
| + | | style="width: 50px; text-align: center;" | 17 | ||
| + | | style="width: 316px;" | '''resetUpdatedValues( strPath )''' | ||
| + | | style="width: 455px;" | Reset latest update sensor data table, strPath: NULL ( All), by JSON Group | ||
| + | |} | ||
'''int initialize ( strName, jInfo )''' | '''int initialize ( strName, jInfo )''' | ||
| Line 237: | Line 311: | ||
}</pre> | }</pre> | ||
| − | '''var '''''' | + | '''var r''''''emoveSensorbyPath'''''''''( strPath )'''' |
| − | *Description: Remove a | + | *Description: Remove a sensor by path |
*Sample Code | *Sample Code | ||
<pre>var strPath = 'SNMP_Handler/SenData/Temperature'; | <pre>var strPath = 'SNMP_Handler/SenData/Temperature'; | ||
| Line 252: | Line 326: | ||
</pre> | </pre> | ||
| − | '''var | + | '''var ''removeSensorbyKey( ''strKey )''' |
*Description: Remove a sensor by key | *Description: Remove a sensor by key | ||
| Line 264: | Line 338: | ||
<pre>remove sensor by key = 172.22.12.49-1.3.6.1.4.1.10297.101.1.4.1.1.15 | <pre>remove sensor by key = 172.22.12.49-1.3.6.1.4.1.10297.101.1.4.1.1.15 | ||
new capability {"SNMP_Handler":{"info":{"bn":"info","e":[{"n":"type","sv":"Protocol","asm":"r"},{"n":"name","sv":"SNMP_Handler","asm":"r"},{"n":"description","sv":"This is a SNMP Manager service","asm":"r"},{"n":"version","sv":"v1.0.2","asm":"r"}]},"SenData":{"bn":"SenData","e":[{"n":"Temperature","u":"Cel","v":26.5,"min":-100,"max":200,"asm":"r"}]},"Info":{"bn":"Info","e":[{"n":"Name","sv":"SenHub","asm":"rw"},{"n":"sw","sv":"1.0.0","asm":"r"}]},"Net":{"bn":"Net","e":[{"n":"sw","sv":"3.0.1","asm":"r"},{"n":"Health","v":100,"asm":"r"}]}}}</pre> | new capability {"SNMP_Handler":{"info":{"bn":"info","e":[{"n":"type","sv":"Protocol","asm":"r"},{"n":"name","sv":"SNMP_Handler","asm":"r"},{"n":"description","sv":"This is a SNMP Manager service","asm":"r"},{"n":"version","sv":"v1.0.2","asm":"r"}]},"SenData":{"bn":"SenData","e":[{"n":"Temperature","u":"Cel","v":26.5,"min":-100,"max":200,"asm":"r"}]},"Info":{"bn":"Info","e":[{"n":"Name","sv":"SenHub","asm":"rw"},{"n":"sw","sv":"1.0.0","asm":"r"}]},"Net":{"bn":"Net","e":[{"n":"sw","sv":"3.0.1","asm":"r"},{"n":"Health","v":100,"asm":"r"}]}}}</pre> | ||
| + | |||
| + | '''var ''removeGroup( ''strPath )''' | ||
| + | |||
| + | *Description: Remove a JSON Group by path | ||
| + | *Sample Code | ||
| + | <pre>var strPath = 'SNMP_Handler/Net'; | ||
| + | dataMgt.removeGroup(strPath); | ||
| + | console.log('remove JSON Group by path = ' + strPath ); | ||
| + | console.log('new capability ' + JSON.stringify(dataMgt.getCapability()));</pre> | ||
| + | |||
| + | *Result | ||
| + | <pre>remove JSON Group by path = SNMP_Handler/Net | ||
| + | new capability {"SNMP_Handler":{"info":{"bn":"info","e":[{"n":"type","sv":"Protocol","asm":"r"},{"n":"name","sv":"SNMP_Handler","asm":"r"},{"n":"description","sv":"This is a SNMP Manager service","asm":"r"},{"n":"version","sv":"v1.0.2","asm":"r"}]},"SenData":{"bn":"SenData","e":[{"n":"Temperature","u":"Cel","v":26.5,"min":-100,"max":200,"asm":"r"},{"n":"Count","u":"","v":0,"asm":"rw"}]},"Info":{"bn":"Info","e":[{"n":"Name","sv":"SenHub","asm":"rw"},{"n":"sw","sv":"1.0.0","asm":"r"}]}}} | ||
| + | </pre> | ||
'''var getCapability ()''' | '''var getCapability ()''' | ||
| Line 291: | Line 379: | ||
*Description: Get value by path | *Description: Get value by path | ||
*Sample Code | *Sample Code | ||
| − | <pre>var strPath = | + | <pre>var strPath = 'SNMP_Handler/SenData/Temperature'; |
console.log('get value by path= ' + strPath); | console.log('get value by path= ' + strPath); | ||
console.log('ret= ' + JSON.stringify(dataMgt.getSenseorbyPath(strPath)));</pre> | console.log('ret= ' + JSON.stringify(dataMgt.getSenseorbyPath(strPath)));</pre> | ||
| Line 349: | Line 437: | ||
[{"path":"SNMP_Handler/SenData/Temperature"},{"path":"SNMP_Handler/SenData/Count","key":"172.22.12.49-1.3.6.1.4.1.10297.101.1.4.1.1.15"},{"path":"SNMP_Handler/Info/Name"},{"path":"SNMP_Handler/Info/sw"},{"path":"SNMP_Handler/Net/sw"},{"path":"SNMP_Handler/Net/Health"}]</pre> | [{"path":"SNMP_Handler/SenData/Temperature"},{"path":"SNMP_Handler/SenData/Count","key":"172.22.12.49-1.3.6.1.4.1.10297.101.1.4.1.1.15"},{"path":"SNMP_Handler/Info/Name"},{"path":"SNMP_Handler/Info/sw"},{"path":"SNMP_Handler/Net/sw"},{"path":"SNMP_Handler/Net/Health"}]</pre> | ||
| − | = | + | = Sample Code = |
== Plugin == | == Plugin == | ||
| Line 363: | Line 451: | ||
<span style="font-size:large;">Template Code: ./module/Simple-plugin_temp.js</span> | <span style="font-size:large;">Template Code: ./module/Simple-plugin_temp.js</span> | ||
| − | = | + | == [http://advgitlab.eastasia.cloudapp.azure.com/EdgeSense/device-snmp-nms-node.js <span style="font-size:large;">SNMP-NMS Project</span>] == |
| − | + | = Source Code = | |
| − | [ | + | [http://advgitlab.eastasia.cloudapp.azure.com/EdgeSense-Open/agentlite-node.js http://advgitlab.eastasia.cloudapp.azure.com/EdgeSense-Open/agentlite-node.js] |
Latest revision as of 10:57, 13 July 2020
Introduction
AgentLite-Node.js is a light weight south-bound agent in Node.js. There are 3 main component:
- Net-Protocol ( ./lib/WISECore3.3.js)",
- main program ( AgentLite3.3.js)
- plugin module ( ./module/plugin_temp.js). Developer need to implement your application in this plugin.js.
AgentLite-Node.js
Sofware Components of AgentLite-Node.js
Configure
./config/agent_config.json : in JSON Format
{
"ServerIP":"127.0.0.1",
"ServerPort": 1883,
"DeviceName": "SNMP_Handler",
"DevType": "Service",
"version": "v1.0.1",
"plugin": "./module/Simple-plugin_test.js"
}
Plugin
A plugin.js with common interfaces. A main program can load a plugin to send and control its sensor data.
Define and Callback functions
| global variable | Description |
|---|---|
| g_strPluginName |
Name of plugin |
| g_jsCapability |
Capability of this plugin |
| g_sendcbf | reply action function point |
| g_sendreportcbf | auto report function point |
| g_sendcapabilitycbf | send capability function point |
| g_sendeventcbf | send event message function point |
| g_sendreplytopiccbf | send update data by reply action topic ( Monitor page ) function point |
Internal Function
Developer needs to implement these functions.
var InitPlugin()
- Description: To initialize process of your plugin.
var UnInitPlugin()
- Description: To uninitialize process of your plugin.
var AutoReport()
- Description: system will call this "AutoReport" after trigging auto report. To send auto report data by "g_sendreportcbf".
var getSenseData( iCmd, strSessionid, jsRequest )
- Description: To receive a get control command and call this function to query sensor data in capability cach.
var StartMonitorData(iCmd, strSessionid, jsMsg )
- Description: To receive a get monitor command and register a timer envet to call "MonitorUpdate" function.
var MonitorStop( )
- Description: To stop a timer event of Monitor sensor data.
var MonitorUpdate()
- Description: To upload sensor data by g_sendreplytopiccbf
Export Interfaces of Plugin
Developers do not need to modify in general
var Handler_Initialize( param )
- Description: Main program calls "Handler_Initialize" to initialize this module.
| Parameter | Description |
|---|---|
| param.sendcbf | reply action function point |
| param.sendreportcbf | auto report function point |
| param.sendcapabilitycbf | send capability function point |
| param.sendeventcbf | send event message function point |
| param.sendreplytopiccbf | send update data by reply action topic ( Monitor page ) function point |
var Handler_Uninitialize( )
- Description: Main program calls "Handler_Uninitialize" to uninitialize this module.
void Handler_AutoReportStart( interval )
- Description: Main program calls the "Handler_AutoReportStart" to start auto report.
| Parameter | Description |
|---|---|
| interval | report interval in second |
var Handler_AutoReportStop()
- Description: Main program calls "'Handler_AutoReportStop'" to stop auto report.
var Handler_Get_Capability()
- Description: Main program calls "'Handler_AutoReportStop'" to get plugin's capability.
var Handler_Recv( strTopic, strMsg )
- Description: Main program calls "'Handler_Recv'" if receive a control message from others.
| Parameter | Description |
|---|---|
| strTopic | received mqtt topic |
| strMsg | received message |
AdvDataMgt
It is a librarie can help that makes it easy to compose a plugin's capability in Advantech sensor data JSON format.
Defined
g_strPluginName: Name of Plugin
- Sample Code: g_strPluginName = 'SNMP_Handler';
g_jPluginInfo: Basic informaion of this plugin, You can extend key: value
- Sample Code: g_jPluginInfo =
{
type:"Protocol",
name:g_strPluginName,
description:"This is a SNMP Manager service",
version:"v1.0.2",
};
Function
| Item | Function | Description |
| 1 | bool initialize ( strName, jInfo ) | To initialize the AdvDataMgt |
| 2 | bool addSensor( strPath, jsSensor, strKey ) |
Add a sensor data by path. |
| 3 | bool removeSensorbyPath( strPath ) |
Remove a sensor by path |
| 4 | bool removeSensorbyKey( strKey ) |
Remove a sensor by key |
| 5 | bool removeGroup( strPath ) | Remove a JSON Goup |
| 6 | var getCapability () |
Get capability. |
| 7 | bool updatebyPath( strPath, value ) |
Update value by path |
| 8 | bool updatebyKey( strKey, value ) |
Update value by key |
| 9 | var getSenseorbyPath( strPath ) |
Get sensor value by path |
| 10 | var getSenseorbyKey( strKey ) |
Get sensor value by key |
| 11 | var queryKeybyPath( strPath ) |
Query key by path |
| 12 | var getAllPath( outRet [ ] ) |
Get all of paths |
| 13 | var getAllKey( outRet [ ] ) |
Get all of keys |
| 14 | var getValuebyKey ( strKey ) | Get value only by key |
| 15 | var getAllLatestValues() | Get all latest sensor data values only |
| 16 | bool getUpdatedValues( outRet{}, strPath ) | Get latest update sensor data values, strPath = null (All), by JSON group |
| 17 | resetUpdatedValues( strPath ) | Reset latest update sensor data table, strPath: NULL ( All), by JSON Group |
int initialize ( strName, jInfo )
- Description: To initialize the AdvDataMgt
- Sample Code
g_jPluginInfo var dataMgt = new dataMgt(); dataMgt.initialize(g_strPluginName,g_jPluginInfo);
- Result
{
"SNMP_Handler": {
"info": {
"e": [{"n": "type","sv": "Protocol","asm": "r"},
{"n": "name","sv": "SNMP_Handler","asm": "r"},
{"n": "description","sv": "This is a SNMP Manager service","asm": "r"},
{"n": "version","sv": "v1.0.2","asm": "r"}],
"bn": "info"
}
}
}
int addSensor( strPath, jsSensor, strKey )
- Description: Add a sensor data by path.
- Sample Code
var prefix = g_strPluginName+'/';
// SenData
var strPath = prefix+'SenData';
dataMgt.addSensor(strPath,{"n":"Temperature","u":"Cel","v":26.5,"min":-100,"max":200,"asm":"r"});
dataMgt.addSensor(strPath,{"n":"Count","u":"","v":0, "asm":"rw"},g_strCountKey);
// Info
strPath = prefix + 'Info';
dataMgt.addSensor(strPath,{"n":"Name","sv":"SenHub","asm":"rw"});
dataMgt.addSensor(strPath,{"n":"sw","sv":"1.0.0","asm":"r"});
// Net
strPath = prefix + 'Net';
dataMgt.addSensor(strPath,{"n":"sw","sv":"3.0.1","asm":"r"});
dataMgt.addSensor(strPath,{"n":"Health","v":100.000000,"asm":"r"});
Result
{
"SNMP_Handler":
{ "SenData":{"e":[{"n":"Temperature","u":"Cel","v":26.5,"min":-100,"max":200,"asm":"r"},{"n":"Count","u":"","bv":false, "asm":"rw"}],"bn":"SenData"},
"Info":{"e":[{"n":"Name","sv":"SenHub","asm":"rw"},{"n":"sw","sv":"1.0.0","asm":"r"}],"bn":"Info"},
"Net":{"e":[{"n":"sw","sv":"3.0.1","asm":"r"},{"n":"Health","v":100.000000,"asm":"r"}],"bn":"Net"}
}
}
var r'emoveSensorbyPath''''( strPath )'
- Description: Remove a sensor by path
- Sample Code
var strPath = 'SNMP_Handler/SenData/Temperature';
dataMgt.removeSensorbyPath(strPath);
console.log('remove sensor by path = ' + strPath );
console.log('new capability ' + JSON.stringify(dataMgt.getCapability()));
- Result
remove sensor by path = SNMP_Handler/SenData/Temperature
new capability {"SNMP_Handler":{"info":{"bn":"info","e":[{"n":"type","sv":"Protocol","asm":"r"},{"n":"name","sv":"SNMP_Handler","asm":"r"},{"n":"description","sv":"This is a SNMP Manager service","asm":"r"},{"n":"version","sv":"v1.0.2","asm":"r"}]},"SenData":{"bn":"SenData","e":[{"n":"Count","u":"","v":0,"asm":"rw"}]},"Info":{"bn":"Info","e":[{"n":"Name","sv":"SenHub","asm":"rw"},{"n":"sw","sv":"1.0.0","asm":"r"}]},"Net":{"bn":"Net","e":[{"n":"sw","sv":"3.0.1","asm":"r"},{"n":"Health","v":100,"asm":"r"}]}}}
var removeSensorbyKey( strKey )
- Description: Remove a sensor by key
- Sample Code
var g_strCountKey= '172.22.12.49-1.3.6.1.4.1.10297.101.1.4.1.1.15';
dataMgt.removeSensorbyKey(g_strCountKey);
console.log('remove sensor by key = ' + g_strCountKey );
console.log('new capability ' + JSON.stringify(dataMgt.getCapability()));
- Result
remove sensor by key = 172.22.12.49-1.3.6.1.4.1.10297.101.1.4.1.1.15
new capability {"SNMP_Handler":{"info":{"bn":"info","e":[{"n":"type","sv":"Protocol","asm":"r"},{"n":"name","sv":"SNMP_Handler","asm":"r"},{"n":"description","sv":"This is a SNMP Manager service","asm":"r"},{"n":"version","sv":"v1.0.2","asm":"r"}]},"SenData":{"bn":"SenData","e":[{"n":"Temperature","u":"Cel","v":26.5,"min":-100,"max":200,"asm":"r"}]},"Info":{"bn":"Info","e":[{"n":"Name","sv":"SenHub","asm":"rw"},{"n":"sw","sv":"1.0.0","asm":"r"}]},"Net":{"bn":"Net","e":[{"n":"sw","sv":"3.0.1","asm":"r"},{"n":"Health","v":100,"asm":"r"}]}}}
var removeGroup( strPath )
- Description: Remove a JSON Group by path
- Sample Code
var strPath = 'SNMP_Handler/Net';
dataMgt.removeGroup(strPath);
console.log('remove JSON Group by path = ' + strPath );
console.log('new capability ' + JSON.stringify(dataMgt.getCapability()));
- Result
remove JSON Group by path = SNMP_Handler/Net
new capability {"SNMP_Handler":{"info":{"bn":"info","e":[{"n":"type","sv":"Protocol","asm":"r"},{"n":"name","sv":"SNMP_Handler","asm":"r"},{"n":"description","sv":"This is a SNMP Manager service","asm":"r"},{"n":"version","sv":"v1.0.2","asm":"r"}]},"SenData":{"bn":"SenData","e":[{"n":"Temperature","u":"Cel","v":26.5,"min":-100,"max":200,"asm":"r"},{"n":"Count","u":"","v":0,"asm":"rw"}]},"Info":{"bn":"Info","e":[{"n":"Name","sv":"SenHub","asm":"rw"},{"n":"sw","sv":"1.0.0","asm":"r"}]}}}
var getCapability ()
- Description: Get capability.
- Sample Code
g_sendreportcbf(g_strPluginName, dataMgt.getCapability());
int updatebyPath( strPath, value )
- Description: Update value by path
- Sample Code
var strPath = 'SNMP_Handler/SenData/Count'; var g_iCount = 300; dataMgt.updatebyPath( strPath, g_iCount );
int updatebyKey( strKey, value )
- Description: Update value by key
- Sample Code
var strPath = 'SNMP_Handler/SenData/Count'; var g_iCount = 500; dataMgt.updatebyKey( 172.22.12.49-1.3.6.1.4.1.10297.101.1.4.1.1.15, g_iCount );
var getSenseorbyPath( strPath )
- Description: Get value by path
- Sample Code
var strPath = 'SNMP_Handler/SenData/Temperature';
console.log('get value by path= ' + strPath);
console.log('ret= ' + JSON.stringify(dataMgt.getSenseorbyPath(strPath)));
- Result
get value by path= SNMP_Handler/SenData/Temperature
ret= {"n":"Temperature","u":"Cel","v":26.5,"min":-100,"max":200,"asm":"r"}
var getSensrobyKey( strKey )
- Description: Get value by key
- Sample
var g_strCountKey = '172.22.12.49-1.3.6.1.4.1.10297.101.1.4.1.1.15';
console.log('get value by key= ' + g_strCountKey);
console.log('ret= ' + JSON.stringify(dataMgt.getSenseorbyKey(g_strCountKey)));
- Result
get value by key= 172.22.12.49-1.3.6.1.4.1.10297.101.1.4.1.1.15
ret= {"n":"Count","u":"","v":0,"asm":"rw"}
var queryKeybyPath( strPath )
- Description: Query key by path
- Sample Code
strPath = 'SNMP_Handler/SenData/Count';
console.log('query key by path= ' + strPath + ' ret= ' + dataMgt.queryKeybyPath(strPath));
- Result
query key by path= SNMP_Handler/SenData/Count ret= 172.22.12.49-1.3.6.1.4.1.10297.101.1.4.1.1.15
var getAllKey( outRet [ ] )
- Description: Get all keys
- Sample Code
var ret = []; if ( dataMgt.getAllKey( ret ) === true ) console.log( 'Number of all key: ' + ret.length + ' result = ' + JSON.stringify( ret ));
- Reslut
Numberof all key: 1
result =
[{"key":"172.22.12.49-1.3.6.1.4.1.10297.101.1.4.1.1.15","path":"SNMP_Handler/SenData/Count"}]
var getAllPath( outRet [ ] )
- Description: Get all paths
- Sample Code
var ret = []; if( dataMgt.getAllPath( ret ) === true ) console.log( 'Number of all Path: ' + ret.length + ' result = ' + JSON.stringify( ret ));
- Result
Number of all Path: 6
result =
[{"path":"SNMP_Handler/SenData/Temperature"},{"path":"SNMP_Handler/SenData/Count","key":"172.22.12.49-1.3.6.1.4.1.10297.101.1.4.1.1.15"},{"path":"SNMP_Handler/Info/Name"},{"path":"SNMP_Handler/Info/sw"},{"path":"SNMP_Handler/Net/sw"},{"path":"SNMP_Handler/Net/Health"}]
Sample Code
Plugin
Sample Code: ./module/plugin_test.js
Template Code: ./module/plugin_temp.js
Plugin with AdvDataMgt
Sample Code: ./module/Simple-plugin_test.js
Template Code: ./module/Simple-plugin_temp.js
SNMP-NMS Project
Source Code
http://advgitlab.eastasia.cloudapp.azure.com/EdgeSense-Open/agentlite-node.js