Reply

Perl equivalent for CLI timeout

Authority
Posts: 40
3224     0

Hi Everyone,

In CCS, we have a separate timeout for action trigger, as below

Action-Timeout
60
 

 

Can anyone tell me what is the Perl equivalent for setting CLI time-out?

On some of our devices, "show run" is exceeding the default cli time-out.

 

Thanks,

Rahul

Re: Perl equivalent for CLI timeout

Adviser
Posts: 53
3225     0

Hi Rahul,

 

The following should help.

 

Thanks,

- Chris

 

For Perl scripting, a new send_async_command method has been introduced in 6.9.2 in NetMRI_Easy.pm to support CLI commands that require more than 10 minutes to complete. In 6.9.1, CLI commands would automatically timeout after 10 minutes. Along with the command to send, a timeout is required to indicate the maximum amount of time the command is expected to take. If the command does not complete by the specified timeout, a timeout will occur. A maximum timeout of 4 hours is supported and the timeout is represented in seconds. An example follows:

 

# BEGIN-SCRIPT-BLOCK

# Script-Filter: true

# Script-Timeout: 3700

# END-SCRIPT-BLOCK

 

use strict;

use warnings;

use NetMRI_Easy;

 

my $easy = new NetMRI_Easy({ debug => 1 });

 

# Note that we set the Script-Timeout above to 3700, which is slightly more

# than the send_async_command timeout below of 3600. This is because 1) the

# default Script-Timeout for Perl scripts is 5 minutes, and, 2) if the

# command does take longer than 1 hour to run, we want the command to

# timeout before the script.

 

my $response = $easy->send_async_command(

         "some command that may take up to 1 hour",

         3600);

 

If debug has been enabled via the NetMRI_Easy.pm constructor (see example above), after the script run has completed, output similar to the following can be seen in the Status Log of the Job Details Viewer:

 

DEBUG: Sending asynchronous command (some command that may take up to 1 hour) ... OK

DEBUG: Received async_command_id 5619 ... OK

DEBUG: Getting the status of async_command_id 5619 ... RUNNING

DEBUG: Getting the status of async_command_id 5619 ... RUNNING

DEBUG: Getting the status of async_command_id 5619 ... RUNNING

DEBUG: Getting the status of async_command_id 5619 ... RUNNING

DEBUG: Getting the status of async_command_id 5619 ... RUNNING

DEBUG: Getting the status of async_command_id 5619 ... RUNNING

DEBUG: Getting the status of async_command_id 5619 ... RUNNING

DEBUG: Getting the status of async_command_id 5619 ... RUNNING

DEBUG: Getting the status of async_command_id 5619 ... RUNNING

DEBUG: Getting the status of async_command_id 5619 ... RUNNING

DEBUG: Getting the status of async_command_id 5619 ... OK

 

Showing results for 
Search instead for 
Did you mean: 

Recommended for You