Script-for-multi-Instances-alerts-processing: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(2 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 - 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 | 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 10: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