Git Product home page Git Product logo

Comments (4)

PChipVIA avatar PChipVIA commented on May 20, 2024 1

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... 👍 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)

from windows.server.webservice.logdirectorywatcher.

Juanito99 avatar Juanito99 commented on May 20, 2024

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!! 👍

I'll consider you suggestions.

from windows.server.webservice.logdirectorywatcher.

Juanito99 avatar Juanito99 commented on May 20, 2024

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

from windows.server.webservice.logdirectorywatcher.

Juanito99 avatar Juanito99 commented on May 20, 2024

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! 👍

Ruben

from windows.server.webservice.logdirectorywatcher.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.