Symantec Access Management

Expand all | Collapse all

Automatic restarts of Siteminder Policy services on windows

  • 1.  Automatic restarts of Siteminder Policy services on windows

    Posted 03-22-2016 04:09 AM

    Hi All,

     

    I need to know about automatic restarts of policy server windows services remotely.

     

    1) Do we have any batch file for that , like it should stop services and then wait till process( smpolicysrv.exe) ends and then restarts it on task scheduled day?

    2)If yes please let me have that.

     

    And also please help me knowing more how can we perform automatic restarts of Siteminder policy server services on windows

     

     

     

    Thanks



  • 2.  Re: Automatic restarts of Siteminder Policy services on windows

    Broadcom Employee
    Posted 03-22-2016 01:49 PM

    'smpolicysrv'  is a command-line utility which is delivered with the  CA SSO/Siteminder Policy Server.  you can use the -stop switch to gracefully stop the policy server.

     

    example: smpolicysrv -stop

    NOTE:  There is no switch in smpolicysrv in Windows to start the policy server again.  This stops the server, however the 'smpolicysrv' service remains running.

     

    To stop the smpolicysrv service you could use either the 'net' or 'sc' commands

     

    examples:

    net stop SmPolicySrv

    sc stop SmPolicySrv

     

    Restart the 'smpoicysrv' service

     

    net start SmPolicySrv

    sc start SmPolicySrv

     

    NOTE:  the 'sc' command can be used to stop a service on a remote host.  These can be used in a script and run within Windows Scheduler.



  • 3.  Re: Automatic restarts of Siteminder Policy services on windows

    Posted 03-22-2016 01:55 PM
      |   view attached

    Thanks LAVST01.

     

    I wanted to restart policy server automated after smpolicysrv process is

    killed .

     

    Use case:

     

    1)STOP smpolicysrv

    2)Check smpolicysrv.exe process is running or not, if it is not running

    then restart and if process is running wait for the process to get killed.

    3) Check status whether services running fine

     

     

    Thanks

     

     

     

     

     

    *Ankit Jain *|  IAM Engineer |  +91 9741336404

    Identity:  Secure, Intelligent, Managed

     

    On Tue, Mar 22, 2016 at 11:20 PM, LAVST01 <



  • 4.  Re: Automatic restarts of Siteminder Policy services on windows

    Posted 03-22-2016 05:20 PM

    Hi Ankit,

     

    Start and stop has already been suggested above using

    net start SmPolicySrv

    net stop SmPolicySrv

     

    For status check you can run:

    SmCommand CA.SM::Status

    from the /bin folder and see if that is what you are looking for. You should then be able to run this from a script. It returns a single word 'running' and if the policy server is down then it returns an error saying instance not found.

    (Alternately on Unix you can use smpolsrv -status which returns a line saying whether PS is running or not. Or you could grep on the process possibly.)

     

    Additionally you should also be able to stop and start the rest of the services such as the Monitor Service etc (if you use them) using the same net start/stop commands.

     

    Hope this helps!

    -Huned.



  • 5.  Re: Automatic restarts of Siteminder Policy services on windows

    Posted 03-23-2016 12:25 PM

    We use the following PowerShell script to automate a policy server restart.   We call it from a batch file which runs in the task scheduler (also included below).  I hope this is helpful.

     

    -- Keats

     

    ##

    ##  restartsmps.ps1

    ##  Script to gracefully shutdown and restart the Siteminder policy server process

    ##

     

    ## Generate log file per day

    $Logfile  = "d:\logs\restartsmps$(get-date -f yyyyMMdd).log"

     

    Function writeLog

    {

      Param ([string]$logstring)

      Write-Host "$(Get-Date -Format g) - $logstring"

      If ($Logfile)

      {

      Add-content $Logfile -value "$(Get-Date -Format g) - $logstring"

      }

    }

     

    $processName = "SmPolicySrv"

    # stop service in the background

    Stop-Service -Name $processName -Force -Verbose

    # loop N times and check status for "Stopped"

    For ($i=1; $i -lt 20; $i++) 

    {

      #give it n seconds to stop

      Start-Sleep -Seconds 10

      $SERVICESTATE = (Get-Service | where{$_.Name -eq $processName}).Status

      #Write-Host $i, $SERVICESTATE

      writeLog "Stopping $processName. Attempt $i. Service state=$SERVICESTATE"

      If ($SERVICESTATE -eq "Stopped") { Break }

    }

    $SERVICESTATE = (Get-Service | where{$_.Name -eq $processName}).Status

    If ($SERVICESTATE -eq "Stopped")

    {

      # Give it a few more seconds just to be safe and then restart the service

      Start-Sleep -Seconds 10

      Start-Service -Name $processName

      Start-Sleep -Seconds 5

      $SERVICESTATE = (Get-Service | where{$_.Name -eq $processName}).Status

      writeLog "Restarted service $processName.  Status is now $SERVICESTATE"

    }

    Else

    {

      writeLog "ERROR: Failed to stop service $processName"

    }

     

    ======================================

    :

    : RestartSMPS.bat

    : Batch file to be used from task scheduler for invoking a PowerShell script

    :

    SET SCRIPT_NAME=D:\scripts\restartsmps.ps1

    SET PS_EXE=C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe

    %PS_EXE% -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process %PS_EXE% -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File """%SCRIPT_NAME%""' -Verb RunAs}"