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

From VoIPmonitor.org
Jump to navigation Jump to search
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)
 +
 +
Script can be still used in case you want to run only spcific type of alert simultaneously:
 +
 
  #!/bin/bash
 
  #!/bin/bash
 
  #query to detect ALERTS that should be started simultaneously - alert choose just concurrent calls alert type in this case
 
  #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

Revision as of 11:04, 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)

Script can be still used in case you want to run only spcific type of alert simultaneously:

#!/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