This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Is it possible to run multiple commands via one command in a device template

I ask because I am running a compliance report on f5's and there are 2 commands necessary to run to get all the text output I need to satisfy my policy reporting.

For example looking at this from a cisco perspective, if I wanted to include the outputs from a 'show run' and a 'show version' in the one backed up "config" I would attempt to change my device template as below...

<!-- edited with XML Spy v4.4 U (http://www.xmlspy.com) by () -->

<!--SolarWinds Network Management Tools-->

<!--Copyright 2005 SolarWinds.Net All rights reserved-->

<Configuration-Management Device="Cisco Devices" SystemOID=" 1.3.6.1.4.1.9">

<Commands>

<Command Name="RESET" Value="terminal width 0${CRLF}terminal length 0"/>

<Command Name="Reboot" Value="reload${CRLF}y${CRLF}y"/>

<Command Name="EnterConfigMode" Value="config terminal"/>

<Command Name="ExitConfigMode" Value="end"/>

<Command Name="Startup" Value="startup"/>

<Command Name="Running" Value="running"/>

<Command Name="DownloadConfig" Value="Show run${CRLF}sh ver"/>

<Command Name="UploadConfig" Value="${EnterConfigMode}${CRLF}${ConfigText}${CRLF}${ExitConfigMode}"/>

<Command Name="DownloadConfigIndirect" Value="copy ${ConfigType} ${TransferProtocol}://${StorageAddress}/${StorageFilename}${CRLF}${CRLF}${CRLF}"/>

<Command Name="UploadConfigIndirect" Value="copy ${TransferProtocol}://${StorageAddress}/${StorageFilename}  ${ConfigType}${CRLF}${CRLF}"/>

<Command Name="DownloadConfigIndirectSCP" Value="copy ${ConfigType} ${TransferProtocol}://${SCPServerUserName}@${SCPStorageAddress}/${StorageFilename}${CRLF}${CRLF}${CRLF}${CRLF}${SCPServerPassword}"/>

<Command Name="UploadConfigIndirectSCP" Value="copy ${TransferProtocol}://${SCPServerUserName}@${SCPStorageAddress}/${StorageFilename}  ${ConfigType}${CRLF}${CRLF}${SCPServerPassword}"/>

<Command Name="EraseConfig" Value="write erase${CRLF}Y"/>

<Command Name="SaveConfig" Value="write memory"/>

<Command Name="Version" Value="show version"/>

</Commands>

</Configuration-Management>

However when I try this, I am only getting back the results of a 'show run' so my guess is that when Solarwinds sees the ${CRLF} it executes that as an 'enter' command and doesn't execute the 'show ver' that follows. Any ideas on how to get the output from 2 commands in to the one back-up file?

Cheers

  • Take a look at that

    You Can have many different commands in the same template

    just not not in the line...

    Juniper Devices-1.3.6.1.4.1.2636 with show chassis hardware

  • You can setup just about anything. I've created enough variables in templates to configure box A and B of VSS or HSRP Pair to setup both boxes with a single template.

    Just build out what you need in the template, and Test. Always Test first. emoticons_wink.png

    I think your setup looks good, part of your setup is matched in an example here : NCM Device Command Templates - SolarWinds Worldwide, LLC. Help and Support

    It looks like you might have seen this already; Creating a new NCM Device Template explained - SolarWinds Worldwide, LLC. Help and Support

  • Thanks guys - I was able to run two commands via the download config button like this....

        <Command Name="DownloadConfig" Value="${echo yes | tmsh list}${CRLF}${ExitConfigMode}${CRLF}${tmsh list sys httpd max-clients}${CRLF}" />

    within this...

    <Configuration-Management Device="F5" SystemOID=" 1.3.6.1.4.1.3375">

      <Commands>

        <Command Name="RESET" Value="" />

        <Command Name="UseExactPromptMatch " Value="true" />

        <Command Name="Reboot" Value="" />

        <Command Name="RebootAt" Value="" />

        <Command Name="EnterConfigMode" Value="" />

        <Command Name="ExitConfigMode" Value="exit" />

        <Command Name="Startup" Value="list" />

        <Command Name="Running" Value="list" />

        <Command Name="DownloadConfig" Value="${echo yes | tmsh list}${CRLF}${ExitConfigMode}${CRLF}${tmsh list sys httpd max-clients}${CRLF}" />

        <Command Name="UploadConfig" Value="" />

        <Command Name="DownloadConfigIndirect" Value="" />

        <Command Name="UploadConfigIndirect" Value="" />

        <Command Name="EraseConfig" Value="" />

        <Command Name="SaveConfig" Value="" />

        <Command Name="Version" Value="" />

        <Command Name="EnableCommand" Value="bash" />

        <Command Name="echo yes | tmsh list" Value="echo yes | tmsh list" />

        <Command Name="tmsh list sys httpd max-clients" Value="list sys httpd max-clients" />

      </Commands>

    </Configuration-Management>

    ​Unfortunately, NCM is only showing the output from the first command in the downloaded config file. I can see the second command running successfully in the session trace but it's not included in the output. I'd consider raising a case on this but I am fairly sure that support will come to the same conclusion as I have

  • In addition - unfortunately, I couldn't see the output of my second command in the 'downloaded config' file although I could see the command being ran in the session trace. It looks to me that NCM just grabs the output of the first command and saves that as a config and won't save the poutput from multiple commnds in a config file. I was thinking about raising a case on this but I am sure that support will come to the same conclusion as I have

  • noobes​ I had actually been having the same issue with out Accedian devices. For whatever reason, there is a specific connection that goes stale, holding the "writelock" permission. On these devices, you cannot see the config unless you have that "writelock" permission. So, in order to do this, when attempting to download the config, I needed to first run the "session writelock" command to gain the permission. Following that, I could then run the "config export" command (equivalent to Cisco's "show run"), which would allow me to get the config.

    I was running into the same problem as you, where NCM would process my device template, running the "session writelock" command, followed by the "config export" command, yet would only ever save the results from the first command. (which obviously does me no good...) The trace files, on the other hand, showed both commands were running, and everything I would have expected to see in the config was sitting right there in the trace log. After some back and forth with support and dev, they finally came back with a super easy way to fix this issue. Now, when NCM downloads the device config, it runs both commands, and the output from the second command is saved into the config type/file.

    Now that you have my backstory, here is the response from support which solved my problem.

    Let us modify the device template.
    ###########################
    add the command:

    <Command Name="UseMultipleDownloadCommands" Value="True" />

    Remove:
    <Command Name="WriteLock" Value="session writelock" />

    Change:
    <Command Name="DownloadConfig" Value="${WriteLock}${CRLF}${ConfigType}" />
    to
    <Command Name="DownloadConfig" Value="session writelock${CRLF}configuration export" />

    Note:

    Without the command Use Multiple download commands, NCM stops after session writelock,
    ###########################

    I'm not 100% this is the absolute best path for you to take, though, I figured I'd put it out there just in case. I had been searching for this solution for a while, looking through countless support docs and Thwack posts. Somehow, I never saw anything that mentioned the use, or even existence, of the "UseMultipleDownloadCommands" command. Yet, after the fact, now knowing what I am looking for, with a simple Thwack/Google search, and a little bit of hindsight, I have found numerous examples.

    Use multiple commands to backup a single configuration - SolarWinds Worldwide, LLC. Help and Support

    Downloading Context from devices as of NCM 7.4.x - SolarWinds Worldwide, LLC. Help and Support

    Cannot download a configuration from a Gigamon device - SolarWinds Worldwide, LLC. Help and Support

    McAfee Firewall Enterprise Secure Computing Sidewinder 8.3.2 NCM Template

    Re: NCM device template - HP1950

    It seems whoever said, "Experience is something you get just AFTER you need it.", was spot on...

    Anyway, I hope this helps.

    Thank you,

    -Will

  • Thanks for that! "Experience is something you get just AFTER you need it." = bang on! I'll give that a try. So the writelock command is something on the Solarwinds side? If not, I'm not sure this will help me as the devices I am trying to run multiple commands on are F5's.

  • noobes​ No, the writelock command is just something my specific device (Accedian Nid) requires before being able to show the config. On the SolarWinds side of things, I think you would be looking for the "UseMultipleDownloadCommands" option. With that enabled, you should be able to capture the results of multiple commands being run within the "DownloadConfig" option.

    So, with the following 2 options in your device template, you should be able to download the config, which would contain the results/output of each command ran within the DownloadOption below.

    <Command Name="UseMultipleDownloadCommands" Value="True" />
    <Command Name="DownloadConfig" Value="command number 1 here${CRLF}command number 2 here${CRLF}command number 3 here${CRLF}etc..." />

    I was just using my Accedian experience as my example, as it basically required 2 completely different commands to be ran in order to get the correct config output to be saved. Adding the usemultiple command is the key to saving the output from each command called inside the downloadconfig option.

    Let me know how it goes.

    Thank you,

    -Will

  • Thanks Will - seems like all my commands are running twice now?...

    Here's the debug output below, the keyword I'm guessing is 'bad substitution'

    *** OnConnect received, err = 0

    Access is restricted to authorised users only.

    srv_Solarwinds@(DeviceName)(cfg-sync In Sync)(Standby)(/Common)(tmos)#

    srv_Solarwinds@(DeviceName)(cfg-sync In Sync)(Standby)(/Common)(tmos)#

    srv_Solarwinds@(DeviceName)(cfg-sync In Sync)(Standby)(/Common)(tmos)# bash

    bash

    [srv_Solarwinds@DeviceName:Standby:In Sync] ~ #

    [srv_Solarwinds@DeviceName:Standby:In Sync] ~ #

    [srv_Solarwinds@DeviceName:Standby:In Sync] ~ # ${echo yes | tmsh list}

    ${echo yes | tmsh list}

    bash: ${echo yes | tmsh list}: bad substitution

    [srv_Solarwinds@DeviceName:Standby:In Sync] ~ #

    [srv_Solarwinds@DeviceName:Standby:In Sync] ~ # ${tmsh list sys httpd max-clients}

    ${tmsh list sys httpd max-cl

    ients}

    bash: ${tmsh list sys httpd max-clients}: bad substitution

    [srv_Solarwinds@DeviceName:Standby:In Sync] ~ #

    [srv_Solarwinds@DeviceName:Standby:In Sync] ~ #

    *** OnConnect received, err = 0

    Access is restricted to authorised users only.

    srv_Solarwinds@(DeviceName)(cfg-sync In Sync)(Standby)(/Common)(tmos)#

    srv_Solarwinds@(DeviceName)(cfg-sync In Sync)(Standby)(/Common)(tmos)#

    srv_Solarwinds@(DeviceName)(cfg-sync In Sync)(Standby)(/Common)(tmos)# bash

    bash

    [srv_Solarwinds@DeviceName:Standby:In Sync] ~ #

    [srv_Solarwinds@DeviceName:Standby:In Sync] ~ #

    [srv_Solarwinds@DeviceName:Standby:In Sync] ~ # ${echo yes | tmsh list}

    ${echo yes | tmsh list}

    bash: ${echo yes | tmsh list}: bad substitution

    [srv_Solarwinds@DeviceName:Standby:In Sync] ~ # exit

    exit

    exit

    srv_Solarwinds@(DeviceName)(cfg-sync In Sync)(Standby)(/Common)(tmos)# ${tmsh list sys httpd max-clients}

    ${tms  h list sys httpd max-clients}

    Syntax Error: unexpected argument "$"

    srv_Solarwinds@(DeviceName)(cfg-sync In Sync)(Standby)(/Common)(tmos)#

    srv_Solarwinds@(DeviceName)(cfg-sync In Sync)(Standby)(/Common)(tmos)#

  • noobes​ Well, I'm not sure why it would double up there, but perhaps we can work through this by stripping things down to basics. Have you tried to bypass all the macros? If not, try the following:

    Not being familiar with your equipment, and the commands required to accomplish your task, do you actually need to exit the config mode after the first command? If so, how/where are you getting into config mode if that command is the first thing ran?

    If you do NOT need to exit config mode, try this:

    <Command Name="DownloadConfig" Value="echo yes | tmsh list${CRLF}tmsh list sys httpd max-clients" />

    And, of course, If you DO need to exit config mode, try this:

    <Command Name="DownloadConfig" Value="echo yes | tmsh list${CRLF}exit${CRLF}tmsh list sys httpd max-clients" />

    After making one of those changes, try to download the running/startup config again (it shouldn't matter which, as the option should be hardcoded to the actual command now).

    Hopefully that will tell us something useful. Otherwise, I reckon we can find the local brain trust and see what they have to say.

    Thank you,

    -Will