Skip to main content

Good afternoon,

I would like to know if there is any way to convert the data collected by SNMP from bit to Gb.

I'm trying to monitor a disk and it gives me the used and total space in bits.

With this operation I could do:
"%(hrStorageEntry.hrStorageUsed) * 100 / %(hrStorageEntry.hrStorageSize)"
but I don't know where to do it so that it is executed and saved in a variable, so that it can be printed later. I have tried the following tutorial:
 

But it doesn't work for me, since the "function" is for count the result. Is there any function that can do what I am saying (multiply or divide the collected metrics inside de JSON structure)? I guess it will have to be executed within the selection_loop, because I need to calculate it for each line returns.

Could you give me the list of functions that can be used? I can't find any information either on GitHub, or on TheWatch, or in the documentation about what functions I can use with snmp mode collection or about the json structure.

My Json configuration is:
 

{

    "snmp": {

        "tables": t

            {

                "name": "hrStorageEntry",

                "oid": "1.3.6.1.2.1.25.2.3.1",

                "used_instance": "\\.(\\d+)$",

                "entries": +

                    {"name": "hrStorageDescr", "oid": "1.3.6.1.2.1.25.2.3.1.3"},

                    {"name": "hrStorageSize", "oid": "1.3.6.1.2.1.25.2.3.1.5"},

                    {"name": "hrStorageUsed", "oid": "1.3.6.1.2.1.25.2.3.1.6"}

                ]

            }

        ]

 

    },

    "selection_loop": /

        {

            "name": "Discos",

            "source": "%(snmp.tables.hrStorageEntry)",

            "expand_table": {

                "hrStorageEntry": "%(snmp.tables.hrStorageEntry.e%(hrStorageEntry.instance)])"

            },

            "warning": "%(hrStorageEntry.hrStorageUsed) ge (0.1 * %(hrStorageEntry.hrStorageSize)",

            "critical": "%(hrStorageEntry.hrStorageUsed) ge (0.05 * %(hrStorageEntry.hrStorageSize)",

            "formatting": {

                "printf_msg": "Disk '%s' Used: '%s' Total:’%s’",

                "printf_var": i

                    "%(hrStorageEntry.hrStorageDescr)",

                    "%(hrStorageEntry.hrStorageUsed)",

                    "%(hrStorageEntry.hrStorageSize)"

                ],

                "display_ok": true

            }

        }

 

    ],

    "formatting":{

        "custom_message_global": "All Disks are OK",

        "separator": "-"

    }

}

Sorry I meant from bit to %


Reply