I am new to NCM but fairly proficient as a script writer and have questions concerning running scripts written in Perl language on NCM. I wrote a simple script that incorporates loops to allow repitition of input. However since NCM generates a form based on the script, I am not sure of what to expect. Any ideas? Thanks for the expected response(s).
You can enhance CiscoWorks NCM usage through scripting with Diagnostics (the automation of 'show commands' and other CLI input) or Custom Command Scripts, which can automate 'show commands' or even do config changing work, if you require.
The basics are these - if you don't specify 'Advanced Script', then you're essentially doing a basic script which does not allow a programmatic language. Perl and TCL/Expect are pre-supplied, but you can incorporate any other command language the underlying operating system can support. A basic script must execute the native language of managed device and NCM handles all the login and prompt handling.
This would be an example of a non-advanced Diagnostic or custom command script that did something with NTP
show ntp association
show ntp status
Now, if you want to do something more programmatic with that, like parsing the results and/or taking action, then you'd need to use the Advanced Scripting option and tell NCM you want to use Perl.
At that point you have to handle the device connectivity (spawn a telnet/SSH), handle the logins and prompts from your script.
In the example above we might write a script that does SSH, handles the banner and prompt determination, executes a 'show ntp status' and parses the output for 'Unsynchronized' or 'stratum 16'.
The 'form' that you allude to is simply the place that you put your Perl code. There are other fields inside the Job/Task creation screen where you can supply arguments/flags to your script (eg. debug flag, etc).
All script input must be collected at the beginning - once the script is running we can't take additional input.
All script output goes to the STDOUT which is the results screen of the job. Of course, you can also send output to files, etc.
I hope that helps, if I need to elaborate on anything, let me know!
Thanks for clarifying the perspective Jason. You mentioned "All script input must be collected at the beginning - once the script is running we can't take additional input". I wouldn't want to sound redundant but just to clarify, does this imply that loops cannot be used to retrieve input since the script must be running so as to loop?
That is essentially correct. All user input needs to be gained at the beginning of the process. Now, if you design your script to take 'input' from reading a file or such, that's fine, but there's no way to return to the web UI and ask the user for additional input while the script is running.
For example, I wrote a script that automated some software image update process [yes, I know that NCM can do software upgrades, but we wanted a specific process and use of transport protocols]... We asked the user for input through the web UI upfront...
Very well put Jason. In that case we shall try to leverage the input using .csv files. What is proposed is to utilize a perl program to generate the .csv files and feed it into the NCM. However I must ask the question of multiple .csv files used to accommodate the various parameters as some are fixed and others rely on looped input. What is the potential of this idea and do you have any sample scripts that utilize multiple .csv files for varying inputs?
Hi everyone, I would like to thank you in advance for any help you can provide a newcomer like myself!
Im studying the 100-105 book by Odom and am currently on the topic of Port security. I purchased a used 2960 and I'm trying to follow a...
While deploying a number of 18xx/2802/3802 model access points (APs), which run AP-COS as their operating platform. It can be observed on some occasions that while many of their access points were able to join the fabric WLC withou...
I am going to design and build an LAN network under a tunnel underground with long distance between the switches.
I will have 2 Catalyst switches and 8 Industrial IE3000, and they will be connected with fiber.
For now I am planning on use Layer-2 s...