Created
June 19, 2014 10:41
-
-
Save buty4649/6c7e2213be33e62851fc to your computer and use it in GitHub Desktop.
1年前からの日付からRRDを生成。6~19時は0、それ以外は1を書き込む
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
rrdtool create nighttime.rrd -b $(date -d "1 years ago" +%s) DS:night:GAUGE:600:0:U RRA:MAX:0.5:1:576 RRA:MAX:0.5:6:432 RRA:MAX:0.5:24:540 RRA:MAX:0.5:288:450 | |
perl -MRRDs -e ' | |
$e=time; | |
$s=$e-3600*24*365; | |
while($s<=$e) { | |
$d=($s + 9 * 3600)%(24 * 3600); | |
if($d >= (19 * 3600) || $d <= (6 * 3600)) { | |
RRDs::update("nighttime.rrd","$s:1"); | |
} else { | |
RRDs::update("nighttime.rrd","$s:0"); | |
} | |
$s+=300; | |
} | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment