Difference between revisions of "Script-for-multi-Instances-alerts-processing"

From VoIPmonitor.org
Jump to navigation Jump to search
(Created page with " #!/bin/bash #query to detect ALERTS that should be started simultaneously alerts=`mysql voipmonitor2 -e "select id from alerts where note like '%RUN-M%' and disable=1 and ...")
 
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
This script is currently not necessary - with latest GUI release you can set multiple instances of alert/reports processing directly in the GUI:
 +
'''In settings->system configuration->Advanced: Number of parallel tasks for cron operations (alerts/reports)''' set there number.
 +
(Beware that multiple simultaneous tasks will use more RAM, then when running one by one)
 +
 +
 +
 
  #!/bin/bash
 
  #!/bin/bash
  #query to detect ALERTS that should be started simultaneously
+
  #query to detect ALERTS that should be started simultaneously - alert choose just concurrent calls alert type in this case
  alerts=`mysql voipmonitor2 -e "select id from alerts where note like '%RUN-M%' and disable=1 and  
+
  alerts=`mysql voipmonitor -e "select id from alerts where note like '%RUN-M%' and disable=1 and  
 
  alert_type=19\G"|grep id|cut -d ':' -f 2`
 
  alert_type=19\G"|grep id|cut -d ':' -f 2`
 
  #maximum count of simultaneous alerts runs
 
  #maximum count of simultaneous alerts runs

Latest revision as of 11:06, 3 July 2020

This script is currently not necessary - with latest GUI release you can set multiple instances of alert/reports processing directly in the GUI: In settings->system configuration->Advanced: Number of parallel tasks for cron operations (alerts/reports) set there number. (Beware that multiple simultaneous tasks will use more RAM, then when running one by one)


#!/bin/bash
#query to detect ALERTS that should be started simultaneously - alert choose just concurrent calls alert type in this case
alerts=`mysql voipmonitor -e "select id from alerts where note like '%RUN-M%' and disable=1 and 
alert_type=19\G"|grep id|cut -d ':' -f 2`
#maximum count of simultaneous alerts runs
simmax=5
#counter
atonce=1
#alerts command string
alertcmd=
tmpcmd=
#log
day=`date "+%m-%d-%Y"`
file=/root/vm-scripts/manual-alerts/alerts-${day}.txt
cd /var/www/html/php
for id in ${alerts[*]}
do
        alertcmd="$tmpcmd php run.php run_alerts -f -I $id"
        if [ "1$atonce" = "1$simmax" ]; then
                atonce=1
                echo "`date "+%H:%M:%S"`" >> $file
                echo $alertcmd >> $file
                #run command
                $($alertcmd)
                #log end
                echo "`date "+%H:%M:%S"`" >> $file
                echo >> $file
                alertcmd=
        else
                ((atonce+=1))
                tmpcmd="$alertcmd &"
        fi
done
echo >> $file
 
#If there are unprocesed rest of tasks (not simmax count) do it
 if [ "1" != "1$alertcmd" ]; then 
 	echo "`date "+%H:%M:%S"`" >> $file
 	echo $alertcmd >> $file
 	#run command
    $($alertcmd)
    #log end
    echo "`date "+%H:%M:%S"`" >> $file
    echo >> $file
    alertcmd=
fi