Linux Training

Linux training for private, public & voluntary sector.

0793 572 8612

City LinUX sample scripts - report


report grabs monitoring activity information from the log files and generates a pdf report suitable for mailing to a client.


report [ -c ] [ -d ] [ -e <e-mail_rcpts> ] [ -o <output_dir> ] [ -s ] [ -v ] [ -V ] <hostid>


report is a Bourne shell script which should work equally well on all versions of UNIX and Linux.


The script is currently hardwired to find explicit strings known to be used in logging activity by other City\ Linux scripts (e.g. chkfw, chkdf etc). A configurable template for the report is combined with the extracted log file data using GNU's gawk to generate a groff document with ms macros. A postscript file is generated from which a pdf file is created using ps2pdf.

The hostid must be given on the command line. The hostid may be the hostname of the subject of the report but I frequently find that in these times when canonical hostnames are so often complex names automatically generated by internet service providers and with no reverse lookup, it is more efficient to use a local id for the clients box which can be resolved through local lookup tables or inserted into the local domains name space.

Templates are kept in the directory " /usr/local/etc/reports.d " with the file name hostid .


-c    Generate a report for the current month.

-d    Set debug mode on.

-e <e-mail_rcpts>
The completed report is emailed to the addresses given with the -e    option. The .IR e-mail recipients may be a comma separated list of email addresses .

-o    <output_directory>
Both postscript and portable document format (.pdf) copies of the report are generated. The reports are output to directory set with the -o    option or "$HOME./clients/$hostid/reports" by default. If the directory does not exist it is created.

-s    Display (show) the report on screen.

Set the operation mode of the script to verbose. In verbose mode The script will echo progress messages and alerts to standard out .

-V    Print the version number to screen and exit.


report -m Nov fcl 

Create a report for the host id " fcl " using log records generated in November.


/var/log/messages, /var/log/reports/<hostid>.<month>.db, /usr/local/etc/reports.d/<hostid>.


The script has very little input error checking.


chkdf, chkftpd, chkfw, chkmail, ftchbkup, rclean, rmq, plbkup, secscan.


Clifford W Fulford, City Linux. Contact or +44 (0)709 229 5385.

The layout and associated style sheets for this page are taken from the World Wide Web Consortium and used here under the W3C software licence.