Recent Discussions
Collection Scripts
hi, Please find my code below import groovy.sql.Sql //@Grab('org.hsqldb:hsqldb:2.7.1:jdk8') //@GrabConfig(systemClassLoader=true) //@Grab("com.sybase.jdbc4.jdbc.SybDriver") Class.forName("com.sybase.jdbc4.jdbc.SybDriver") // Get basic info to connect def hostname = hostProps.get("system.hostname") def user = hostProps.get("sybase.user") def pass = hostProps.get("sybase.pass") def port = 21000 // Construct an SQL instance with a url and a driver def url = "jdbc:sybase:Tds:##hostname##:21000", username=user, password=pass //def url = "jdbc:sybase:Tds:hostname:port", "user", "pass" // sybase SQL Driver def driver = "com.sybase.jdbc4.jdbc.SybDriver" // Create a connection to the SQL server sql = Sql.newInstance(url,user,pass,driver) sql.withTransaction { // Iterate over query results and list the databases sql.eachRow("select name from master..sysdatabases") { name= it.toString().split(":")[1].replace("]","") // Create an instance for each database println name+"##"+name } } sql.close() return 0340Views10likes89CommentsIs there a way to set custom property values from your groovy script in your datasource?
Hey there. I’m relatively new to logic monitor and I received a request from a client. The request is as follows. They wanted us to be able to provide not only blocked processes alerts for their SQL dbs but also for us to provide a breakdown of what is blocking what. My solution to this was to edit the datasource that contains the processblocked datapoint. I made some good progress. I was able to create a custom property field for the instances that I’m monitoring. I then edited thescript for the collector attributeso that in theory that if particular datapoint (processessblocked) shows a value of greater than 0, it uses hostSets() to change that custom property value to the blocker session ids using some custom sql script within. When I test it using the test button pointed at my sql server, it works exactly as i expected. It shows the default value of the property unless it hits that block process value of 1 or more. then the property reads with the needed info. However after I save the datasource. And put this in to practice, no matter what the custom property on those instances never update or change. I also tried applying similar logic to the active discovery script with the same results. Seems to work fine through testing but then nothing in the actual instance changes. I can post any or all of the groovy script if need be. Is it something simple like some sort of syntax I’m not getting or am I not even in the right area to do what I’m attempting to do? Any help would be appreciated and like I said, I’ll gladly provide any more info or code if need be. ThanksSolved708Views11likes70CommentsCollection the data metrics where there are unique keys
SPID = 1 BLOCKED = 0 SPID = 3 BLOCKED = 0 SPID = 4 BLOCKED = 0 SPID = 5 BLOCKED = 0 SPID = 6 BLOCKED = 0 SPID = 7 BLOCKED = 0 SPID = 8 BLOCKED = 0 SPID = 9 BLOCKED = 0 SPID = 10 BLOCKED = 0 SPID = 11 BLOCKED = 0 SPID = 12 BLOCKED = 0 SPID = 13 BLOCKED = 0 SPID = 14 BLOCKED = 0 SPID = 17 BLOCKED = 0 SPID = 37 BLOCKED = 0 SPID = 60 BLOCKED = 0 SPID = 107 BLOCKED = 0 SPID = 147 BLOCKED = 0 SPID = 165 BLOCKED = 0 SPID = 183 BLOCKED = 0 SPID = 251 BLOCKED = 0 SPID = 273 BLOCKED = 0 SPID = 319 BLOCKED = 0 SPID = 430 BLOCKED = 0 SPID = 435 BLOCKED = 0 SPID = 466 BLOCKED = 0 SPID = 470 BLOCKED = 0 SPID = 494 BLOCKED = 0 SPID = 522 BLOCKED = 0 SPID = 539 BLOCKED = 0 SPID = 555 BLOCKED = 0 SPID = 584 BLOCKED = 0 SPID = 596 BLOCKED = 0 SPID = 600 BLOCKED = 0 SPID = 651 BLOCKED = 0 SPID = 673 BLOCKED = 0 i want to capture the above data, the above data is my querry result. please tell me the data point settings341Views4likes58CommentsSQL Certificates
Hello, I am trying to collect the SQL Certificates obtain by "Select name, expiry_date from sys.certificates" to have an alert when their expiration date arrived. I tried by datasource but apparently it is not feasible after consultation with LM Support. I was directed to Property Sources but not finding my way in this new environment... Any groowvy script to be used for that? 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.*; import groovy.sql.Sql // needed for SQL connection and query def hostname = hostProps.get("system.hostname"); import groovy.sql.Sql // needed for SQL connection and query def url = "jdbc:sqlserver://" + hostname + ";databaseName=master;integratedSecurity=true"; def driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; sql = Sql.newInstance(url, driver) // connects to SQL server def query_result = sql.firstRow("SELECT name, expiry_date from sys.certificates") full_name_certificate = query_result.name full_date_certificate = query_result.expiry_date sql.close() // Close connection ... return 0; This part looks okay but how to get the information in the Alert... ... Thanks, DomSolved123Views2likes42CommentsCertificate "IssuedBy" "Daystoexpire" to be displayed...
Hello, I have the discovery script: Quote ##--------------- Discovery ------------------## $pshost = Get-Host # Get the PowerShell Host. $pswindow = $pshost.UI.RawUI # Get the PowerShell Host's UI. $newsize = $pswindow.BufferSize # Get the UI's current Buffer Size. $newsize.width = 800 # Set the new buffer's width to 800 columns. $pswindow.buffersize = $newsize # Set the new Buffer Size as active. $newsize = $pswindow.windowsize # Get the UI's current Window Size. $newsize.width = 800 # Set the new Window Width to 800 columns. $pswindow.windowsize = $newsize # Set the new Window Size as active. $readOnly = [System.Security.Cryptography.X509Certificates.OpenFlags]"ReadOnly" $localMachine = [System.Security.Cryptography.X509Certificates.StoreLocation]"LocalMachine" $store = new-object System.Security.Cryptography.X509Certificates.X509Store( "\\##SYSTEM.SYSNAME##\my", $localMachine ) ##--------------- Discovery ------------------## $pshost = Get-Host # Get the PowerShell Host. $pswindow = $pshost.UI.RawUI # Get the PowerShell Host's UI. $newsize = $pswindow.BufferSize # Get the UI's current Buffer Size. $newsize.width = 800 # Set the new buffer's width to 800 columns. $pswindow.buffersize = $newsize # Set the new Buffer Size as active. $newsize = $pswindow.windowsize # Get the UI's current Window Size. $newsize.width = 800 # Set the new Window Width to 800 columns. $pswindow.windowsize = $newsize # Set the new Window Size as active. $readOnly = [System.Security.Cryptography.X509Certificates.OpenFlags]"ReadOnly" $localMachine = [System.Security.Cryptography.X509Certificates.StoreLocation]"LocalMachine" $store = new-object System.Security.Cryptography.X509Certificates.X509Store( "\\##SYSTEM.SYSNAME##\my", $localMachine ) $store.Open( $readOnly ) $store.Certificates ` | Select-Object { ` $_.Thumbprint + "##" ` + $(If ($_.FriendlyName -eq "") {"Unknown friendly name (" + $_.Thumbprint + ")"} Else {$_.FriendlyName}) + "##" ` + $_.Subject + $(If ($_.Subject -ne "") {"(..." + $_.Thumbprint.SubString($_.Thumbprint.length - 5, 5) + ")"} Else {"Unknown subject (" + $_.Thumbprint + ")"}) + "##" ` + "##" ` + "cert.issuer=" + $_.Issuer ` + "&cert.friendlyname=" + $_.FriendlyName ` + "&cert.serialnumber=" + $_.SerialNumber ` + "&cert.thumbprint=" + $_.Thumbprint ` } ` | Format-Table -HideTableHeaders then the Quote ##-------------- Counters --------------------## $pshost = Get-Host # Get the PowerShell Host. $pswindow = $pshost.UI.RawUI # Get the PowerShell Host's UI. $newsize = $pswindow.BufferSize # Get the UI's current Buffer Size. $newsize.width = 800 # Set the new buffer's width to 800 columns. $pswindow.buffersize = $newsize # Set the new Buffer Size as active. $newsize = $pswindow.windowsize # Get the UI's current Window Size. $newsize.width = 800 # Set the new Window Width to 800 columns. $pswindow.windowsize = $newsize # Set the new Window Size as active. $readOnly = [System.Security.Cryptography.X509Certificates.OpenFlags]"ReadOnly" $localMachine = [System.Security.Cryptography.X509Certificates.StoreLocation]"LocalMachine" $store = new-object System.Security.Cryptography.X509Certificates.X509Store( "\\##SYSTEM.SYSNAME##\my", $localMachine ) $properties = @( # @{n='WildValue';e={"##WildValue##"}}, @{n='CommonName';e={$_.Subject}}, @{n='Thumbprint';e={$_.Thumbprint}}, # @{n='Description';e={"##Description##"}}, @{n='Properties';e={"##Properties##"}}, @{n='IssuedBy';e={($_.Issuer)}}, @{n='daystoexpire';e={($_.NotAfter - [datetime]::Today).Days}} ) $store.Open( $readOnly ) $store.Certificates ` | Where-Object {($_.Thumbprint -like "##WildValue##")} ` | Select-Object $properties ` | Format-Table -HideTableHeaders But when populating the groups I have No Data... and So we see the data in the Raw Request/ Response fields... What is happening? Thanks, Dom28Views1like41CommentsReplace IP by DNS Name
Hello, I got from Eric and Josh a script which is having the basic code to do the task I need. I would like to replace the IP Address/DNS Name by the DNS Name for all our servers. ######################### API Function Script ######################### #------------------------------------------------------------------------------------------------------------ # Prerequisites: # # Requires -Version 3 #------------------------------------------------------------------------------------------------------------ # Initialize Variables <# account info #> $accessId = "1234567890-" $accessKey = '1234567890-' $company = "xxxxxxxx" #------------------------------------------------------------------------------------------------------------ # Functionize the reusable code that builds and executes the query function Send-Request() { Param( [Parameter(position = 0, Mandatory = $true)] [string]$path, [Parameter(position = 1, Mandatory = $false)] [string]$httpVerb = 'GET', [Parameter(position = 2, Mandatory = $false)] [string]$queryParams, [Parameter(position = 3, Mandatory = $false)] [PSObject]$data ) # Use TLS 1.2 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 <# Construct URL #> $url = "https://$company.logicmonitor.com/santaba/rest$path$queryParams" <# 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 + $path <# 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') $headers.Add("X-version", '2') <# Make request & retry if failed due to rate limiting #> $Stoploop = $false do { try { <# Make Request #> $response = Invoke-RestMethod -Uri $url -Method $httpVerb -Body $data -Header $headers $Stoploop = $true } catch { switch ($_) { { $_.Exception.Response.StatusCode.value__ -eq 429 } { Write-Host "Request exceeded rate limit, retrying in 60 seconds..." Start-Sleep -Seconds 60 $response = Invoke-RestMethod -Uri $url -Method $httpVerb -Body $data -Header $headers } { $_.Exception.Response.StatusCode.value__ } { Write-Host "Request failed, not as a result of rate limiting" # Dig into the exception to get the Response details. # Note that value__ is not a typo. Write-Host "StatusCode:" $_.Exception.Response.StatusCode.value__ Write-Host "StatusDescription:" $_.Exception.Response.StatusCode $_.ErrorDetails.Message -match '{"errorMessage":"([\d\S\s]+)","errorCode":(\d+),' Write-Host "LM ErrorMessage" $matches[1] Write-Host "LM ErrorCode" $matches[2] $response = $null $Stoploop = $true } default { Write-Host "An Unknown Exception occurred:" Write-Host $_ | Format-List -Force $response = $null $Stoploop = $true } } } } While ($Stoploop -eq $false) Return $response } # Get list of Resources $members = {VRPSCCMRS01} $httpVerb = 'GET' $resourcePath = "/device/devices/$member.id" $queryParams = $null $data = $null $results = Send-Request $resourcePath $httpVerb $queryParams $data foreach ($hostname in $results.items) { $sysname = (($hostname.systemProperties) | Where-Object -Property "Name" -eq "system.sysname").value if ($sysname -match "\.") { $newName = $sysname.split(".")[0] } else { $newName = $sysname } if ($hostname.Name -eq $newName) { Write-Host "Name `"$($hostname.displayName)`" matched no change needed" } else { $httpVerb = 'PATCH' $resourcePath = "/device/devices/$($deviceId)" $queryParams = "?patchFields=Name&opType=replace" $data = @{ Name = $newName } | ConvertTo-Json Send-Request $resourcePath $httpVerb $queryParams $data Write-Host "Changed host id $($hostname.id) Name from `"$($hostname.ips)`" to `"$newName`"." } } but for now I am getting an error: Request failed, not as a result of rate limiting StatusCode: 404 StatusDescription: NotFound LM ErrorMessage HTTP 404 Not Found LM ErrorCode 1400 Any idea of the issue? Test in progress Thanks, Dom159Views1like41CommentsNew VMware modules dropped
Did anybody else notice the ~44 new and ~5 updated modules around VMware dropping in the last hour or so? Does anyone know how to implement these new modules? Since there was talk of making the instances into resources I don’t want to just bring them in without knowing how it’s going to mess with my device list (which is tightly bound to billing for us).685Views30likes40CommentsUsing Postman to create multiple Websites via API & CSV?
Hi, I’m testing out creating websites (or resources) via the API. I have a standard Post working in Postman just fine. However, when I then try to do the same thing via a CSV file in the Runner section, I’m getting 401 Authorization errors. When I look at the data that’s being sent, it looks the same as what’s sent when I run it manually. Is there something special I need to do when running a Post command via the Runner vs the manual Send command? Thanks.Solved433Views12likes40CommentsPing Failing from collector to device and back?
Hello I am getting errors:“VIPEIEEMP01 is suffering ping loss. 100.0% of pings are not returning, placing the host into critical state.” “The host VIPEIEEMP01 is down. No data has been received” If I do a ping from the command prompt of the Clientto theCollectorit works The firewall is wide opened!!! What did I miss? Thanks, Dom793Views15likes40CommentsMaking a Backup for Cisco ISE in LogicMonitor
I am trying to setup a ConfigSource in LogicMonitor for Cisco ISE backups. We want the backup to only pull when a change is made in ISE. The out-of-the-box Cisco_IOS and Cisco_NXOS ConfigSources don't seem to work for ISE. So I tried to make a ConfigSource from the LM pagehttps://www.logicmonitor.com/support/logicmodules/articles/creating-a-configsourcebut I haven't been able to get it to work properly. I made a copy ofCisco_IOS so I could have the Config Checks and removed the scripts. I have the following: AppliesTo: ( ( startsWith( system.sysinfo, "Cisco Identity Services Engine" ) ) ) && ( (ssh.user && ssh.pass ) || (config.user && config.pass) ) Parameters: import com.santaba.agent.groovyapi.expect.Expect host = hostProps.get("system.hostname"); user = hostProps.get("config.user"); pass = hostProps.get("config.pass"); cli=Expect.open(host, user, pass); cli.expect("#"); cli.send("terminal length 0\n"); cli.expect("#"); cli.send("show running-config all\n"); cli.expect(/Current configuration.*\n/); cli.send("exit\n"); cli.expect("#exit"); config=cli.before(); config = config.replaceAll(/ntp clock-period \d+/,"ntp clock-period "); cli.expectClose(); println config; Test comes back with the error: The script failed, elapsed time: 60 seconds - End of stream reached, no match found java.io.IOException: End of stream reached, no match found Does anyone have any ideas?177Views1like39Comments