Skip to content

Commit

Permalink
Merge pull request #3 from stegenfeldt/master
Browse files Browse the repository at this point in the history
Merge from master
  • Loading branch information
svantegraden authored Oct 3, 2018
2 parents 2753fa7 + 5c97c85 commit 24861cc
Show file tree
Hide file tree
Showing 39 changed files with 1,096 additions and 234 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,5 @@ ModelManifest.xml
/Atea.Windows.Server.Monitoring/AteaST.snk
/Atea.Windows.Service.Monitoring/AteaST.snk
/AteaST.snk
VisualStudioAuthoringConsole_x64.msi
_Scripts/VisualStudioAuthoringConsole_x64.msi
34 changes: 33 additions & 1 deletion Atea.Windows.File.Monitoring/Atea.Windows.File.Monitoring.mpproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,16 @@
<Compile Include="HealthModel\Discoveries\FCTFolderDiscovery.mpx">
<SubType>Code</SubType>
</Compile>
<Compile Include="HealthModel\Discoveries\FileAgeFolderDiscovery.mpx">
<SubType>Code</SubType>
</Compile>
<Compile Include="HealthModel\Discoveries\FileMonitoringSeedDiscovery.mpx">
<SubType>Code</SubType>
</Compile>
<Compile Include="HealthModel\Monitors\FileAge.mptg.mpx">
<SubType>Code</SubType>
<DependentUpon>HealthModel\Monitors\FileAge.mptg</DependentUpon>
</Compile>
<Compile Include="HealthModel\Rules\FCTFolderAlertRule.mpx">
<SubType>Code</SubType>
</Compile>
Expand All @@ -67,6 +74,9 @@
<Compile Include="ManagementPack.mpx">
<SubType>Code</SubType>
</Compile>
<Compile Include="ServiceModel\Classes\FileAgeFolder.mpx">
<SubType>Code</SubType>
</Compile>
<Compile Include="ServiceModel\Classes\FileCreationTimeFolder.mpx">
<SubType>Code</SubType>
</Compile>
Expand All @@ -79,12 +89,27 @@
<Compile Include="TypeLibrary\ModuleTypes\DataSources\FCTMonitoringPropertyBagDS.mpx">
<SubType>Code</SubType>
</Compile>
<Compile Include="TypeLibrary\ModuleTypes\DataSources\FileAgeFolderDiscoveryDS.mpx">
<SubType>Code</SubType>
</Compile>
<Compile Include="TypeLibrary\ModuleTypes\DataSources\FileAgePropertyBagDS.mpx">
<SubType>Code</SubType>
</Compile>
<Compile Include="TypeLibrary\ModuleTypes\ProbeActions\FCTpsFolderDiscoveryProbe.mpx">
<SubType>Code</SubType>
</Compile>
<Compile Include="TypeLibrary\ModuleTypes\ProbeActions\FCTvbsPropertyBagProbe.mpx">
<SubType>Code</SubType>
</Compile>
<Compile Include="TypeLibrary\ModuleTypes\ProbeActions\FileAgeFolderDiscoveryProbe.mpx">
<SubType>Code</SubType>
</Compile>
<Compile Include="TypeLibrary\ModuleTypes\ProbeActions\FileAgePoSHProbe.mpx">
<SubType>Code</SubType>
</Compile>
<Compile Include="TypeLibrary\MonitorTypes\FileAgeMonitoryType.mpx">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Folder Include="HealthModel" />
Expand All @@ -106,9 +131,16 @@
<Folder Include="TypeLibrary\ModuleTypes" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Scripts\AteaFCTPSPropertyBag.ps1" />
<EmbeddedResource Include="Scripts\FileAgePB.ps1" />
<EmbeddedResource Include="Scripts\AteaFileCreationTimePoSHDiscovery.ps1" />
<EmbeddedResource Include="Scripts\FCTvbsPropertyBag.vbs" />
<EmbeddedResource Include="Scripts\FileAgePoSHDiscovery.ps1" />
</ItemGroup>
<ItemGroup>
<Content Include="HealthModel\Monitors\FileAge.mptg">
<SubType>Content</SubType>
<Generator>FragmentGenerator</Generator>
</Content>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VSAC\Microsoft.SystemCenter.OperationsManager.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<ManagementPackFragment SchemaVersion="2.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Monitoring>
<Discoveries>
<Discovery ID="Atea.Windows.File.FileAgeFolder.Discovery" Enabled="true" Target="Atea.Windows.File.Monitoring.Seed" ConfirmDelivery="true" Remotable="false" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="Atea.Windows.File.FileAgeFolder" />
</DiscoveryTypes>
<DataSource ID="DiscoveryDS" TypeID="Atea.Windows.File.FileAgeFolder.DiscoveryDS">
<MPElement>$MPElement$</MPElement>
<TargetID>$Target/Id$</TargetID>
<ComputerName>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$</ComputerName>
<IntervalSeconds>14400</IntervalSeconds>
</DataSource>
</Discovery>
</Discoveries>
</Monitoring>
<LanguagePacks>
<LanguagePack ID="ENU" IsDefault="true">
<DisplayStrings>
<DisplayString ElementID="Atea.Windows.File.FileAgeFolder.Discovery">
<Name>Atea FileAge Folder Discovery</Name>
</DisplayString>
</DisplayStrings>
</LanguagePack>
</LanguagePacks>
</ManagementPackFragment>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
<PathType>0</PathType>
<AttributeType>0</AttributeType>
</RegistryAttributeDefinition>
<RegistryAttributeDefinition>
<AttributeName>FAgeKeyExist</AttributeName>
<Path>SOFTWARE\Atea\FileAgeMonitoring</Path>
<PathType>0</PathType>
<AttributeType>0</AttributeType>
</RegistryAttributeDefinition>
</RegistryAttributeDefinitions>
<Frequency>14400</Frequency>
<ClassId>$MPElement[Name="Atea.Windows.File.Monitoring.Seed"]$</ClassId>
Expand All @@ -27,15 +33,30 @@
</Settings>
</InstanceSettings>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Values/FCKeyExist</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">true</Value>
</ValueExpression>
</SimpleExpression>
<Or>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Values/FCKeyExist</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">true</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Values/FAgeKeyExist</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">true</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</Or>
</Expression>
</DataSource>
</Discovery>
Expand Down
41 changes: 41 additions & 0 deletions Atea.Windows.File.Monitoring/HealthModel/Monitors/FileAge.mptg
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<TemplateGroup>
<Instances>
<Instance ID="Instance1cb8bbbf42bb4bd8ba0ce5a2d4aaa2da" Type="Microsoft.SystemCenter.Authoring.CodeGeneration.Monitoring.UnitMonitor" Version="1.0.0.0">
<UnitMonitorConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<MonitorType>Windows.File.FileAge.MonitorType</MonitorType>
<MonitorConfig>&lt;TimeoutSeconds&gt;300&lt;/TimeoutSeconds&gt;&lt;IntervalSeconds&gt;300&lt;/IntervalSeconds&gt;&lt;FolderFriendlyName&gt;$Target/Property[Type="Atea.Windows.File.FileAgeFolder"]/FriendlyName$&lt;/FolderFriendlyName&gt;&lt;FileAgeAttribute&gt;$Target/Property[Type="Atea.Windows.File.FileAgeFolder"]/FileAgeAttribute$&lt;/FileAgeAttribute&gt;</MonitorConfig>
<MonitorOperationalStates>
<OperationalState>
<OperationalStateId>Healthy</OperationalStateId>
<OperationalStateDisplayName>No Files Found</OperationalStateDisplayName>
<MonitorTypeStateId>Healthy</MonitorTypeStateId>
<HealthState>Success</HealthState>
</OperationalState>
<OperationalState>
<OperationalStateId>Error</OperationalStateId>
<OperationalStateDisplayName>Bad Files Found</OperationalStateDisplayName>
<MonitorTypeStateId>Error</MonitorTypeStateId>
<HealthState>Error</HealthState>
</OperationalState>
</MonitorOperationalStates>
<ParentMonitor>Health!System.Health.AvailabilityState</ParentMonitor>
<Accessibility>Public</Accessibility>
<Id>FileAgeMonitor</Id>
<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>
<Remotable>true</Remotable>
<Priority>Normal</Priority>
<AlertAutoResolve>true</AlertAutoResolve>
<AlertOnState>Error</AlertOnState>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>MatchMonitorHealth</AlertSeverity>
<AlertName>Files with bad timestamp found</AlertName>
<AlertDescription>$Data/Context/Property[@Name="Summary"]$</AlertDescription>
<ConfirmDelivery>false</ConfirmDelivery>
</UnitMonitorConfig>
</Instance>
</Instances>
</TemplateGroup>
Binary file not shown.
69 changes: 0 additions & 69 deletions Atea.Windows.File.Monitoring/Scripts/AteaFCTPSPropertyBag.ps1

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ param([string]$sourceId, [string]$managedEntityId, [string]$computerName)

$RegistryPath = "hklm:\Software\Atea\FileCreationTime\"
$SubKeys = Get-ChildItem $RegistryPath
$OpsmgrAPI = New-Object -ComObject "MOM.ScriptAPI"
#$OpsmgrAPI.LogScriptEvent("AteaFilCreationPoSHDiscovery.ps1", 242, 4, "Running File Creation Folder discovery with parameters $sourceId, $managedEntityId, $computerName")
$discoveryData = $OpsmgrAPI.CreateDiscoveryData(0, $sourceId, $managedEntityId)
$omApi = New-Object -ComObject "MOM.ScriptAPI"
#$omApi.LogScriptEvent("AteaFilCreationPoSHDiscovery.ps1", 242, 4, "Running File Creation Folder discovery with parameters $sourceId, $managedEntityId, $computerName")
$discoveryData = $omApi.CreateDiscoveryData(0, $sourceId, $managedEntityId)
ForEach ($SubKey in $SubKeys)
{
$FriendlyName = ($SubKey.Name.Substring($SubKey.Name.LastIndexOfAny("\")+1))
Expand All @@ -18,12 +18,12 @@ ForEach ($SubKey in $SubKeys)
$FilePattern = $SubKey.GetValue("FilePattern")
$AgeInMinutes = $SubKey.GetValue("AgeInMinutes")
$Operator = $SubKey.GetValue("Operator")


if (($FolderPath -ne $null) -and ($Recursive -ne $null) -and ($FilePattern -ne $null) -and ($AgeInMinutes -ne $null) -and ($Operator -ne $null))
{
$Operator = $Operator.Trim()

#Add values to property bag for Discovery
$discoveryInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Atea.Windows.File.FileCreationTimeFolder']$")
$discoveryInstance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $computerName)
Expand Down
Loading

0 comments on commit 24861cc

Please sign in to comment.