Web site optimization - 588 Part IV: Using PHP for Sysadmin Tasks
588 Part IV: Using PHP for Sysadmin Tasks Listing 16-10 shows an example configuration file for this script. Listing 16-10: hdmonitor.conf Defined in the $MAXSIZE array are three mount points (partitions), which can be also written as follows: $MAXSIZE = array ( / => 30, /usr => 50, /mnt/win => 90 ); These three mount points will be monitored by the script when it is run daily via cron. Whenever any of these mount points exceed the usage percentage stated here, the $MAIL_TEMPLATE file is used to send mail to the e-mail addresses listed in this mail template. Listing 16-11 shows the monitoring script called hdmonitor.php. Listing 16-11: hdmonitor.php #!/usr/bin/php -q / ] = $system->chostname(); $alertInfo[ /<%IP_ADDR%>/ ] = $system->ip_addr(); $alertInfo[ /<%KERNEL%>/ ] = $system->kernel(); $alertInfo[ /<%TODAY%>/ ] = date( M-d-Y h:i:s A );