Recent Discussions
SQL CERTIFICATE MONITORING
How to monitor SQL certificate using port 1433? Do anyone have any custom groovy script to monitor All certificate using any port or any specific port specifically port 1433. We are using the certificate on our SQL server for their encrypted communication & need to check al servers certificate expiration days. Any help would be appreciated.sachin-tanwar28 days agoNeophyte39Views0likes2CommentsDatapoints configuration Discussion
Hello Team, I am trying to create a custom datasource to check the service status. It retrieves a list of services from the host properties(auto.service.names), connects to the host using SSH, checks the status of each service using the systemctl command, and outputs the results. Active Discovery Script: import com.santaba.agent.groovyapi.expect.Expect; import com.santaba.agent.groovyapi.snmp.Snmp; import com.santaba.agent.groovyapi.http.*; import com.santaba.agent.groovyapi.jmx.*; import org.xbill.DNS.*; // Get the service names from the host property def serviceNames = hostProps.get("auto.service.names") ?: "" def serviceArray = serviceNames.split(",").collect { it.trim() } // SSH details for connecting to the host host = hostProps.get("system.hostname") user = hostProps.get("ssh.user") pass = hostProps.get("ssh.pass") port = hostProps.get("ssh.port")?.toInteger() ?: 22 cert = hostProps.get("ssh.cert") ?: '~/.ssh/id_rsa' timeout = 15000 // Timeout in milliseconds // Initialize JSCH for SSH connection import com.jcraft.jsch.JSch def getServiceStatus(serviceName) { def command = "systemctl is-active ${serviceName}" return getCommandOutput(command).trim() } def getCommandOutput(String input_command) { def output = "" def session = null def channel = null try { def jsch = new JSch() if (user && !pass) { jsch.addIdentity(cert) } session = jsch.getSession(user, host, port) session.setConfig("StrictHostKeyChecking", "no") session.setTimeout(timeout) if (pass) { session.setPassword(pass) } session.connect() channel = session.openChannel("exec") channel.setCommand(input_command) def commandOutput = channel.getInputStream() channel.connect() output = commandOutput.text } finally { if (channel) { channel.disconnect() } if (session) { session.disconnect() } } return output } // Output each service with its status serviceArray.each { serviceName -> def status = getServiceStatus(serviceName) println "${serviceName}##${serviceName}##Status: ${status}" } return 0 Collection Script: Below, I am trying to use the ##WILDVALUE## from the active discovery script to collect the service status value. com.jcraft.jsch.JSch // Initialize JSCH for SSH connection // SSH details for connecting to the host host = hostProps.get("system.hostname") user = hostProps.get("ssh.user") pass = hostProps.get("ssh.pass") port = hostProps.get("ssh.port")?.toInteger() ?: 22 cert = hostProps.get("ssh.cert") ?: '~/.ssh/id_rsa' timeout = 15000 // Timeout in milliseconds // Function to retrieve the service status def getServiceStatus(serviceName) { def command = "systemctl is-active ${serviceName}" def result = getCommandOutput(command) return result?.trim() } // Function to execute command and retrieve output def getCommandOutput(String command) { def output = "" def session = null def channel = null def reader = null try { def jsch = new JSch() if (user && !pass) { jsch.addIdentity(cert) } session = jsch.getSession(user, host, port) session.setConfig("StrictHostKeyChecking", "no") session.setTimeout(timeout) if (pass) { session.setPassword(pass) } session.connect() channel = session.openChannel("exec") channel.setCommand(command) channel.setInputStream(null) channel.setErrStream(System.err) reader = new BufferedReader(new InputStreamReader(channel.getInputStream())) channel.connect() def line while ((line = reader.readLine()) != null) { output += line + "\n" } // Ensuring the channel finishes before disconnecting while (!channel.isClosed()) { Thread.sleep(100) } } catch (Exception e) { println "Error executing command: ${e.message}" } finally { reader?.close() channel?.disconnect() session?.disconnect() } return output } // Retrieve the current service name based on ##WILDVALUE## def serviceName = datasourceinstanceProps.values().collect { it.wildvalue }.find { it != null } if (serviceName) { def status = getServiceStatus(serviceName) def statusValue = (status == "active") ? 1 : 0 println "Service:${serviceName} Status:${statusValue}" return statusValue } else { println "Error: No service name found for ##WILDVALUE##." return null } I need help creating the datapoint to collect service status value. Thanks in advance. The error I am currently getting: param prefix is not invalid in format - (valid_prefixes=[datacollector.], method=namevalue, param=datacollector)Hshukla30 days agoNeophyte46Views3likes2CommentsHP Aruba 6000 switch Support?
Good Afternoon, It seems that the newest switch chassis from Aruba/HP Isn't playing too nicely with LM at the moment. The same DataSources that were useful for the previous HP Switches don't appear to work for the newer 6000 series devices (we have a 6000 and a few 6500s) specifically, the Memory snmp query seems to poll no data - luckily the default CPU for SNMP does work. Has anyone run into this themselves?Jordan-Eil3 months agoNeophyte34Views1like0CommentsChange Auditing for Group Hierarchy
We had a couple of folders move on us (erroneous clicks by our users). Tracking down where they came from was difficult. I've written a solution using a configSource. AppliesTo() targets a collector we've set aside for doing RestAPI queries with longer timeouts for scripting: $company = "<Your Company From the URL Here>" $URLBase = "https://$company.logicmonitor.com/santaba/rest" $accessID = "##ApiAccessID.key##" $accessKey = "##ApiAccessKey.key##" #region Initialization and Functions #-------- The Functions ---------- function Send-Request { param ( $cred , $URL , $accessid = $null, $accesskey = $null, $data = $null, $version = '3' , $httpVerb = "GET" ) if ( $accessId -eq $null) { exit 1 } <# Use TLS 1.2 #> [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 <# Get current time in milliseconds #> $epoch = [Math]::Round( ( New-TimeSpan ` -start (Get-Date -Date "1/1/1970") ` -end (Get-Date).ToUniversalTime()).TotalMilliseconds ) <# Concatenate Request Details #> $requestVars = $httpVerb + $epoch + $data + $resourcePath <# Construct Signature #> $hmac = New-Object System.Security.Cryptography.HMACSHA256 $hmac.Key = [Text.Encoding]::UTF8.GetBytes( $accessKey ) $signatureBytes = $hmac.ComputeHash( [Text.Encoding]::UTF8.GetBytes( $requestVars ) ) $signatureHex = [System.BitConverter]::ToString( $signatureBytes ) -replace '-' $signature = [System.Convert]::ToBase64String( [System.Text.Encoding]::UTF8.GetBytes( $signatureHex.ToLower() ) ) <# Construct Headers #> $auth = 'LMv1 ' + $accessId + ':' + $signature + ':' + $epoch $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" $headers.Add( "Authorization", $auth ) $headers.Add( "Content-Type" , 'application/json' ) # uses version 2 of the API $headers.Add( "X-version" , $version ) <# Make Request #> $response = Invoke-RestMethod ` -Uri $URL ` -Method $httpVerb ` -Body $data ` -Header $headers ` -erroraction SilentlyContinue ` -warningaction SilentlyContinue Return $response } function Get-LMRestAPIObjectListing { param ( $URLBase , $resourcePathRoot , # "/device/devices" $size = 1000 , $accessKey , $accessId , $version = '2' ) $output = @() $looping = $true $counter = 0 while ($looping) { #re-calc offset based on iteration $offset = $counter * $size $resourcePath = $resourcePathRoot $queryParam = "?size=$size&offset=$offset" $url = $URLBase + $resourcePath + $queryParam # Make Request $response = Send-Request ` -accesskey $accessKey ` -accessid $accessId ` -URL $url ` -version $version if ( $response.items.count -eq $size ) { # Return set is full, more items to retrieve $output += $response.items $counter++ } elseif ( $response.items.count -gt 0 ) { # Return set is not full, store date, end loop $output += $response.items $looping = $false } else { # Return set is empty, no data to store, end loop $looping = $false } } write-output $output } #endregion #region Get Groups $resourcePath = "/device/groups" $Groups = Get-LMRestAPIObjectListing ` -resourcePathRoot $resourcePath ` -accessKey $accessKey ` -accessId $accessID ` -URLBase $URLBase #endregion $groups | sort id | select id, parentid, fullpath | format-table -autosizeCole_McDonald4 months agoProfessor65Views4likes3CommentsLinux services and autodiscovery
Hey guys, I just wanted to let you know that I took LogicMonitor's default datasource, "Linux_SSH_ServiceStatus", and added auto discovery to it. The only thing that is needed at the resource or group level is that the following three properties are set: ssh.user ssh.pass linux.ssh.services.regex ( default: "sshd\.service" ) I published the datasource under 93Y4PC (currently under security review as of this post) The discovery script gets the output of systemctl list-units --all --type=service --plain --state=loaded | egrep service Loop through each line of the output and see if it matches the regex from the property, "linux.ssh.services.regex" A person could even set the regex to be ".*" which would grab all of the services.. then turn around and create a filter to exclude certain things. For example if I wanted everything but services with the name ssh in them, I could create a filter that says ##WILDVALUE## not contain ssh.Keimond7 months agoNeophyte84Views2likes4CommentsPowershell in five easy steps
A few years ago, I wrote a powershell tutorial. Thought some may find it useful. On to the Future with Powershell – PowerShell.org It's less programming tutorial than other programming tutorials. I wrote it for the "you can tear this mouse from my cold hands" type of admin who are being forced to learn powershell to do their jobs. It's peppered with some nuggets of geeky humor to keep it rolling forward and is just enough to get someone started using powershell (or any other programming language) by focusing on the larger concepts of Storage, Input, Output, Decisions, Loops... the building blocks of every language from assembly to applescript.106Views6likes2Comments