Implementing Zabbix LLD Monitoring IIS sites with PowerShell scripts

Source: Internet
Author: User

Demand:

Automation of IIS site monitoring is required in the production environment, and the PID of the station name and site process needs to be obtained. With the site name you can get the value of the related monitoring item with the Windows built-in key. such as the get of the site, the number of post requests, the site version information, and so on. However, you also need to monitor the number of SQL connections for the IIS site, which requires the IIS site to be accessed and has a SQL process. The number of SQL connections for each site is then judged by the process number.


Script content:

Get.sitename

[email protected] () [System.Collections.ArrayList] $arraylist =$ sitearray$command=c:\windows\system32\inetsrv\appcmd.exe list vdirforeach  ($i  in $ command) {     $site = $i. Split ("") [1].split ("/") [0].split (' \ "') [1].trim (')       $arraylist. Insert (0, $site)} #echo   $arraylist $a= $arraylist .count-1#echo  $aecho       "{' n" echo     ' t ' "Data" ':[foreach  ($i  in 0: $a) {      echo  ' n ' t ' t ' {'       $web = $arraylist [$i]      $dir = ' "{#SITENAME}" ' + ': ' + ' "' + $web + '" '      echo  ' t ' t$dir      echo  ' t ' "}"      if  ($i  -lt  $a)       {     echo  ' t ' t ', '      }}echo  ' T]echo   "}" 



Get.site.pid

[Email protected] () [email protected] () [System.Collections.ArrayList] $arraylist = $sitearray [system.collections.arraylist]$ pidlist= $pidarray $command=c:\windows\system32\inetsrv\appcmd.exe list wpforeach  ($i  in   $command) {    $site = $i. Split (': ') [1].replace (') ', ')     $pidlist. Insert (0,$ I.split () [1])     $arraylist. Insert (0, $site)   } $a = $arraylist. count-1#echo $ arraylist#echo  $pidlistecho      "{' n"  echo     ' t ' "data" ': [ foreach  ($i  in 0: $a) {     echo  ' n ' t ' t ' {'        $web = $arraylist [$i]      $id = $pidlist [$i]      $dir 1 = ' "{ #WP_NAME} "' + ': ' + '" ' + $web + ' "'       $dir 2= '" {#WP_PID} "' + ': ' + $id       echo  ' t ' t ' t$dir1 ', ' $dir 2     echo  ' t '} '       if&nBSP; ($i  -lt  $a)      {     echo  ' t ', '       } }echo  ' t]echo  '} "


Reference:

Https://github.com/Yxnt/zabbix-w3wp


This article is from the "Zengestudy" blog, make sure to keep this source http://zengestudy.blog.51cto.com/1702365/1857764

Implementing Zabbix LLD Monitoring IIS sites with PowerShell scripts

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.