parse mibs file report undefined error
Zddu opened this issue · 3 comments
hello,
When I parse the mibs file, I get the following error:
TypeError: Cannot read property 'MACRO' of undefined
at Object.Compile (\net-snmp\lib\mib.js:375:70)
Does MACRO do anything?
How can I fix this error?
thanks!
Hi @Zddu - can you please include the MIB file that you are parsing when you get this error?
Thank you for your reply!
This error seems to have disappeared, probably because I corrected the order of importing MIBs files. The reason for this error is that I want to import more than 100 MIBs files. The code is as follows:
export const parserFile = (mibName: string) => {
const store = snmp.createModuleStore();
const load = async (path: string) => {
fileNameArr.forEach(filename => {
const filePath = path + /${filename}
;
const stat = fs.lstatSync(filePath);
if (stat.isFile) {
try {
console.log('loading...', filename);
store.loadFromFile(filePath);
} catch (error) {
console.log(filename);
console.log(error);
}
}
});
};
load('src/monitor/mibs');
return store.getModule(mibName);
};
Filenamearr is an array of file names. I arrange the MIBs files in the order of import. The reason why I load so many MIBs files is that I want to write MySQL according to objectname, oid, description and other fields. In this way, I can translate oid through objectname and objectname through oid
Yes, ordering the loading of the MIB files according to dependencies is essential. Good to know that you've resolved the issue! :-)