Guest User

Untitled

a guest
Nov 20th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.32 KB | None | 0 0
  1. ################################################################################
  2. # get_services.ps1
  3. #
  4. ################################################################################
  5.  
  6. $services = Get-Service | select name
  7.  
  8. Write-Host "{"
  9. Write-Host " `"data`":[`n"
  10. ForEach($s in $services) {
  11. $line= "{ `"{#SERVICE}`" : `"" + $s.Name + "`" }"
  12. Write-Host $line
  13. }
  14. Write-Host
  15. Write-Host " ]"
  16. Write-Host "}"
  17.  
  18. ################################################################################
  19. # get_servicestate.ps1
  20. #
  21. ################################################################################
  22.  
  23. Param ([String] $name = 0)
  24. $service = Get-Service -Name $name
  25. Write-Host $service.Status
  26.  
  27. ### Option: UserParameter
  28. # User-defined parameter to monitor. There can be several user-defined parameters.
  29. # Format: UserParameter=<key>,<shell command>
  30. #
  31. # Mandatory: no
  32. # Default:
  33. # UserParameter=
  34. UserParameter=org.service.discovery,powershell -NoProfile -ExecutionPolicy Bypass -File "S:ZabbixtemplatesZabbix_Services_monitoringget_services.ps1"
  35. UserParameter=org.service.state[*],powershell -NoProfile -ExecutionPolicy Bypass -File S:ZabbixtemplatesZabbix_Services_monitoringget_servicestate.ps1 "$1"
  36.  
  37. <?xml version="1.0" encoding="UTF-8"?>
  38. <zabbix_export>
  39. <version>3.0</version>
  40. <date>2017-11-20T16:44:57Z</date>
  41. <groups>
  42. <group>
  43. <name>
  44. Templates
  45. </name>
  46. </group>
  47. </groups>
  48. <templates>
  49. <template>
  50. <template>Template Microsoft Services</template>
  51. <name>Template Microsoft Services</name>
  52. <description/>
  53. <groups>
  54. <group>
  55. <name>
  56. Templates
  57. </name>
  58. </group>
  59. </groups>
  60. <applications>
  61. <application>
  62. <name>Windows Services</name>
  63. </application>
  64. </applications>
  65. <items/>
  66. <discovery_rules>
  67. <discovery_rule>
  68. <name>Windows Service</name>
  69. <type>0</type>
  70. <snmp_community/>
  71. <snmp_oid/>
  72. <key>org.service.discovery</key>
  73. <delay>30</delay>
  74. <status>1</status>
  75. <allowed_hosts/>
  76. <snmpv3_contextname/>
  77. <snmpv3_securityname/>
  78. <snmpv3_securitylevel>0</snmpv3_securitylevel>
  79. <snmpv3_authprotocol>0</snmpv3_authprotocol>
  80. <snmpv3_authpassphrase/>
  81. <snmpv3_privprotocol>0</snmpv3_privprotocol>
  82. <snmpv3_privpassphrase/>
  83. <delay_flex/>
  84. <params/>
  85. <ipmi_sensor/>
  86. <authtype>0</authtype>
  87. <username/>
  88. <password/>
  89. <publickey/>
  90. <privatekey/>
  91. <port/>
  92. <filter>
  93. <evaltype>0</evaltype>
  94. <formula/>
  95. <conditions/>
  96. </filter>
  97. <lifetime>30</lifetime>
  98. <description/>
  99. <item_prototypes>
  100. <item_prototype>
  101. <name>Windows Service {#SERVICE}</name>
  102. <type>0</type>
  103. <snmp_community/>
  104. <multiplier>0</multiplier>
  105. <snmp_oid/>
  106. <key>org.service.state[{#SERVICE}]</key>
  107. <delay>30</delay>
  108. <history>90</history>
  109. <trends>0</trends>
  110. <status>0</status>
  111. <value_type>4</value_type>
  112. <allowed_hosts/>
  113. <units/>
  114. <delta>0</delta>
  115. <snmpv3_contextname/>
  116. <snmpv3_securityname/>
  117. <snmpv3_securitylevel>0</snmpv3_securitylevel>
  118. <snmpv3_authprotocol>0</snmpv3_authprotocol>
  119. <snmpv3_authpassphrase/>
  120. <snmpv3_privprotocol>0</snmpv3_privprotocol>
  121. <snmpv3_privpassphrase/>
  122. <formula>1</formula>
  123. <delay_flex/>
  124. <params/>
  125. <ipmi_sensor/>
  126. <data_type>0</data_type>
  127. <authtype>0</authtype>
  128. <username/>
  129. <password/>
  130. <publickey/>
  131. <privatekey/>
  132. <port/>
  133. <description/>
  134. <inventory_link>0</inventory_link>
  135. <applications>
  136. <application>
  137. <name>Windows Services</name>
  138. </application>
  139. </applications>
  140. <valuemap/>
  141. <logtimefmt/>
  142. <application_prototypes/>
  143. </item_prototype>
  144. </item_prototypes>
  145. <trigger_prototypes>
  146. <trigger_prototype>
  147. <expression>{Template Microsoft Services:org.service.state[{#SERVICE}].str(Stopped)}<>0</expression>
  148. <name>Windows Service {#SERVICE} is down</name>
  149. <url/>
  150. <status>0</status>
  151. <priority>4</priority>
  152. <description/>
  153. <type>0</type>
  154. <dependencies/>
  155. </trigger_prototype>
  156. </trigger_prototypes>
  157. <graph_prototypes/>
  158. <host_prototypes/>
  159. </discovery_rule>
  160. </discovery_rules>
  161. <macros/>
  162. <templates/>
  163. <screens/>
  164. </template>
  165. </templates>
  166. </zabbix_export>
Add Comment
Please, Sign In to add comment