Junos OS saves the current core file (0) and the four previous core files, which are numbered from 1 through 4 (from newest to oldest): Note. By default, all members of a configured user group (with read-only permissions) can access the core dump files and attach them to cases associated with JTAC.
What I like about JUNOS is that it’s designed with programmability in mind. All the show commands have xml output that can be requested using RPC. They also have rich and well-documented APIs and python library(PyEZ). Possibilities are endless once we have the XML output. You can write apps and integrate the Junos API within.
BeatifulSoup4 is a popular library used to parse data out of XML and HTML markup. We’ll use BS4 to extract information out of JUNOS RPC-Reply which encoded in XML. I have following RPC string which displays the output of “show system core-dumps”. Basically, I want to get the list of core-dump files and time they were generated.
We’ll import the bs4 module. For the purpose of this post, XML Reply is stored as a string but you can request the output using JUNOS PYEZ module.
Initialize the Soup class.
select()
method returns a list containing BeautifulSoup objects which identifies multiple occurrence of the specified tag, within the XML hierarchy. Let’s extract the content of file-information tag, which contains core-dump file-name and the time the it was generated.![Analysis Analysis](/uploads/1/2/6/3/126343573/229533708.jpg)
As you can see, the
select()
method has returned a list with a single BeautifulSoup element, since our reply contained output with a single file. To further extract the file-name and file-information; we’ll call the select method of the element.To extract the text payload of the tags we’ll use the
get_text()
method of the elements.That gave us the file name, which identifies the core-dump file name and path, and file-date, which contains the time the core-dump file was generated in EPOCH format.
This was just a POC but you can do anything with this information. Encode it into a JSON and throw it at your javascript frontend or store it into a database.. possibilities are endless!
JUNOS XML RPC Reply can be parsed using BeautifulSoup to extract specific information out of the reply. This is extremely useful, especially if you want to deploy your own application which interfaces with the network.