印刷割り当てに達したときに役立つエラーメッセージを印刷する


0

私はここのオフィスでプリンタの印刷割り当てを設定しようとしています。ただし、クォータに達したときに表示され、印刷は静かに失敗し、ユーザーは何が起こっているのかまったくわかりません。

ページの割り当ては、/etc/cups/printers.confのPageLimitディレクティブを変更することによって設定されました

メッセージが表示されているようです

E [04/Mar/2013:15:34:28 -0700] Returning IPP client-error-not-possible for Create-Job
(ipp://localhost:631/printers/Hewlett-Packard-HP-LaserJet-4100-MFP) from localhost

/var/log/cups/error_logの私のログ。

次のようなコマンドで何かをハッキングしてみました

tail -f /var/log/cups/error_log | grep 'client-error-not-possible for Create-Job' | DISPLAY=:0 notify-send -t 30000 -i 'notification-message-email' 'Printing Quota reached for this Printer'

しかし、最初のエラーメッセージで一度だけメッセージが表示されるため、実際には機能しないようです。

考えや解決策はありますか?これにはプリベークされたソリューションがあるはずです。

1

Answered here on Super User by Semafoor:

I would look into using incrontab for monitoring changes to the file system, and combine that with the little script you already have.

This looks approximately as follows. First, save the script that you want to execute as a file, e.g. as cups_monitor.sh in /usr/local/bin (don't forget to make it executable).

#!/bin/sh
VAR=`tail -n 1 /var/log/cups/error_log | grep 'client-error-not-possible for Create-Job'`
if [[ -n "$VAR" ]]; then
   echo "$VAR" | DISPLAY=:0 notify-send -t 30000 -i
fi

You might want to check this. My scripts are never right first try :). Also note that it is possible that this script does not capture your error message if it is followed by other message: I only look at the last line of the log file (-n 1); this should be easy to change.

Then edit your incrontab

incrontab -e

by adding the line

/var/log/cups/error_log IN_CLOSE_WRITE /usr/local/bin/cups_monitor.sh

The IN_CLOSE_WRITE is called an 'event symbol' and indicates that you want to want to call your script when/var/log/cups/error_log was closed after it was opened for writing; you can find other events in the man page of incrontab.

Keep in mind that I did not test this. You can see whether the incrontab file was changed successfully and whether it calls your script or not by looking in the syslog (tail /var/log/syslog).