home *** CD-ROM | disk | FTP | other *** search
- <%
- '*********************************************************
- '
- ' Tektronix Windows 2000 Print Status ASP Page Project
- '
- ' Copyright (c) Tektronix, Inc. 1999
- '
- ' Description
- '
- ' Printer SNMP Interface Functions
- '
- ' History
- '
- ' Version 1.0 7/22/99 Greg Thornton
- ' Version 1.1 8/12/99 Greg Thornton
- ' Version 1.2 9/24/99 Greg Thornton, MS session variable bug
- '
- '*********************************************************
-
- '*********************************************************
- '
- ' SNMP Definitions
- '
- '*********************************************************
-
- Const SNMP_PROGID = "OlePrn.OleSNMP"
- Const SNMP_RETRY_COUNT = 3
- Const SNMP_TIMEOUT = 2000
-
- Const gpidGeneral = ".1.3.6.1.4.1.128.2.1.3.1"
- Const gpidGeneralProduct = ".1.3.6.1.4.1.128.2.1.3.1.2.0"
- Const gpidGeneralStatus = ".1.3.6.1.4.1.128.2.1.3.1.4.0"
- Const gpidGeneralPrinterBusy = ".1.3.6.1.4.1.128.2.1.3.1.5.0"
- Const gpidGeneralEngineFailure = ".1.3.6.1.4.1.128.2.1.3.1.6.0"
-
- Const prtAlert = ".1.3.6.1.2.1.43.18"
- Const prtAlertIndex = ".1.3.6.1.2.1.43.18.1.1.1."
- Const prtAlertSeverityLevel = ".1.3.6.1.2.1.43.18.1.1.2."
- Const prtAlertCode = ".1.3.6.1.2.1.43.18.1.1.7."
-
- Const gpidInput = ".1.3.6.1.4.1.128.2.1.3.2"
- Const gpidInputNumber = ".1.3.6.1.4.1.128.2.1.3.2.1.0"
- Const gpidInputTrayId = ".1.3.6.1.4.1.128.2.1.3.2.2.1.2."
- Const gpidInputTrayType = ".1.3.6.1.4.1.128.2.1.3.2.2.1.3."
- Const gpidInputMaxCapacity = ".1.3.6.1.4.1.128.2.1.3.2.2.1.5."
- Const gpidInputCurrentLevel = ".1.3.6.1.4.1.128.2.1.3.2.2.1.6."
- Const gpidInputStatus = ".1.3.6.1.4.1.128.2.1.3.2.2.1.7."
- Const gpidInputMediaType = ".1.3.6.1.4.1.128.2.1.3.2.2.1.8."
- Const gpidInputMediaSize = ".1.3.6.1.4.1.128.2.1.3.2.2.1.9."
-
- Const gpidMarker = ".1.3.6.1.4.1.128.2.1.3.4"
- Const gpidMarkerLifeCounts = ".1.3.6.1.4.1.128.2.1.3.4.4.0"
- Const gpidMarkerStatus = ".1.3.6.1.4.1.128.2.1.3.4.8.0"
- Const gpidMarkerSuppliesNumber = ".1.3.6.1.4.1.128.2.1.3.4.9.0"
- Const gpidMarkerSuppliesColorantId = ".1.3.6.1.4.1.128.2.1.3.4.10.1.2."
- Const gpidMarkerSuppliesType = ".1.3.6.1.4.1.128.2.1.3.4.10.1.4."
- Const gpidMarkerSuppliesMaxCapacity = ".1.3.6.1.4.1.128.2.1.3.4.10.1.6."
- Const gpidMarkerSuppliesCurrentLevel = ".1.3.6.1.4.1.128.2.1.3.4.10.1.7."
- Const gpidMarkerSuppliesMaxLifeCount = ".1.3.6.1.4.1.128.2.1.3.4.10.1.8."
- Const gpidMarkerSuppliesLifeCount = ".1.3.6.1.4.1.128.2.1.3.4.10.1.9."
- Const gpidMarkerSuppliesStatus = ".1.3.6.1.4.1.128.2.1.3.4.10.1.10."
- Const gpidMarkerSuppliesRemaining = ".1.3.6.1.4.1.128.2.1.3.4.10.1.11."
-
- Const sysContact = ".1.3.6.1.2.1.1.4.0"
- Const sysLocation = ".1.3.6.1.2.1.1.6.0"
-
-
- '*********************************************************
- '
- ' snmpXXXX Definitions
- '
- '*********************************************************
- const GENERAL_PRODUCT = 0
- const GENERAL_STATUS = 1
- const GENERAL_PRINTER_BUSY = 2
- const GENERAL_ENGINE_FAILURE = 3
-
- const INPUT_TRAY_ID = 0
- const INPUT_STATUS = 1
- const INPUT_MEDIA_TYPE = 2
- const INPUT_MEDIA_SIZE = 3
- const INPUT_MAX_CAPACITY = 4
- const INPUT_CURRENT_LEVEL = 5
- const INPUT_TRAY_TYPE = 6
-
- const MARKER_COLORANT = 0
- const MARKER_TYPE = 1
- const MARKER_MAX_CAPACITY = 2
- const MAKER_LEVEL = 3
- const MARKER_MAX_LIFE = 4
- const MARKER_LIFE = 5
- const MARKER_SUPPLY_STATUS = 6
- const MARKER_SUPPLY_REMAINING = 7
-
- const ALERT_LEVEL = 0
- const ALERT_CODE = 1
-
- Dim snmpGpidInput
- Dim snmpGpidMarkerStatus
- Dim snmpGpidMarkerLifeCounts
- Dim snmpGpidMarker
- Dim snmpPrtAlert
- Dim snmpGpidGeneral
- Dim snmpSysContact
- Dim snmpSysLocation
-
- '*********************************************************
- '
- ' Explicit SNMP object values
- '
- '*********************************************************
- Const SNMP_GPID_INPUT_STATUS_LOW = 5
- Const SNMP_GPID_INPUT_MEDIA_SIZE_OTHER = 1
- Const SNMP_GPID_INPUT_MEDIA_SIZE_UNKNOWN = 2
- Const SNMP_GPID_INPUT_MEDIA_TYPE_OTHER = 1
- Const SNMP_GPID_INPUT_MEDIA_TYPE_UNKNOWN = 2
- Const SNMP_GPID_INPUT_TRAY_TYPE_REMOVEABLE = 3
- Const SNMP_GPID_MARKER_SUPPLIES_TYPE_OTHER = 1
- Const SNMP_GPID_MARKER_SUPPLIES_COLORANTID_C = 4
- Const SNMP_GPID_MARKER_SUPPLIES_COLORANTID_M = 5
- Const SNMP_GPID_MARKER_SUPPLIES_COLORANTID_Y = 6
- Const SNMP_GPID_MARKER_SUPPLIES_COLORANTID_K = 7
- Const cyanMarker = 4
- Const magentaMarker = 5
- Const yellowMarker = 6
- Const blackMarker = 7
- Const tonerDischarge = 12
- Const paperFeedUnit = 17
- Const tensionUnit = 18
- Const wasteToner = 4
- Const toner = 3
- Const wasteInk = 8
- Const wax_solid = 12
- Const wasteWax = 14
- Const feeder = 16
- Const tensioner = 17
-
- ' gpidGeneralStatus enumerations
-
- Const other = 1
- Const unknown = 2
- Const ready = 3
- Const critical = 4
- Const non_critical = 5
- Const critical_and_non_critical = 6
- Const onRequest = 7
- Const unavailable = 8
- Const busy = 9
- Const waiting = 10
-
- Const prtAlertSeverityLevelOther = 1
- Const prtAlertSeverityLevelCritical = 3
- Const prtAlertSeverityLevelWarning = 4
-
- Const gpidGeneralPrinterBusyReady = 2
- Const gpidGeneralPrinterBusyPrinting = 3
- Const gpidGeneralPrinterBusyReceivingData = 4
-
-
- ' Printer Model Enumerations
-
- Const M_340 = 1
- Const M_350 = 2
- Const M_360 = 3
- Const M_380 = 4
- Const M_450 = 5
- Const M_480 = 6
- Const M_540 = 7
- Const M_550 = 8
- Const M_560 = 9
- Const M_600 = 10
- Const M_740 = 11
- Const M_780 = 12
- Const M_840 = 13
- Const M_UNKNOWN = 14
-
-
- Function GetModel(snmpModel)
- If NOT Instr(snmpModel,"740") = O Then
- GetModel = M_740
- ElseIf NOT Instr(snmpModel,"840") = O Then
- GetModel = M_840
- ElseIf NOT Instr(snmpModel,"780") = O Then
- GetModel = M_780
- ElseIf NOT Instr(snmpModel,"340") = O Then
- GetModel = M_340
- ElseIf NOT Instr(snmpModel,"350") = O Then
- GetModel = M_350
- ElseIf NOT Instr(snmpModel,"360") = O Then
- GetModel = M_360
- ElseIf NOT Instr(snmpModel,"540") = O Then
- GetModel = M_540
- ElseIf NOT Instr(snmpModel,"550") = O Then
- GetModel = M_550
- ElseIf NOT Instr(snmpModel,"560") = O Then
- GetModel = M_560
- ElseIf NOT Instr(snmpModel,"380") = O Then
- GetModel = M_380
- ElseIf NOT Instr(snmpModel,"450") = O Then
- GetModel = M_450
- ElseIf NOT Instr(snmpModel,"480") = O Then
- GetModel = M_480
- ElseIf NOT Instr(snmpModel,"600") = O Then
- GetModel = M_600
- Else
- GetModel = M_UNKNOWN
- End If
- End Function
-
- Function FilterGpidMarker(model,m_colorant,m_type)
- Dim Filter
-
- Filter = FALSE
-
- Select Case m_type
- Case wasteToner, wasteInk, wasteWax, unknown, feeder, tensioner
- ' Only report true consumables
- Filter = TRUE
- Case Else
- Select Case model
- Case M_740, M_560, M_550, M_540
- If m_type = other Then
- Select Case m_colorant
- Case tonerDischarge, paperFeedUnit, tensionUnit
- Filter = TRUE
- End Select
- End If
- End Select
- End Select
- FilterGpidMarker = Filter
- End Function
-
- '*********************************************************
- ' Name: GetSNMPStatus
- '
- ' Description:
- ' This function gets raw SNMP printer status and
- ' stores this status in the global snmpXXXX variables.
- ' If the printer model specified by snmpGpidGeneral
- ' is M_UNKNOWN, this function will return with only
- ' the snmpGpidGeneral variable initialized.
- ' Inputs:
- ' None.
- ' Outputs:
- ' snmpXXXX variables initiated with printer status.
- ' Serveral of the variables are arrays. Use Ubound function
- ' to determine array size.
- ' Returns:
- ' Model value.
- '*********************************************************
-
-
- Function GetSNMPStatus()
-
- Dim objSNMP, snmpQuery, snmpResponse, i, strIndex
- Dim strIP, strCommunity, strDevice, model
-
- strIP = request("MS_IPaddress")
- strCommunity = request("MS_Community")
- strDevice = cStr(request("MS_Device"))
-
- Set objSNMP = Server.CreateObject(SNMP_PROGID)
-
- objSNMP.open strIP, strCommunity, SNMP_RETRY_COUNT, SNMP_TIMEOUT
-
- '******************************************************
- 'Get gpidGeneral
- '******************************************************
- snmpQuery = Array(gpidGeneralProduct, gpidGeneralStatus, gpidGeneralPrinterBusy, gpidGeneralEngineFailure)
- snmpGpidGeneral = objSNMP.GetList(snmpQuery)
- model = GetModel(snmpGpidGeneral(GENERAL_PRODUCT))
- GetSNMPStatus = model
-
- If model = M_UNKNOWN Then
- Exit Function
- End If
-
- '******************************************************
- 'Get prtAlert
- '******************************************************
-
- Select Case model
- '******************************************************
- 'GetTree returns an array of dimension 2 x N. The
- 'first dimension selects between the SNMP object id
- '(with index value 0) and the SNMP object value (with
- 'index value 1). The second dimension defines the number
- 'of SNMP object id / value pairs returned.
- '******************************************************
-
- Case M_360, M_740, M_780, M_840
- snmpResponse = objSNMP.GetTree(prtAlertIndex & strDevice)
- If UBound(snmpResponse, 2) >= 0 Then
- ReDim snmpPrtAlert(1, UBound(snmpResponse, 2))
- For i = 0 To UBound(snmpResponse, 2)
- strIndex = "." & cStr(i+1)
- snmpPrtAlert(ALERT_LEVEL, i) = objSNMP.Get(prtAlertSeverityLevel & strDevice & strIndex)
- snmpPrtAlert(ALERT_CODE, i) = objSNMP.Get(prtAlertCode & strDevice & strIndex)
- Next
- End If
-
- Case Else
- '******************************************************
- 'A bug in older printer model prtAlert reporting requires
- 'different method for reading prtAlert. This method could be
- 'used for all printers. Since the above method has been
- 'tested already I will apply this only to the older
- 'printer models (call it superstition).
- '******************************************************
- snmpResponse1 = objSNMP.GetTree(prtAlertSeverityLevel & strDevice)
- snmpResponse2 = objSNMP.GetTree(prtAlertCode & strDevice)
- If UBound(snmpResponse1, 2) >= 0 Then
-
- If UBound(snmpResponse1, 2) <= UBound(snmpResponse2, 2) Then
- j = UBound(snmpResponse1, 2)
- Else
- j = UBound(snmpResponse2, 2)
- End If
-
- ReDim snmpPrtAlert(1,j)
- For i = 0 To j
- snmpPrtAlert(ALERT_LEVEL, i) = snmpResponse1(1,i)
- snmpPrtAlert(ALERT_CODE, i) = snmpResponse2(1,i)
- Next
- End If
-
- End Select
-
- '******************************************************
- 'Get gpidInput
- '******************************************************
- snmpResponse = objSNMP.Get(gpidInputNumber)
- If snmpResponse > 0 Then
- ReDim snmpGpidInput(6, snmpResponse - 1)
- For i = 0 To snmpResponse - 1
- strIndex = cStr(i+1)
- snmpGpidInput(INPUT_TRAY_ID, i) = objSNMP.Get(gpidInputTrayId & strIndex)
- snmpGpidInput(INPUT_STATUS, i) = objSNMP.Get(gpidInputStatus & strIndex)
- snmpGpidInput(INPUT_MEDIA_TYPE, i) = objSNMP.Get(gpidInputMediaType & strIndex)
- snmpGpidInput(INPUT_MEDIA_SIZE, i) = objSNMP.Get(gpidInputMediaSize & strIndex)
- snmpGpidInput(INPUT_MAX_CAPACITY, i) = objSNMP.Get(gpidInputMaxCapacity & strIndex)
- snmpGpidInput(INPUT_CURRENT_LEVEL, i) = objSNMP.Get(gpidInputCurrentLevel & strIndex)
- snmpGpidInput(INPUT_TRAY_TYPE, i) = objSNMP.Get(gpidInputTrayType & strIndex)
- Next
- End If
-
- '******************************************************
- 'Get gpidMarker filtering any unwanted marker devices
- '******************************************************
- snmpGpidMarkerStatus = objSNMP.Get(gpidMarkerStatus)
- snmpGpidMarkerLifeCounts = objSNMP.Get(gpidMarkerLifeCounts)
- snmpResponse = objSNMP.Get(gpidMarkerSuppliesNumber)
- Select Case model
- Case M_740, M_780
- supply_parms = 7
- Case Else
- supply_parms = 6
- End Select
- If snmpResponse > 0 Then
- ReDim snmpGpidMarker(supply_parms, snmpResponse - 1)
- j = 0
- For i = 0 To snmpResponse - 1
- strIndex = cStr(i+1)
- m_colorant = objSNMP.Get(gpidMarkerSuppliesColorantId & strIndex)
- m_type = objSNMP.Get(gpidMarkerSuppliesType & strIndex)
- If NOT FilterGpidMarker(model,m_colorant,m_type) Then
- snmpGpidMarker(MARKER_COLORANT, j) = m_colorant
- snmpGpidMarker(MARKER_TYPE, j) = m_type
- snmpGpidMarker(MARKER_MAX_CAPACITY, j) = objSNMP.Get(gpidMarkerSuppliesMaxCapacity & strIndex)
- snmpGpidMarker(MAKER_LEVEL, j) = objSNMP.Get(gpidMarkerSuppliesCurrentLevel & strIndex)
- snmpGpidMarker(MARKER_MAX_LIFE, j) = objSNMP.Get(gpidMarkerSuppliesMaxLifeCount & strIndex)
- snmpGpidMarker(MARKER_LIFE, j) = objSNMP.Get(gpidMarkerSuppliesLifeCount & strIndex)
- snmpGpidMarker(MARKER_SUPPLY_STATUS, j) = objSNMP.Get(gpidMarkerSuppliesStatus & strIndex)
- If supply_parms = 7 Then
- snmpGpidMarker(MARKER_SUPPLY_REMAINING, j) = objSNMP.Get(gpidMarkerSuppliesRemaining & strIndex)
- End If
- j = j + 1
- End If
- Next
- ReDim Preserve snmpGpidMarker(supply_parms,j-1)
- End If
-
- '******************************************************
- 'Get sys
- '******************************************************
- snmpSysContact = objSNMP.Get(sysContact)
- snmpSysLocation = objSNMP.Get(sysLocation)
-
- objSNMP.close
-
- End Function
-
- Function DumpStatus( label, status, dimensions )
-
- Dim strHTML, i, j
-
- If IsArray( status ) = False Then Exit Function
-
- If dimensions = 1 Then
- strHTML = label & "(" & cStr( UBound( status, 1 )) & ")<br>"
- For i = 0 To UBound(status, 1)
- strHTML = strHTML & " " & cStr(status(i)) & "<br>"
- Next
- ElseIf dimensions = 2 Then
- strHTML = label & "(" & cStr(UBound(status, 1)) & "," & cStr(UBound(status, 2)) & ")<br>"
- For i = 0 To UBound(status, 2)
- For j = 0 To UBound(status, 1)
- strHTML = strHTML & cStr(status(j, i)) & " "
- Next
- strHTML = strHTML & "<br>"
- Next
- End If
-
- DumpStatus = strHTML
-
- End Function
-
- Function DumpSNMPStatus()
-
- Dim strHTML, i, j
-
- strHTML = DumpStatus( "snmpGpidGeneral", snmpGpidGeneral, 1 )
- strHTML = strHTML & DumpStatus( "snmpGpidInput", snmpGpidInput, 2 )
- strHTML = strHTML & DumpStatus( "snmpGpidMarker", snmpGpidMarker, 2 )
- strHTML = strHTML & DumpStatus( "snmpPrtAlert", snmpPrtAlert, 2 )
-
- DumpSNMPStatus = strHTML
-
- End Function
-
- %>
-
-
-
-