Ad Widget

Collapse

Item Preprocessing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JamesPickup
    Junior Member
    • Sep 2024
    • 4

    #1

    Item Preprocessing

    I am making an API call to a Netflow collector using an HTTP agent Item in Zabbix, which returns JSON:

    {"volume":"179.288 GB","max":"444.324 Mbps","granularity":"10 Minute Average","startTime":"2024-11-22 10:00","endTime":"2024-11-22 11:00","devName":"10.133.14.5","devTraffic":[{"seriesname":"10.133.14.5","data":[[1732269600000,0.4335181612533333],[1732270200000,0.38681981957333333],[1732270800000,0.41928402750666666],[1732271400000,0.4443239848666667],[1732272000000,0.27023713624],[1732272600000,0.43630378266666664],[1732273200000,2.257808E-5]],"yaxiscolumnorder":[0]}],"avgSpeed":"398.418 Mbps","YAxis":"Gbps"}

    or

    {"volume":"525.727 GB","max":"1.510 Gbps","granularity":"10 Minute Average","startTime":"2024-11-22 10:00","endTime":"2024-11-22 11:00","devName":"10.133.14.4","devTraffic":[{"seriesname":"10.133.14.4","data":[[1732269600000,1.0055900881066666],[1732270200000,0.9072969555066667],[1732270800000,1.1287709371466668],[1732271400000,1.2801433879733333],[1732272000000,1.1733471851866666],[1732272600000,1.51046208856],[1732273200000,0.004088235546666667]],"yaxiscolumnorder":[0]}],"avgSpeed":"1.168 Gbps","YAxis":"Gbps"}

    I am only interested in the max speed, so I was running a JSON Path to extract the parameter $.max which works great, except that, as show above, some time its in Gbps and some times its in Mbps. Is there anything I can do in Preprocessing to covert this into a standard?

    For example if it is in Gbps convert it to Mbps?

    Many thanks in advance
    Last edited by JamesPickup; 22-11-2024, 13:21.
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    JS, which first looks, is there M or G and then multiplies stuff with correct number and returns the value.

    Comment


    • JamesPickup
      JamesPickup commented
      Editing a comment
      thanks you for responding but I dont understand what is "JS" or how to implement? Assume it is JavaScript.
      Last edited by JamesPickup; 22-11-2024, 14:24.
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #3
    yes... JavaScript

    Comment

    Working...