Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash -x
- ### MoveSCU Verbose Parser for Zabbix Trapper Items
- myAET="ZABBIX"
- callAET=$1
- pacsIP=$2
- pacsPort=$3
- query=$4
- moveQueryVerbose="/etc/zabbix/scripts/moveQueryVerbose"
- moveQueryStatus="/etc/zabbix/scripts/moveQueryStatus"
- moveQueryDuration="/etc/zabbix/scripts/moveQueryDuration"
- movescu=$( which movescu )
- agentConfig="/etc/zabbix/zabbix_agentd.conf"
- zServer="`ifconfig eth0 | grep 'inet addr:' | sed -r 's/^.*inet\saddr\://;s/\s{2}Bcast.*$//'`"
- port="10051"
- agentHost=$( cat /etc/hostname )
- zSend=$( which zabbix_sender )
- db='pacs_db_name'
- user='zabbix_user'
- pass='zabbix_user_pass'
- queryRetrieve="QueryRetrieveLevel=SERIES"
- sIUID="SeriesInstanceUID=$seriesIUID"
- moveQueryStatusMethod() {
- mysqlQuery="select series_iuid from pacsdb.series where series_no='101' order by study_fk desc limit 1;"
- seriesIUID=$( echo $mysqlQuery | mysql -N -h $pacsIP -u $user --password="$pass" --connect_timeout=10 $db )
- if [[ -z $seriesIUID ]] ; then
- mysqlQuery="select series_iuid from pacsdb.series where series_no='1' order by study_fk desc limit 1;"
- seriesIUID=$( echo $mysqlQuery | mysql -N -h $pacsIP -u $user --password="$pass" $db )
- seriesNum="SeriesNumber=1"
- fi
- queryRetrieve="QueryRetrieveLevel=SERIES"
- sIUID="SeriesInstanceUID=$seriesIUID"
- start=$( date +%s%N | cut -b1-13 )
- $movescu -S -k $queryRetrieve -k $sIUID -aet $myAET -aec $callAET -aem $myAET -v -to 7 $pacsIP $pacsPort 2>$moveQueryVerbose
- end=$( date +%s%N | cut -b1-13 )
- moveDuration=$(( $end - $start ))
- echo $moveDuration > $moveQueryDuration
- while read line ; do
- moveStatus=$( echo $line | grep Success )
- if [[ -z $moveStatus ]] ; then
- moveSeriesStatus=0
- continue
- else
- moveStatus=$( echo $line | grep -oP '(?<=0x0000\:\s)(\w+)(?=$)' )
- if [[ $moveStatus = "Success" ]] ; then
- moveSeriesStatus=1
- fi
- break
- fi
- done < $moveQueryVerbose
- if [[ $moveSeriesStatus -eq 0 ]] ; then
- echo 0 > $moveQueryDuration
- fi
- $zSend -c $agentConfig -z $zServer -p $port -s $agentHost -k movescu[$callAET,$pacsIP,$pacsPort,status] -o $moveSeriesStatus
- rm $moveQueryVerbose
- exit 0
- }
- moveQueryDurationMethod() {
- $zSend -c $agentConfig -z $zServer -p $port -s $agentHost -k movescu[$callAET,$pacsIP,$pacsPort,duration] -o $( cat $moveQueryDuration )
- rm $moveQueryDuration
- exit 0
- }
- if [[ $query = "status" ]] ; then
- moveQueryStatusMethod
- elif [[ $query = "duration" ]] ; then
- moveQueryDurationMethod
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement