Xymon Mailing List Archive search

How to setup a custom script to attempt server logons and other functions

9 messages in this thread

list Don Kuhlman · Thu, 8 Mar 2012 22:30:43 +0000 ·
Hi folks. I've been googling all day, searching the forums, and looking at other spots but obviously I'm doing something wrong.

I'm trying to now setup some customization in Xymon for business applications.

I want to do it either with a homemade script, download, or using built in features.

My first task is to try and login to an ftp server using a test id and password to verify it is up and accepting connections.

Next would be to connect via sFTP and try the same thing.

I'm also trying to do the same kind of tasks with webpages that host applications.

Can someone point me to the best way to do this from our Xymon server, and if there are code snips of how to make an ftp connection, send an ID, Password, and then quit, I would really appreciate knowing where to find them.

Regards,

Don K
list Larry Barber · Thu, 8 Mar 2012 17:07:11 -0600 ·
I typically use Python with pexpect to do this sort of thing. The folowing
snippet will log on to a Brocade switch, run a command and return the
result:

while True:
        logon_cmd = 'ssh ' + cfg_file.getVal("remote_user") + '@' +
remote_host
        #print 'logon_cmd = ' + logon_cmd
        child=pexpect.spawn(logon_cmd)
        i = child.expect(['password:',pexpect.EOF],timeout=10)
        if i == 1:
                print "EOF-1 returned"
                time.sleep(30)
                continue
        child.sendline(cfg_file.getVal("remote_pw"))
        remote_prompt = cfg_file.getVal("remote_prompt")
        i = child.expect([remote_prompt, pexpect.EOF],timeout=10)
        #returned_lines = child.after
        #print returned_lines
        if i == 1:
                print "EOF-2 returned"
                time.sleep(30)
                continue
        remote_cmd = cfg_file.getVal("portshow_cmd")
        #print "remote_cmd = " + remote_cmd
        child.sendline(remote_cmd)
        i = child.expect([remote_prompt, pexpect.EOF],timeout=10)
        if i == 1:
                print "EOF-3 returned"
                time.sleep(30)
                continue
        returned_lines = child.before
        child.close();

Thanks,
Larry Barber
quoted from Don Kuhlman


On Thu, Mar 8, 2012 at 4:30 PM, Don Kuhlman <user-5eb2bfadc6c6@xymon.invalid> wrote:
 Hi folks. I've been googling all day, searching the forums, and looking
at other spots but obviously I'm doing something wrong.

 I'm trying to now setup some customization in Xymon for business
applications.

 I want to do it either with a homemade script, download, or using built
in features.

 My first task is to try and login to an ftp server using a test id and
password to verify it is up and accepting connections.

 Next would be to connect via sFTP and try the same thing.

 I'm also trying to do the same kind of tasks with webpages that host
applications.

 Can someone point me to the best way to do this from our Xymon server,
and if there are code snips of how to make an ftp connection, send an ID,
Password, and then quit, I would really appreciate knowing where to find
them.

 Regards,

 Don K

list Phil Crooker · Fri, 09 Mar 2012 11:37:01 +1100 ·
I use expect for this sort of job - scripting of an interactive task.
This uses tcl, so some learning to achieve, but expect works well and is
well documented.

cheers, Phil

On 9/03/2012 at 9:00 AM, in message
<user-9884b3151707@xymon.invalid>, Don
quoted from Larry Barber
Kuhlman <user-5eb2bfadc6c6@xymon.invalid> wrote:
Hi folks. I've been googling all day, searching the forums, and
looking at 
other spots but obviously I'm doing something wrong.

I'm trying to now setup some customization in Xymon for business applications.

I want to do it either with a homemade script, download, or using
built in 
features.

My first task is to try and login to an ftp server using a test id
and 
password to verify it is up and accepting connections.

Next would be to connect via sFTP and try the same thing.

I'm also trying to do the same kind of tasks with webpages that host
applications.

Can someone point me to the best way to do this from our Xymon
server, and 
if there are code snips of how to make an ftp connection, send an ID,
Password, and then quit, I would really appreciate knowing where to
find 
them.

Regards,

Don K
list Japheth Cleaver · Thu, 8 Mar 2012 17:01:21 -0800 (PST) ·
lftp is another good tool for scripting access.

-jc
quoted from Phil Crooker


On Thu, March 8, 2012 4:37 pm, Phil Crooker wrote:
I use expect for this sort of job - scripting of an interactive task.
This uses tcl, so some learning to achieve, but expect works well and is
well documented.

cheers, Phil

On 9/03/2012 at 9:00 AM, in message
<user-9884b3151707@xymon.invalid>, Don
Kuhlman <user-5eb2bfadc6c6@xymon.invalid> wrote:
Hi folks. I've been googling all day, searching the forums, and
looking at
other spots but obviously I'm doing something wrong.

I'm trying to now setup some customization in Xymon for business
applications.

I want to do it either with a homemade script, download, or using
built in
features.

My first task is to try and login to an ftp server using a test id
and
password to verify it is up and accepting connections.

Next would be to connect via sFTP and try the same thing.

I'm also trying to do the same kind of tasks with webpages that host
applications.

Can someone point me to the best way to do this from our Xymon
server, and
if there are code snips of how to make an ftp connection, send an ID,
Password, and then quit, I would really appreciate knowing where to
find
them.

Regards,

Don K
list Gautier Begin · Fri, 9 Mar 2012 08:16:11 +0100 ·
I have made a script with the last command that list all connections on UNIX.

Cordialement, Regards,Mit freundlichen Grüßen,

Gautier BEGIN

Admin and Tools Team
CSC Computer Sciences Luxembourg S.A.
12D Impasse Drosbach
L-1882 Luxembourg

Global Outsourcing Service | p:+352 24 834 276 | m:+352 621 229 172 | user-083785ae1711@xymon.invalid | www.csc.com


CSC • This is a PRIVATE message. If you are not the intended recipient, please delete without copying and kindly advise us by e-mail of the mistake in delivery.  NOTE: Regardless of content, this e-mail shall not operate to bind CSC to any order or other contract unless pursuant to explicit written agreement or government initiative expressly permitting the use of e-mail for such purpose
 • CSC Computer Sciences SAS • Registered Office: Immeuble Le Balzac, 10 Place des Vosges, 92072 Paris La Défense Cedex, France • Registered in France: RCS Nanterre B 315 268 664


From:   user-87556346d4af@xymon.invalid
To:     "Phil Crooker" <user-e8e31cd73303@xymon.invalid>, "Don Kuhlman" <user-5eb2bfadc6c6@xymon.invalid>
Cc:     Xymon Email List <xymon at xymon.com>
Date:   03/09/2012 01:59 AM
Subject:        Re: [Xymon] How to setup a custom script to attempt server logons and other functions
Sent by:        xymon-bounces at xymon.com
quoted from Japheth Cleaver


lftp is another good tool for scripting access.

-jc


On Thu, March 8, 2012 4:37 pm, Phil Crooker wrote:
I use expect for this sort of job - scripting of an interactive task.
This uses tcl, so some learning to achieve, but expect works well and is
well documented.

cheers, Phil

On 9/03/2012 at 9:00 AM, in message
<user-9884b3151707@xymon.invalid>, Don
Kuhlman <user-5eb2bfadc6c6@xymon.invalid> wrote:
Hi folks. I've been googling all day, searching the forums, and
looking at
other spots but obviously I'm doing something wrong.

I'm trying to now setup some customization in Xymon for business
applications.

I want to do it either with a homemade script, download, or using
built in
features.

My first task is to try and login to an ftp server using a test id
and
password to verify it is up and accepting connections.

Next would be to connect via sFTP and try the same thing.

I'm also trying to do the same kind of tasks with webpages that host
applications.

Can someone point me to the best way to do this from our Xymon
server, and
if there are code snips of how to make an ftp connection, send an ID,
Password, and then quit, I would really appreciate knowing where to
find
them.

Regards,

Don K
list Steve Anderson · Fri, 9 Mar 2012 11:25:29 +0000 ·
Perl is pretty much perfect for this kind of thing. You do need to install some modules though. CPAN makes life easier.

FTP:
Net::FTP. An example test is attached. It's pretty much the sample code from http://perldoc.perl.org/Net/FTP.html, with a little editing to hook it into Hobbit.
SFTP:
Net::SSH2. http://search.cpan.org/~rkitover/Net-SSH2-0.40/lib/Net/SSH2.pm

WebPages:
LWP::UserAgent if you set it up right, you can hit multiple pages, using a cookie store to maintain cookie based logins.


Steve Anderson
quoted from Don Kuhlman

From: xymon-bounces at xymon.com [mailto:xymon-bounces at xymon.com] On Behalf Of Don Kuhlman
Sent: 08 March 2012 22:31
To: xymon at xymon.com
Subject: [Xymon] How to setup a custom script to attempt server logons and other functions

Hi folks. I've been googling all day, searching the forums, and looking at other spots but obviously I'm doing something wrong.

I'm trying to now setup some customization in Xymon for business applications.

I want to do it either with a homemade script, download, or using built in features.

My first task is to try and login to an ftp server using a test id and password to verify it is up and accepting connections.

Next would be to connect via sFTP and try the same thing.

I'm also trying to do the same kind of tasks with webpages that host applications.

Can someone point me to the best way to do this from our Xymon server, and if there are code snips of how to make an ftp connection, send an ID, Password, and then quit, I would really appreciate knowing where to find them.

Regards,

Don K

This email has been scanned by Westcoastcloud.
http://www.westcoastcloud.com

BiP Solutions Limited is a company registered in Scotland with Company
Number SC086146 and VAT number 383030966 and having its registered
office at Medius, 60 Pacific Quay, Glasgow, G51 1DZ.

****************************************************************************
This e-mail (and any attachment) is intended only for the attention of
the addressee(s). Its unauthorised use, disclosure, storage or copying
is not permitted. If you are not the intended recipient, please destroy
all copies and inform the sender by return e-mail.
This e-mail (whether you are the sender or the recipient) may be
monitored, recorded and retained by BiP Solutions Ltd.
E-mail monitoring/ blocking software may be used, and e-mail content may
be read at any time.You have a responsibility to ensure laws are not
broken when composing or forwarding e-mails and their contents.
****************************************************************************
Attachments (1)
list Bruce White · Fri, 9 Mar 2012 09:49:16 -0600 ·
The built in "ftp" test will check that ftp is up and accepting
commands.   You won't need to create a special user or embed a password
in some script.

 
            .....Bruce

 
From: xymon-bounces at xymon.com [mailto:xymon-bounces at xymon.com] On Behalf
Of Steve Anderson
Sent: Friday, March 09, 2012 5:25 AM
To: Don Kuhlman; xymon at xymon.com
quoted from Steve Anderson
Subject: Re: [Xymon] How to setup a custom script to attempt server
logons and other functions

 
Perl is pretty much perfect for this kind of thing. You do need to
install some modules though. CPAN makes life easier.

 
FTP:

Net::FTP. An example test is attached. It's pretty much the sample code
from http://perldoc.perl.org/Net/FTP.html, with a little editing to hook
it into Hobbit.

SFTP:

Net::SSH2.
http://search.cpan.org/~rkitover/Net-SSH2-0.40/lib/Net/SSH2.pm 

 
WebPages:

LWP::UserAgent if you set it up right, you can hit multiple pages, using
a cookie store to maintain cookie based logins.

 
Steve Anderson

 
From: xymon-bounces at xymon.com [mailto:xymon-bounces at xymon.com] On Behalf
Of Don Kuhlman
Sent: 08 March 2012 22:31
To: xymon at xymon.com
Subject: [Xymon] How to setup a custom script to attempt server logons
and other functions

 
Hi folks. I've been googling all day, searching the forums, and looking
at other spots but obviously I'm doing something wrong.

 
I'm trying to now setup some customization in Xymon for business
applications.

 
I want to do it either with a homemade script, download, or using built
in features.

 
My first task is to try and login to an ftp server using a test id and
password to verify it is up and accepting connections.

 
Next would be to connect via sFTP and try the same thing.

 
I'm also trying to do the same kind of tasks with webpages that host
applications.

 
Can someone point me to the best way to do this from our Xymon server,
and if there are code snips of how to make an ftp connection, send an
ID, Password, and then quit, I would really appreciate knowing where to
find them.

 
Regards,

 
Don K

 
 

Bruce White
Senior Enterprise Systems Engineer | Phone: X-XXX-XXX-XXXX | Fax: XXX-XXX-XXXX | user-58f975e8bf9d@xymon.invalid | http://www.fellowes.com/
 
 
 
Disclaimer: The information contained in this message may be privileged and confidential and protected from disclosure. If the reader of this message is not the intended recipient or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. Thank you. Fellowes, Inc.
quoted from Steve Anderson
 

This email has been scanned by Westcoastcloud.
http://www.westcoastcloud.com


BiP Solutions Limited is a company registered in Scotland with Company
Number SC086146 and VAT number 383030966 and having its registered
office at Medius, 60 Pacific Quay, Glasgow, G51 1DZ.

************************************************************************
****
This e-mail (and any attachment) is intended only for the attention of
the addressee(s). Its unauthorised use, disclosure, storage or copying
is not permitted. If you are not the intended recipient, please destroy
all copies and inform the sender by return e-mail.
This e-mail (whether you are the sender or the recipient) may be
monitored, recorded and retained by BiP Solutions Ltd.
E-mail monitoring/ blocking software may be used, and e-mail content may
be read at any time.You have a responsibility to ensure laws are not
broken when composing or forwarding e-mails and their contents.
************************************************************************
****
list Don Kuhlman · Fri, 9 Mar 2012 17:13:28 +0000 ·
Thanks everyone for the quick and helpful replies!

Bruce, could you clarify what you meant about the built in ftp test?  How would you use it to check that an ID/PW can login to the ftp server  and perform a command?

Regards,

Don K
quoted from Bruce White
From: "White, Bruce" <user-58f975e8bf9d@xymon.invalid<mailto:user-58f975e8bf9d@xymon.invalid>>
Date: Fri, 9 Mar 2012 09:49:16 -0600
To: Steve Anderson <user-a1c59649b432@xymon.invalid<mailto:user-a1c59649b432@xymon.invalid>>, Don Kuhlman <user-5eb2bfadc6c6@xymon.invalid<mailto:user-5eb2bfadc6c6@xymon.invalid>>, <xymon at xymon.com<mailto:xymon at xymon.com>>
Subject: RE: [Xymon] How to setup a custom script to attempt server logons and other functions

The built in “ftp” test will check that ftp is up and accepting commands.   You won’t need to create a special user or embed a password in some script.

            …..Bruce


Bruce White

Senior Enterprise Systems Engineer | Phone: X-XXX-XXX-XXXX | Fax: XXX-XXX-XXXX | user-58f975e8bf9d@xymon.invalid<mailto:user-58f975e8bf9d@xymon.invalid> | www.fellowes.com<http://www.fellowes.com/>;


[cid:fellbrand1.jpg at fece75cf.c6184add]
quoted from Bruce White


Disclaimer: The information contained in this message may be privileged and confidential and protected from disclosure. If the reader of this message is not the intended recipient or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. Thank you. Fellowes, Inc.


From: xymon-bounces at xymon.com<mailto:xymon-bounces at xymon.com> [mailto:xymon-bounces at xymon.com] On Behalf Of Steve Anderson
Sent: Friday, March 09, 2012 5:25 AM
To: Don Kuhlman; xymon at xymon.com<mailto:xymon at xymon.com>
Subject: Re: [Xymon] How to setup a custom script to attempt server logons and other functions

Perl is pretty much perfect for this kind of thing. You do need to install some modules though. CPAN makes life easier.

FTP:
Net::FTP. An example test is attached. It’s pretty much the sample code from http://perldoc.perl.org/Net/FTP.html, with a little editing to hook it into Hobbit.
SFTP:
Net::SSH2. http://search.cpan.org/~rkitover/Net-SSH2-0.40/lib/Net/SSH2.pm

WebPages:
LWP::UserAgent if you set it up right, you can hit multiple pages, using a cookie store to maintain cookie based logins.


Steve Anderson

From: xymon-bounces at xymon.com<mailto:xymon-bounces at xymon.com> [mailto:xymon-bounces at xymon.com]<mailto:[mailto:xymon-bounces at xymon.com]> On Behalf Of Don Kuhlman
Sent: 08 March 2012 22:31
To: xymon at xymon.com<mailto:xymon at xymon.com>
Subject: [Xymon] How to setup a custom script to attempt server logons and other functions

Hi folks. I've been googling all day, searching the forums, and looking at other spots but obviously I'm doing something wrong.

I'm trying to now setup some customization in Xymon for business applications.

I want to do it either with a homemade script, download, or using built in features.

My first task is to try and login to an ftp server using a test id and password to verify it is up and accepting connections.

Next would be to connect via sFTP and try the same thing.

I'm also trying to do the same kind of tasks with webpages that host applications.

Can someone point me to the best way to do this from our Xymon server, and if there are code snips of how to make an ftp connection, send an ID, Password, and then quit, I would really appreciate knowing where to find them.

Regards,

Don K

This email has been scanned by Westcoastcloud.
http://www.westcoastcloud.com

BiP Solutions Limited is a company registered in Scotland with Company
Number SC086146 and VAT number 383030966 and having its registered
office at Medius, 60 Pacific Quay, Glasgow, G51 1DZ.

****************************************************************************
This e-mail (and any attachment) is intended only for the attention of
the addressee(s). Its unauthorised use, disclosure, storage or copying
is not permitted. If you are not the intended recipient, please destroy
all copies and inform the sender by return e-mail.
This e-mail (whether you are the sender or the recipient) may be
monitored, recorded and retained by BiP Solutions Ltd.
E-mail monitoring/ blocking software may be used, and e-mail content may
be read at any time.You have a responsibility to ensure laws are not
broken when composing or forwarding e-mails and their contents.
****************************************************************************
list Bruce White · Sun, 11 Mar 2012 08:07:54 -0500 ·
The built in network ftp test.  It will not check ids/passwords, but it
does check that ftp is running and is accepting commands.   It opens the
21 port on an ftp sever and then issues a quit to disconnect.  All you
need to do is put the "ftp" tag  on the server's entry in the hosts.cfg
file and Xymon will do the rest.  If ftp is not functional, it will let
you know.  No need to write a script, no need to create a special ID for
your script and no need to embed the password for you special user into
a script.  
quoted from Bruce White

 
            ......Bruce

 
From: xymon-bounces at xymon.com [mailto:xymon-bounces at xymon.com] On Behalf
Of Don Kuhlman

Sent: Friday, March 09, 2012 11:13 AM
To: xymon at xymon.com
quoted from Don Kuhlman
Subject: Re: [Xymon] How to setup a custom script to attempt server
logons and other functions

 
Thanks everyone for the quick and helpful replies!

 
Bruce, could you clarify what you meant about the built in ftp test?
How would you use it to check that an ID/PW can login to the ftp server
and perform a command?

 
Regards,

 
Don K

From: "White, Bruce" <user-58f975e8bf9d@xymon.invalid>
Date: Fri, 9 Mar 2012 09:49:16 -0600
To: Steve Anderson <user-a1c59649b432@xymon.invalid>, Don Kuhlman <

user-5eb2bfadc6c6@xymon.invalid>, <xymon at xymon.com>
quoted from Don Kuhlman
Subject: RE: [Xymon] How to setup a custom script to attempt server
logons and other functions

 
The built in "ftp" test will check that ftp is up and accepting
commands.   You won't need to create a special user or embed a password
in some script.

 
            .....Bruce

 
Bruce White

Senior Enterprise Systems Engineer | Phone: X-XXX-XXX-XXXX | Fax:

XXX-XXX-XXXX | user-58f975e8bf9d@xymon.invalid | www.fellowes.com
quoted from Don Kuhlman
<http://www.fellowes.com/>; 

 
Disclaimer: The information contained in this message may be privileged
and confidential and protected from disclosure. If the reader of this
message is not the intended recipient or an employee or agent
responsible for delivering this message to the intended recipient, you
are hereby notified that any dissemination, distribution or copying of
this communication is strictly prohibited. If you have received this
communication in error, please notify us immediately by replying to the
message and deleting it from your computer. Thank you. Fellowes, Inc.

 
From: xymon-bounces at xymon.com [mailto:xymon-bounces at xymon.com] On Behalf
Of Steve Anderson
Sent: Friday, March 09, 2012 5:25 AM
To: Don Kuhlman; xymon at xymon.com
Subject: Re: [Xymon] How to setup a custom script to attempt server
logons and other functions

 
Perl is pretty much perfect for this kind of thing. You do need to
install some modules though. CPAN makes life easier.

 
FTP:

Net::FTP. An example test is attached. It's pretty much the sample code
from http://perldoc.perl.org/Net/FTP.html, with a little editing to hook
it into Hobbit.

SFTP:

Net::SSH2. 
http://search.cpan.org/~rkitover/Net-SSH2-0.40/lib/Net/SSH2.pm 

 
WebPages:

LWP::UserAgent if you set it up right, you can hit multiple pages, using
a cookie store to maintain cookie based logins.

 
Steve Anderson

 
From: xymon-bounces at xymon.com [mailto:xymon-bounces at xymon.com] On Behalf
Of Don Kuhlman
Sent: 08 March 2012 22:31
To: xymon at xymon.com
Subject: [Xymon] How to setup a custom script to attempt server logons
and other functions

 
Hi folks. I've been googling all day, searching the forums, and looking
at other spots but obviously I'm doing something wrong.

 
I'm trying to now setup some customization in Xymon for business
applications.

 
I want to do it either with a homemade script, download, or using built
in features.

 
My first task is to try and login to an ftp server using a test id and
password to verify it is up and accepting connections.

 
Next would be to connect via sFTP and try the same thing.

 
I'm also trying to do the same kind of tasks with webpages that host
applications.

 
Can someone point me to the best way to do this from our Xymon server,
and if there are code snips of how to make an ftp connection, send an
ID, Password, and then quit, I would really appreciate knowing where to
find them.

 
Regards,

 
Don K

 
 
Bruce White
Senior Enterprise Systems Engineer | Phone: X-XXX-XXX-XXXX | Fax: XXX-XXX-XXXX | user-58f975e8bf9d@xymon.invalid | http://www.fellowes.com/
 
 
 
Disclaimer: The information contained in this message may be privileged and confidential and protected from disclosure. If the reader of this message is not the intended recipient or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. Thank you. Fellowes, Inc.
 

This email has been scanned by Westcoastcloud.
http://www.westcoastcloud.com


BiP Solutions Limited is a company registered in Scotland with Company
Number SC086146 and VAT number 383030966 and having its registered
office at Medius, 60 Pacific Quay, Glasgow, G51 1DZ.

************************************************************************
****
This e-mail (and any attachment) is intended only for the attention of
the addressee(s). Its unauthorised use, disclosure, storage or copying
is not permitted. If you are not the intended recipient, please destroy
all copies and inform the sender by return e-mail.
This e-mail (whether you are the sender or the recipient) may be
monitored, recorded and retained by BiP Solutions Ltd.
E-mail monitoring/ blocking software may be used, and e-mail content may
be read at any time.You have a responsibility to ensure laws are not
broken when composing or forwarding e-mails and their contents.
************************************************************************
****