<?xml version="1.0" encoding="UTF-8"?> <zabbix_export> <version>2.0</version> <date>2015-06-05T11:21:26Z</date> <groups> <group> <name>My Templates</name> </group> </groups> <templates> <template> <template>1C Habr template</template> <name>1C Habr template</name> <groups> <group> <name>My Templates</name> </group> </groups> <applications> <application> <name>1 </name> </application> </applications> <items> <item> <name>1 </name> <type>2</type> <snmp_community/> <multiplier>0</multiplier> <snmp_oid/> <key>exchange.status</key> <delay>0</delay> <history>90</history> <trends>365</trends> <status>0</status> <value_type>3</value_type> <allowed_hosts/> <units/> <delta>0</delta> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <formula>1</formula> <delay_flex/> <params/> <ipmi_sensor/> <data_type>0</data_type> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description/> <inventory_link>0</inventory_link> <applications> <application> <name>1 </name> </application> </applications> <valuemap> <name>1Ok / 0Fail</name> </valuemap> </item> <item> <name> 1 </name> <type>2</type> <snmp_community/> <multiplier>0</multiplier> <snmp_oid/> <key>exchange.restart</key> <delay>0</delay> <history>90</history> <trends>365</trends> <status>0</status> <value_type>3</value_type> <allowed_hosts/> <units/> <delta>0</delta> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <formula>1</formula> <delay_flex/> <params/> <ipmi_sensor/> <data_type>0</data_type> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description/> <inventory_link>0</inventory_link> <applications> <application> <name>1 </name> </application> </applications> <valuemap> <name>1C Restart</name> </valuemap> </item> </items> <discovery_rules/> <macros/> <templates/> <screens/> </template> </templates> <triggers> <trigger> <expression>{1C Habr template:exchange.status.nodata(30m)}=1&{1C Habr template:exchange.status.time()}>084500&{1C Habr template:exchange.status.time()}<200000</expression> <name>{HOST.NAME} 1C 30 </name> <url/> <status>0</status> <priority>1</priority> <description/> <type>0</type> <dependencies/> </trigger> <trigger> <expression>{1C Habr template:exchange.restart.count(1h,100)}>2</expression> <name>{HOST.NAME} 1C 3 1 </name> <url/> <status>0</status> <priority>1</priority> <description/> <type>0</type> <dependencies/> </trigger> <trigger> <expression>{1C Habr template:exchange.restart.last(0)}=2</expression> <name>{HOST.NAME} 1C !</name> <url/> <status>0</status> <priority>2</priority> <description/> <type>0</type> <dependencies/> </trigger> </triggers> </zabbix_export>
& {1C Habr template: exchange.status.time ()}> 084500 & {1C Habr template: exchange.status.time ()} <200000
EnableRemoteCommands = 1
(, ) = (()); = "http://zabbix.example.com/zabbix_sender/index.php?server=" + + "&key=" + + "&value=" + ; WinHttp = COM("WinHttp.WinHttpRequest.5.1"); WinHttp.Option(2,"Windows-1251"); WinHttp.Open("GET", , 0); WinHttp.SetRequestHeader("Accept-Language", "ru"); WinHttp.SetRequestHeader("Accept-Charset","Windows-1251"); WinHttp.setRequestHeader("Content-Language", "ru"); WinHttp.setRequestHeader("Content-Charset", "Windows-1251"); WinHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=Windows-1251"); WinHttp.Send(); = WinHttp.ResponseText(); ; ; = "OK" ; ; ;
param([string]$programm_name="nul") Try{ $servername=$env:computername $zabbixhost="zabbix.example.com" $zabbix_key=$programm_name+".restart" switch ($programm_name) { "exchange" { $window_name="1: - : " $schedule_name="" } default { throw "No param" } } ################### , ################### Get-Process | Where-Object {$_.MainWindowTitle -eq $window_name} | Stop-Process -Force Sleep 10; schtasks /end /TN $schedule_name Sleep 10; schtasks /run /TN $schedule_name if ($LastExitCode -ne 0){ throw "LastExitCode -ne 0" } #Send to Zabbix $get_str1="https://$zabbixhost/zabbix_sender/index.php?server=$servername&key=$zabbix_key$vm_name&value=100" $wc = New-Object system.Net.WebClient; $Result = $wc.downloadString("$get_str1") } Catch { #Send to Zabbix Error $get_str2="https://$zabbixhost/zabbix_sender/index.php?server=$servername&key=$zabbix_key$vm_name&value=2" $wc = New-Object system.Net.WebClient; $Result = $wc.downloadString("$get_str2") }
<?xml version="1.0" encoding="UTF-16"?> <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"> <RegistrationInfo> <Author>example/username</Author> </RegistrationInfo> <Triggers /> <Principals> <Principal id="Author"> <UserId>Server\username</UserId> <LogonType>InteractiveToken</LogonType> <RunLevel>HighestAvailable</RunLevel> </Principal> </Principals> <Settings> <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy> <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries> <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries> <AllowHardTerminate>true</AllowHardTerminate> <StartWhenAvailable>false</StartWhenAvailable> <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable> <IdleSettings> <Duration>PT10M</Duration> <WaitTimeout>PT1H</WaitTimeout> <StopOnIdleEnd>true</StopOnIdleEnd> <RestartOnIdle>false</RestartOnIdle> </IdleSettings> <AllowStartOnDemand>true</AllowStartOnDemand> <Enabled>true</Enabled> <Hidden>false</Hidden> <RunOnlyIfIdle>false</RunOnlyIfIdle> <WakeToRun>false</WakeToRun> <ExecutionTimeLimit>P3D</ExecutionTimeLimit> <Priority>7</Priority> </Settings> <Actions Context="Author"> <Exec> <Command>powershell.exe</Command> <Arguments>-windowstyle hidden -nologo -NonInteractive -File "C:\ZBX\restart-1c.ps1" exchange</Arguments> </Exec> </Actions> </Task>
Source: https://habr.com/ru/post/259601/
All Articles