Kiln » KilnSupportScripts Powershell Scripts to help monitor a Kiln environment. Contact Fog Creek support before using.
Clone URL:  
Monitor-Kiln.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#----------------------------------------------------------------------------- # This script will check that Kiln is running and healthy by hitting a variety of HTTP endpoints # # Usage example: # ./Monitor-Kiln.ps1 -kilnURL "http://localhost/fogbugz/kiln" # #----------------------------------------------------------------------------- param([string]$kilnURL = "http://localhost/fogbugz/kiln", [string]$backendVersionUrl = "http://localhost:56783/version", [string]$EsUrl = "http://localhost:9200/", [string]$QueueStatsUrl = "http://localhost:56785/stats.json") function Write-WithTime($msg){ write "$(Get-Date -format o) $msg" } function Test-ProcessRunning($processName, $count = 1) { Write-WithTime "Checking that $count instance(s) of $processName are running..." $result = (Get-Process $processName -ea SilentlyContinue | select id | measure).count -ge $count if ($result) { Write-WithTime "Success!" } else { Write-WithTime "FAILURE!" } } function Test-ElasticSearchRunning() { Write-WithTime "Checking that 1 instances(s) of ElasticSearch are running..." $result = (Get-WmiObject win32_process -Filter "name like 'java.exe'" | select commandline | select-string "ElasticSearch" | measure).count -eq 1 if ($result) { Write-WithTime "Success!" } else { Write-WithTime "FAILURE!" } } function Test-HttpResponse($url, $searchString) { Write-WithTime "Checking for expected response from URL ($url)..." try { $response = (New-Object net.webclient).DownloadString($url) $response = (New-Object net.webclient).DownloadString($url) $result = $response | select-string $searchString if ($result) { Write-WithTime "Success!" } else { Write-WithTime "FAILURE!" } } catch [Net.WebException] { Write-WithTime $_.Exception.ToString() } } Test-ProcessRunning "backend" Test-ProcessRunning "redis-server" 2 Test-ProcessRunning "QueueService" Test-ElasticSearchRunning Test-HttpResponse $kilnURL "Log on to Kiln" Test-HttpResponse $backendVersionUrl '"hg_version"' Test-HttpResponse $EsUrl '"status" : 200' Test-HttpResponse $QueueStatsUrl '"queueName":"Kiln"' # TODO: Parse the QueueStats data and alert when poor behavior is detected. Attempt automatic restart?