diff options
Diffstat (limited to 'utils')
-rwxr-xr-x | utils/buffer_size.sh | 32 | ||||
-rw-r--r-- | utils/clear_wrong_reminder.sql | 4 | ||||
-rwxr-xr-x | utils/get_last_test_db.sh | 3 | ||||
-rwxr-xr-x | utils/get_last_test_log.sh | 3 | ||||
-rwxr-xr-x | utils/get_live_db.sh | 3 | ||||
-rw-r--r-- | utils/heartbeat_hammer.sh | 39 | ||||
-rwxr-xr-x | utils/init_jmauve.sh | 80 | ||||
-rwxr-xr-x | utils/init_mauve.sh | 83 | ||||
-rwxr-xr-x | utils/packet_processing.sh | 32 | ||||
-rwxr-xr-x | utils/run_android.sh | 2 | ||||
-rwxr-xr-x | utils/supportbot-mauve | 73 | ||||
-rwxr-xr-x | utils/test-smack.rb | 101 |
12 files changed, 39 insertions, 416 deletions
diff --git a/utils/buffer_size.sh b/utils/buffer_size.sh deleted file mode 100755 index 02984b2..0000000 --- a/utils/buffer_size.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -NO_ARGS=0 -OPTERROR=65 -if [ $# -eq "$NO_ARGS" ] # Script invoked with no command-line args? -then - echo "Usage: `basename $0` File.log" - exit $OPTERROR # Exit and explain usage, if no argument(s) given. -fi -logFile=$1 - -egrep 'Buffer has [0-9]* packets left' $logFile |\ - awk 'BEGIN {print " date sz"} {print s++ " " $1 "::" $2 " " $10}' > data - -R --vanilla --no-save --slave <<RSCRIPT -lst <- read.table("data") -attach(lst) -summary(sz) -png(filename="buffer.png", width=1024) -dates <- strptime(as.character(date), "%Y-%m-%d::%H:%M:%S") -plot(dates, sz, type='l', - main="Mauve server: Maximum buffer size per second", - xlab="Time", - ylab="Maximum number of packets waiting to be processed") -abline(h=1.05, col="red") -abline(h=mean(sz), col="blue") -RSCRIPT -img=`which qiv` -if [ $? != 0 ] -then echo "Cannot display image here" -else $img buffer.png -fi diff --git a/utils/clear_wrong_reminder.sql b/utils/clear_wrong_reminder.sql deleted file mode 100644 index fde0504..0000000 --- a/utils/clear_wrong_reminder.sql +++ /dev/null @@ -1,4 +0,0 @@ -select * from 'mauve_alerts' where update_type='cleared' and will_unacknowledge_at != 0; - -update 'mauve_alerts' set will_unacknowledge_at=NULL where update_type='cleared' and will_unacknowledge_at != 0; - diff --git a/utils/get_last_test_db.sh b/utils/get_last_test_db.sh deleted file mode 100755 index 71ce4f1..0000000 --- a/utils/get_last_test_db.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -test=`echo $1 | sed s/://` -sqlitebrowser `/bin/ls -dtr /tmp/mauve_test/* | tail -1`/$test\(ZTestCases\)/mauve_test.db diff --git a/utils/get_last_test_log.sh b/utils/get_last_test_log.sh deleted file mode 100755 index 26597d0..0000000 --- a/utils/get_last_test_log.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -test=`echo $1 | sed s/://` -less `/bin/ls -dtr /tmp/mauve_test/* | tail -1`/$test\(ZTestCases\)/log000001 diff --git a/utils/get_live_db.sh b/utils/get_live_db.sh deleted file mode 100755 index 35c5aea..0000000 --- a/utils/get_live_db.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -scp one-eyed-jack:/var/lib/mauveserver/alerts.db . && \ - sqlitebrowser alerts.db diff --git a/utils/heartbeat_hammer.sh b/utils/heartbeat_hammer.sh new file mode 100644 index 0000000..12b74bc --- /dev/null +++ b/utils/heartbeat_hammer.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +PRE="ruby -I lib bin/mauvesend [::1]" +F=60 +S=10 +n=$* + +_host () { + hostname="imaginary-$i.example.com" + down="n" + + while( true ) ; do + + if [ "$down" == "n" ] ; then + $PRE -o $hostname -i heartbeat -r +$F -c now -s "heartbeat failed" --detail="<p>The heartbeat wasn't sent for this host</p><p>This indicates that the host might be down</p>" + sleep $((F - $RANDOM*$S/32768 - $S)) + else + sleep $((RANDOM*$S/32768 + $F + $S)) + fi + + if [ $RANDOM -gt 30000 ] ; then + [ "$down" == "n" ] && echo "Host $hostname down" + down="y" + else + [ "$down" == "y" ] && echo "Host $hostname up" + down="n" + fi + done +} + +echo -e "This command will go beserk. To kill run\n pkill -t `tty`\n\nGiving you 5 seconds to quit!" + +sleep 5 + +for i in `seq 1 100` ; do + _host $i & + sleep 0.2 +done + diff --git a/utils/init_jmauve.sh b/utils/init_jmauve.sh deleted file mode 100755 index 3011d62..0000000 --- a/utils/init_jmauve.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/sh -### BEGIN INIT INFO -# Provides: mauveserver -# Required-Start: $remote_fs $syslog -# Required-Stop: $remote_fs $syslog -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Start the mauve alerting daemon at boot time -# Description: Start the mauve alerting daemon at boot time -### END INIT INFO - -PATH=/bin:/sbin:/usr/bin:/usr/local/bin -DAEMON=/usr/bin/jmauveserver -DAEMON_OPTS=/etc/mauvealert/mauveserver.conf -DESC="mauvealert server" -PIDFILE=/var/run/jmauveserver.pid -LOG=/var/log/mauve - -test -x $DAEMON || exit 0 - -. /lib/lsb/init-functions - -case "$1" in - start) - log_begin_msg "Starting $DESC:" "$NAME" - if [ ! -d $LOG ]; then mkdir $LOG; fi - chown mauveserver $LOG /var/lib/mauveserver - $DAEMON $DAEMON_OPTS & - echo $! > $PIDFILE - for i in `seq 0 1 11`;do sleep 1; echo -n '.'; done - kill -0 $(cat $PIDFILE) - if [ $? != 0 ] ; then echo -n "failed"; else echo -n "success"; fi - - # Email on start. - address="yann@bytemark.co.uk" - lastLog=`/bin/ls -tr $LOG/*.log | tail -1` - logLastLines=`tail -101 $lastLog` - echo $logLastLines | mail -s "Mauve was started at `date`" $address - - log_end_msg $? - ;; - stop) - log_begin_msg "Stopping $DESC:" "$NAME" - if [ -f $PIDFILE ] ; then - kill `cat $PIDFILE` - rm $PIDFILE - - # Email on stop. - address="yann@bytemark.co.uk" - lastLog=`/bin/ls -tr $LOG/*.log | tail -1` - logLastLines=`tail -101 $lastLog` - echo $logLastLines | mail -s "Mauve was stopped at `date`" $address - - else - echo Not running to stop - exit 1 - fi - log_end_msg $? - ;; - reload) - if [ -f $PIDFILE ] ; then - echo Sending restart signal to mauveserver - kill -HUP `cat $PIDFILE` - else - echo Not running to reload - fi - ;; - restart|reload|force-reload) - $0 stop - sleep 1 - $0 start - ;; - *) - N=/etc/init.d/$NAME - echo "Usage: $N {start|stop|restart}" >&2 - exit 1 - ;; -esac - -exit 0 diff --git a/utils/init_mauve.sh b/utils/init_mauve.sh deleted file mode 100755 index 309562c..0000000 --- a/utils/init_mauve.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/sh -### BEGIN INIT INFO -# Provides: mauveserver -# Required-Start: $remote_fs $syslog -# Required-Stop: $remote_fs $syslog -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Start the mauve alerting daemon at boot time -# Description: Start the mauve alerting daemon at boot time -### END INIT INFO - -PATH=/bin:/sbin:/usr/bin:/usr/local/bin -DAEMON=/usr/bin/mauveserver -DAEMON_OPTS=/etc/mauvealert/mauveserver.conf -DESC="mauvealert server" -PIDFILE=/var/run/mauveserver.pid -LOG=/var/log/mauve - -test -x $DAEMON || exit 0 - -. /lib/lsb/init-functions - -case "$1" in - start) - log_begin_msg "Starting $DESC:" "$NAME" - if [ ! -d $LOG ]; then mkdir $LOG; fi - chown mauveserver $LOG /var/lib/mauveserver - $DAEMON $DAEMON_OPTS & - echo $! > $PIDFILE - #start-stop-daemon --background --make-pidfile --pidfile $PIDFILE \ - # --start --quiet --chuid mauveserver \ - # --exec "$DAEMON" --oknodo -- $DAEMON_OPTS - sleep 3 - #kill -0 $(cat $PIDFILE) - #if [ $? != 0 ] ; then echo -n "failed"; else echo -n "success"; fi - - # Email on start. - address="yann@bytemark.co.uk" - lastLog=`/bin/ls -tr $LOG/*.log | tail -1` - logLastLines=`tail -101 $lastLog` - echo $logLastLines | mail -s "Mauve was started at `date`" $address - - log_end_msg $? - ;; - stop) - log_begin_msg "Stopping $DESC:" "$NAME" - if [ -f $PIDFILE ] ; then - kill `cat $PIDFILE` - rm $PIDFILE - - # Email on stop. - address="yann@bytemark.co.uk" - lastLog=`/bin/ls -tr $LOG/*.log | tail -1` - logLastLines=`tail -101 $lastLog` - echo $logLastLines | mail -s "Mauve was stopped at `date`" $address - - else - echo Not running to stop - exit 1 - fi - log_end_msg $? - ;; - reload) - if [ -f $PIDFILE ] ; then - echo Sending restart signal to mauveserver - kill -HUP `cat $PIDFILE` - else - echo Not running to reload - fi - ;; - restart|reload|force-reload) - $0 stop - sleep 1 - $0 start - ;; - *) - N=/etc/init.d/$NAME - echo "Usage: $N {start|stop|restart}" >&2 - exit 1 - ;; -esac - -exit 0 diff --git a/utils/packet_processing.sh b/utils/packet_processing.sh deleted file mode 100755 index d78a916..0000000 --- a/utils/packet_processing.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -NO_ARGS=0 -OPTERROR=65 -if [ $# -eq "$NO_ARGS" ] # Script invoked with no command-line args? -then - echo "Usage: `basename $0` File.log" - exit $OPTERROR # Exit and explain usage, if no argument(s) given. -fi -logFile=$1 - -egrep 'Packet processed in [\.0-9]* seconds' $logFile |\ - awk 'BEGIN {print " date sz"} {print s++ " " $1 "::" $2 " " $11}' > data - -R --vanilla --no-save --slave <<RSCRIPT -lst <- read.table("data") -attach(lst) -summary(sz) -png(filename="packets.png", width=1024) -dates <- strptime(as.character(date), "%Y-%m-%d::%H:%M:%S") -plot(dates, sz, type='l', - main="Mauve server: maximum processing time of a packet per second.", - xlab="Time", - ylab="Maximum processing time of one packet") -abline(h=1.05, col="red") -abline(h=mean(sz), col="blue") -RSCRIPT -img=`which qiv` -if [ $? != 0 ] -then echo "Cannot display image here" -else $img packets.png -fi diff --git a/utils/run_android.sh b/utils/run_android.sh deleted file mode 100755 index e932257..0000000 --- a/utils/run_android.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -/usr/local/android-sdk-linux_x86/tools/android& diff --git a/utils/supportbot-mauve b/utils/supportbot-mauve deleted file mode 100755 index 614c5f5..0000000 --- a/utils/supportbot-mauve +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/ruby -require 'fileutils' -require 'yaml' -require 'timeout' -require 'rubygems' -require 'cgi' - -class RT - class Ticket < Struct.new(:id, :subject, :content) - end - - def initialize(cli, ticket_query) - @cli = cli - @ticket_query = ticket_query - end - - def query(args) - IO.popen("#{@cli} #{args}", "r") do |io| - io.read - end - end - - def tickets - query(@ticket_query).split("\n").map do |line| - if /^(\d+): (.*)$/.match(line) - t = Ticket.new($1.to_i, $2, "") - query("show ticket/#{t.id}/attachments").split("\n")[-5..-1].each do |line2| - next unless /\s(\d+):\s+\(text\/(plain|html)/.match(line2) - is_html = $2 == "html" - - attachment = query("show -f Content ticket/#{t.id}/attachments/#{$1}"). - split("Content: ")[1]. - split("\n"). - map { |line3| line3.gsub(/^\s+/,"") }. - join("\n") - next unless attachment.match(/Action=Take/) - if is_html - t.content += attachment + "<hr/>" - else - t.content += "<pre>"+attachment+"</pre><hr/>" - end - end - t - else - nil - end - end.compact - end -end - -class String; def escape; gsub(/[^A-Za-z0-9]/) { |x| "\\#{x}" }; end end - -config = File.open("supportbot.config") { |fh| - YAML::parse(fh.read).transform } - -system("mauvesend -o supportbot -i heartbeat -r +10m -c now -s \"heartbeat not received\" -d \"Headtbeat send from supportbot-mauve code. It maybe down.\"") - -rt = RT.new(config['rt']['bin'], config['rt']['ticket_query2']) - -if 0 < rt.tickets.size - args = %w( mauvesend alert.bytemark.co.uk -o supportbot ) - args += rt.tickets.map do |ticket| - ["-i", ticket.id.to_s, - "-u", ticket.id.to_s, - "-s", ticket.subject, - "-d", ticket.content - ] - end.flatten - exec(*args) -else - args = %w( mauvesend alert.bytemark.co.uk --id supportbot -o supportbot -p -c now ) - exec(*args) -end diff --git a/utils/test-smack.rb b/utils/test-smack.rb deleted file mode 100755 index 022f9d0..0000000 --- a/utils/test-smack.rb +++ /dev/null @@ -1,101 +0,0 @@ -#!/usr/bin/jruby -# CLASSPATH="$CLASSPATH:/home/yann/projects/mauvealert/jars/smack.jar:/home/yann/projects/mauvealert/jars/smackx.jar -# ./test-smack - -require 'java' -require '../jars/smack.jar' -require '../jars/smackx.jar' -require 'rubygems' -require 'rainbow' -require 'pp' - -include_class "org.jivesoftware.smack.XMPPConnection" -include_class "org.jivesoftware.smackx.muc.MultiUserChat" - -user_jid='mauvealert' -password='WojIsEv8ScaufOm1' -msg = "What fresh hell is this? -- Dorothy Parker." -begin - - print "XMPP object instanciated.\n".color(:green) - xmpp = XMPPConnection.new("chat.bytemark.co.uk") - - - print "Connection done.\n".color(:green) - xmpp.connect - if true != xmpp.isConnected - print "Failed to connect".color(:red) - return -1 - end - - - print "Login.\n".color(:green) - xmpp.login(user_jid, password, "Testing_smack") - if true != xmpp.isAuthenticated() - print "Failed to authenticate\n".color(:red) - return -1 - end - if true == xmpp.isSecureConnection() - print "Connection is secure\n".color(:green) - else - print "Connection is NOT secure.\n".color(:yellow) - end - - - print "Get chat manager.\n".color(:green) - chat = xmpp.getChatManager.createChat( - "yann@chat.bytemark.co.uk", nil) - - print "Sending message to #{chat.getParticipant}.\n".color(:green) - chat.sendMessage(msg) - - - print "Joining, sending a message and leaving a room.\n".color(:green) - #muc = MultiUserChat.new(xmpp, "office@conference.chat.bytemark.co.uk") - muc = MultiUserChat.new(xmpp, "test@conference.chat.bytemark.co.uk") - muc.join("Mauve alert bot") - muc.sendMessage(msg) - sleep 1 - #muc.leave() - - - print "Adieu monde cruel!\n".color(:green) - xmpp.disconnect - - - print "all done.\n".color(:green) -rescue => ex - print "EPIC FAIL: Raised #{ex.class} because #{ex.message}\n\n".color(:red) - raise ex -end - -=begin -require 'java' -require './jars/smack.jar' -require './jars/smackx.jar' -include_class "org.jivesoftware.smack.XMPPConnection" -include_class "org.jivesoftware.smackx.muc.MultiUserChat" -user_jid='mauvealert' -password='WojIsEv8ScaufOm1' -msg = "What fresh hell is this? -- Dorothy Parker." -xmpp = XMPPConnection.new("chat.bytemark.co.uk") -xmpp.connect -xmpp.login(user_jid, password, "mauve_test") - -jid="yann@chat.bytemark.co.uk" -chat = xmpp.getChatManager.createChat(jid, nil) -chat.sendMessage(msg) - -xmpp.getRoster().reload() -xmpp.getRoster().getPresence(jid).isAvailable() -xmpp.getRoster().getPresence(jid).getStatus() - -muc = MultiUserChat.new(xmpp, 'office@conference.chat.bytemark.co.uk/mauvealert') -muc.join("Mauve alert bot") -muc.sendMessage(msg) - -muc2 = MultiUserChat.new(xmpp, "test@conference.chat.bytemark.co.uk") -muc2.join("Mauve alert bot") -muc2.sendMessage(msg) - -=end |