Reply
Highlighted
Accepted Solution

NetMRI Script Output CCS | PERL

dgttn
Techie
Posts: 7
3889     0

Hi,

 

I would like to create a script, CCS or Perl, to analyze the session.log file and verify the banner when the script connects to the device.

For example, I would like to analyze the banner “Nexus 5000 Switch” to create an issue if the banner is “Nexus 6000 Switch”

But can’t I how do that, you can help me ?

 

Best Regards,

Dam

Re: NetMRI Script Output CCS | PERL

Expert
Posts: 227
3890     0

I don't know of a way you can do that in CCS.  It's probably possible in Perl.  But first, I don't follow what you're trying to validate.  Within the config of the switch you have a "banner motd" command which creates the banner to be displayed.  Instead of trying to validate that within a CLI session, why not create a policy which tests for it in the stored running-config and causes a Policy Violation issue to fire if the banner is not correct?

Re: NetMRI Script Output CCS | PERL

Moderator Dave_Signori
Moderator
Posts: 62
3890     0

If you go to Configuration -> Policy Design Center -> Rules and search on Banner, there are some out of the box sample banner rules that could get you started.

 

Dave

@DaveSignori

Re: NetMRI Script Output CCS | PERL

dgttn
Techie
Posts: 7
3890     0

When you create a CCS sript you have a session.log file. So I would like to scan this file for check the content banner. And no create a policy whith the command banner motd.

Re: NetMRI Script Output CCS | PERL

Adviser
Posts: 406
3890     0

Using the API you can do it, this is not my script one of my good buddies

 

#
# Choose a job...
# This just chooses the first successfully completed job for a particular date.  Anything that
# returns a single job will work.
#
 
print "Selecting a job...\n";
my @jobs = $netmri->broker->Job->find({
        op_EndTime => 'like',
        val_c_EndTime => '2014-03-19%',
        op_Status => '=',
        val_c_Status => 'OK'
});
my $job = $jobs[0];
 
print "\nCollecting all.zip files for job ".$job->JobID."...\n";
my @job_details = $netmri->broker->job_detail->index({
        id => $job->JobID
});
 
#
# Loop through the device details records for the chosen job.  For each device, dump the all.zip file.
#
 
foreach my $jd (@job_details){
        $devid = $jd->{device}->DeviceID;
        $ipaddr = $jd->{device}->DeviceIPDotted;
        $localfilename = $job->JobID."_".$ipaddr."_all.zip";
        print "DeviceID=$devid\tIP=$ipaddr\t\tFilename: $localfilename...\n";
        open (OUTFILE, ">>$localfilename");
        $file = $netmri->broker->job_detail->device_files({
                id => $job->JobID,
                deviceid => $devid,
                filename => "all.zip"
        });
        print (OUTFILE $file);
        close (OUTFILE);
}
 
Follow me on LinkedIn: https://www.linkedin.com/in/sifbaksh
Twitter: https://twitter.com/sifbaksh

Re: NetMRI Script Output CCS | PERL

dgttn
Techie
Posts: 7
3890     0

Thank you Sif !

Showing results for 
Search instead for 
Do you mean 

Recommended for You