【发布时间】:2020-08-14 10:07:55
【问题描述】:
我正在尝试在 Zabbix 中配置一个项目来预处理收集的一些数据,我需要编写一段 Javascript 代码来循环通过 API CALL 收集的 Zabbix 吐出的结果并计算字数在转储文件中找到“ERROR”和“WAITING”(只有大写字母)。
下面是要循环的文件的sn-p:
{"body":[{"entity":{"entityType":"xxx.xxx","id":"JA0483_APSDD285_log-sp2340L-dol-ss",
"name":"log-sp2340L-dol-ss","description":"","modifiedTime":1587753102338,"creationTime":1587769148481,
"displayName":"Log:_Dolomite","version":"1.0.0.669","drillHoleID":"APSDD285","type":"USRLOG",
"mode":"MOSAIC","layout":"STACKEDSECTION","categoryIds":["minerallogs"],"fileFormat":"CSV",
"compressionLevel":"NONE","pixelSize":0.0,"storeSize":7676,"generatedDate":1587753102338,
"depthFrom":0.0,"depthTo":0.0,"dataLength":0.0,"storePath":"ProcessedProducts/",
"entityType":"XXX.XXX"},"size":7676,"progress":3882,"status":"ERROR","message":"Server error response code 409:
Key JA0483_APSDD285_log-sp2340L-dol-ss already exists in the store. Use update instead","order":0,
"dateAdded":1587769395658,"dateTransferred":1587769443174,"nextRetryDate":1587769443166,"numRetries":1},
{"entity":{"entityType":"XXX.XXX","id":"JA0483_APSDD234_log-sp2350L-chl-fe-10cm","name":"log-sp2350L-chl-fe-10cm",
"description":"","modifiedTime":1587767851726,"creationTime":1587785977841,"displayName":"__Log: Fe-chlorite (2350nm)",
"version":"1.0.0.673","drillHoleID":"APSDD234","type":"USRLOG","mode":"MOSAIC","layout":"DOWNHOLE",
"categoryIds":["minerallogs"],"fileFormat":"CSV","compressionLevel":"NONE","pixelSize":0.0,"storeSize":39078,
"generatedDate":1587767851726,"depthFrom":0.0,"depthTo":0.0,"dataLength":0.0,"storePath":"ProcessedProducts/JA0483",
"entityType":"XXX.XXX"},"size":39078,"progress":3983,"status":"ERROR","message":"Server error response code 409:
Key JA0483_APSDD234_log-sp2350L-chl-fe-10cm already exists in the store. Use update instead"
代码的想法只是计算 ERRORs 和 WAITINGs 的发现。例如 ERROR = 30,WAITING = 20 等。
这可能吗?我根本没有使用 JavaScript 的经验,但我对 Python 和 Bash 有很好的了解,但 Zabbix 不知道这些语言来对给定项目进行预处理。所以我希望能得到社区的一些帮助。
【问题讨论】:
标签: javascript zabbix