Junos
Highlighted
Junos

OP Script for crash info

‎11-19-2007 03:24 PM
Anybody try to use OP script for display crash info file?
 
  <op-script-results> {
        var $rpc = <get-directory-list> {
                   <root-path="/var/crash/">;
        }
How can you tell script to pull file from root-path?
 
Thanks,
 
 
 
8 REPLIES 8
Highlighted
Junos

Re: OP Script for crash info

‎11-20-2007 07:20 AM
Hi,

You could use

$filename = $rpc[directory-name="/var/crash/"]/directory-name/file-information/file-name;

to obtain the each filename. You'd need to run through the directory with a for-each to get at each one.

Rgds,

Guy
---
Guy Davies
Highlighted
Junos

Re: OP Script for crash info

‎11-20-2007 07:24 AM
An easy way to see the output that you're looking for is to do the following at the CLI.

file list /var/crash | display xml

That gives you the output you need to match against. Oh, and it should be 'var $filename = ...' in the response above.

Rgds,

Guy
---
Guy Davies
Highlighted
Junos

Re: OP Script for crash info

[ Edited ]
‎11-20-2007 11:46 AM
Hi,
 
error: Invalid type
error: xmlXPathCompiledEval: 1 object left on the stack
 
 for-each ($list=$rpc[directory-name="/var/crash/"]/directory-na
me/file-information/file-name){
                 <file-information>{
                           <file-name>file-name; copy-of .;
 
I am trying to combine several CLI (like sh bgp nei | resolve, sh ospf nei | resolve, and crash file.. etc) to use as initial troubleshoot tool.
 
Any recommendation?
Oh, I just need display file name ( <file-name>core-CSBR0.core.0</file-name>)....
thx,
 


Message Edited by pynoc on 11-20-2007 11:48 AM
Highlighted
Junos

Re: OP Script for crash info

‎11-21-2007 12:38 AM
Hi Pynoc,

This appears to be two separate requirements.

1. display the filenames.
2. display some output from regular commands (I'm not sure if you want to modify the output or just output it as is).

Both should be relatively trivial.

You've just included snippets of SLAX so far. If you've written a complete script, could you post it and I'll try to work out where any issues lie. I'm afraid I'm a bit busy to actually write examples at the moment.

Rgds,

Guy
---
Guy Davies
Highlighted
Junos

Re: OP Script for crash info

‎12-04-2007 10:54 AM
Hi,
Thanks for tip for syslog and file list script.
Now I am back to script and ask another favor for debug my bgp script...Smiley Very Happy
No error msg with script but No output display..Smiley Sad
I feel like dummy with if statement, would let me know why...
Thanks,
Peter
 
 
with XML....
<?xml version="1.0" standalone="yes"?>
  <xsl:import href="../import/junos.xsl"/>
  <xsl:template match="/">
    <op-script-results>
      <xsl:variable name="bgp" select="jcs:invoke('get-bgp-information')"/>
      <output>
         <xsl:for-each select="$bgp/bgp-peer">
            <xsl:choose>
               <xsl:when test="peer-state = 'Active'">
                   <xsl:value-of select="peer-address"/>
                      <xsl:text></xsl:text>
                   <xsl:value-of select= "elapsed-time"/>
                      <xsl:text></xsl:text>
                   <xsl:value-of select= "peer-state"/>
                      <xsl:text></xsl:text>
                </xsl:when>
               <xsl:when test="peer-state ='10.191.96.30'">
                   <xsl:value-of select="peer-address"/>
                      <xsl:text></xsl:text>
                   <xsl:value-of select= "elapsed-time"/>
                      <xsl:text></xsl:text>
                   <xsl:value-of select= "peer-state"/>
                      <xsl:text></xsl:text>
                </xsl:when>
               <xsl:when test="peer-state = '10.191.96.31'">
                   <xsl:value-of select="peer-address"/>
                      <xsl:text></xsl:text>
                   <xsl:value-of select= "elapsed-time"/>
                      <xsl:text></xsl:text>
                   <xsl:value-of select= "peer-state"/>
                      <xsl:text></xsl:text>
                </xsl:when>
                <xsltherwise></xsltherwise>
            </xsl:choose>
          </xsl:for-each>
        </output>
      </op-script-results>
   </xsl:template>
</xsl:stylesheet>
 
Try with SLAX......
version 1.0;
import "../import/junos.xsl";
param $state = "Active";
param $rtc_id = "10.191.96.31";
param $utc_id = "10.191.96.30";
match/ {
    <op-script-results> {
            var $rpc = <get-bgp-information>{
                  <brief>;
                     if ($state){
                         <peer-state> $state;
                     }
                     if ($rtc_id){
                         <peer-address> $rtc_id;
                     }
                     if ($utc_id){
                         <peer-address> $utc_id;
                     }
             }
            var $bgp= jcs:invoke($rpc);
            <bgp-information junos:style="brief">{
                for-each ($bgp/bgp-information/bgp-peer[peer-state == $state]){
                    <bgp-information> {
                         <peer-address> ../peer-state; copy-of .;
                    }
                }
               for-each ($bgp/bgp-information/bgp-peer[peer-address == $rtc_id]){
                     <bgp-information>{
                         <peer-address> ../peer-state; copy-of .;
                     }
               }
               for-each ($bgp/bgp-information/bgp-peer[peer-address == $utc_id]){
                      <bgp-information>{
                         <peer-address> ../peer-state; copy-of .;
                      }
               }
            }
     }
}
 
Highlighted
Junos

Re: OP Script for crash info

‎12-05-2007 06:43 AM
Hi Peter,

I'm afraid I'm struggling to see what you're trying to do with this script. Can you describe your requirements and I'll see what we can try to do with your script 🙂

Rgds,

Guy
---
Guy Davies
Highlighted
Junos

Re: OP Script for crash info

‎12-05-2007 06:52 AM
Hi,
I want to see Active bgp peer neighbor if any and rtc_id & utc_id (my route reflector: .30 & .31) bgp peer and uptime status.
 
Thanks,
Peter
 
Highlighted
Junos

Re: OP Script for crash info

‎12-06-2007 03:04 AM
Hi Peter,

If you just want to output that bad things are happening (because your session is Active) then the attached script will do. It will always output the actual state of each neighbour.

Rgds,

Guy
---
Guy Davies

Attachments

Feedback