{"id":208,"date":"2018-08-29T16:55:05","date_gmt":"2018-08-29T13:55:05","guid":{"rendered":"https:\/\/itbru.ru\/?p=208"},"modified":"2018-08-29T16:55:05","modified_gmt":"2018-08-29T13:55:05","slug":"exchange-zabbixpowershell","status":"publish","type":"post","link":"https:\/\/itbru.ru\/index.php\/2018\/08\/29\/exchange-zabbixpowershell\/","title":{"rendered":"\u041c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0431\u0430\u0437 Exchange. Zabbix+PowerShell"},"content":{"rendered":"<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0431\u0430\u0437 Exchange \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u043d\u0435 \u0442\u0430\u043a\u043e\u0439 \u0443\u0436 \u043f\u0440\u043e\u0441\u0442\u043e\u0439. \u0418\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438 Zabbix \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u0442\u044c \u0431\u0430\u0437\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442, \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0435\u0433\u043e \u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0443\u0447\u0438\u0442\u044c.<\/p>\n<p><!--more--><\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0443\u0441 \u0431\u0430\u0437 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 PowerShell:<\/p>\n<pre class=\"lang:ps decode:true \">Get-MailboxDatabaseCopyStatus -Identity *<\/pre>\n<p>\u042d\u0442\u0443 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043d\u0430 \u043b\u044e\u0431\u043e\u043c \u0438\u0437 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 Exchange \u0438 \u043e\u043d\u0430 \u0432\u0435\u0440\u043d\u0435\u0442 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u0439 \u0441\u0442\u0430\u0442\u0443\u0441 \u0432\u0441\u0435\u0445 \u0431\u0430\u0437. \u0422\u0443\u0442 \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u043f\u0440\u0438\u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043b\u0438 \u0431\u0430\u0437\u0430, \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0431\u0430\u0437\u044b.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b Zabbix \u0443\u0432\u0435\u0434\u043e\u043c\u0438\u043b \u043d\u0430\u0441 \u0435\u0441\u043b\u0438 \u0441 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0438\u0437 \u0431\u0430\u0437 \u0447\u0442\u043e-\u0442\u043e \u043d\u0435 \u0442\u0430\u043a.<\/p>\n<ol>\n<li>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043a\u043b\u044e\u0447 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Zabbix \u0430\u0433\u0435\u043d\u0442\u0435 \u043d\u0430 Exchange \u0441\u0435\u0440\u0432\u0435\u0440\u0435. \u041f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 \u043a\u043e\u043d\u0444\u0438\u0433 \u0441\u0442\u0440\u043e\u043a\u0443:<\/li>\n<\/ol>\n<pre class=\"lang:ps decode:true\">UserParameter=DB_status,PowerShell.exe -nologo \"C:\\scripts\\DB_status_tst.ps1\"<\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0417\u0430\u0431\u0431\u0438\u043a\u0441\u043e\u043c \u043a\u043b\u044e\u0447\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 DB_status \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0441\u043a\u0440\u0438\u043f\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043b\u0435\u0436\u0438\u0442 \u0432 \u043f\u0430\u043f\u043a\u0435 &#171;C:\\scripts\\&#187; \u0438 \u0438\u043c\u0435\u0435\u0442 \u0438\u043c\u044f &#171;DB_status_tst.ps1&#187;.<\/p>\n<p>2. \u0421\u043a\u0440\u0438\u043f\u0442 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0442\u0434\u0430\u0442\u044c \u043d\u0430\u0441 \u0441\u0442\u0430\u0442\u0443\u0441 \u0431\u0430\u0437. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442 \u044f \u0440\u0435\u0448\u0438\u043b \u0447\u0442\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u0445\u043e\u0440\u043e\u0448\u043e \u0441\u043a\u0440\u0438\u043f\u0442 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0430\u043c &#171;\u041e\u041a&#187;, \u0435\u0441\u043b\u0438 \u0441 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0431\u0430\u0437\u043e\u0439 \u0447\u0442\u043e-\u0442\u043e \u043d\u0435 \u0442\u0430\u043a, \u0442\u043e \u0441\u043a\u0440\u0438\u043f\u0442 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u0432 \u0447\u0435\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0438 \u0441 \u043a\u0430\u043a\u043e\u0439 \u0431\u0430\u0437\u043e\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0435\u0441\u043b\u0438 \u0443 \u0431\u0430\u0437\u044b DB1 \u0434\u043b\u0438\u043d\u043d\u0430\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u044c &#8212; \u0441\u043a\u0440\u0438\u043f\u0442 \u043e\u0442\u0434\u0430\u0441\u0442 \u043d\u0430\u043c &#171;queue DB1&#187;. \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u0430\u043c \u0441\u043a\u0440\u0438\u043f\u0442:<\/p>\n<pre class=\"lang:ps decode:true \">Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 #\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c \r\n$dbs = Get-MailboxDatabaseCopyStatus -Identity * #\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0442\u0430\u0442\u0443\u0441 \u0431\u0430\u0437\r\n$nok = $NULL\r\nforeach ($db in $dbs) #\u041f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c \u0431\u0430\u0437\u044b\r\n{\r\n    $status = $db.status\r\n    $name = $db.DatabaseName\r\n    $queue = $db.CopyQueueLength\r\n    $index = $db.ContentIndexState\r\n    if ($status -ne \"Healthy\" -and $status -ne \"Mounted\") #\u0415\u0441\u043b\u0438 \u0441\u0442\u0430\u0442\u0443\u0441 \u0431\u0430\u0437\u044b \u043d\u0435 Healthy \u0438 \u043d\u0435 Mounted\r\n    {\r\n        $nok += \"not ok \"+ $name + \"; \"\r\n    }\r\n    if ($queue -gt 100) #\u0415\u0441\u043b\u0438 \u0434\u043b\u0438\u043d\u043d\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 100\r\n    {\r\n        $nok += \"queue \"+ $name + \"; \"\r\n    }\r\n    if ($index -ne \"Healthy\") #\u0415\u0441\u043b\u0438 \u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0435 \u0438\u0441\u043f\u0440\u0430\u0432\u0435\u043d\r\n    {\r\n        $nok += \"index \"+ $name + \"; \"\r\n    }\r\n}\r\n#\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\r\nif ($nok -ne $NULL)\r\n{\r\n    Write-Host $nok\r\n}\r\nelse\r\n{\r\n    Write-Host \"OK\"\r\n}<\/pre>\n<p>3. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Zabbix<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-210\" src=\"https:\/\/itbru.ru\/wp-content\/uploads\/2018\/08\/zbx.jpg\" alt=\"\" width=\"776\" height=\"102\" \/><\/p>\n<p>4.\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0442\u0440\u0438\u0433\u0433\u0435\u0440<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-212\" src=\"https:\/\/itbru.ru\/wp-content\/uploads\/2018\/08\/zbx1.jpg\" alt=\"\" width=\"813\" height=\"674\" \/><\/p>\n<p>\u041e\u0431\u0440\u0430\u0449\u0430\u0435\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043f\u043e\u043b\u0435 Description. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u0430 \u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0442\u043e, \u0447\u0442\u043e \u043e\u0442\u0434\u0430\u043b \u043d\u0430\u0448 \u0441\u043a\u0440\u0438\u043f\u0442. \u0422.\u0435. \u0438\u043c\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u043e\u0439 \u0431\u0430\u0437\u044b.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0431\u0430\u0437 Exchange \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u043d\u0435 \u0442\u0430\u043a\u043e\u0439 \u0443\u0436 \u043f\u0440\u043e\u0441\u0442\u043e\u0439. \u0418\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438 Zabbix \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u0442\u044c \u0431\u0430\u0437\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442, \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0435\u0433\u043e \u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0443\u0447\u0438\u0442\u044c.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,15],"tags":[],"class_list":["post-208","post","type-post","status-publish","format-standard","hentry","category-exchange","category-zabbix"],"_links":{"self":[{"href":"https:\/\/itbru.ru\/index.php\/wp-json\/wp\/v2\/posts\/208","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itbru.ru\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itbru.ru\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itbru.ru\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/itbru.ru\/index.php\/wp-json\/wp\/v2\/comments?post=208"}],"version-history":[{"count":1,"href":"https:\/\/itbru.ru\/index.php\/wp-json\/wp\/v2\/posts\/208\/revisions"}],"predecessor-version":[{"id":213,"href":"https:\/\/itbru.ru\/index.php\/wp-json\/wp\/v2\/posts\/208\/revisions\/213"}],"wp:attachment":[{"href":"https:\/\/itbru.ru\/index.php\/wp-json\/wp\/v2\/media?parent=208"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itbru.ru\/index.php\/wp-json\/wp\/v2\/categories?post=208"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itbru.ru\/index.php\/wp-json\/wp\/v2\/tags?post=208"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}