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