Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

sweet..thank you both. i added a few things, i am going to use nslookup to get the ips, then i am putting them into an array and looping through that. this way i dont have to modify the script when the ip changes. also this script needs to return and exit status for nagios it will be part of the monitoring framework..

here is what i came up with, it runs fine, but i am open for suggestions..
#!/usr/bin/perl #nagios return codes: 0->All Good, 2->Critical use Net::Nslookup; use Socket; #global var. exit status# $exit_status = 0; sub GetIps { #here we are getting the ip addresses and populating the ip array @ips; @ips= nslookup(domain =>"google.com"); } sub FirstCheck { foreach (@ips) { $socket = new IO::Socket::INET->new(PeerAddr => $_, PeerPort => '777', Proto => 'tcp', Timeout => 2, ) or print "could not create bind to $_. port 777: $@\n" + and $exit_status=2 ; close($socket); } } sub SecondCheck { foreach (@ips) { $socket = new IO::Socket::INET->new(PeerAddr => $_, PeerPort => '443', Proto => 'tcp', Timeout => 2, ) or print "could not create bind to $_. port 443: $@\n" + and $exit_status=2; close($socket); } } #calling in the subz! &GetIps; &FirstCheck; &SecondCheck; #exiting the program with an exit status. exit ($exit_status);

also perl throws a bunch of errors if i run this with strict. anyone want to try it in strict and tell me whats wrong?


In reply to Re^2: netcat in perl by jose_m
in thread netcat in perl by jose_m

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (1)
As of 2024-04-18 23:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found