Sendlog program and command-line arguments
The Sendlog program usually resides in the same directory as the CO-logmon program. Sendlog is a simple but powerful utility that allows you to send an arbitrary syslog message of arbitrary severity and facility to a syslog host. The program does not require the running of the CO-logmon program or any other file or program on the Unix platform. Sendlog is completely stand-alone, and you can copy or move it to any location on any system.
The command uses a shell prompt in a Unix shell script. You can also launch it from other scripting languages such as Perl, PHP, Ruby, and many others.
Sendlog command-line arguments
The arguments to the UNIX Sendlog program are simple, especially when compared to various SNMP trap-generating programs and utilities. The command requires three, four, or five arguments. The basic syntax of the command is as follows:
The following table describes the arguments:
Argument | Description |
|---|---|
(destName) | The first argument is required and is the host name or IP address of the device that is running the syslog receiver, which must be listening to port 514 at the address. Either an IP address or an official host name or alias is required as the first argument. |
(message) | The second argument is required and is the message to send to the remote syslog server. The message needs the double quotation marks if the message contains any spaces. The message can be up to 1024 characters long and should generally not include any strange characters, to promote readability of the message by users. |
(sevNum) | The third argument is optional and is the severity number, ranging from 0=emergency to 7=debug. If this option is not specified, the default severity for sending a message is 7=debug. For a list of severities, see Facilities-and-severities. |
(facilNum) | The fourth argument, the facility number, is optional. The facility number ranges from 0=kernel to 23=local7. If this option is not specified, the default facility for sending a message is 1=user. For a list of severities, see Facilities-and-severities. |
Sendlog command-line examples
To illustrate the operation, consider the following instances of the Sendlog program usage that might be typical in an operations center. You could incorporate these messages into a batch file, or they might be the result of a program check that you launch periodically by a UNIX script or cron job.
Example | Description |
|---|---|
Sendlog 127.0.0.1 “This is a debug message” | This command sends a message to the syslog program running 127.0.0.1. The severity and facility are not specified. These items default to the values of debug and user. |
Sendlog 192.168.1.1 “The system is restarting” 6 | This command sends a message to the syslog program running 192.168.1.1. The severity is info, and the facility is not specified, so it defaults to user. |
Sendlog myhost “Error during file transfer” 3 11 | This command sends a message to the syslog program running at the myhost platform. The severity is error, and the facility is ftp. The command is fully qualified and uses all the available arguments. You can specify either an IP address or an official host name. |
The severities and facility codes are useful for categorizing the message at the syslog receiver program. Although their numeric values express these values, they are easily referable.
Running the Sendlog program with no command-line arguments lists all numeric severity and facility numbers, along with brief notes on usage.