Hello again,
thanks to everybody who answered my previous question. You gave me an idea and I'm now trying to create something like this.
In bacula-dir.conf I have added one line to a test job: RunAfterJob = "/etc/bacula/scripts/trap_job %c %i %e %j %n"
the trap_job script is at the moment very simple and looks like: #!/bin/bash
/usr/bin/snmptrap -v1 -c community trap_host\ .1.3.6.1.4.1.318.0.15 '' '' 6 100 \ .1.3.6.1.4.1.318.0.15.1 s "$1 $2 $3 $4 $5"
that is all at the bacula server side.
Now the snmptrapd/nagios host config:
snmptrapd.conf traphandle .1.3.6.1.6.3.1.1.5.1 /usr/lib/nagios/plugins/check_bacula_trap
Now it is the question as I am writing the check_bacula_trap, what are exactly the exit status codes of bacula job - at the moment I only know "OK", but I need rest of them to properly prepare "case" instructions...
/usr/lib/nagios/plugins/check_bacula_trap #!/bin/bash # Arguments:
# First line passed from snmptrapd is FQDN of host that sent the trap read host read nothing1 read nothing2 read nothing3 read status
# Debug #/bin/echo -e "$status" > /tmp/bacula_trap.log
CLIENT=`/bin/echo -e "$status" | tr -d "\"" | awk -F " " ' {print $2}'` JOBID=`/bin/echo -e "$status" | tr -d "\"" | awk -F " " ' {print $3}'` EXITSTATUS=`/bin/echo -e "$status" | tr -d "\"" | awk -F " " ' {print $4}'` JOBNAME=`/bin/echo -e "$status" | tr -d "\"" | awk -F " " ' {print $6}'`
case $EXITSTATUS in OK) EXITCODE="0" ;; WARNING) EXITCODE="1" ;; CRITICAL) EXITCODE="2" ;; UNKNOWN) EXITCODE="-1" ;; esac
CommandFile="/var/log/nagios/rw/nagios.cmd"
# get the current date/time in seconds since UNIX epoch datetime=`date +%s`
# create the command line to add to the command file # $1 - host # $2 - service # $3 - return code (0-ok, 1-warn, 2-crit, -1-unkn) # $4 - some output
cmdline="[$datetime] PROCESS_SERVICE_CHECK_RESULT;$1;$2;$3;$$"
# append the command to the end of the command file `$echocmd $cmdline >> $CommandFile`
This is the very first version as You can see but maybe someone will be interested in this.
You must only create passive service in nagios/services.cfg and that should work.
When I finish it I will publish everything on my Web site and let You know about it.
But now I need some help in developing this - so the exit status codes are.....
Best regards
Marcin
------------------------------------------------------- This SF.Net email is sponsored by: New Crystal Reports XI. Version 11 adds new functionality designed to reduce time involved in creating, integrating, and deploying reporting solutions. Free runtime info, new features, or free trial, at: http://www.businessobjects.com/devxi/728 _______________________________________________ Bacula-users mailing list Bacula-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bacula-users