Kiln » KilnSupportScripts Powershell Scripts to help monitor a Kiln environment. Contact Fog Creek support before using.
Clone URL:  
Pushed to one repository · View In Graph Contained in tip

add LogOrWrite method, refactor stuff

Changeset 3ac204ef9f66

Parent 3f1c112aee7f

by Profile picture of User 476Ben McCormack <benm@fogcreek.com>

Changes to one file · Browse files at 3ac204ef9f66 Showing diff from parent 3f1c112aee7f Diff from another changeset...

Change 1 of 2 Show Entire File checkBackend.ps1 Stacked
 
 
 
 
1
2
3
4
5
 
 
 
 
 
 
 
 
6
7
8
 
35
36
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
39
40
41
 
42
43
44
45
46
 
47
48
49
 
1
2
3
4
5
6
7
 
8
9
10
11
12
13
14
15
16
17
18
 
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
73
 
74
75
76
77
@@ -1,8 +1,18 @@
+$g_backendUrl = "http://localhost:56783/" +$g_kilnRepositories = "C:\KilnRepositories" +  function Get-URL([string] $url){   (New-Object net.webclient).DownloadString($url)  }   -$g_backendUrl = "http://localhost:56783/" +function LogOrWrite($msg, $logFile = ""){ + if ($logFile -ne "") { + write $msg | out-file -append $logFile + } + else { + write $msg + } +}    function Test-KilnVersion(){   try { @@ -35,15 +45,33 @@
  }  }   +function Get-MiniRedisSize([string] $kilnRepositoriesDir = $g_kilnrepositories, [string] $logFile = ""){ + try { + $kilnRepo = (Resolve-Path $kilnRepositoriesDir -ErrorAction Stop).path + } + catch { + LogOrWrite "Could not find Kiln Repositories Directory: $kilnRepositoriesDir" $logFile + } + try { + $miniRedis = (Resolve-Path ($kilnRepo + "\miniredis.db") -ErrorAction Stop).path + } + catch { + LogOrWrite "Could not find miniredis.db file in $kilnRepo" $logFile + } + $lenMiniRedis = (get-childitem -path $miniRedis).length + LogOrWrite "The size of miniredis.db is: $lenMiniRedis" $logFile + return $lenMiniRedis +} +  function Check-KilnBackend([string] $sRepoGUID, [string] $sChangeset1, [string] $sChangeset2, [string] $logFile = ""){   if (-Not ((Test-KilnVersion) -and (Test-KilnDiff $sRepoGUID $sChangeset1 $sChangeset2))){   #Restart the Kiln storage Service because something bad happened - write "$(Get-Date -format o) Something is wrong. Restarting Kiln Storage Service" | foreach{if ($logFile -ne "") {out-file -append $logFile} else {out-default}} + LogOrWrite "$(Get-Date -format o) Something is wrong. Restarting Kiln Storage Service" $logFile   Restart-Service "KilnStorageService"   return $False   }   else { - write "$(Get-Date -format o) Kiln backend is OK" | foreach{if ($logFile -ne "") {$_ | out-file -append $logFile} else {$_ | out-default}} + LogOrWrite "$(Get-Date -format o) Kiln backend is OK" $logFile   return $True   }  }