Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- start_daytime=$(date --date "$1 00:00:00" +%s)
- end_daytime=$(date --date "$2 00:00:00" +%s)
- itemid=${3:-23347}
- sql_string="select history.itemid, items.name, history.clock, history.value \
- from history INNER JOIN items ON history.itemid=items.itemid \
- where value = ( select max(value) from history where itemid=$itemid and \
- clock >= $start_daytime and clock <= $end_daytime) \
- and history.itemid=$itemid and history.clock >= $start_daytime \
- and history.clock <= $end_daytime\G"
- for f in $(mysql -B -s -r -u root -p zabbix -e "$sql_string" | sed -e '/^\*.*\*$/d' -e 's/ //g')
- do
- if [ ${f%:*} = "clock" ]; then
- date_str=$(date --date @${f##*:})
- echo ${f%:*}:${date_str}
- else
- echo $f
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement