I’m looking to add an alert when a new ticket is created or status has
I’ve done this with a local schellscript and the ‘lynx’
ascii-browser for only a very spacial case but it might
be an idea to start with?
Thie following is not really a ‘runnable version’,
because I had to remove some parts specific to my
own setup and system, but it will be a ‘nearly’ usable
example.
May be it helps? I run this while ‘on dipatch duty’
to not need to look at RT while working on other windows.
#!/bin/bash
the trick in this script is, that ‘echo’ builtin of bash
seems NOT to puts iths argument into the commandline
so running “echo … ‘$PASSWORD’| lynx …” does
not show tha password, and because it must be entered
it is not saved in a File. But of course you may
install/use this only on ‘locally secure hosts’ because
the Password will exist in ClearText in Memory at rntime.
Startup URL
STURI=‘https://…SERVER…/rt/…URL_to_GET’
user to ask RT with
USER=…username_to_login_with…
ask every N Seconds
SLEEPTIME=${SLEEPTIME:-30}
PLAYER=…soundplayer_used…
ADDSOUND=…wherever_the_sound_is…
########################### change at your own risk ########################
cd hopefully to the locally-correct home?
cd $HOME
(re)set terminal if aborted
trap “stty echo echoe echok; exit 1” 0 1 2 3 15
ok, now check sound / ask for password
$PLAYER $PWDSOUND
read without echo
echo -n 'pw: ’
stty -echo -echoe -echok echonl; read line ; stty echo echoe echok
password now known
check access:
if echo -e “-dump\n-source\n-auth=${USER}:$line\n${STURI}” | lynx - >/dev/null 2>&1
then
echo Access OK, backgrounding…
else
echo “${BELL}SORRY, cannot access RT”
exit 1
fi
OK run in background!
(
# loop forever
while true
do
#[1] DER Trick
if echo -e “-dump\n-source\n-auth=${USER}:$line\n${STURI}” | lynx - | tee ~/.rtcheck.html | awk $ADEBUG ’
BEGIN { if (DEBUG) { print 0 }; mibad=0; red=0 }
DEBUG==1 { print $0 }
/class=“oddline MIbad”/ { mibad=1; if (DEBUG) { print 1 }; next }
/class=“evenline MIbad”/ { mibad=1; if (DEBUG) { print 1 }; next }
mibad==1 && /Query.*eingang.*Rechnerbetrieb/ {
if (DEBUG) { print 2 }; red=1
}
mibad==1 { if (DEBUG) { print 0 }; mibad=0 }
END { if (red) {
if (DEBUG) { print “red” }; exit 0
} else {
if (DEBUG) { print “green” }; exit 1
}
}’
then
$PLAYER $ATTSOUND
fi
sleep $SLEEPTIME
done
) &
–
Christoph von Stuckrad * * |nickname |stucki@mi.fu-berlin.de
Freie Universitaet Berlin |/_*|‘stucki’ |Tel(days):+49 30 838-75 459|
Mathematik & Informatik EDV |\ *|if online|Tel(else):+49 30 77 39 6600|
Takustr. 9 / 14195 Berlin * * |on IRCnet|Fax(alle):+49 30 838-75 454/
Thanks for the info.
I wrote something similar in perl maily because I didn’t want to tied
it to any one PC. just make it +x and place it in your cgi-bin dir and
open it in a web browser.
Firefox (windows) seemed to want to install quicktime, and since I
hate QT and RA, I just use IE. Weird for a simpe .wav file.
#!/usr/bin/perl
use strict;
use Date::Manip;
my $refresh=300; #in sec
my $date=UnixDate(“now”,“%Y-%m-%d %H:%MGMT”);
$ENV{‘RTUSER’}=“nagios”;
$ENV{‘RTPASSWD’}=“ThePassw0rd”;
$ENV{‘RTSERVER’}=“http://yourserver/rt”;
my $naghome=“/home/noc”;
my $ref=$refresh/60;
my $cmd=“$naghome/scripts/rt-3.4 ls -s "'Status' = 'new'\ OR
'Status' = 'open'"”;
#print $cmd.“\n”;
open (RT, “$cmd|”) || die “$cmd $!\n”;
print “Content-type: text/html\n\n”;
print ‘
’;
print “Date: $date : Refreshed every $ref minutes
”;
my $skip=0;
while (
print '<EMBED SRC=“/offline7.wav” VSPACE=“0”
HSPACE=“0” AUTOSTART=TRUE LOOP=FALSE HIDDEN=TRUE>';
$skip=1;
}
} else {
print “All is well!”;
}
}
close RT;
-Erik-