Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I think roboticus said it fairly well, check the services it provides.

Without knowing more about the server it is hard to get more specific.

To add a little more detail. You can ping most servers to see if they have a healthy network stack, either by using system calls or backticks (not my first choice) or by using Net::ICMP. To use the `backtick` method enclose any valid system command in backticks and the output of the command will be assigned to the variable. It is messy, and you often lose return codes from the commands, but it is simple.

#!/usr/bin/perl $result = `/sbin/ping -q -c 5 | grep loss`; if ($result =~ /(\d+\.\d+\%) packet loss/) { print "We lost $1 of the traffic\n"; }

To use any of the ICMP modules such as Net::Ping let your friend CPAN explain everything, but feel free to ask again when you have a more specific question.

You can also monitor a server via SNMP. Most servers respond to the OID system.sysuptime.0.

If you don't know what an OID is, read the Net::SNMP documentation. In order to use SNMP, you'll need to find a SNMP package and read the docs, something like Net::SNMP or SNMP::Simple. From a Unix host you can also call the Net-SNMP using the system call or `snmpget $args` like in the above code example, but again, that is probably not the best way to do it. Generally I prefer to use modules like Net::SNMP.

If the server has a web server running, using LWP::Simple to get a test document is pretty easy.

If you have CGI enabled on the web server, you can write a CGI to run some health checks, and then use LWP::Simple to get the web page.

For example if you have a perl script called health.cgi, you can run any commands you want to check the servers health and print out valid html, and then from another machine run a perl script using LWP::Simple to get

Think about those things to get started, and if you have more specific questions, feel free to ask again.

I hope this helps you get started.

In reply to Re: How do you check the status of a given server? by techgrrl
in thread How do you check the status of a given server? by dr.jekyllandme

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

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (4)
    As of 2018-05-24 04:29 GMT
    Find Nodes?
      Voting Booth?