in More Search Options

Restart Service if down

Last post 02-08-2008 11:06 by aLTeReGo. 30 replies.
Page 1 of 2 (31 items) 1 2 Next >
Sort Posts:
  • 08-21-2007 2:01 PM

    • JustinY
    • Top 500 Contributor
    • Joined on 07-27-2007
    • Posts 28
    • Points 66

    Restart Service if down

    Has anyone been able to restart the service if its down?

     I created an action to execute an external program that looks something like this

    "sc.exe \\${Node.DNS} start ${ApplicationName}" now if it actually type that in a cmd prompt and substitute Node.DNS for the DNS name of the server with the application down, and substitute ApplicationName for the name of the service Im trying to start it works.  However it does not seem to be working through Orion.

    • Post Points: 10
  • 08-23-2007 10:08 In reply to

    • ceclark
    • Top 50 Contributor
    • Joined on 09-16-2004
    • Posts 202
    • Points 383

    Re: Restart Service if down

     Is sc.exe in your path? I'm not sure where the script is run from, but you might want to try and use the full path to sc.exe.

     

    • Post Points: 3
  • 08-23-2007 11:26 In reply to

    • JustinY
    • Top 500 Contributor
    • Joined on 07-27-2007
    • Posts 28
    • Points 66

    Re: Restart Service if down

    I got a reply from support.  You currently cannot pass variables to an external program as parameters.

    • Post Points: 5
  • 08-25-2007 9:00 In reply to

    • rgward
    • Top 25 Contributor
    • Joined on 09-02-2003
    • USA
    • Posts 230
    • Points 533

    Re: Restart Service if down

    Justin, did support say when the functionality might be added?  8.5 or 8.6?

    • Post Points: 1
  • 08-28-2007 7:26 PM In reply to

    • aLTeReGo
    • Top 10 Contributor
    • Joined on 01-31-2004
    • 127.0.0.1
    • Posts 863
    • Points 2,421

    Re: Restart Service if down

    JustinY:

    I got a reply from support.  You currently cannot pass variables to an external program as parameters.

     

    That's pretty disappointing. I'm also interested in this functionality.

    • Post Points: 3
  • 12-17-2007 10:21 In reply to

    • WINNT
    • Top 75 Contributor
    • Joined on 06-22-2004
    • USA
    • Posts 99
    • Points 580

    Re: Restart Service if down

    You can pass variables to external programs.  This has worked at least since v7.  I have done this with sc.exe.  Let me know if you need the syntax. 

    • Post Points: 5
  • 12-17-2007 10:29 In reply to

    • torrielw
    • Top 50 Contributor
    • Joined on 05-23-2007
    • Raleigh NC
    • Posts 178
    • Points 432

    Re: Restart Service if down

    I'm interested in the syntax.

     

    Thanks

    • Post Points: 1
  • 12-17-2007 11:34 In reply to

    • JustinY
    • Top 500 Contributor
    • Joined on 07-27-2007
    • Posts 28
    • Points 66

    Re: Restart Service if down

    I would deffinatly like to know the syntax.  If its possible Im supprised that support didnt know about it.

    • Post Points: 3
  • 12-17-2007 4:30 PM In reply to

    • EMetro
    • Top 500 Contributor
    • Joined on 09-25-2007
    • Houston
    • Posts 24
    • Points 58

    Re: Restart Service if down

     on a similar note...

    My situation is that I know the application that launches the process and wish to "launch external application" by way of an advanced alert.  When I choose, "launch external application", It only seems to like apps located on the polling machine. I can't navigate through the "My Network Places" to find it, and entering a string using the IP doesn't seem to work. 

     

    I think I might be having a holiday brain failure, but I welcome any help that might be given.

    Any ideas?   

    _____
    ED
    • Post Points: 1
  • 12-18-2007 9:00 In reply to

    • WINNT
    • Top 75 Contributor
    • Joined on 06-22-2004
    • USA
    • Posts 99
    • Points 580

    Re: Restart Service if down

    I created a folder named AlertActions where I keep my batch files and executables. 

    Here is the alert action:

    "D:\Program Files\SolarWinds\Orion\AlertActions\StartService_YourServiceName.bat" ${NodeName}

    The batch file looks like this:

    ------------------- cut ------------------

    sc \\%1 start YourServiceName

    --------------- end cut    -------------

    If you need access to start the service on a remote machine, you need to add the orion server as an admin on the remote server, or create an admin account that you can connect with and add to your batch file like this:

    ------------------- cut ------------------

    net use \\%1 /user:domain\user password

    sc \\%1 start YourServiceName

    net use \\%1 /d

    --------------- end cut    -------------

    Here is an example with an actual service name:

    "D:\Program Files\SolarWinds\Orion\AlertActions\StartService_Spooler.bat" ${NodeName} 

    ------------------- cut ------------------

    ::Make a connection to the remote Windows computer 

    net use \\%1 /user:CORP\Orion S0m3W0rd

    ::Start the Windows print spooler service

    sc \\%1 start Spooler

    ::Clean-up the connection (optional)

    net use \\%1 /d

    --------------- end cut    -------------

    If you want to go the net use route, you might want to convert the batch file to VB and then encrypt the file, or use Windows encryption on the batch file.

    Hope this helps.

    • Post Points: 5
  • 12-24-2007 3:27 PM In reply to

    • JustinY
    • Top 500 Contributor
    • Joined on 07-27-2007
    • Posts 28
    • Points 66

    Re: Restart Service if down

    Hey thanks.  Thats pretty helpful actually.  I tried to use that from the Syslog alert, but it does not support variables like the monitor does.  Thats a feature that would be nice.

    I was trying to use the Syslog alerts to detect issues on our desktops, and write scripts to automatically correct the problem.  The scripts work.  If I pass the hostname as a parameter into my script it fixes the problem automatically, but the Syslog alerts just pass ${NodeName} into the script.  Bummer

    • Post Points: 1
  • 12-27-2007 2:56 PM In reply to

    • EMetro
    • Top 500 Contributor
    • Joined on 09-25-2007
    • Houston
    • Posts 24
    • Points 58

    Re: Restart Service if down

    /scratchhead...

     

    Now.. I've created a .bat file on the local machine.  Tested it and it works.   My problem with SolarWinds persists though.   My alarm is set to run the .bat file, but it doesn't seem to trigger.  The email comes through, the alarm is 'working'.   When I run a test on the alarm, it says it's successful, but the file never actually runs.

    Any Ideas as to why SolarWinds might have a problem with running a .bat file?

     

    _____
    ED
    • Post Points: 3
  • 12-28-2007 9:35 In reply to

    • WINNT
    • Top 75 Contributor
    • Joined on 06-22-2004
    • USA
    • Posts 99
    • Points 580

    Re: Restart Service if down

    What is the action you are running?  It might have something to do with spaces in the command, or permissions.

    • Post Points: 3
  • 12-28-2007 2:19 PM In reply to

    • EMetro
    • Top 500 Contributor
    • Joined on 09-25-2007
    • Houston
    • Posts 24
    • Points 58

    Re: Restart Service if down

    In the case the service is determined to be stopped, the actions are to execute a .bat file with the following syntax followed by generating an email.

    psservice \\computerip -u logonid -p password start "service name"


    When the .bat file is run manually, the service starts. 

    When the alarm is tested, the test log indicates the file has been run successfully and an email is received, however, the service is not started. 

    Lastly, if the alarm is tested by way of actual functionality (stopping the service manually while the alarm is set), again, the email is received, yet the service is not started. 
     

    _____
    ED
    • Post Points: 3
  • 12-28-2007 3:47 PM In reply to

    • WINNT
    • Top 75 Contributor
    • Joined on 06-22-2004
    • USA
    • Posts 99
    • Points 580

    Re: Restart Service if down

    I was more interested in the exact text of the Orion action.  Does is look something like this?

     "D:\Program Files\SolarWinds\Orion\AlertActions\TracertDownNode-ALERT.bat"  ${NodeName}

    In your case:

     "D:\Program Files\SolarWinds\Orion\AlertActions\StartService-ALERT.bat"  ${IP_Address}

    Are you also passing the service name as a variable or is that hard-coded in your batch file? 

     

     

     

     

     

     

    • Post Points: 3
  • 01-03-2008 1:24 PM In reply to

    • EMetro
    • Top 500 Contributor
    • Joined on 09-25-2007
    • Houston
    • Posts 24
    • Points 58

    Re: Restart Service if down

    Sorry for the delay in getting back to this... holidays plus work always make things interesting.  Hope y'all had a safe past few weeks.

    As for the problem, it still persists.  

    In test, I have a .bat file on my local machine that starts a service.
    When run, it works properly. The batch file is very simple... it just says:
    net start "service name"

    In SolarWinds, I have my alert set up to Email myself and then run the batch file.
    So far... the email is sent properly, but the batch file doesn't run.
    This is what the test log says... which indicates success, however, the service still isn't starting.

    _____
    1/3/2008 12:36:44 PM:    Initiating test for alert EM19 Test Alerts.
    1/3/2008 12:36:44 PM:    Retrieved 2 actions for alert EM19 Test Alerts.
    1/3/2008 12:36:44 PM:    Preparing action type EMail to test alert EM19 Test Alerts.
    1/3/2008 12:36:44 PM:    Email '$(AlertTriggerName}' from '$(AlertTriggerName}' to '"EM19 Process Test" <nobody@nobody.com>' has been successfully handed to the local mail handler for alert EM19 Test Alerts.
    1/3/2008 12:36:44 PM:    Action type EMail for alert EM19 Test Alerts completed successfully.
    1/3/2008 12:36:44 PM:    Completed action type EMail for alert EM19 Test Alerts.
    1/3/2008 12:36:44 PM:    Preparing action type ExecuteProgram to test alert EM19 Test Alerts.
    1/3/2008 12:36:44 PM:    Alert EM19 Test Alerts: Success - "\\computername\availablesharedfolder\Test.bat"
    1/3/2008 12:36:44 PM:    Action type ExecuteProgram for alert EM19 Test Alerts completed successfully.
    1/3/2008 12:36:44 PM:    Completed action type ExecuteProgram for alert EM19 Test Alerts.
    1/3/2008 12:36:44 PM:    Completed test for alert EM19 Test Alerts.
    _____ 

     

    Per usual, I appreciate any advice
     

    _____
    ED
    • Post Points: 5
  • 01-03-2008 1:49 PM In reply to

    • aLTeReGo
    • Top 10 Contributor
    • Joined on 01-31-2004
    • 127.0.0.1
    • Posts 863
    • Points 2,421

    Re: Restart Service if down

    The bat file is being executed in the security context of service. In this case it's the local system account. The local system account does not have sufficient privileges to access the remote computer \\computername. The reason this is working when you run the bat file is because your account has the privileges necessary to access the BAT file on the remote share.

    Hope this helps.

    • Post Points: 3
  • 01-03-2008 2:09 PM In reply to

    • EMetro
    • Top 500 Contributor
    • Joined on 09-25-2007
    • Houston
    • Posts 24
    • Points 58

    Re: Restart Service if down

    This being the case, any suggestions on how to enter credentials to allow this to work?

     

    _____
    ED
    • Post Points: 3
  • 01-03-2008 2:23 PM In reply to

    • aLTeReGo
    • Top 10 Contributor
    • Joined on 01-31-2004
    • 127.0.0.1
    • Posts 863
    • Points 2,421

    Re: Restart Service if down

    I would recommend you look into the "runas" command.

    • Post Points: 1
  • 01-04-2008 7:04 In reply to

    • WINNT
    • Top 75 Contributor
    • Joined on 06-22-2004
    • USA
    • Posts 99
    • Points 580

    Re: Restart Service if down

    I don't quite follow.  The alert action is supposed to execute a batch file located on a remote system that starts a service on the Orion server?  The syntax NET START only works on the computer running the command.  If you want to start a service on a remote computer you will need SC.exe or PSSERVICE.exe. 

    • Post Points: 3
Page 1 of 2 (31 items) 1 2 Next >