Tools for printer discovery and monitoring: - snmp_scanner.py: SNMP-based printer discovery - generate_printer_templates.py: Generate Zabbix templates - analyze_supplies.py: Analyze printer supply levels - extract_summary.py: Extract printer data summaries Includes Zabbix templates for: - HP Color/Mono printers - HP DesignJet T1700 - Xerox Color/Mono/Enterprise printers 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
364 lines
18 KiB
JSON
364 lines
18 KiB
JSON
{
|
|
"zabbix_export": {
|
|
"version": "7.4",
|
|
"template_groups": [
|
|
{
|
|
"uuid": "3cd4e8d0b828464e8f4b3becf13a9dbd",
|
|
"name": "Printers"
|
|
}
|
|
],
|
|
"templates": [
|
|
{
|
|
"uuid": "737fbe29a53540109e13ebbf61ed6eec",
|
|
"template": "HP LaserJet - Monochrome",
|
|
"name": "HP LaserJet - Monochrome",
|
|
"description": "HP LaserJet printers (all models - mono)",
|
|
"groups": [
|
|
{
|
|
"name": "Printers"
|
|
}
|
|
],
|
|
"items": [
|
|
{
|
|
"uuid": "227f072b96694bff9c5d908652957c23",
|
|
"name": "Printer Model",
|
|
"type": "SNMP_AGENT",
|
|
"snmp_oid": "get[1.3.6.1.2.1.25.3.2.1.3.1]",
|
|
"key": "printer.model",
|
|
"delay": "1h",
|
|
"history": "90d",
|
|
"trends": "0d",
|
|
"value_type": "TEXT",
|
|
"description": "Printer Model",
|
|
"tags": [
|
|
{
|
|
"tag": "component",
|
|
"value": "printer"
|
|
},
|
|
{
|
|
"tag": "type",
|
|
"value": "info"
|
|
}
|
|
],
|
|
"preprocessing": [
|
|
{
|
|
"type": "JAVASCRIPT",
|
|
"parameters": [
|
|
"// Handle hex-encoded SNMP strings\n// Try multiple approaches to convert hex to ASCII\n\n// First, check if it looks like hex (with spaces, newlines, or other separators)\nvar hexPattern = /^[0-9A-Fa-f\\s]+$/;\nif (hexPattern.test(value) && value.length > 4) {\n // Extract all hex pairs (2 characters)\n var hexBytes = value.match(/[0-9A-Fa-f]{2}/g);\n if (hexBytes && hexBytes.length > 0) {\n var result = '';\n for (var i = 0; i < hexBytes.length; i++) {\n var code = parseInt(hexBytes[i], 16);\n // Only keep printable ASCII (0x20-0x7E)\n if (code >= 32 && code <= 126) {\n result += String.fromCharCode(code);\n }\n }\n if (result.length > 0) {\n return result;\n }\n }\n}\n\n// Fallback: Remove non-printable characters\nreturn value.replace(/[^\\x20-\\x7E]/g, '');"
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"uuid": "7e8af2ec750a4ca59fd36cb431ad406c",
|
|
"name": "Printer Hostname",
|
|
"type": "SNMP_AGENT",
|
|
"snmp_oid": "get[1.3.6.1.2.1.1.5.0]",
|
|
"key": "printer.hostname",
|
|
"delay": "1h",
|
|
"history": "90d",
|
|
"trends": "0d",
|
|
"value_type": "TEXT",
|
|
"description": "Printer Hostname",
|
|
"tags": [
|
|
{
|
|
"tag": "component",
|
|
"value": "printer"
|
|
},
|
|
{
|
|
"tag": "type",
|
|
"value": "info"
|
|
}
|
|
],
|
|
"preprocessing": [
|
|
{
|
|
"type": "JAVASCRIPT",
|
|
"parameters": [
|
|
"// Handle hex-encoded SNMP strings\n// Try multiple approaches to convert hex to ASCII\n\n// First, check if it looks like hex (with spaces, newlines, or other separators)\nvar hexPattern = /^[0-9A-Fa-f\\s]+$/;\nif (hexPattern.test(value) && value.length > 4) {\n // Extract all hex pairs (2 characters)\n var hexBytes = value.match(/[0-9A-Fa-f]{2}/g);\n if (hexBytes && hexBytes.length > 0) {\n var result = '';\n for (var i = 0; i < hexBytes.length; i++) {\n var code = parseInt(hexBytes[i], 16);\n // Only keep printable ASCII (0x20-0x7E)\n if (code >= 32 && code <= 126) {\n result += String.fromCharCode(code);\n }\n }\n if (result.length > 0) {\n return result;\n }\n }\n}\n\n// Fallback: Remove non-printable characters\nreturn value.replace(/[^\\x20-\\x7E]/g, '');"
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"uuid": "845eb41cb4c44404a30cf25b3dd27625",
|
|
"name": "Printer Serial Number",
|
|
"type": "SNMP_AGENT",
|
|
"snmp_oid": "get[1.3.6.1.2.1.43.5.1.1.17.1]",
|
|
"key": "printer.serial",
|
|
"delay": "1h",
|
|
"history": "90d",
|
|
"trends": "0d",
|
|
"value_type": "TEXT",
|
|
"description": "Printer Serial Number",
|
|
"tags": [
|
|
{
|
|
"tag": "component",
|
|
"value": "printer"
|
|
},
|
|
{
|
|
"tag": "type",
|
|
"value": "info"
|
|
}
|
|
],
|
|
"preprocessing": [
|
|
{
|
|
"type": "JAVASCRIPT",
|
|
"parameters": [
|
|
"// Handle hex-encoded SNMP strings\n// Try multiple approaches to convert hex to ASCII\n\n// First, check if it looks like hex (with spaces, newlines, or other separators)\nvar hexPattern = /^[0-9A-Fa-f\\s]+$/;\nif (hexPattern.test(value) && value.length > 4) {\n // Extract all hex pairs (2 characters)\n var hexBytes = value.match(/[0-9A-Fa-f]{2}/g);\n if (hexBytes && hexBytes.length > 0) {\n var result = '';\n for (var i = 0; i < hexBytes.length; i++) {\n var code = parseInt(hexBytes[i], 16);\n // Only keep printable ASCII (0x20-0x7E)\n if (code >= 32 && code <= 126) {\n result += String.fromCharCode(code);\n }\n }\n if (result.length > 0) {\n return result;\n }\n }\n}\n\n// Fallback: Remove non-printable characters\nreturn value.replace(/[^\\x20-\\x7E]/g, '');"
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"uuid": "9b6c3fe6dc57455ab27e0fc37dda9548",
|
|
"name": "System Location",
|
|
"type": "SNMP_AGENT",
|
|
"snmp_oid": "get[1.3.6.1.2.1.1.6.0]",
|
|
"key": "printer.location",
|
|
"delay": "1h",
|
|
"history": "90d",
|
|
"trends": "0d",
|
|
"value_type": "TEXT",
|
|
"description": "System Location",
|
|
"tags": [
|
|
{
|
|
"tag": "component",
|
|
"value": "printer"
|
|
},
|
|
{
|
|
"tag": "type",
|
|
"value": "info"
|
|
}
|
|
],
|
|
"preprocessing": [
|
|
{
|
|
"type": "JAVASCRIPT",
|
|
"parameters": [
|
|
"// Handle hex-encoded SNMP strings\n// Try multiple approaches to convert hex to ASCII\n\n// First, check if it looks like hex (with spaces, newlines, or other separators)\nvar hexPattern = /^[0-9A-Fa-f\\s]+$/;\nif (hexPattern.test(value) && value.length > 4) {\n // Extract all hex pairs (2 characters)\n var hexBytes = value.match(/[0-9A-Fa-f]{2}/g);\n if (hexBytes && hexBytes.length > 0) {\n var result = '';\n for (var i = 0; i < hexBytes.length; i++) {\n var code = parseInt(hexBytes[i], 16);\n // Only keep printable ASCII (0x20-0x7E)\n if (code >= 32 && code <= 126) {\n result += String.fromCharCode(code);\n }\n }\n if (result.length > 0) {\n return result;\n }\n }\n}\n\n// Fallback: Remove non-printable characters\nreturn value.replace(/[^\\x20-\\x7E]/g, '');"
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"uuid": "8048a1831e60432d92d68ed84b14337b",
|
|
"name": "Black Toner Part Number",
|
|
"type": "SNMP_AGENT",
|
|
"snmp_oid": "get[1.3.6.1.2.1.43.11.1.1.6.1.1]",
|
|
"key": "printer.cartridge.black",
|
|
"delay": "1h",
|
|
"history": "90d",
|
|
"trends": "0d",
|
|
"value_type": "TEXT",
|
|
"description": "Black Toner Part Number",
|
|
"tags": [
|
|
{
|
|
"tag": "component",
|
|
"value": "printer"
|
|
},
|
|
{
|
|
"tag": "type",
|
|
"value": "info"
|
|
}
|
|
],
|
|
"preprocessing": [
|
|
{
|
|
"type": "JAVASCRIPT",
|
|
"parameters": [
|
|
"// Clean up part number by removing serial numbers and firmware\n// Handles formats like:\n// \"Toner Cartridge;SNACC7952D80730000\" -> \"Toner Cartridge\"\n// \"Black Cartridge HP 58A (CF258A);FW:V4.23.3\" -> \"Black Cartridge HP 58A (CF258A)\"\n// \"Drum Cartridge, PN 101R00554;SN2600A90008100000\" -> \"Drum Cartridge, PN 101R00554\"\n\n// First, apply hex conversion if needed\nvar hexPattern = /^[0-9A-Fa-f\\s]+$/;\nif (hexPattern.test(value) && value.length > 4) {\n var hexBytes = value.match(/[0-9A-Fa-f]{2}/g);\n if (hexBytes && hexBytes.length > 0) {\n var result = '';\n for (var i = 0; i < hexBytes.length; i++) {\n var code = parseInt(hexBytes[i], 16);\n if (code >= 32 && code <= 126) {\n result += String.fromCharCode(code);\n }\n }\n if (result.length > 0) {\n value = result;\n }\n }\n}\n\n// Remove serial numbers (;SN followed by anything)\nvalue = value.replace(/;SN[^;]*/g, '');\n\n// Remove firmware info (;FW: or ;FW followed by anything)\nvalue = value.replace(/;FW[^;]*/g, '');\n\n// Remove any other semicolon-separated metadata\n// (but keep the main description before first semicolon)\nvar parts = value.split(';');\nvalue = parts[0];\n\n// Trim whitespace\nvalue = value.trim();\n\n// For Xerox printers reporting just \"Toner Cartridge\" without PN,\n// try to add known part numbers (must match model-specific logic)\n// This is handled by triggers showing compatibility notes instead\n\nreturn value;"
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"uuid": "e8a6e88325684ba7becb20cd7594e3ee",
|
|
"name": "Black Toner Current",
|
|
"type": "SNMP_AGENT",
|
|
"snmp_oid": "get[1.3.6.1.2.1.43.11.1.1.9.1.1]",
|
|
"key": "printer.toner.black.current",
|
|
"delay": "1h",
|
|
"history": "90d",
|
|
"trends": "365d",
|
|
"value_type": "FLOAT",
|
|
"description": "Black Toner Current",
|
|
"tags": [
|
|
{
|
|
"tag": "component",
|
|
"value": "printer"
|
|
},
|
|
{
|
|
"tag": "type",
|
|
"value": "raw"
|
|
}
|
|
],
|
|
"preprocessing": [
|
|
{
|
|
"type": "JAVASCRIPT",
|
|
"parameters": [
|
|
"// Handle SNMP unknown values (-3, -2, etc.)\n// Per RFC 3805: -1 = other, -2 = unknown, -3 = unknown\n// Convert to 0 to indicate empty/problem state\nvar numValue = parseInt(value);\nif (numValue < 0) {\n return '0';\n}\nreturn value;"
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"uuid": "fcb17eb74a054da9956f58b1fc6f1966",
|
|
"name": "Black Toner Max",
|
|
"type": "SNMP_AGENT",
|
|
"snmp_oid": "get[1.3.6.1.2.1.43.11.1.1.8.1.1]",
|
|
"key": "printer.toner.black.max",
|
|
"delay": "1h",
|
|
"history": "90d",
|
|
"trends": "365d",
|
|
"value_type": "FLOAT",
|
|
"description": "Black Toner Max",
|
|
"tags": [
|
|
{
|
|
"tag": "component",
|
|
"value": "printer"
|
|
},
|
|
{
|
|
"tag": "type",
|
|
"value": "raw"
|
|
}
|
|
],
|
|
"preprocessing": [
|
|
{
|
|
"type": "JAVASCRIPT",
|
|
"parameters": [
|
|
"// Handle SNMP unknown values (-3, -2, etc.)\n// Per RFC 3805: -1 = other, -2 = unknown, -3 = unknown\n// Convert to 0 to indicate empty/problem state\nvar numValue = parseInt(value);\nif (numValue < 0) {\n return '0';\n}\nreturn value;"
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"uuid": "fa8cdd36a1c145aba509a1fa1cb45fa6",
|
|
"name": "Black Toner Level",
|
|
"type": "CALCULATED",
|
|
"key": "printer.toner.black",
|
|
"delay": "1h",
|
|
"history": "90d",
|
|
"trends": "365d",
|
|
"value_type": "FLOAT",
|
|
"params": "round((last(//printer.toner.black.current)/last(//printer.toner.black.max))*100,0)",
|
|
"description": "Black Toner Level",
|
|
"tags": [
|
|
{
|
|
"tag": "component",
|
|
"value": "supplies"
|
|
},
|
|
{
|
|
"tag": "type",
|
|
"value": "level"
|
|
}
|
|
],
|
|
"units": "%",
|
|
"triggers": [
|
|
{
|
|
"uuid": "50d1ec3985124431b218e560976a7f74",
|
|
"expression": "last(/HP LaserJet - Monochrome/printer.toner.black)<20 and length(last(/HP LaserJet - Monochrome/printer.cartridge.black))>0",
|
|
"name": "Black Toner Level is low on {{HOST.NAME}}. Current level: {{ITEM.LASTVALUE}}. Replacement part: {{ITEM.LASTVALUE2}} (See compatibility notes for potential alternatives)",
|
|
"priority": "WARNING",
|
|
"tags": [
|
|
{
|
|
"tag": "scope",
|
|
"value": "availability"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"uuid": "8b3fd779d96242a283b4e624da3fd84c",
|
|
"expression": "last(/HP LaserJet - Monochrome/printer.toner.black)<10 and length(last(/HP LaserJet - Monochrome/printer.cartridge.black))>0",
|
|
"name": "Black Toner Level is low on {{HOST.NAME}}. Current level: {{ITEM.LASTVALUE}}. Replacement part: {{ITEM.LASTVALUE2}} (See compatibility notes for potential alternatives)",
|
|
"priority": "HIGH",
|
|
"tags": [
|
|
{
|
|
"tag": "scope",
|
|
"value": "availability"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"uuid": "2f42ce1f233c4d8cb5e3b1dedd4d7ddb",
|
|
"name": "Maintenance Kit Part Number",
|
|
"type": "SNMP_AGENT",
|
|
"snmp_oid": "get[1.3.6.1.4.1.11.2.3.9.4.2.1.1.3.3.0]",
|
|
"key": "printer.maintenance.model",
|
|
"delay": "1h",
|
|
"history": "90d",
|
|
"trends": "0d",
|
|
"value_type": "TEXT",
|
|
"description": "Maintenance Kit Part Number",
|
|
"tags": [
|
|
{
|
|
"tag": "component",
|
|
"value": "printer"
|
|
},
|
|
{
|
|
"tag": "type",
|
|
"value": "info"
|
|
}
|
|
],
|
|
"preprocessing": [
|
|
{
|
|
"type": "JAVASCRIPT",
|
|
"parameters": [
|
|
"// Clean up part number by removing serial numbers and firmware\n// Handles formats like:\n// \"Toner Cartridge;SNACC7952D80730000\" -> \"Toner Cartridge\"\n// \"Black Cartridge HP 58A (CF258A);FW:V4.23.3\" -> \"Black Cartridge HP 58A (CF258A)\"\n// \"Drum Cartridge, PN 101R00554;SN2600A90008100000\" -> \"Drum Cartridge, PN 101R00554\"\n\n// First, apply hex conversion if needed\nvar hexPattern = /^[0-9A-Fa-f\\s]+$/;\nif (hexPattern.test(value) && value.length > 4) {\n var hexBytes = value.match(/[0-9A-Fa-f]{2}/g);\n if (hexBytes && hexBytes.length > 0) {\n var result = '';\n for (var i = 0; i < hexBytes.length; i++) {\n var code = parseInt(hexBytes[i], 16);\n if (code >= 32 && code <= 126) {\n result += String.fromCharCode(code);\n }\n }\n if (result.length > 0) {\n value = result;\n }\n }\n}\n\n// Remove serial numbers (;SN followed by anything)\nvalue = value.replace(/;SN[^;]*/g, '');\n\n// Remove firmware info (;FW: or ;FW followed by anything)\nvalue = value.replace(/;FW[^;]*/g, '');\n\n// Remove any other semicolon-separated metadata\n// (but keep the main description before first semicolon)\nvar parts = value.split(';');\nvalue = parts[0];\n\n// Trim whitespace\nvalue = value.trim();\n\n// For Xerox printers reporting just \"Toner Cartridge\" without PN,\n// try to add known part numbers (must match model-specific logic)\n// This is handled by triggers showing compatibility notes instead\n\nreturn value;"
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"uuid": "6dd361f669354c1f8e4c7d8a06de531d",
|
|
"name": "Maintenance Kit Remaining",
|
|
"type": "SNMP_AGENT",
|
|
"snmp_oid": "get[1.3.6.1.4.1.11.2.3.9.4.2.1.4.1.2.0]",
|
|
"key": "printer.maintenance.remaining",
|
|
"delay": "1h",
|
|
"history": "90d",
|
|
"trends": "365d",
|
|
"value_type": "FLOAT",
|
|
"description": "Maintenance Kit Remaining",
|
|
"tags": [
|
|
{
|
|
"tag": "component",
|
|
"value": "printer"
|
|
},
|
|
{
|
|
"tag": "type",
|
|
"value": "raw"
|
|
}
|
|
],
|
|
"units": "pages",
|
|
"triggers": [
|
|
{
|
|
"uuid": "2f962a6eab824126b1270e464e265d97",
|
|
"expression": "last(/HP LaserJet - Monochrome/printer.maintenance.remaining)<10000 and length(last(/HP LaserJet - Monochrome/printer.maintenance.model))>0",
|
|
"name": "Maintenance Kit Remaining is low on {{HOST.NAME}}. Current level: {{ITEM.LASTVALUE}}. Replacement part: {{ITEM.LASTVALUE2}} (See compatibility notes for potential alternatives)",
|
|
"priority": "WARNING",
|
|
"tags": [
|
|
{
|
|
"tag": "scope",
|
|
"value": "availability"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"uuid": "67f1ab49058d4be89b40ba9eff8c027b",
|
|
"expression": "last(/HP LaserJet - Monochrome/printer.maintenance.remaining)<5000 and length(last(/HP LaserJet - Monochrome/printer.maintenance.model))>0",
|
|
"name": "Maintenance Kit Remaining is low on {{HOST.NAME}}. Current level: {{ITEM.LASTVALUE}}. Replacement part: {{ITEM.LASTVALUE2}} (See compatibility notes for potential alternatives)",
|
|
"priority": "HIGH",
|
|
"tags": [
|
|
{
|
|
"tag": "scope",
|
|
"value": "availability"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
} |