rrdtool rrd -> png convert
아래에서 traffinc_in 부분과 traffic_out 부분은 상황에 따라 반대로 입력해야 하는 상황이 발생될수 있음
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
#/bin/bash # rrd -> png convert RRD_FILE="/usr/share/cacti/rra/_l44416_traffic_in_40.rrd" for T2 in day week month year do STARTTIME=`date -d "$T2 ago" +%s` AGO_DATE=`date -d @${STARTTIME} +%Y-%m-%d` NOW_TIME=`date '+%H\:%M\:%S'` NOW_DATE=`date '+%Y-%m-%d %H\:%M\:%S'` COMMENT="From $AGO_DATE $NOW_TIME To $NOW_DATE " /usr/bin/rrdtool graph /usr/share/cacti/img/traffic-$T2.png \ --imgformat=PNG \ --start=$STARTTIME \ --end=-300 \ --title="192.168.10.1" \ --rigid \ --base=1000 \ --height=180 \ --width=510 \ --alt-autoscale-max \ --lower-limit=0 \ COMMENT:" $COMMENT " \ COMMENT:" \n" \ --vertical-label="bits per second" \ --slope-mode \ --font TITLE:9: \ --font AXIS:7: \ --font LEGEND:8: \ --font UNIT:7: \ DEF:a="${RRD_FILE}":traffic_out:AVERAGE \ DEF:b="${RRD_FILE}":traffic_in:AVERAGE \ CDEF:cdefa=a,8,* \ CDEF:cdefe=b,8,* \ AREA:cdefa#00CF00FF:"Inbound" \ GPRINT:cdefa:LAST:" Current\:%8.2lf %s" \ GPRINT:cdefa:MAX:"Maximum\:%8.2lf %s\n" \ LINE1:cdefe#002A97FF:"Outbound" \ GPRINT:cdefe:LAST:"Current\:%8.2lf %s" \ GPRINT:cdefe:MAX:"Maximum\:%8.2lf %s\n" done |
스크립트 실행
1 2 3 4 5 6 7 8 9 10 11 12 |
[root@localhost ~]# sh rrd_conver.sh 595x306 595x306 595x306 595x306 [root@localhost ~]# ll /usr/share/cacti/img/ 합계 112 -rw-r--r-- 1 root root 30440 5월 7 17:36 traffic-day.png -rw-r--r-- 1 root root 24719 5월 7 17:36 traffic-month.png -rw-r--r-- 1 root root 31373 5월 7 17:36 traffic-week.png -rw-r--r-- 1 root root 18596 5월 7 17:36 traffic-year.png |