Closed PChipVIA closed 6 years ago
Hi @PChipVIA ,
thanks for your kind feedback. I am aware of the volatile properties and also that it's not a best-practice to do so. As the discovery only runs every 4 hours and the data which is changed is small I believed that there is more benefit than disadvantage by providing the information so that you can get this information at glance in the state view.
Have you noticed any negative performance impact on the database or on the agent machine after importing the MP?
After reading Brians article again I think collecting the size via rule might be also quiet interesting.
Thank you!! :+1:
I'll consider you suggestions.
Hi @Juanito99 ,
For the volatile properties, I think the entire record updates if a single property changes so IMHO the cons outweigh the pros. Collection Rule indeed would be best as it would allow one to see growth/trends over time. I haven't installed the MP, just wanted to reverse engineer how you detected Tomcat servers and how you detected the log folder... :+1: Learn every day!
If I can add a little more to the thread. Couple things
I see you hard code the folder to basefolder\logs, but if I'm not mistaken, the location may be configured elsewhere. You should parse the basefolder\conf\logging.properties file for the exact location(s)
Which brings me to my next point that from what I see there are several logs and each may be in a different folder (from what I assume from the logging.properties it is one per handler)
The discovery script also does not take in account that there may be several Tomcat services installed on the same server, each of which with their own config
I created a PoC script which addresses the points above (of course there is a need to adjust the classes, relationships & monitoring) ` ForEach ($Tomcat in Get-ChildItem -Path HKLM:\SYSTEM\CurrentControlSet\services\Tomcat*) {
$apacheBaseDirectory = [Regex]::Matches($Tomcat.GetValue('ImagePath'), '(?i)[a-z\\0-9\._()\-: ]{1,}(?=bin\\tomcat\d{1}.exe)') | Select-Object -ExpandProperty Value
$apacheLogConfig = Get-Content (Join-Path $apacheBaseDirectory 'conf\logging.properties') | Where-Object { $_ -notmatch "^(\s+)?;|^\s*$|^#" }
[PSCustomObject]@{
Tomcat = $Tomcat.Name -split '\\' | Select-Object -Last 1
BaseDirectory = $apacheBaseDirectory
LogConfig = $apacheLogConfig
} | Format-Table # Format List/Table not needed in script, just to show handlers on screen
ForEach ($Handler in ($apacheLogConfig | Where-Object{ $_ -match '^handlers = (.*)' }) -replace '^handlers = ' -split '\s*,\s*' | Where-Object{ $_ -match 'file' }) {
$HandlerDirectory = $HandlerPrefix = $null
$HandlerDirectory = (($apacheLogConfig | Where-Object{ $_ -match "^$Handler\.directory" }) -split '\s=\s')[1] -replace '\/', '\' -replace '\$\{catalina.base\}\\', $apacheBaseDirectory
$HandlerPrefix = (($apacheLogConfig | Where-Object{ $_ -match "^$Handler\.prefix" }) -split '\s=\s')[1]
[PSCustomObject]@{
Handler = $Handler.Split('.')[0]
Level = (($apacheLogConfig | Where-Object{ $_ -match "^$Handler\.level" }) -split '\s=\s')[1]
Directory = $HandlerDirectory
Prefix = $HandlerPrefix
# Not to use in discovery, but should be in probe script
LogSize = [Math]::Round(((Get-ChildItem (Join-Path $HandlerDirectory "$HandlerPrefix*") | Measure-Object -property length -sum).Sum / 1mb -as [double]), 2)
}
}
} `
(sorry first time posting on GitHub, can't seem to figure out the code stuff)
Hi @PChipVia,
great feedback. Many thanks. I am on the way to vacation and a bit limited with phone and time, so keep a bit short this time :-)
If I don't mixup I pulled the log folder out of the registry, or just for Apache ...
You are absolutely right about I only cover one instance. Haven't thought there might be multliple. I will check the code when back :-)
Second when I am back I will remove the frequently changing properties. Thinking a while longer I think I may be one of the reasons for slowing down our SCOM ... Oops ... As you said learn every day :-)
I will update here and would be glad to get feedback after updated later ...
Kind regards
Ruben
Hi @PChipVIA ,
I changed the classes and removed those attributes as suggested. A rule is now recording the size of the log file folders.
For the mentioned Tomcat issue I can't find the time at the moment. - Nevertheless, may thanks for this hint! :+1:
Ruben
Hi Looking at class Windows.Server.Webservice.LogdirectoryWatcher.WebSite.Base, I noticed that it contains at least 4 volatile properties: LogDirModifiedDate,LogDirScanDate, LogDirSizeInMB, LogDirNoOfFiles.
As per https://social.technet.microsoft.com/wiki/contents/articles/14256.operations-manager-management-pack-authoring-classes-and-relationships.aspx#Properties_that_Update_Too_Frequently you should not have properties in classes that change often (as it may cause config churn -- Some post from Kevin Holman). Logically those properties will change every time the discovery will run (every 14400 seconds).
Unless needed, I would recommend you stop discovering them..
HTH