Advertisement
kazoda

Zabbix api history.get awk

Aug 10th, 2014
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Awk 0.38 KB | None | 0 0
  1. BEGIN {
  2.         FS = ":";
  3.         OUTDIR="/work/zabbix/"
  4. }
  5. /^ITEM-ID/ {itemid = gensub(/\s/,"","g",$2);rmfile=OUTDIR itemid;system("test -e " rmfile " && rm " rmfile)}
  6. /"value"/ {val = gensub(/\s\"(.+)\"\,/,"\\1","g",$2)}
  7. /"clock"/ {clk = gensub(/\s\"(.+)\"/,"\\1","g",$2)
  8.         clk = strftime("%Y/%m/%d %H:%M:%S",clk)
  9.         printf "%s\n", clk "," val >> OUTDIR itemid
  10.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement