mbdraks / fortinet-zabbix

Zabbix Templates for Fortinet devices
93 stars 57 forks source link

Parsing fgHaStatsSyncDatimeUnsucc and fgHaStatsSyncDatimeSucc #48

Open enotspe opened 3 years ago

enotspe commented 3 years ago

Hi,

According to Fortinet MIB, those OIDs (fgHaStatsSyncDatimeUnsucc and fgHaStatsSyncDatimeSucc) should return DateAndTime octect string with the specified format. However, I can not manage to parse that data type.

Most of the times I get 00 00 01 01 00 00 00 00 or 07 E5 08 14 0A 1A 10 00

How can I convert it to human readable and meaningful format? It would be great to convert it to uptime or unixtime formats so we can create an alert for those OIDs.

Have you been able to parse them?? I am running 6.4.X by the way.

enotspe commented 3 years ago

I made this script, kinds of works.... just add it to preprocessing

`var splitData = value.split(" ");

year = parseInt(splitData[0]+splitData[1], 16); month = parseInt(splitData[2], 16); day = parseInt(splitData[3], 16); hour = parseInt(splitData[4], 16); minute = parseInt(splitData[5], 16); second = parseInt(splitData[6], 16); deci_sec = parseInt(splitData[7], 16);

date = year + '-' + month + '-' + day; time = hour + ':' + minute + ':' + second + '.' + deci_sec;

date_time = date + ' ' + time;

return date_time;`

mbdraks commented 3 years ago

@enotspe Looks good, I'll test and merge it once I can properly validate.

I believe there's some other fields that could benefit from this approach too, tks for the contribution!