4 Replies Latest reply on Oct 26, 2018 10:37 AM by troyison

    Run Local Script Via NCM Job

    troyison

      Hello,

       

      We are trying to run a batch script that is local to the main app server as a NCM job and as an alert based triggered external script, but run into connection refused errors

       

      What we would like to do is run C:\Scripts\reportgen.bat on a schedule via Solarwinds, but when we run the job the logs state "connection refused" when connecting to the main server (itself).

       

      Any thoughts on how we can run this script on a regular basis?

        • Re: Run Local Script Via NCM Job
          wluther

          troyison Are you able to successfully run the batch file manually, completely bypassing the internal workings of your SolarWinds server? Also, if you don't mind, would you elaborate a bit on the purpose/functions of the batch file, please?

           

           

          Thank you,

           

          -Will

            • Re: Run Local Script Via NCM Job
              troyison

              The script does run on its own sucessfully.

               

              The script actaully calls plink and then uses ssh keys to log into a Linux server and run a script there to do data gathering and parsing not related to Solarwinds.

               

              The overall scope of this is that my company does not allow cron on Linux servers or Windows scheduled jobs (I have no idea why) so we are trying to use Solarwinds jobs as a pseudo-cron.

                • Re: Run Local Script Via NCM Job
                  wluther

                  troyison Ah, I see, so you have your alert action set to execute the batch file, then automatically repeat every hour. I used to do something similar to make sure the alerts were working. (v11.x gave us some troubles and this helped fix it)

                   

                  So, your batch file works fine when executed manually, but fails when ran by the alert. Does the server have permission to execute the file? (I think it uses the Network Services account, or something like that)

                   

                  Which versions of SolarWinds products/Win server are you using? (not that it should matter too much)

                   

                  Can you execute a more basic batch file? Perhaps something that simply makes a new folder, or copies a file? I have configured a few alerts to run various PowerShell scripts, and I had many issues getting everything to work easily.

                   

                  This is what ended up working for me:

                  C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -Command "C:\New-SW_Add_Interface_Graphs_To_View_v2-2_CPvars.ps1 "${N=SwisEntity;M=InterfaceID} ${N=SwisEntity;M=CustomProperties.GraphViewID}  ${N=SwisEntity;M=CustomProperties.GraphType} ${N=SwisEntity;M=CustomProperties.GraphViewIDColumn} ${N=SwisEntity;M=CustomProperties.GraphViewIDRow}

                   

                   

                  And this batch file is located on the same server that is monitoring the node? (You only have 1 polling server?)

                    • Re: Run Local Script Via NCM Job
                      troyison

                      We are on Win 2016, and running Orion 2018 HF6 and NCM 7.8

                       

                      I aslo confirmed that the script is on the same poller as the device (windows server) I am tring to run the script on.

                       

                      I made a small batch file that just runs a mkdir on the device (mkdir E:\Batch_for_Linux\test) which run sucessfully when I run it maunally.  Then I called it using Powershell (C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -Command "E:\Batch_for_Linux\mkdir_test.bat").

                       

                      However, when I run it the log shows:

                       

                      server1 (10.10.10.10):

                      ERROR: Connection Refused by 10.10.10.10
                      ___________________________________________________________________________
                      10/26/2018 3:03:18 PM : Completed mkdir_test
                      Execution time : 0 seconds