p1.py 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. #!/usr/bin/env python3
  2. from cmk.graphing.v1 import Title
  3. from cmk.graphing.v1.graphs import Graph, MinimalRange
  4. from cmk.graphing.v1.metrics import (
  5. Color,
  6. DecimalNotation,
  7. Metric,
  8. SINotation,
  9. StrictPrecision,
  10. Unit,
  11. )
  12. # Voltage
  13. metric_p1_voltage = Metric(
  14. name="p1_voltage_v",
  15. title=Title("Voltage"),
  16. unit=Unit(
  17. DecimalNotation("V"),
  18. StrictPrecision(1),
  19. ),
  20. color=Color.BLUE,
  21. )
  22. graph_p1_voltage = Graph(
  23. name="p1_voltage",
  24. title=Title("P1 voltage"),
  25. simple_lines=["p1_voltage_v"],
  26. minimal_range=MinimalRange(200, 260),
  27. )
  28. # Power
  29. metric_p1_power = Metric(
  30. name="p1_power_w",
  31. title=Title("Power"),
  32. unit=Unit(
  33. SINotation("W"),
  34. StrictPrecision(0),
  35. ),
  36. color=Color.BLUE,
  37. )
  38. graph_p1_power = Graph(
  39. name="p1_power",
  40. title=Title("P1 power"),
  41. simple_lines=["p1_power_w"],
  42. minimal_range=MinimalRange(0, 3000),
  43. )
  44. # Current
  45. metric_p1_current = Metric(
  46. name="p1_current_a",
  47. title=Title("Current"),
  48. unit=Unit(
  49. DecimalNotation("A"),
  50. StrictPrecision(3),
  51. ),
  52. color=Color.BLUE,
  53. )
  54. graph_p1_current = Graph(
  55. name="p1_current",
  56. title=Title("P1 current"),
  57. simple_lines=["p1_current_a"],
  58. minimal_range=MinimalRange(0, 20),
  59. )
  60. # Energy import
  61. metric_p1_energy_total = Metric(
  62. name="p1_energy_total_kwh",
  63. title=Title("Total"),
  64. unit=Unit(
  65. SINotation("Wh"),
  66. StrictPrecision(3),
  67. ),
  68. color=Color.BLUE,
  69. )
  70. metric_p1_energy_t1 = Metric(
  71. name="p1_energy_t1_kwh",
  72. title=Title("Tariff 1"),
  73. unit=Unit(
  74. SINotation("Wh"),
  75. StrictPrecision(3),
  76. ),
  77. color=Color.GREEN,
  78. )
  79. metric_p1_energy_t2 = Metric(
  80. name="p1_energy_t2_kwh",
  81. title=Title("Tariff 2"),
  82. unit=Unit(
  83. SINotation("Wh"),
  84. StrictPrecision(3),
  85. ),
  86. color=Color.ORANGE,
  87. )
  88. graph_p1_energy = Graph(
  89. name="p1_energy",
  90. title=Title("P1 energy"),
  91. simple_lines=[
  92. "p1_energy_total_kwh",
  93. "p1_energy_t1_kwh",
  94. "p1_energy_t2_kwh",
  95. ],
  96. minimal_range=MinimalRange(0, 1),
  97. )
  98. # Gas
  99. metric_p1_gas = Metric(
  100. name="p1_gas_m3",
  101. title=Title("Gas"),
  102. unit=Unit(
  103. DecimalNotation("m³"),
  104. StrictPrecision(2),
  105. ),
  106. color=Color.BLUE,
  107. )
  108. graph_p1_gas = Graph(
  109. name="p1_gas",
  110. title=Title("P1 gas consumption"),
  111. simple_lines=["p1_gas_m3"],
  112. minimal_range=MinimalRange(0, 1),
  113. )
  114. # Voltage sag/swell counters
  115. metric_p1_voltage_sag_l1 = Metric(
  116. name="p1_voltage_sag_l1",
  117. title=Title("Voltage sags L1"),
  118. unit=Unit(DecimalNotation(""), StrictPrecision(0)),
  119. color=Color.BLUE,
  120. )
  121. metric_p1_voltage_sag_l2 = Metric(
  122. name="p1_voltage_sag_l2",
  123. title=Title("Voltage sags L2"),
  124. unit=Unit(DecimalNotation(""), StrictPrecision(0)),
  125. color=Color.GREEN,
  126. )
  127. metric_p1_voltage_sag_l3 = Metric(
  128. name="p1_voltage_sag_l3",
  129. title=Title("Voltage sags L3"),
  130. unit=Unit(DecimalNotation(""), StrictPrecision(0)),
  131. color=Color.ORANGE,
  132. )
  133. graph_p1_voltage_sags = Graph(
  134. name="p1_voltage_sags",
  135. title=Title("P1 voltage sags"),
  136. simple_lines=[
  137. "p1_voltage_sag_l1",
  138. "p1_voltage_sag_l2",
  139. "p1_voltage_sag_l3",
  140. ],
  141. minimal_range=MinimalRange(0, 1),
  142. )
  143. # Voltage swell counters
  144. metric_p1_voltage_swell_l1 = Metric(
  145. name="p1_voltage_swell_l1",
  146. title=Title("Voltage swells L1"),
  147. unit=Unit(DecimalNotation(""), StrictPrecision(0)),
  148. color=Color.BLUE,
  149. )
  150. metric_p1_voltage_swell_l2 = Metric(
  151. name="p1_voltage_swell_l2",
  152. title=Title("Voltage swells L2"),
  153. unit=Unit(DecimalNotation(""), StrictPrecision(0)),
  154. color=Color.GREEN,
  155. )
  156. metric_p1_voltage_swell_l3 = Metric(
  157. name="p1_voltage_swell_l3",
  158. title=Title("Voltage swells L3"),
  159. unit=Unit(DecimalNotation(""), StrictPrecision(0)),
  160. color=Color.ORANGE,
  161. )
  162. graph_p1_voltage_swells = Graph(
  163. name="p1_voltage_swells",
  164. title=Title("P1 voltage swells"),
  165. simple_lines=[
  166. "p1_voltage_swell_l1",
  167. "p1_voltage_swell_l2",
  168. "p1_voltage_swell_l3",
  169. ],
  170. minimal_range=MinimalRange(0, 1),
  171. )
  172. # Power failures
  173. metric_p1_any_power_fail = Metric(
  174. name="p1_any_power_failure",
  175. title=Title("Any power failures"),
  176. unit=Unit(DecimalNotation(""), StrictPrecision(0)),
  177. color=Color.BLUE,
  178. )
  179. metric_p1_long_power_fail = Metric(
  180. name="p1_long_power_failure",
  181. title=Title("Long power failures"),
  182. unit=Unit(DecimalNotation(""), StrictPrecision(0)),
  183. color=Color.RED,
  184. )
  185. graph_p1_power_failures = Graph(
  186. name="p1_power_failures",
  187. title=Title("P1 power failures"),
  188. simple_lines=[
  189. "p1_any_power_failure",
  190. "p1_long_power_failure",
  191. ],
  192. minimal_range=MinimalRange(0, 1),
  193. )