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

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
#!/usr/bin/perl ############################################################### # Script for logging automation to a Syslog server # # For public use, creator takes no responsibilities for # # any damages, misconfigs or loss of sanity resulting from # # these script(s) # ############################################################### use Net::Syslog ; use Getopt::Std ; use Net::Ping ; #Set an array with legal Priority values @priVals = ("emerg", "alert", "crit", "err", "warning", "notice", "inf +o", "debug") ; $priLen = $#priVals ; getopts('m:p:t:') ; unless ( defined $opt_p && defined $opt_t ) { die ("Missing Options!\n Required:\n\n -p <proirity of message>\n + Can be emerg, alert, crit, err, warning, notice, info, debug\n\n +-t <text of Message to syslog>\n Note: If you use spaces in your m +essage, surround the message in quotes\n\n -m <machine name or IP>\n + Note: this is optional, default is 127.0.0.1\n") ; } if ( !defined $opt_m ) { $opt_m = "127.0.0.1" ; } $pingResult = Net::Ping->new('icmp') ; die ("\nSysLoggerErr:1\nCannot resolve $opt_m\n") unless $pingResult-> +ping($opt_m) ; $pingResult->close() ; PRI: for ( $i ; $i <= $priLen ; $i++ ) { last PRI if $opt_p eq $priVals[$i] ; if ( $i == 7 ) { die ("Not a valid Priority, check caps as this is case sensitive +!\n") ; } next PRI if $opt_p ne $priVals[$i] ; } $syslog = new Net::Syslog ( SyslogHost=>$opt_m, Facility=>'syslog', Pr +iority=>$opt_p ) ; $syslog->send("$opt_t\n") ; exit (0) ;

In reply to SysLogger by Rex(Wrecks)

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 taking refuge in the Monastery: (7)
As of 2024-03-29 13:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found