3 Replies Latest reply on May 21, 2018 12:39 PM by jspath55

    Monitoring via custom Java code

    yagyavir.singh@gmail.com

      I have a custom java code that is able to monitor a workflow (Check server reachability --> Login to SFTP (URL availability and login to sftp) --> create a test file --> Check another folder to identify if file has processed)

      I want to know if there is a way to use this java code in SAM application template or some how use Orion to poll this java code and use results for alerting.

       

      !SAM, !NPM

      aLTeReGo

        • Re: Monitoring via custom Java code
          yagyavir.singh@gmail.com

          I am giving a try by executing java code from powershell and capture System.out.println() output in powershell script to generate Statistic and message variable for Orion.

          My script run just fine if I execute from powershell console but fails to run from Orion template with an error message that Java is not recognized.

           

          Classpath and Path variables are set to point at JRE\bin

           

          Output from powershell console:

           

          PS C:\Users\XYZ.admin\Desktop\Powershell_Script> .\JavatoPS.ps1

          Value of Java code is: Nodes: N1=yes,N2=no, N3=Yes, N4=no-File:drive1=no file, drive2=yes-Login:

          ***FINAL****

          Message: 2 Unreachable nodes - N2,  N4

          Statistic: 2

           

          Below is the error output from application template debug log message:

           

          Errors:      ====================================================

          The term 'java' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

          At line:2 char:21

          + $scriptblock = {java <<<<  HelloWorld "Nodes: N1=yes,N2=no, N3=Yes, N4=no-File:drive1=no file, drive2=yes-Login:sftp1=yes"}

              + CategoryInfo          : ObjectNotFound: (java:String) [], CommandNotFoundException

              + FullyQualifiedErrorId : CommandNotFoundException

           

          You cannot call a method on a null-valued expression.

          At line:8 char:28

          + $occurrence = $output.Split <<<< ($sperator, $option)

              + CategoryInfo          : InvalidOperation: (Split:String) [], RuntimeException

              + FullyQualifiedErrorId : InvokeMethodOnNull

          Result:      ====================================================

           

          Component Evidence Type: DynamicEvidence

          Component Type: None

          Actual Outcome: Undefined

           

          Registered Errors:

           

          Dynamic Monitor Result Info:

           

          Outcome based on statistic thresholds: Undefined

           

          End PowerShell Execute Result ===================================

           

           

          Any suggestion, idea or pointers that I should check?

            • Re: Monitoring via custom Java code
              jspath55

              I am starting down a similar path.

               

              > Classpath and Path variables are set to point at JRE\bin

               

              Here's what worked for me (at least in the PowerShell window):

               

              $env:Path      = $env:Path + ";[path to java bin]"

              $env:CLASSPATH = "e:\ [etc etc etc] .jar"

               

                • Re: Monitoring via custom Java code
                  jspath55

                  I tried putting the environment variables and logic into the SolarWinds script window but ran into roadblocks.  Since I had to write the PowerShell wrapper around the Java call and test it on a target client machine, I ended up simply calling that wrapper script remotely from SolarWinds, as in:

                   

                  e:\bin\javacode.ps1

                   

                  It's not what the instructions say but it works.