質問編集履歴
8
回答結果を反映
test
CHANGED
File without changes
|
test
CHANGED
@@ -186,110 +186,99 @@
|
|
186
186
|
Tunnel_level_quality_analysis_df.to_csv(tmp_csv, encoding='utf-8', index=False)
|
187
187
|
|
188
188
|
s3 = boto3.resource('s3')
|
189
|
-
s3.meta.client.upload_file(tmp_csv 'utlink-vmanage-bucket', 'csv/Tunnel_level_quality_analysis.csv')
|
189
|
+
s3.meta.client.upload_file(tmp_csvm 'utlink-vmanage-bucket', 'csv/Tunnel_level_quality_analysis.csv')
|
190
190
|
|
191
191
|
print("debug2")
|
192
192
|
|
193
193
|
def get_request(vmanage_info_df):
|
194
|
-
d
|
194
|
+
#api_datalist = []
|
195
|
-
|
196
|
-
for i in range(13):
|
197
|
-
|
198
|
-
|
195
|
+
for row in vmanage_info_df.itertuples():
|
199
|
-
|
196
|
+
vmanage_host = row[1]
|
200
|
-
|
197
|
+
vmanage_port = row[2]
|
201
|
-
|
198
|
+
vmanage_username = row[3]
|
202
|
-
|
199
|
+
vmanage_password = row[4]
|
203
|
-
|
200
|
+
|
204
|
-
|
201
|
+
base_url = `https://%s:%s`%(vmanage_host, vmanage_port)
|
205
|
-
|
202
|
+
|
206
|
-
|
203
|
+
login_action = `/j_security_check`
|
207
|
-
|
204
|
+
|
208
|
-
|
205
|
+
login_data = {`j_username` : vmanage_username, `j_password` : vmanage_password}
|
209
|
-
|
206
|
+
|
210
|
-
|
207
|
+
login_url = base_url + login_action
|
211
|
-
|
208
|
+
|
212
|
-
|
209
|
+
session = requests.session()
|
213
|
-
|
210
|
+
|
214
|
-
|
211
|
+
pring("debug3")
|
215
|
-
|
212
|
+
|
216
|
-
|
213
|
+
login_response = session.post(url=login_url, data=login_data, verify=False)
|
217
|
-
|
214
|
+
if b`<html>` in login_response.content:
|
215
|
+
print("Login token Failed")
|
216
|
+
exit(1)
|
217
|
+
|
218
|
+
xsrf_token_url = base_url + '/dataservice/client/token'
|
219
|
+
|
220
|
+
login_token = session.get(url=xsrf_token_url, verify=False)
|
221
|
+
if login_token.status_code == 200:
|
222
|
+
if b`<html>` in login_token.content:
|
218
223
|
print("Login token Failed")
|
219
224
|
exit(1)
|
220
225
|
|
226
|
+
session.headers[`X-XSRF-TOKEN`] = login_token.content
|
227
|
+
|
228
|
+
|
221
|
-
|
229
|
+
device_url = base_url + `/dataservice/device`
|
222
|
-
|
230
|
+
print("device_url")
|
231
|
+
print(device_url)
|
232
|
+
|
223
|
-
|
233
|
+
device_list = session.get(url=device_url, verify=False)
|
224
|
-
|
234
|
+
if device_list.status_code = 200:
|
235
|
+
json_data = device_list.json()
|
236
|
+
else:
|
237
|
+
print (device_list.status_code)
|
238
|
+
|
225
|
-
|
239
|
+
df = pd.json_normalize(json_data["data"]
|
240
|
+
df = df[(df["device-type"] == "vedge") & (df["reachability"] == "reachable")]
|
241
|
+
|
242
|
+
print("filter_df")
|
243
|
+
print(df)
|
244
|
+
|
245
|
+
df = df[["deviceId", "system-ip", "host-name", "device-model", "bfdSessionsUp", "bfdSessions"]]
|
246
|
+
|
247
|
+
for data in df.itertuples():
|
248
|
+
System_ip = data[1]
|
249
|
+
query_data = ["query":(略),["value":[System_ip],(略)"type":"sum"}]}}
|
250
|
+
print("query_data")
|
251
|
+
print(query_data)
|
252
|
+
|
253
|
+
device_url = base_url + '/dataservice/statistics/approute/fec/aggregation'
|
254
|
+
#print("device_url")
|
255
|
+
#print(device_url)
|
256
|
+
|
257
|
+
device_list = session.post(url=device_url, json=query_data, headers=headers_post, verify=False)
|
226
|
-
|
258
|
+
print("device_list")
|
227
|
-
|
259
|
+
print(device_list)
|
260
|
+
|
261
|
+
if device_list.status_code == 200:
|
262
|
+
print (device_list.status_code)
|
263
|
+
json_data = device_list.json()
|
228
264
|
|
229
|
-
|
265
|
+
df2 = pd.json_normalize(json_data["data"])
|
230
266
|
|
231
|
-
|
267
|
+
#先頭にsystemip
|
232
|
-
d
|
268
|
+
df2.insert(0, 'System_ip', data[1])
|
269
|
+
#末尾にdatetime
|
270
|
+
df2['dt'] = datetime.now(),strftime('%Y%m%d% %H:%M:%S')
|
271
|
+
c = df2.pop('dt')
|
272
|
+
df2.insert(df2.shape[1], c.name, c)
|
273
|
+
|
233
|
-
print("d
|
274
|
+
print("df2")
|
234
|
-
print(d
|
275
|
+
print(df2)
|
235
|
-
|
236
|
-
|
276
|
+
|
237
|
-
if device_list.status_code = 200:
|
238
|
-
json_data = vdevice_list.json()
|
239
277
|
else:
|
240
|
-
print (device_list.status_code)
|
241
|
-
|
242
|
-
df = pd.json_normalize(json_data["data"]
|
243
|
-
df = df[(df["device-type"] == "vedge") & (df["reachability"] == "reachable")]
|
244
|
-
|
245
|
-
print("filter_df")
|
246
|
-
print(df)
|
247
|
-
|
248
|
-
df = df[["deviceId", "system-ip", "host-name", "device-model", "bfdSessionsUp", "bfdSessions"]]
|
249
|
-
|
250
|
-
for data in df.itertuples():
|
251
|
-
System_ip = data[1]
|
252
|
-
query_data = ["query":(略),["value":[System_ip],(略)"type":"sum"}]}}
|
253
|
-
print("query_data")
|
254
|
-
print(query_data)
|
255
|
-
|
256
|
-
device_url = base_url + '/dataservice/statistics/approute/fec/aggregation'
|
257
|
-
print("device_url")
|
258
|
-
print(device_url)
|
259
|
-
|
260
|
-
device_list = session.post(url=device_url, json=query_data, headers=headers_post, verify=False)
|
261
|
-
print("device_list")
|
262
|
-
print(device_list)
|
263
|
-
|
264
|
-
if device_list.status_code == 200:
|
265
|
-
json_data = device_list.json()
|
266
|
-
|
267
|
-
df2 = pd.json_normalize(json_data["data"])
|
268
|
-
|
269
|
-
#先頭にsystemip
|
270
|
-
df2.insert(0, 'System_ip', data[1])
|
271
|
-
#末尾にdatetime
|
272
|
-
df2['df'] = datetime.now(),strftime('%Y%m%d% %H:%M:%S')
|
273
|
-
c = df2.pop('dt')
|
274
|
-
df.insert(df2.shape[1], c.name, c)
|
275
|
-
|
276
|
-
print("df2")
|
277
|
-
print(df2)
|
278
|
-
df2 = pd.DataFrame({'v1' :[i, i*10]})
|
279
|
-
dfs.append(df2)
|
280
|
-
|
281
|
-
else:
|
282
|
-
|
278
|
+
print(device_list.status_code)
|
283
|
-
|
284
|
-
|
279
|
+
|
285
|
-
|
280
|
+
|
286
|
-
|
287
|
-
|
281
|
+
return df
|
288
|
-
|
289
|
-
df_ret = pd.concat(dfs).rest_index(drop=True)
|
290
|
-
return df_ret
|
291
|
-
#df_ret = get_request(vmanage_info_df)
|
292
|
-
#print(df_ret)
|
293
282
|
```
|
294
283
|
|
295
284
|
|
@@ -335,3 +324,34 @@
|
|
335
324
|
Python3.9
|
336
325
|
ここにより詳細な情報を記載してください。
|
337
326
|
|
327
|
+
### 回答動作確認コード
|
328
|
+
文字数制限のため追記箇所のみ記載
|
329
|
+
```
|
330
|
+
・・・・(略)・・・・
|
331
|
+
dfs = []
|
332
|
+
def lambda_handler(event, context):
|
333
|
+
・・・・(略)・・・・
|
334
|
+
print("df2")
|
335
|
+
print(df2)
|
336
|
+
dfs.append(df2)
|
337
|
+
・・・・(略)・・・・
|
338
|
+
df_con = pd.concat(dfs).reset_index(drop=True)
|
339
|
+
print(df_con)
|
340
|
+
return df_con
|
341
|
+
```
|
342
|
+
|
343
|
+
```Result
|
344
|
+
System_ip loss_percentage ・・・・ vqoe_score dt
|
345
|
+
1.1.1.1 99.99・・・・5 2023/01/01 01:01:01
|
346
|
+
1.1.1.1 99.98・・・・5 2023/01/01 01:01:01
|
347
|
+
1.1.1.1 99.97・・・・5 2023/01/01 01:01:01
|
348
|
+
1.1.1.1 99.96・・・・5 2023/01/01 01:01:01
|
349
|
+
・・・・(略)・・・・
|
350
|
+
1.1.1.4 99.99・・・・5 2023/01/01 01:01:01
|
351
|
+
1.1.1.4 99.98・・・・5 2023/01/01 01:01:01
|
352
|
+
1.1.1.4 99.97・・・・5 2023/01/01 01:01:01
|
353
|
+
1.1.1.4 99.96・・・・5 2023/01/01 01:01:01
|
354
|
+
```
|
355
|
+
|
356
|
+
```
|
357
|
+
|
7
ソース修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -275,7 +275,7 @@
|
|
275
275
|
|
276
276
|
print("df2")
|
277
277
|
print(df2)
|
278
|
-
df2 = pd.
|
278
|
+
df2 = pd.DataFrame({'v1' :[i, i*10]})
|
279
279
|
dfs.append(df2)
|
280
280
|
|
281
281
|
else:
|
6
該当のソースコード(df2はprintで確認_回答反映
test
CHANGED
File without changes
|
test
CHANGED
@@ -149,7 +149,7 @@
|
|
149
149
|
1.1.1.4 1.1.1.4 ・・・ 8 8
|
150
150
|
```
|
151
151
|
|
152
|
-
### 該当のソースコード(df2はprintで確認
|
152
|
+
### 該当のソースコード(df2はprintで確認_回答反映
|
153
153
|
|
154
154
|
```Python
|
155
155
|
import json
|
@@ -186,99 +186,110 @@
|
|
186
186
|
Tunnel_level_quality_analysis_df.to_csv(tmp_csv, encoding='utf-8', index=False)
|
187
187
|
|
188
188
|
s3 = boto3.resource('s3')
|
189
|
-
s3.meta.client.upload_file(tmp_csv
|
189
|
+
s3.meta.client.upload_file(tmp_csv 'utlink-vmanage-bucket', 'csv/Tunnel_level_quality_analysis.csv')
|
190
190
|
|
191
191
|
print("debug2")
|
192
192
|
|
193
193
|
def get_request(vmanage_info_df):
|
194
|
-
|
194
|
+
dfs = []
|
195
|
+
|
196
|
+
for i in range(13):
|
197
|
+
|
195
|
-
for row in vmanage_info_df.itertuples():
|
198
|
+
for row in vmanage_info_df.itertuples():
|
196
|
-
vmanage_host = row[1]
|
199
|
+
vmanage_host = row[1]
|
197
|
-
vmanage_port = row[2]
|
200
|
+
vmanage_port = row[2]
|
198
|
-
vmanage_username = row[3]
|
201
|
+
vmanage_username = row[3]
|
199
|
-
vmanage_password = row[4]
|
202
|
+
vmanage_password = row[4]
|
200
|
-
|
203
|
+
|
201
|
-
base_url = `https://%s:%s`%(vmanage_host, vmanage_port)
|
204
|
+
base_url = `https://%s:%s`%(vmanage_host, vmanage_port)
|
202
|
-
|
205
|
+
|
203
|
-
login_action = `/j_security_check`
|
206
|
+
login_action = `/j_security_check`
|
204
|
-
|
207
|
+
|
205
|
-
login_data = {`j_username` : vmanage_username, `j_password` : vmanage_password}
|
208
|
+
login_data = {`j_username` : vmanage_username, `j_password` : vmanage_password}
|
206
|
-
|
209
|
+
|
207
|
-
login_url = base_url + login_action
|
210
|
+
login_url = base_url + login_action
|
208
|
-
|
211
|
+
|
209
|
-
session = requests.session()
|
212
|
+
session = requests.session()
|
210
|
-
|
213
|
+
|
211
|
-
pring("debug3")
|
214
|
+
pring("debug3")
|
212
|
-
|
215
|
+
|
213
|
-
login_response = session.post(url=login_url, data=login_data, verify=False)
|
216
|
+
login_response = session.post(url=login_url, data=login_data, verify=False)
|
214
|
-
if b`<html>` in login_response.content:
|
217
|
+
if b`<html>` in login_response.content:
|
215
|
-
print("Login token Failed")
|
216
|
-
exit(1)
|
217
|
-
|
218
|
-
xsrf_token_url = base_url + '/dataservice/client/token'
|
219
|
-
|
220
|
-
login_token = session.get(url=xsrf_token_url, verify=False)
|
221
|
-
if login_token.status_code == 200:
|
222
|
-
if b`<html>` in login_token.content:
|
223
218
|
print("Login token Failed")
|
224
219
|
exit(1)
|
225
220
|
|
221
|
+
xsrf_token_url = base_url + '/dataservice/client/token'
|
222
|
+
|
223
|
+
login_token = session.get(url=xsrf_token_url, verify=False)
|
224
|
+
if login_token.status_code = 200:
|
225
|
+
if b`<html>` in login_token.content:
|
226
|
+
print("Login token Failed")
|
227
|
+
exit(1)
|
228
|
+
|
226
|
-
session.headers[`X-XSRF-TOKEN`] = login_token.content
|
229
|
+
session.headers[`X-XSRF-TOKEN`] = login_token.content
|
227
|
-
|
228
|
-
|
230
|
+
|
231
|
+
|
229
|
-
device_url = base_url + `/dataservice/device`
|
232
|
+
device_url = base_url + `/dataservice/device`
|
230
|
-
print("device_url")
|
233
|
+
print("device_url")
|
231
|
-
print(device_url)
|
234
|
+
print(device_url)
|
232
|
-
|
235
|
+
|
233
|
-
device_list = session.get(url=device_url, verify=False)
|
236
|
+
device_list = session.get(url=device_url, verify=False)
|
234
|
-
if device_list.status_code = 200:
|
237
|
+
if device_list.status_code = 200:
|
235
|
-
json_data = device_list.json()
|
238
|
+
json_data = vdevice_list.json()
|
236
|
-
else:
|
239
|
+
else:
|
237
|
-
print (device_list.status_code)
|
238
|
-
|
239
|
-
df = pd.json_normalize(json_data["data"]
|
240
|
-
df = df[(df["device-type"] == "vedge") & (df["reachability"] == "reachable")]
|
241
|
-
|
242
|
-
print("filter_df")
|
243
|
-
print(df)
|
244
|
-
|
245
|
-
df = df[["deviceId", "system-ip", "host-name", "device-model", "bfdSessionsUp", "bfdSessions"]]
|
246
|
-
|
247
|
-
for data in df.itertuples():
|
248
|
-
System_ip = data[1]
|
249
|
-
query_data = ["query":(略),["value":[System_ip],(略)"type":"sum"}]}}
|
250
|
-
print("query_data")
|
251
|
-
print(query_data)
|
252
|
-
|
253
|
-
device_url = base_url + '/dataservice/statistics/approute/fec/aggregation'
|
254
|
-
#print("device_url")
|
255
|
-
#print(device_url)
|
256
|
-
|
257
|
-
device_list = session.post(url=device_url, json=query_data, headers=headers_post, verify=False)
|
258
|
-
print("device_list")
|
259
|
-
print(device_list)
|
260
|
-
|
261
|
-
if device_list.status_code == 200:
|
262
240
|
print (device_list.status_code)
|
241
|
+
|
242
|
+
df = pd.json_normalize(json_data["data"]
|
243
|
+
df = df[(df["device-type"] == "vedge") & (df["reachability"] == "reachable")]
|
244
|
+
|
245
|
+
print("filter_df")
|
246
|
+
print(df)
|
247
|
+
|
248
|
+
df = df[["deviceId", "system-ip", "host-name", "device-model", "bfdSessionsUp", "bfdSessions"]]
|
249
|
+
|
250
|
+
for data in df.itertuples():
|
251
|
+
System_ip = data[1]
|
252
|
+
query_data = ["query":(略),["value":[System_ip],(略)"type":"sum"}]}}
|
253
|
+
print("query_data")
|
254
|
+
print(query_data)
|
255
|
+
|
256
|
+
device_url = base_url + '/dataservice/statistics/approute/fec/aggregation'
|
257
|
+
print("device_url")
|
258
|
+
print(device_url)
|
259
|
+
|
260
|
+
device_list = session.post(url=device_url, json=query_data, headers=headers_post, verify=False)
|
261
|
+
print("device_list")
|
262
|
+
print(device_list)
|
263
|
+
|
264
|
+
if device_list.status_code == 200:
|
263
|
-
json_data = device_list.json()
|
265
|
+
json_data = device_list.json()
|
264
|
-
|
266
|
+
|
265
|
-
df2 = pd.json_normalize(json_data["data"])
|
267
|
+
df2 = pd.json_normalize(json_data["data"])
|
266
|
-
|
268
|
+
|
267
|
-
#先頭にsystemip
|
269
|
+
#先頭にsystemip
|
268
|
-
df2.insert(0, 'System_ip', data[1])
|
270
|
+
df2.insert(0, 'System_ip', data[1])
|
269
|
-
#末尾にdatetime
|
271
|
+
#末尾にdatetime
|
270
|
-
df2['d
|
272
|
+
df2['df'] = datetime.now(),strftime('%Y%m%d% %H:%M:%S')
|
271
|
-
c = df2.pop('dt')
|
273
|
+
c = df2.pop('dt')
|
272
|
-
df
|
274
|
+
df.insert(df2.shape[1], c.name, c)
|
273
|
-
|
275
|
+
|
274
|
-
print("df2")
|
276
|
+
print("df2")
|
275
|
-
print(df2)
|
277
|
+
print(df2)
|
276
|
-
|
278
|
+
df2 = pd.dataFrame({'v1' :[i, i*10]})
|
279
|
+
dfs.append(df2)
|
280
|
+
|
277
|
-
else:
|
281
|
+
else:
|
278
|
-
print(device_list.status_code)
|
282
|
+
print(device_list.status_code)
|
283
|
+
|
279
|
-
|
284
|
+
print("df_intertuples")
|
280
|
-
|
285
|
+
print(df)
|
286
|
+
|
281
|
-
return df
|
287
|
+
return df
|
288
|
+
|
289
|
+
df_ret = pd.concat(dfs).rest_index(drop=True)
|
290
|
+
return df_ret
|
291
|
+
#df_ret = get_request(vmanage_info_df)
|
292
|
+
#print(df_ret)
|
282
293
|
```
|
283
294
|
|
284
295
|
|
5
ソースコードを修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -149,9 +149,9 @@
|
|
149
149
|
1.1.1.4 1.1.1.4 ・・・ 8 8
|
150
150
|
```
|
151
151
|
|
152
|
-
### 該当のソースコード(
|
152
|
+
### 該当のソースコード(df2はprintで確認
|
153
|
-
|
153
|
+
|
154
|
-
```
|
154
|
+
```Python
|
155
155
|
import json
|
156
156
|
import boto3
|
157
157
|
import csv
|
@@ -170,7 +170,7 @@
|
|
170
170
|
|
171
171
|
def lambda_handler(event, context):
|
172
172
|
s3 = boto3.resource(`s3`)
|
173
|
-
bucket_name
|
173
|
+
bucket_name = os.environ.get(`S3_BUCKET`)
|
174
174
|
|
175
175
|
vmanage_info = "tmp/vmanage_info.csv"
|
176
176
|
bucket.download_file(os.environ.get(`CSV_VMANAGE_INFO`), vmanage_info)
|
@@ -186,111 +186,99 @@
|
|
186
186
|
Tunnel_level_quality_analysis_df.to_csv(tmp_csv, encoding='utf-8', index=False)
|
187
187
|
|
188
188
|
s3 = boto3.resource('s3')
|
189
|
-
s3.meta.client.upload_file(tmp_csv 'utlink-vmanage-bucket', 'csv/Tunnel_level_quality_analysis.csv')
|
189
|
+
s3.meta.client.upload_file(tmp_csvm 'utlink-vmanage-bucket', 'csv/Tunnel_level_quality_analysis.csv')
|
190
190
|
|
191
191
|
print("debug2")
|
192
192
|
|
193
193
|
def get_request(vmanage_info_df):
|
194
|
-
dfs = []
|
195
194
|
#api_datalist = []
|
196
|
-
|
197
|
-
for i in range(13):
|
198
|
-
|
199
|
-
|
195
|
+
for row in vmanage_info_df.itertuples():
|
200
|
-
|
196
|
+
vmanage_host = row[1]
|
201
|
-
|
197
|
+
vmanage_port = row[2]
|
202
|
-
|
198
|
+
vmanage_username = row[3]
|
203
|
-
|
199
|
+
vmanage_password = row[4]
|
204
|
-
|
200
|
+
|
205
|
-
|
201
|
+
base_url = `https://%s:%s`%(vmanage_host, vmanage_port)
|
206
|
-
|
202
|
+
|
207
|
-
|
203
|
+
login_action = `/j_security_check`
|
208
|
-
|
204
|
+
|
209
|
-
|
205
|
+
login_data = {`j_username` : vmanage_username, `j_password` : vmanage_password}
|
210
|
-
|
206
|
+
|
211
|
-
|
207
|
+
login_url = base_url + login_action
|
212
|
-
|
208
|
+
|
213
|
-
|
209
|
+
session = requests.session()
|
214
|
-
|
210
|
+
|
215
|
-
|
211
|
+
pring("debug3")
|
216
|
-
|
212
|
+
|
217
|
-
|
213
|
+
login_response = session.post(url=login_url, data=login_data, verify=False)
|
218
|
-
|
214
|
+
if b`<html>` in login_response.content:
|
215
|
+
print("Login token Failed")
|
216
|
+
exit(1)
|
217
|
+
|
218
|
+
xsrf_token_url = base_url + '/dataservice/client/token'
|
219
|
+
|
220
|
+
login_token = session.get(url=xsrf_token_url, verify=False)
|
221
|
+
if login_token.status_code == 200:
|
222
|
+
if b`<html>` in login_token.content:
|
219
223
|
print("Login token Failed")
|
220
224
|
exit(1)
|
221
225
|
|
226
|
+
session.headers[`X-XSRF-TOKEN`] = login_token.content
|
227
|
+
|
228
|
+
|
222
|
-
|
229
|
+
device_url = base_url + `/dataservice/device`
|
223
|
-
|
230
|
+
print("device_url")
|
231
|
+
print(device_url)
|
232
|
+
|
224
|
-
|
233
|
+
device_list = session.get(url=device_url, verify=False)
|
225
|
-
|
234
|
+
if device_list.status_code = 200:
|
235
|
+
json_data = device_list.json()
|
236
|
+
else:
|
237
|
+
print (device_list.status_code)
|
238
|
+
|
226
|
-
|
239
|
+
df = pd.json_normalize(json_data["data"]
|
240
|
+
df = df[(df["device-type"] == "vedge") & (df["reachability"] == "reachable")]
|
241
|
+
|
242
|
+
print("filter_df")
|
243
|
+
print(df)
|
244
|
+
|
245
|
+
df = df[["deviceId", "system-ip", "host-name", "device-model", "bfdSessionsUp", "bfdSessions"]]
|
246
|
+
|
247
|
+
for data in df.itertuples():
|
248
|
+
System_ip = data[1]
|
249
|
+
query_data = ["query":(略),["value":[System_ip],(略)"type":"sum"}]}}
|
250
|
+
print("query_data")
|
251
|
+
print(query_data)
|
252
|
+
|
253
|
+
device_url = base_url + '/dataservice/statistics/approute/fec/aggregation'
|
254
|
+
#print("device_url")
|
255
|
+
#print(device_url)
|
256
|
+
|
257
|
+
device_list = session.post(url=device_url, json=query_data, headers=headers_post, verify=False)
|
227
|
-
|
258
|
+
print("device_list")
|
228
|
-
|
259
|
+
print(device_list)
|
260
|
+
|
261
|
+
if device_list.status_code == 200:
|
262
|
+
print (device_list.status_code)
|
263
|
+
json_data = device_list.json()
|
229
264
|
|
230
|
-
|
265
|
+
df2 = pd.json_normalize(json_data["data"])
|
231
266
|
|
232
|
-
|
267
|
+
#先頭にsystemip
|
233
|
-
d
|
268
|
+
df2.insert(0, 'System_ip', data[1])
|
269
|
+
#末尾にdatetime
|
270
|
+
df2['dt'] = datetime.now(),strftime('%Y%m%d% %H:%M:%S')
|
271
|
+
c = df2.pop('dt')
|
272
|
+
df2.insert(df2.shape[1], c.name, c)
|
273
|
+
|
234
|
-
print("d
|
274
|
+
print("df2")
|
235
|
-
print(d
|
275
|
+
print(df2)
|
236
|
-
|
237
|
-
|
276
|
+
|
238
|
-
if device_list.status_code = 200:
|
239
|
-
json_data = vdevice_list.json()
|
240
277
|
else:
|
241
|
-
print (device_list.status_code)
|
242
|
-
|
243
|
-
df = pd.json_normalize(json_data["data"]
|
244
|
-
df = df[(df["device-type"] == "vedge") & (df["reachability"] == "reachable")]
|
245
|
-
|
246
|
-
print("filter_df")
|
247
|
-
print(df)
|
248
|
-
|
249
|
-
df = df[["deviceId", "system-ip", "host-name", "device-model", "bfdSessionsUp", "bfdSessions"]]
|
250
|
-
|
251
|
-
for data in df.itertuples():
|
252
|
-
System_ip = data[1]
|
253
|
-
query_data = ["query":(略),["value":[System_ip],(略)"type":"sum"}]}}
|
254
|
-
print("query_data")
|
255
|
-
print(query_data)
|
256
|
-
|
257
|
-
device_url = base_url + '/dataservice/statistics/approute/fec/aggregation'
|
258
|
-
print("device_url")
|
259
|
-
print(device_url)
|
260
|
-
|
261
|
-
device_list = session.post(url=device_url, json=query_data, headers=headers_post, verify=False)
|
262
|
-
print("device_list")
|
263
|
-
print(device_list)
|
264
|
-
|
265
|
-
if device_list.status_code == 200:
|
266
|
-
json_data = device_list.json()
|
267
|
-
|
268
|
-
df2 = pd.json_normalize(json_data["data"])
|
269
|
-
|
270
|
-
#先頭にsystemip
|
271
|
-
df2.insert(0, 'System_ip', data[1])
|
272
|
-
#末尾にdatetime
|
273
|
-
df2['df'] = datetime.now(),strftime('%Y%m%d% %H:%M:%S')
|
274
|
-
c = df2.pop('dt')
|
275
|
-
df.insert(df2.shape[1], c.name, c)
|
276
|
-
|
277
|
-
print("df2")
|
278
|
-
print(df2)
|
279
|
-
#df2 = pd.dataFrame({'v1' :[i, i*10]})
|
280
|
-
dfs.append(df2)
|
281
|
-
|
282
|
-
else:
|
283
|
-
|
278
|
+
print(device_list.status_code)
|
284
|
-
|
285
|
-
|
279
|
+
|
286
|
-
|
280
|
+
|
287
|
-
|
288
|
-
|
281
|
+
return df
|
289
|
-
|
290
|
-
df_ret = pd.concat(dfs).rest_index(drop=True)
|
291
|
-
return df_ret
|
292
|
-
df_ret = get_request(vmanage_info_df)
|
293
|
-
print(df_ret)
|
294
282
|
```
|
295
283
|
|
296
284
|
|
4
range修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -194,7 +194,7 @@
|
|
194
194
|
dfs = []
|
195
195
|
#api_datalist = []
|
196
196
|
|
197
|
-
for i in range(3):
|
197
|
+
for i in range(13):
|
198
198
|
|
199
199
|
for row in vmanage_info_df.itertuples():
|
200
200
|
vmanage_host = row[1]
|
3
回答を反映したソースを追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -60,9 +60,6 @@
|
|
60
60
|
1.1.1.4 99.97・・・・5 2023/01/01 01:01:01
|
61
61
|
1.1.1.4 99.96・・・・5 2023/01/01 01:01:01
|
62
62
|
```
|
63
|
-
|
64
|
-
|
65
|
-
|
66
63
|
|
67
64
|
### 発生している問題・エラーメッセージ
|
68
65
|
|
@@ -152,9 +149,9 @@
|
|
152
149
|
1.1.1.4 1.1.1.4 ・・・ 8 8
|
153
150
|
```
|
154
151
|
|
155
|
-
### 該当のソースコード
|
152
|
+
### 該当のソースコード(回答を反映
|
156
|
-
|
153
|
+
|
157
|
-
```
|
154
|
+
```
|
158
155
|
import json
|
159
156
|
import boto3
|
160
157
|
import csv
|
@@ -189,101 +186,113 @@
|
|
189
186
|
Tunnel_level_quality_analysis_df.to_csv(tmp_csv, encoding='utf-8', index=False)
|
190
187
|
|
191
188
|
s3 = boto3.resource('s3')
|
192
|
-
s3.meta.client.upload_file(tmp_csv
|
189
|
+
s3.meta.client.upload_file(tmp_csv 'utlink-vmanage-bucket', 'csv/Tunnel_level_quality_analysis.csv')
|
193
190
|
|
194
191
|
print("debug2")
|
195
192
|
|
196
193
|
def get_request(vmanage_info_df):
|
194
|
+
dfs = []
|
197
|
-
api_datalist = []
|
195
|
+
#api_datalist = []
|
196
|
+
|
197
|
+
for i in range(3):
|
198
|
+
|
198
|
-
for row in vmanage_info_df.itertuples():
|
199
|
+
for row in vmanage_info_df.itertuples():
|
199
|
-
vmanage_host = row[1]
|
200
|
+
vmanage_host = row[1]
|
200
|
-
vmanage_port = row[2]
|
201
|
+
vmanage_port = row[2]
|
201
|
-
vmanage_username = row[3]
|
202
|
+
vmanage_username = row[3]
|
202
|
-
vmanage_password = row[4]
|
203
|
+
vmanage_password = row[4]
|
203
|
-
|
204
|
+
|
204
|
-
base_url = `https://%s:%s`%(vmanage_host, vmanage_port)
|
205
|
+
base_url = `https://%s:%s`%(vmanage_host, vmanage_port)
|
205
|
-
|
206
|
+
|
206
|
-
login_action = `/j_security_check`
|
207
|
+
login_action = `/j_security_check`
|
207
|
-
|
208
|
+
|
208
|
-
login_data = {`j_username` : vmanage_username, `j_password` : vmanage_password}
|
209
|
+
login_data = {`j_username` : vmanage_username, `j_password` : vmanage_password}
|
209
|
-
|
210
|
+
|
210
|
-
login_url = base_url + login_action
|
211
|
+
login_url = base_url + login_action
|
211
|
-
|
212
|
+
|
212
|
-
session = requests.session()
|
213
|
+
session = requests.session()
|
213
|
-
|
214
|
+
|
214
|
-
pring("debug3")
|
215
|
+
pring("debug3")
|
215
|
-
|
216
|
+
|
216
|
-
login_response = session.post(url=login_url, data=login_data, verify=False)
|
217
|
+
login_response = session.post(url=login_url, data=login_data, verify=False)
|
217
|
-
if b`<html>` in login_response.content:
|
218
|
+
if b`<html>` in login_response.content:
|
218
|
-
print("Login token Failed")
|
219
|
-
exit(1)
|
220
|
-
|
221
|
-
xsrf_token_url = base_url + '/dataservice/client/token'
|
222
|
-
|
223
|
-
login_token = session.get(url=xsrf_token_url, verify=False)
|
224
|
-
if login_token.status_code = 200:
|
225
|
-
if b`<html>` in login_token.content:
|
226
219
|
print("Login token Failed")
|
227
220
|
exit(1)
|
228
221
|
|
222
|
+
xsrf_token_url = base_url + '/dataservice/client/token'
|
223
|
+
|
224
|
+
login_token = session.get(url=xsrf_token_url, verify=False)
|
225
|
+
if login_token.status_code = 200:
|
226
|
+
if b`<html>` in login_token.content:
|
227
|
+
print("Login token Failed")
|
228
|
+
exit(1)
|
229
|
+
|
229
|
-
session.headers[`X-XSRF-TOKEN`] = login_token.content
|
230
|
+
session.headers[`X-XSRF-TOKEN`] = login_token.content
|
230
|
-
|
231
|
-
|
231
|
+
|
232
|
+
|
232
|
-
device_url = base_url + `/dataservice/device`
|
233
|
+
device_url = base_url + `/dataservice/device`
|
233
|
-
print("device_url")
|
234
|
-
print(device_url)
|
235
|
-
|
236
|
-
device_list = session.get(url=device_url, verify=False)
|
237
|
-
if device_list.status_code = 200:
|
238
|
-
json_data = vdevice_list.json()
|
239
|
-
else:
|
240
|
-
print (device_list.status_code)
|
241
|
-
|
242
|
-
df = pd.json_normalize(json_data["data"]
|
243
|
-
df = df[(df["device-type"] == "vedge") & (df["reachability"] == "reachable")]
|
244
|
-
|
245
|
-
print("filter_df")
|
246
|
-
print(df)
|
247
|
-
|
248
|
-
df = df[["deviceId", "system-ip", "host-name", "device-model", "bfdSessionsUp", "bfdSessions"]]
|
249
|
-
|
250
|
-
for data in df.itertuples():
|
251
|
-
System_ip = data[1]
|
252
|
-
query_data = ["query":(略),["value":[System_ip],(略)"type":"sum"}]}}
|
253
|
-
print("query_data")
|
254
|
-
print(query_data)
|
255
|
-
|
256
|
-
device_url = base_url + '/dataservice/statistics/approute/fec/aggregation'
|
257
234
|
print("device_url")
|
258
235
|
print(device_url)
|
259
236
|
|
260
|
-
device_list = session.
|
237
|
+
device_list = session.get(url=device_url, verify=False)
|
261
|
-
print("device_list")
|
262
|
-
print(device_list)
|
263
|
-
|
264
|
-
if device_list.status_code =
|
238
|
+
if device_list.status_code = 200:
|
265
|
-
json_data = device_list.json()
|
239
|
+
json_data = vdevice_list.json()
|
266
|
-
|
267
|
-
df2 = pd.json_normalize(json_data["data"])
|
268
|
-
|
269
|
-
#先頭にsystemip
|
270
|
-
df2.insert(0, 'System_ip', data[1])
|
271
|
-
#末尾にdatetime
|
272
|
-
df2['df'] = datetime.now(),strftime('%Y%m%d% %H:%M:%S')
|
273
|
-
c = df2.pop('dt')
|
274
|
-
df.insert(df2.shape[1], c.name, c)
|
275
|
-
|
276
|
-
print("df2")
|
277
|
-
print(df2)
|
278
|
-
|
279
240
|
else:
|
280
|
-
print(device_list.status_code)
|
241
|
+
print (device_list.status_code)
|
242
|
+
|
281
|
-
|
243
|
+
df = pd.json_normalize(json_data["data"]
|
244
|
+
df = df[(df["device-type"] == "vedge") & (df["reachability"] == "reachable")]
|
245
|
+
|
282
|
-
print("
|
246
|
+
print("filter_df")
|
283
247
|
print(df)
|
248
|
+
|
284
|
-
|
249
|
+
df = df[["deviceId", "system-ip", "host-name", "device-model", "bfdSessionsUp", "bfdSessions"]]
|
250
|
+
|
251
|
+
for data in df.itertuples():
|
252
|
+
System_ip = data[1]
|
253
|
+
query_data = ["query":(略),["value":[System_ip],(略)"type":"sum"}]}}
|
254
|
+
print("query_data")
|
255
|
+
print(query_data)
|
256
|
+
|
257
|
+
device_url = base_url + '/dataservice/statistics/approute/fec/aggregation'
|
258
|
+
print("device_url")
|
259
|
+
print(device_url)
|
260
|
+
|
261
|
+
device_list = session.post(url=device_url, json=query_data, headers=headers_post, verify=False)
|
262
|
+
print("device_list")
|
263
|
+
print(device_list)
|
264
|
+
|
265
|
+
if device_list.status_code == 200:
|
266
|
+
json_data = device_list.json()
|
267
|
+
|
268
|
+
df2 = pd.json_normalize(json_data["data"])
|
269
|
+
|
270
|
+
#先頭にsystemip
|
271
|
+
df2.insert(0, 'System_ip', data[1])
|
272
|
+
#末尾にdatetime
|
273
|
+
df2['df'] = datetime.now(),strftime('%Y%m%d% %H:%M:%S')
|
274
|
+
c = df2.pop('dt')
|
275
|
+
df.insert(df2.shape[1], c.name, c)
|
276
|
+
|
277
|
+
print("df2")
|
278
|
+
print(df2)
|
279
|
+
#df2 = pd.dataFrame({'v1' :[i, i*10]})
|
280
|
+
dfs.append(df2)
|
281
|
+
|
282
|
+
else:
|
283
|
+
print(device_list.status_code)
|
284
|
+
|
285
|
+
print("df_intertuples")
|
286
|
+
print(df)
|
287
|
+
|
285
|
-
return df
|
288
|
+
return df
|
289
|
+
|
290
|
+
df_ret = pd.concat(dfs).rest_index(drop=True)
|
291
|
+
return df_ret
|
292
|
+
df_ret = get_request(vmanage_info_df)
|
293
|
+
print(df_ret)
|
286
|
-
```
|
294
|
+
```
|
295
|
+
|
287
296
|
|
288
297
|
### 試したこと
|
289
298
|
|
2
タイトルを変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Python APIの結果を
|
1
|
+
Python APIの結果をdataframeを使ってget_request()にすべての結果を入れることができない
|
test
CHANGED
File without changes
|
1
指摘により修正し、再度検証した結果、次の問題について修正・追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -15,7 +15,9 @@
|
|
15
15
|
1.1.1.4
|
16
16
|
```
|
17
17
|
|
18
|
-
例として、2つ目のAPI結果では1デバイスに複数のTunnel結果が
|
18
|
+
例として、2つ目のAPI結果では、1デバイスに複数のTunnel結果が出力される。
|
19
|
+
1.1.1.1以下に存在する複数のトンネル(abc, edf, ghi, jki...)
|
20
|
+
|
19
21
|
```example
|
20
22
|
deviceId debice loss latency
|
21
23
|
1.1.1.1 abc 999 999
|
@@ -23,7 +25,42 @@
|
|
23
25
|
1.1.1.1 ghi 999 999
|
24
26
|
1.1.1.1 jkl 999 999
|
25
27
|
```
|
28
|
+
|
29
|
+
指摘により、1デバイスxn個のトンネルが、デバイス一覧すべてをprintすることで
|
30
|
+
Logでは取得できていることを確認できたが、
|
31
|
+
以下の箇所のロジックにて、csvで出力することができない
|
32
|
+
|
33
|
+
Tunnel_level_quality_analysis_df = get_request(vmanage_info_df)
|
34
|
+
以上の一文でget_request(vmanage_info_df)をcsvに入れると認識している。
|
35
|
+
|
26
|
-
しかし
|
36
|
+
しかし、csvの結果が、デバイス一覧のみしか出力されていない。
|
37
|
+
df = df[["deviceId", "system-ip", "host-name", "device-model", "bfdSessionsUp", "bfdSessions"]]
|
38
|
+
の結果しか入っていない状況です。
|
39
|
+
|
40
|
+
想定結果のcsv
|
41
|
+
```Result_from_csv
|
42
|
+
System_ip loss_percentage ・・・・ vqoe_score dt
|
43
|
+
1.1.1.1 99.99・・・・5 2023/01/01 01:01:01
|
44
|
+
1.1.1.1 99.98・・・・5 2023/01/01 01:01:01
|
45
|
+
1.1.1.1 99.97・・・・5 2023/01/01 01:01:01
|
46
|
+
1.1.1.1 99.96・・・・5 2023/01/01 01:01:01
|
47
|
+
System_ip loss_percentage ・・・・ vqoe_score dt
|
48
|
+
1.1.1.2 99.99・・・・5 2023/01/01 01:01:01
|
49
|
+
1.1.1.2 99.98・・・・5 2023/01/01 01:01:01
|
50
|
+
1.1.1.2 99.97・・・・5 2023/01/01 01:01:01
|
51
|
+
1.1.1.2 99.96・・・・5 2023/01/01 01:01:01
|
52
|
+
System_ip loss_percentage ・・・・ vqoe_score dt
|
53
|
+
1.1.1.3 99.99・・・・5 2023/01/01 01:01:01
|
54
|
+
1.1.1.3 99.98・・・・5 2023/01/01 01:01:01
|
55
|
+
1.1.1.3 99.97・・・・5 2023/01/01 01:01:01
|
56
|
+
1.1.1.3 99.96・・・・5 2023/01/01 01:01:01
|
57
|
+
System_ip loss_percentage ・・・・ vqoe_score dt
|
58
|
+
1.1.1.4 99.99・・・・5 2023/01/01 01:01:01
|
59
|
+
1.1.1.4 99.98・・・・5 2023/01/01 01:01:01
|
60
|
+
1.1.1.4 99.97・・・・5 2023/01/01 01:01:01
|
61
|
+
1.1.1.4 99.96・・・・5 2023/01/01 01:01:01
|
62
|
+
```
|
63
|
+
|
27
64
|
|
28
65
|
|
29
66
|
|
@@ -44,73 +81,75 @@
|
|
44
81
|
|
45
82
|
query_data
|
46
83
|
{'query':(略),{'value':['1.1.1.1'],(略). 'type':'sum'}]}}
|
47
|
-
devide_url
|
48
|
-
https://vmanage_ABC//dataservice/statistics/approute/fec/aggregation
|
49
84
|
device_list
|
50
85
|
<Response [200]>
|
51
86
|
200
|
52
|
-
df_json_data
|
53
|
-
[{'loss_percentage': 99.99, (略), 'vqoe_score': 5}]
|
54
|
-
df
|
87
|
+
df2
|
55
|
-
loss_percentage・・・・vqoe_score
|
88
|
+
System_ip loss_percentage ・・・・ vqoe_score dt
|
89
|
+
1.1.1.1 99.99・・・・5 2023/01/01 01:01:01
|
90
|
+
1.1.1.1 99.98・・・・5 2023/01/01 01:01:01
|
91
|
+
1.1.1.1 99.97・・・・5 2023/01/01 01:01:01
|
92
|
+
1.1.1.1 99.96・・・・5 2023/01/01 01:01:01
|
56
|
-
|
93
|
+
df_itertuples
|
94
|
+
deviceId system_ip・・・bdfSessionsUp bfdSessions
|
57
|
-
|
95
|
+
1.1.1.1 1.1.1.1 ・・・ 8 8
|
58
|
-
|
96
|
+
1.1.1.2 1.1.1.2 ・・・ 8 8
|
59
|
-
|
97
|
+
1.1.1.3 1.1.1.3 ・・・ 8 8
|
98
|
+
1.1.1.4 1.1.1.4 ・・・ 8 8
|
60
99
|
|
61
100
|
query_data
|
62
|
-
{'query':(略),{'value':['1.1.1.
|
101
|
+
{'query':(略),{'value':['1.1.1.1'],(略). 'type':'sum'}]}}
|
63
|
-
devide_url
|
64
|
-
https://vmanage_ABC//dataservice/statistics/approute/fec/aggregation
|
65
102
|
device_list
|
66
103
|
<Response [200]>
|
67
104
|
200
|
68
|
-
df_json_data
|
69
|
-
[{'loss_percentage': 99.99, (略), 'vqoe_score': 5}]
|
70
|
-
df
|
105
|
+
df2
|
71
|
-
loss_percentage・・・・vqoe_score
|
106
|
+
System_ip loss_percentage ・・・・ vqoe_score dt
|
107
|
+
1.1.1.2 99.99・・・・5 2023/01/01 01:01:01
|
108
|
+
1.1.1.2 99.98・・・・5 2023/01/01 01:01:01
|
109
|
+
1.1.1.2 99.97・・・・5 2023/01/01 01:01:01
|
110
|
+
1.1.1.2 99.96・・・・5 2023/01/01 01:01:01
|
72
|
-
|
111
|
+
df_itertuples
|
112
|
+
deviceId system_ip・・・bdfSessionsUp bfdSessions
|
73
|
-
|
113
|
+
1.1.1.1 1.1.1.1 ・・・ 8 8
|
74
|
-
|
114
|
+
1.1.1.2 1.1.1.2 ・・・ 8 8
|
75
|
-
|
115
|
+
1.1.1.3 1.1.1.3 ・・・ 8 8
|
116
|
+
1.1.1.4 1.1.1.4 ・・・ 8 8
|
76
117
|
|
77
118
|
query_data
|
78
|
-
{'query':(略),{'value':['1.1.1.
|
119
|
+
{'query':(略),{'value':['1.1.1.1'],(略). 'type':'sum'}]}}
|
79
|
-
devide_url
|
80
|
-
https://vmanage_ABC//dataservice/statistics/approute/fec/aggregation
|
81
120
|
device_list
|
82
121
|
<Response [200]>
|
83
122
|
200
|
84
|
-
df_json_data
|
85
|
-
[{'loss_percentage': 99.99, (略), 'vqoe_score': 5}]
|
86
|
-
df
|
123
|
+
df2
|
87
|
-
loss_percentage・・・・vqoe_score
|
124
|
+
System_ip loss_percentage ・・・・ vqoe_score dt
|
125
|
+
1.1.1.3 99.99・・・・5 2023/01/01 01:01:01
|
126
|
+
1.1.1.3 99.98・・・・5 2023/01/01 01:01:01
|
127
|
+
1.1.1.3 99.97・・・・5 2023/01/01 01:01:01
|
128
|
+
1.1.1.3 99.96・・・・5 2023/01/01 01:01:01
|
88
|
-
|
129
|
+
df_itertuples
|
130
|
+
deviceId system_ip・・・bdfSessionsUp bfdSessions
|
89
|
-
|
131
|
+
1.1.1.1 1.1.1.1 ・・・ 8 8
|
90
|
-
|
132
|
+
1.1.1.2 1.1.1.2 ・・・ 8 8
|
91
|
-
|
133
|
+
1.1.1.3 1.1.1.3 ・・・ 8 8
|
134
|
+
1.1.1.4 1.1.1.4 ・・・ 8 8
|
92
135
|
|
93
136
|
query_data
|
94
137
|
{'query':(略),{'value':['1.1.1.1'],(略). 'type':'sum'}]}}
|
95
|
-
devide_url
|
96
|
-
https://vmanage_ABC//dataservice/statistics/approute/fec/aggregation
|
97
138
|
device_list
|
98
139
|
<Response [200]>
|
99
140
|
200
|
100
|
-
df_json_data
|
101
|
-
[{'loss_percentage': 99.99, (略), 'vqoe_score': 5}]
|
102
|
-
df
|
141
|
+
df2
|
103
|
-
loss_percentage・・・・vqoe_score
|
104
|
-
99.99・・・・5
|
105
|
-
99.98・・・・5
|
106
|
-
99.97・・・・5
|
107
|
-
99.96・・・・5
|
108
|
-
|
109
142
|
System_ip loss_percentage ・・・・ vqoe_score dt
|
110
143
|
1.1.1.4 99.99・・・・5 2023/01/01 01:01:01
|
111
144
|
1.1.1.4 99.98・・・・5 2023/01/01 01:01:01
|
112
145
|
1.1.1.4 99.97・・・・5 2023/01/01 01:01:01
|
113
146
|
1.1.1.4 99.96・・・・5 2023/01/01 01:01:01
|
147
|
+
df_itertuples
|
148
|
+
deviceId system_ip・・・bdfSessionsUp bfdSessions
|
149
|
+
1.1.1.1 1.1.1.1 ・・・ 8 8
|
150
|
+
1.1.1.2 1.1.1.2 ・・・ 8 8
|
151
|
+
1.1.1.3 1.1.1.3 ・・・ 8 8
|
152
|
+
1.1.1.4 1.1.1.4 ・・・ 8 8
|
114
153
|
```
|
115
154
|
|
116
155
|
### 該当のソースコード
|
@@ -224,23 +263,25 @@
|
|
224
263
|
|
225
264
|
if device_list.status_code == 200:
|
226
265
|
json_data = device_list.json()
|
266
|
+
|
267
|
+
df2 = pd.json_normalize(json_data["data"])
|
268
|
+
|
269
|
+
#先頭にsystemip
|
270
|
+
df2.insert(0, 'System_ip', data[1])
|
271
|
+
#末尾にdatetime
|
272
|
+
df2['df'] = datetime.now(),strftime('%Y%m%d% %H:%M:%S')
|
273
|
+
c = df2.pop('dt')
|
274
|
+
df.insert(df2.shape[1], c.name, c)
|
275
|
+
|
276
|
+
print("df2")
|
277
|
+
print(df2)
|
278
|
+
|
227
279
|
else:
|
228
280
|
print(device_list.status_code)
|
229
281
|
|
230
|
-
df = pd.json_normalize(json_data["data"])
|
231
|
-
|
232
|
-
print("df_
|
282
|
+
print("df_itertuples")
|
233
|
-
print(json_data["data"])
|
234
|
-
|
235
|
-
print("df")
|
236
283
|
print(df)
|
237
|
-
|
238
|
-
|
284
|
+
|
239
|
-
df['df'] = datetime.now(),strftime('%Y%m%d% %H:%M:%S')
|
240
|
-
c = df.pop('dt')
|
241
|
-
df.insert(df.shape[1], c.name, c)
|
242
|
-
|
243
|
-
print(df)
|
244
285
|
return df
|
245
286
|
```
|
246
287
|
|