Junos OS

last person joined: 14 hours ago 

Ask questions and share experiences about Junos OS.
  • 1.  Strategy to shutdown some devices at specific time

    Posted 03-08-2016 00:56

    Hi all,

    I would need to automate some devices shutdown at specific time.

    Sorry but I am not so expert.

    I was thinking to create an op script and then schedule its execution via  junos space station but I have no idea if it is possible or not.

    Are there any other solutions?

    If you were me what would you do?

     

    Thank You

     

    Regards

     

    M

     



  • 2.  RE: Strategy to shutdown some devices at specific time

    Posted 03-08-2016 02:16

    Hi mauog,

     

    You can use the " request system power-off at time" command to schedule the shutting down of your devices as long as all their clocks are in sync . You can send the command either through junos space or ssh or any other method.

     

    The time format is as follows :

     

    at time

    (Optional) Time at which to power off the software, specified in one of the following ways:

    • now—Power off the software immediately. This is the default.
    • +minutes—Number of minutes from now to power off the software.
    • yymmddhhmm—Absolute time at which to power off the software, specified as year, month, day, hour, and minute.
    • hh:mm—Absolute time on the current day at which to power off the software.


  • 3.  RE: Strategy to shutdown some devices at specific time

    Posted 03-08-2016 02:19

    * You can also use Ansible if you're up to it.



  • 4.  RE: Strategy to shutdown some devices at specific time

    Posted 03-08-2016 03:23

    I just tryed to figure out some solution thanks to elkadiki.

     

    1) I can create an OP script similar to this one below and then schedule it... it should work

     

    version 1.0;
    ns junos = "http://xml.juniper.net/junos/*/junos";
    ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
    ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";
    import "../import/junos.xsl";
    match / {
    <op-script-results> {
    /* String example */
    var $command = <command> "request system power-off"";
    var $results = jcs:invoke( $command );

    expr jcs:syslog( 145, $results );


    }
    }

     

    2) I could go via ssh to devices running "request system power-off" at time yyddhhmm".

     

    3) I was not able to find how to run the command via junos space. I know that exists looking glass to show some output from devices but you can use it only to a limited set of command whic request is not included in. Coudl you better explain me how can I follow this way?

     

    Thank You

     

    Regards

     

    M



  • 5.  RE: Strategy to shutdown some devices at specific time

    Posted 03-08-2016 03:45

    Hi mauog,

     

    Actually with SSH you don't even have to login and out , if you are on a linux box you can just issue the command to the device over ssh without logging in and out ( you'll have to provide username/password ). There are other tools that allow parallel transmission of commands over ssh like pssh or  ansibile ( there is already a module for it in ansible ), that basically send a command to a list of devices/hosts stored in a file ( hosts file ). If this isn't a one time thing I find command line faster for larger networks.  

     

    *if you found my answer helped solved your problem please mark it as such.

     

     



  • 6.  RE: Strategy to shutdown some devices at specific time
    Best Answer

     
    Posted 03-08-2016 05:39

    Junos Space 14.x and higher already have the functionality to shutdown or reboot multiple devices at a scheduled time.

     

    From within the Device Management view, select the devices that you wish to schedule, then select Actions | Device Operations | Reboot Devices

     

    In the dialog box displayed, expand the "options" and select the checkbox "Power off", optionally enter an appropriate message, then select "Schedule at a later time" and select the appropriate time for the task to be executed.

     

    http://www.juniper.net/techpubs/en_US/junos-space15.1/platform/topics/task/operational/devices-rebooting.html

     

    You could still go the SLAX route and avoid having to deploy a script on each device, as you can have SLAX scripts executed locally on Junos Space and they can then go and "talk to" the selected devices.  This is an approach that I had used prior to the current reboot/power-off functionality being added.  I still have some scripts that are being used for multi-re chassis (MX960 etc) where a user might want to just reboot one of the RE's rather than both etc.

     

    Of course there are a multitude of different approaches for off-box scripts Python/PyEz/SpaceEz/Ansible/Perl/Ruby etc. etc.

     

    Regards,

    Andy