Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

PrinterAlert.py

By: OrangutanClyde on Feb 5th, 2013  |  syntax: Python  |  size: 7.91 KB  |  views: 193  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. from pysnmp.entity.rfc3413.oneliner import cmdgen
  2.  
  3. cmdGen = cmdgen.CommandGenerator()
  4. #9201 Cartridge Free ColorQube Black Ink
  5. errorIndication, errorStatus, errorIndex, var9201K = cmdGen.getCmd(
  6.                 cmdgen.CommunityData('public'),
  7.                 cmdgen.UdpTransportTarget(('10.187.48.131', 161)),
  8.                 '.1.3.6.1.2.1.43.11.1.1.9.1.1'
  9. )
  10. #9201 Cartridge Free ColorQube Cyan Ink
  11. errorIndication, errorStatus, errorIndex, var9201C = cmdGen.getCmd(
  12.                 cmdgen.CommunityData('public'),
  13.                 cmdgen.UdpTransportTarget(('10.187.48.131', 161)),
  14.                 '.1.3.6.1.2.1.43.11.1.1.9.1.2'
  15. )
  16. #9201 Cartridge Free ColorQube Magenta Ink
  17. errorIndication, errorStatus, errorIndex, var9201M = cmdGen.getCmd(
  18.                 cmdgen.CommunityData('public'),
  19.                 cmdgen.UdpTransportTarget(('10.187.48.131', 161)),
  20.                 '.1.3.6.1.2.1.43.11.1.1.9.1.3'
  21. )
  22. #9201 Cartridge Free ColorQube Yellow Ink
  23. errorIndication, errorStatus, errorIndex, var9201Y = cmdGen.getCmd(
  24.                 cmdgen.CommunityData('public'),
  25.                 cmdgen.UdpTransportTarget(('10.187.48.131', 161)),
  26.                 '.1.3.6.1.2.1.43.11.1.1.9.1.4'
  27. )
  28.  
  29. #7242 Black Toner
  30. errorIndication, errorStatus, errorIndex, var7242K = cmdGen.getCmd(
  31.     cmdgen.CommunityData('public'),
  32.     cmdgen.UdpTransportTarget(('10.187.48.128', 161)),
  33.     '.1.3.6.1.2.1.43.11.1.1.9.1.1'
  34. )
  35. #7242 Cyan Toner
  36. errorIndication, errorStatus, errorIndex, var7242C = cmdGen.getCmd(
  37.     cmdgen.CommunityData('public'),
  38.     cmdgen.UdpTransportTarget(('10.187.48.128', 161)),
  39.     '.1.3.6.1.2.1.43.11.1.1.9.1.4'
  40. )
  41. #7242 Magenta Toner
  42. errorIndication, errorStatus, errorIndex, var7242M = cmdGen.getCmd(
  43.     cmdgen.CommunityData('public'),
  44.     cmdgen.UdpTransportTarget(('10.187.48.128', 161)),
  45.     '.1.3.6.1.2.1.43.11.1.1.9.1.3'
  46. )
  47. #7242 Yellow Toner
  48. errorIndication, errorStatus, errorIndex, var7242Y = cmdGen.getCmd(
  49.     cmdgen.CommunityData('public'),
  50.     cmdgen.UdpTransportTarget(('10.187.48.128', 161)),
  51.     '.1.3.6.1.2.1.43.11.1.1.9.1.2'
  52. )
  53. val7242Kcap = int(4030)
  54. val7242CMYcap = int(1370)
  55.  
  56. #M24 Black Toner
  57. errorIndication, errorStatus, errorIndex, varM24K = cmdGen.getCmd(
  58.     cmdgen.CommunityData('public'),
  59.     cmdgen.UdpTransportTarget(('10.187.48.130', 161)),
  60.     '.1.3.6.1.2.1.43.11.1.1.9.1.1'
  61. )
  62. #M24 Cyan Toner
  63. errorIndication, errorStatus, errorIndex, varM24C = cmdGen.getCmd(
  64.     cmdgen.CommunityData('public'),
  65.     cmdgen.UdpTransportTarget(('10.187.48.130', 161)),
  66.     '.1.3.6.1.2.1.43.11.1.1.9.1.4'
  67. )
  68. #M24 Magenta Toner
  69. errorIndication, errorStatus, errorIndex, varM24M = cmdGen.getCmd(
  70.     cmdgen.CommunityData('public'),
  71.     cmdgen.UdpTransportTarget(('10.187.48.130', 161)),
  72.     '.1.3.6.1.2.1.43.11.1.1.9.1.3'
  73. )
  74. #M24 Yellow Toner
  75. errorIndication, errorStatus, errorIndex, varM24Y = cmdGen.getCmd(
  76.     cmdgen.CommunityData('public'),
  77.     cmdgen.UdpTransportTarget(('10.187.48.130', 161)),
  78.     '.1.3.6.1.2.1.43.11.1.1.9.1.2'
  79. )
  80. valM24Kcap = int(26000)
  81. valM24CYcap = int(16000)
  82. valM24Mcap = int(15000)
  83.  
  84. #8700X Cartridge Free ColorQube Black Ink
  85. errorIndication, errorStatus, errorIndex, var8700XK = cmdGen.getCmd(
  86.                 cmdgen.CommunityData('public'),
  87.                 cmdgen.UdpTransportTarget(('10.187.48.132', 161)),
  88.                 '.1.3.6.1.2.1.43.11.1.1.9.1.1'
  89. )
  90. #8700X Cartridge Free ColorQube Cyan Ink
  91. errorIndication, errorStatus, errorIndex, var8700XC = cmdGen.getCmd(
  92.                 cmdgen.CommunityData('public'),
  93.                 cmdgen.UdpTransportTarget(('10.187.48.132', 161)),
  94.                 '.1.3.6.1.2.1.43.11.1.1.9.1.2'
  95. )
  96. #8700X Cartridge Free ColorQube Magenta Ink
  97. errorIndication, errorStatus, errorIndex, var8700XM = cmdGen.getCmd(
  98.                 cmdgen.CommunityData('public'),
  99.                 cmdgen.UdpTransportTarget(('10.187.48.132', 161)),
  100.                 '.1.3.6.1.2.1.43.11.1.1.9.1.3'
  101. )
  102. #8700X Cartridge Free ColorQube Yellow Ink
  103. errorIndication, errorStatus, errorIndex, var8700XY = cmdGen.getCmd(
  104.                 cmdgen.CommunityData('public'),
  105.                 cmdgen.UdpTransportTarget(('10.187.48.132', 161)),
  106.                 '.1.3.6.1.2.1.43.11.1.1.9.1.4'
  107. )
  108.  
  109. #C35 Black Toner
  110. errorIndication, errorStatus, errorIndex, varC35K = cmdGen.getCmd(
  111.     cmdgen.CommunityData('public'),
  112.     cmdgen.UdpTransportTarget(('10.187.48.133', 161)),
  113.     '.1.3.6.1.2.1.43.11.1.1.9.1.4'
  114. )
  115. #C35 Cyan Toner
  116. errorIndication, errorStatus, errorIndex, varC35C = cmdGen.getCmd(
  117.     cmdgen.CommunityData('public'),
  118.     cmdgen.UdpTransportTarget(('10.187.48.133', 161)),
  119.     '.1.3.6.1.2.1.43.11.1.1.9.1.1'
  120. )
  121. #C35 Magenta Toner
  122. errorIndication, errorStatus, errorIndex, varC35M = cmdGen.getCmd(
  123.     cmdgen.CommunityData('public'),
  124.     cmdgen.UdpTransportTarget(('10.187.48.133', 161)),
  125.     '.1.3.6.1.2.1.43.11.1.1.9.1.2'
  126. )
  127. #C35 Yellow Toner
  128. errorIndication, errorStatus, errorIndex, varC35Y = cmdGen.getCmd(
  129.     cmdgen.CommunityData('public'),
  130.     cmdgen.UdpTransportTarget(('10.187.48.133', 161)),
  131.     '.1.3.6.1.2.1.43.11.1.1.9.1.3'
  132. )
  133. valC35Kcap = int(6000)
  134. valC35CMYcap = int(6000)
  135.  
  136. colours = ["Cyan", "Magenta", "Yellow", "Black"]
  137. warnHalf = 50
  138. warnQuart = 25
  139. warnLow = 10
  140. var9201Cvalue = var9201C[0][1]
  141. var9201Mvalue = var9201M[0][1]
  142. var9201Yvalue = var9201Y[0][1]
  143. var9201Kvalue = var9201K[0][1]
  144. var7242Cvalue = int(var7242C[0][1]) / val7242CMYcap * 100
  145. var7242Mvalue = int(var7242M[0][1]) / val7242CMYcap * 100
  146. var7242Yvalue = int(var7242Y[0][1]) / val7242CMYcap * 100
  147. var7242Kvalue = int(var7242K[0][1]) / val7242Kcap * 100
  148. varM24Cvalue = int(varM24C[0][1]) / valM24CYcap * 100
  149. varM24Mvalue = int(varM24M[0][1]) / valM24Mcap * 100
  150. varM24Yvalue = int(varM24Y[0][1]) / valM24CYcap * 100
  151. varM24Kvalue = int(varM24K[0][1]) / valM24Kcap * 100
  152. var8700XCvalue = var8700XC[0][1]
  153. var8700XMvalue = var8700XM[0][1]
  154. var8700XYvalue = var8700XY[0][1]
  155. var8700XKvalue = var8700XK[0][1]
  156. varC35Cvalue = int(varC35C[0][1]) / valC35CMYcap * 100
  157. varC35Mvalue = int(varC35M[0][1]) / valC35CMYcap * 100
  158. varC35Yvalue = int(varC35Y[0][1]) / valC35CMYcap * 100
  159. varC35Kvalue = int(varC35K[0][1]) / valC35Kcap * 100
  160. x9201list = [var9201Cvalue, var9201Mvalue, var9201Yvalue, var9201Kvalue]
  161. x7242list = [var7242Cvalue, var7242Mvalue, var7242Yvalue, var7242Kvalue]
  162. xM24list = [varM24Cvalue, varM24Mvalue, varM24Yvalue, varM24Kvalue]
  163. x8700Xlist = [var8700XCvalue, var8700XMvalue, var8700XYvalue, var8700XKvalue]
  164. C35list = [varC35Cvalue, varC35Mvalue, varC35Yvalue, varC35Kvalue]
  165.  
  166. print("Xerox ColorQube 9201")
  167. for index, value in enumerate(x9201list):
  168.         if value < warnLow:
  169.                 print('%s %s' % (colours[index], "is low - Check your stock!"))
  170.         elif value < warnQuart:
  171.                 print('%s %s' % (colours[index], "is below 25%"))
  172.         elif value < warnHalf:
  173.                 print('%s %s' % (colours[index], "is below 50%"))
  174.         else:
  175.                 print('%s %s' % (colours[index], "is OK!"))
  176.  
  177. print("\nXerox WorkCentre 7242")
  178. for index, value in enumerate(x7242list):
  179.         if value < warnLow:
  180.                 print('%s %s' % (colours[index], "is low - Check your stock!"))
  181.         elif value < warnQuart:
  182.                 print('%s %s' % (colours[index], "is below 25%"))
  183.         elif value < warnHalf:
  184.                 print('%s %s' % (colours[index], "is below 50%"))
  185.         else:
  186.                 print('%s %s' % (colours[index], "is OK!"))
  187.  
  188. print("\nXerox WorkCentre M24")
  189. for index, value in enumerate(xM24list):
  190.         if value < warnLow:
  191.                 print('%s %s' % (colours[index], "is low - Check your stock!"))
  192.         elif value < warnQuart:
  193.                 print('%s %s' % (colours[index], "is below 25%"))
  194.         elif value < warnHalf:
  195.                 print('%s %s' % (colours[index], "is below 50%"))
  196.         else:
  197.                 print('%s %s' % (colours[index], "is OK!"))
  198.  
  199. print("\nXerox ColorQube 8700X")
  200. for index, value in enumerate(x8700Xlist):
  201.         if value < warnLow:
  202.                 print('%s %s' % (colours[index], "is low - Check your stock!"))
  203.         elif value < warnQuart:
  204.                 print('%s %s' % (colours[index], "is below 25%"))
  205.         elif value < warnHalf:
  206.                 print('%s %s' % (colours[index], "is below 50%"))
  207.         else:
  208.                 print('%s %s' % (colours[index], "is OK!"))
  209.  
  210. print("\nKonica Mita C35")
  211. for index, value in enumerate(C35list):
  212.         if value < warnLow:
  213.                 print('%s %s' % (colours[index], "is low - Check your stock!"))
  214.         elif value < warnQuart:
  215.                 print('%s %s' % (colours[index], "is below 25%"))
  216.         elif value < warnHalf:
  217.                 print('%s %s' % (colours[index], "is below 50%"))
  218.         else:
  219.                 print('%s %s' % (colours[index], "is OK!"))