Script-for-multi-Instances-alerts-processing: Difference between revisions
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 ...") |
No edit summary |
||
Line 1: | Line 1: | ||
#!/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 voipmonitor2 -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` |
Revision as of 13:37, 18 April 2019
#!/bin/bash #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 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