How Expect plugin woks under Nagios

Stanley Hopcroft stanleyhopcroft at gmail.com
Thu Aug 31 05:29:51 CEST 2006


Dear Sir,

I am writing to thank you for your letter and say,

On 31/08/06, Horvath Tamas <zsitfa at t-online.hu> wrote:
> Hi!
>
> I wrote an expect plug-in to check PIX startup config checksum.
>
> It works from command line when I started it as nagios user.
>
> But it does not work from Nagios.

Yep. They work as well as TCL/Expect in my dull hands can be 'expected' to.

My suggestion is you don't want the pain of spawn, send, expect partic
with the quoting nightmare and TCL to boot.

Have a look at Net::Telnet::Cisco eg to pluck out DTP negotiation from trunks


  $x = Net::Telnet::Cisco->new(         Host    => $sw,
                                        Timeout => $TIMEOUT,
                                        Errmode => 'return',
                                        $debug ? (Input_Log => *STDERR)  : (),
                                ) or
    do {
      warn qq<## Net::Telnet::Cisco constructor failed for "$sw",
timed out connecting to device.> ;
      next
    } ;

  unless ( $x->login(Password => $pw) ) {
    warn qq<## Net::Telnet::Cisco login method failed for "$sw".> ;
  } else {
    print "$sw.\n" ;
    print "$sw Enable.\n" ;
    unless ( $x->enable($epw) ) {
      warn qq<## Net::Telnet::Cisco enable method failed for "$sw".> ;
    } else {
      print "$sw conf t.\n" ;
      $x->cmd("conf t") ;
      $x->cmd("int Gi $if") ;
      $x->cmd("switchport mode trunk") ;
      $x->cmd("switchport nonegotiate") ;
      $x->cmd("exit") ;
      $x->cmd("exit") ;
      $x->cmd("quit") ;
    }
  }

}

If you really don't like Perl, then other alternatives are

1 Python Expect

2 Rancid clogin.

>
> Does anybody have any experience with expect plugins?
>
> Thanks in advance, Tamas!
>

HTH

Yours sincerely.

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list