<% ' Extended Zabbix functions to get ALL supply items (toner, ink, drums, maintenance kits, etc.) %> <% ' Function to get ALL printer supply/maintenance levels (combines multiple tag queries) Function GetAllPrinterSupplies(hostIP) Dim jsonRequest, response ' First, find the host by IP jsonRequest = "{" & _ """jsonrpc"":""2.0""," & _ """method"":""host.get""," & _ """params"":{" & _ """output"":[""hostid""]," & _ """filter"":{" & _ """host"":[""" & hostIP & """]" & _ "}" & _ "}," & _ """id"":4" & _ "}" response = ZabbixAPICall(jsonRequest) ' Check if result array is empty If InStr(response, """result"":[]") > 0 Then GetAllPrinterSupplies = "{""error"":""Host not found in Zabbix"",""ip"":""" & hostIP & """}" Exit Function End If ' Extract hostid from result array Dim hostID, startPos, endPos startPos = InStr(response, """hostid"":""") If startPos > 0 Then startPos = startPos + 10 endPos = InStr(startPos, response, """") hostID = Mid(response, startPos, endPos - startPos) Else GetAllPrinterSupplies = "{""error"":""Could not extract hostid"",""response"":""" & Left(response, 200) & """}" Exit Function End If If hostID = "" Or IsNull(hostID) Then GetAllPrinterSupplies = "{""error"":""HostID is empty"",""hostid"":""" & hostID & """}" Exit Function End If ' Get ALL printer items including info items (status:0 = enabled, don't filter by monitored) Dim itemRequest itemRequest = "{" & _ """jsonrpc"":""2.0""," & _ """method"":""item.get""," & _ """params"":{" & _ """output"":[""itemid"",""name"",""lastvalue"",""lastclock"",""units"",""status"",""state""]," & _ """hostids"":[""" & hostID & """]," & _ """selectTags"":""extend""," & _ """sortfield"":""name""" & _ "}," & _ """id"":5" & _ "}" ' Make the item.get call Dim itemResponse itemResponse = ZabbixAPICall(itemRequest) ' Return the item response GetAllPrinterSupplies = itemResponse End Function %>