ネットワークに接続されたプリンタのプリンタスケジューラが不調になった場合,snmptrapコマンドを実行します。snmptrapコマンドのスクリプトの例を説明します。定義例を次に示します。
#! /bin/sh
#
#
# This script checks to see if the printer scheduler (lpshed) is
# running. This check is performed every hour. If the scheduler is not
# running, the agent sends an SNMP trap to the management station.
#
# If a management station receives a trap from a system with enterprise
# equal to .1.3.6.1.4.1.4242, generic-trap equal to 6, and the specific trap
# equal to 2, the management station knows that the printer scheduler for that
# agent-addr is down.
# The agent sends how many hours the lp scheduler has been down with the trap.
#
AGENT_ADDRESS=15.6.71.223
MGMT_STATION=flcndmak
hours=0
while true
do
sleep 3600
pid='ps -ef | grep lpsched | grep -v grep |wc -l'
if [ $pid -eq 0]
then
hours='expr $hours + 1'
snmptrap -cpublic $MGMT_STATION .1.3.6.1.4.1.4242 $AGENT_ADDRESS 6
2 0 ¥
.1.3.6.1.4.1.4242.4.2.0 Integer $hours
else
hours=0
fi
done
snmptrap:cannot set locale($LANG="Ja_JP")
LC_ALL=C
export LC_ALL
snmptrap flcndmak .1.3.6.1.4.1.4242 15.6.71.223 6 2 0