7
7
print ("no args. [input] [output]" );
8
8
exit ()
9
9
10
- print ('input file' , sys .argv [1 ])
11
- print ('out file' , sys .argv [2 ]);
10
+ #print('input file', sys.argv[1])
11
+ #print('out file', sys.argv[2]);
12
+
13
+ maxpoints = 20
12
14
13
15
rrdpath = 'c:\\ tools\\ rrdtool\\ rrdtool.exe'
14
16
@@ -32,7 +34,7 @@ def statenr(c):
32
34
mon = int (fn [1 :3 ])
33
35
day = int (fn [3 :5 ])
34
36
35
- print ('base name' , fn , mon , day )
37
+ # print('; base name', fn, mon, day)
36
38
37
39
stm = io .open (file = sys .argv [1 ], mode = '+rt' );
38
40
@@ -64,6 +66,15 @@ def statenr(c):
64
66
stempl += ':' + dd [0 ]
65
67
stempl = stempl [1 :]
66
68
69
+ dataps = []
70
+
71
+ def writecmd (dps ):
72
+ print (rrdpath , 'update' , sys .argv [2 ], '-t' , stempl , end = ' ' )
73
+ for p in dps :
74
+ print (p , end = ' ' )
75
+ print ()
76
+
77
+
67
78
while True :
68
79
ln = stm .readline ()
69
80
num += 1
@@ -77,11 +88,13 @@ def statenr(c):
77
88
hh = int (d0 [0 ])
78
89
mm = int (d0 [1 ])
79
90
dnow = datetime .date .today ()
80
- y = dnow .year if mm < dnow .month or (mon == dnow .month and day <= dnow .day ) else dnow .year - 1
91
+ y = dnow .year if mon < dnow .month or (mon == dnow .month and day <= dnow .day ) else dnow .year - 1
81
92
tstamp = datetime .datetime (year = y , month = mon , day = day , hour = hh , minute = mm )
82
93
unixts = int (tstamp .timestamp ())
94
+ #print(num, tstamp, unixts)
83
95
#print(num, tstamp, dt[0], unixts)
84
96
97
+
85
98
s = str (unixts )
86
99
for dd in ds :
87
100
ix = dd [1 ]
@@ -92,6 +105,12 @@ def statenr(c):
92
105
s += ':'
93
106
s += str (v )
94
107
95
-
96
- print (rrdpath , 'update ' , sys .argv [2 ], '-t' , stempl , s )
108
+ dataps .append (s )
109
+
110
+ if len (dataps ) >= maxpoints :
111
+ writecmd (dataps )
112
+ dataps = []
113
+
114
+ if len (dataps ) >= maxpoints :
115
+ writecmd (dataps )
97
116
0 commit comments