Skip to content

Commit

Permalink
Merge pull request #24 from stegenfeldt/feature/file-update-time
Browse files Browse the repository at this point in the history
Feature/file update time
  • Loading branch information
stegenfeldt authored Apr 4, 2017
2 parents c58eb61 + 2848b7f commit 772840d
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
<ParentMonitor>Health!System.Health.AvailabilityState</ParentMonitor>
<Accessibility>Public</Accessibility>
<Id>FileAgeMonitor</Id>
<DisplayName>Atea Windows File Age Monitor</DisplayName>
<Description>This monitor will look for files in a folder, recursively if configured such, and alert if one of more files are found.</Description>
<DisplayName>File Age Monitor</DisplayName>
<Description>This monitor will look for files in a folder, recursively if configured so, and alert if one of more files are found.</Description>
<Target>Atea.Windows.File.FileAgeFolder</Target>
<Enabled>true</Enabled>
<Category>AvailabilityHealth</Category>
Expand All @@ -32,7 +32,7 @@
<AlertOnState>Error</AlertOnState>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>MatchMonitorHealth</AlertSeverity>
<AlertName>File Age Monitor has found bad files </AlertName>
<AlertName>Files with bad timestamp found</AlertName>
<AlertDescription>$Data/Context/Property[@Name="Summary"]$</AlertDescription>
<ConfirmDelivery>false</ConfirmDelivery>
</UnitMonitorConfig>
Expand Down
Binary file not shown.
8 changes: 4 additions & 4 deletions Atea.Windows.File.Monitoring/Scripts/FileAgePB.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if (![System.Diagnostics.EventLog]::SourceExists($EventLogSourceName)) {
if (Test-Path -Path $RegistryPath) {
# Yes, we can read from $RegistryPath
$SubKeys = Get-ChildItem $RegistryPath

if ($SubKeys -ne $null) {
# Found configuration keys, processing folders
ForEach ($SubKey in $SubKeys) {
Expand All @@ -43,7 +43,7 @@ if (Test-Path -Path $RegistryPath) {
">=" {$Operator = "-ge"}
default {$Operator = "-gt"}
}

$summaryMessage = "File Age Monitor on '$FriendlyName', looking for '$FilePattern' where $FileAgeAttribute $Operator $AgeInMinutes in $FolderPath"

if ($Recursive.Trim() -eq "false")
Expand All @@ -59,7 +59,7 @@ if (Test-Path -Path $RegistryPath) {
$Files = @(Invoke-Command -ScriptBlock $ScriptBlock)
if ($Files.Count -gt 0) {
$summaryMessage += "Found $($Files.Count) matching files:`n"
$summaryMessage += "File Name`tFile Path`t`tAge (minutes)`tTimeStamp`n"
#$summaryMessage += "File Name`tFile Path`t`tAge (minutes)`tTimeStamp`n"
ForEach ($File in $Files)
{
$FileName = $File.Name
Expand All @@ -70,7 +70,7 @@ if (Test-Path -Path $RegistryPath) {
"LastAccessTime" {$FileDateTime = $File.LastAccessTime}
}
$FileAgeMinutes = [math]::Round(((Get-Date) - $FileDateTime).TotalMinutes,0)
$summaryMessage += "$FileName`t$FileFullName`t$FileAgeMinutes`t$($FileDateTime -f "o")`n"
$summaryMessage += "$FileName`n`tMinutes since $($FileAgeAttribute): $FileAgeMinutes`n`tTimestamp: $($FileDateTime -f "o")`n`tFile Path: $FileFullName`n`n"
}
#We have old files, and a message. Build the property bag
$propertyBag = $omApi.CreatePropertyBag()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery>$Data/Property[@Name='FileCount']$</XPathQuery>
<XPathQuery Type="String">Property[@Name='FileCount']</XPathQuery>
</ValueExpression>
<Operator>NotEqual</Operator>
<ValueExpression>
<Value>0</Value>
<Value Type="String">0</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
Expand All @@ -42,11 +42,11 @@
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery>$Data/Property[@Name='FileCount']$</XPathQuery>
<XPathQuery Type="String">Property[@Name='FileCount']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value>0</Value>
<Value Type="String">0</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
gwmi -query "select * from Win32_Service where State='Running'" | ft Name,DisplayName -AutoSize
Get-WMIObject -query "select * from Win32_Service where State='Running'" | Format-Table Name,DisplayName -AutoSize
Binary file modified Released/Atea.Windows.File.Monitoring.mp
Binary file not shown.
Binary file modified Released/Atea.Windows.Installer.msi
Binary file not shown.

0 comments on commit 772840d

Please sign in to comment.