-
Notifications
You must be signed in to change notification settings - Fork 11
/
veeam_enterprisemanager.sh
628 lines (576 loc) · 36.8 KB
/
veeam_enterprisemanager.sh
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
#!/bin/bash
## .SYNOPSIS
## Grafana Dashboard for Veeam Enterprise Manager v12.1.1 - Using RestAPI to InfluxDB Script
##
## .DESCRIPTION
## This Script will query the Veeam Enterprise Manager RestAPI and send the data directly to InfluxDB, which can be used to present it to Grafana.
## The Script and the Grafana Dashboard it is provided as it is, and bear in mind you can not open support Tickets regarding this project. It is a Community Project
##
## .THANKS
## Thank you to tigattack - https://github.com/tigattack for the help moving the Veeam scripts to InfluxDB v2
##
## .Notes
## NAME: veeam_enterprisemanager.sh
## ORIGINAL NAME: veeam_enterprisemanager.sh
## LASTEDIT: 22/01/2024
## VERSION: 12.1.1
## KEYWORDS: Veeam, InfluxDB, Grafana
## .Link
## https://jorgedelacruz.es/
## https://jorgedelacruz.uk/
##
# Configurations
##
# Endpoint URL for InfluxDB
veeamInfluxDBURL="http://YOURINFLUXSERVERIP" #Your InfluxDB Server, http://FQDN or https://FQDN if using SSL
veeamInfluxDBPort="8086" #Default Port
veeamInfluxDBBucket="veeam" # InfluxDB bucket name (not ID)
veeamInfluxDBToken="TOKEN" # InfluxDB access token with read/write privileges for the bucket
veeamInfluxDBOrg="ORG NAME" # InfluxDB organisation name (not ID)
# Endpoint URL for login action
veeamUsername="YOUREMUSER" #Your username, if using domain based account, please add it like user@domain.com (if you use domain\account it is not going to work!)
veeamPassword='YOUREMPASSWORD'
veeamJobSessions="100"
veeamAuth=$(echo -ne "$veeamUsername:$veeamPassword" | base64);
veeamRestServer="YOUREMSERVERIP"
veeamRestPort="9398" #Default Port
veeamSessionId=$(curl -X POST "https://$veeamRestServer:$veeamRestPort/api/sessionMngr/?v=latest" -H "Authorization:Basic $veeamAuth" -H "Content-Length: 0" -H "Accept: application/json" -k --silent | awk 'NR==1{sub(/^\xef\xbb\xbf/,"")}1' | jq --raw-output ".SessionId")
veeamXRestSvcSessionId=$(echo -ne "$veeamSessionId" | base64);
timestart=$(date --date="-1 days" +%FT%TZ)
##
# Veeam Enterprise Manager Overview. Overview of Backup Infrastructure and Job Status
##
veeamEMUrl="https://$veeamRestServer:$veeamRestPort/api/reports/summary/overview"
veeamEMOUrl=$(curl -X GET "$veeamEMUrl" -H "Accept:application/json" -H "X-RestSvcSessionId: $veeamXRestSvcSessionId" -H "Cookie: X-RestSvcSessionId=$veeamXRestSvcSessionId" -H "Content-Length: 0" 2>&1 -k --silent | awk 'NR==1{sub(/^\xef\xbb\xbf/,"")}1')
veeamBackupServers=$(echo "$veeamEMOUrl" | jq --raw-output ".BackupServers")
veeamProxyServers=$(echo "$veeamEMOUrl" | jq --raw-output ".ProxyServers")
veeamRepositoryServers=$(echo "$veeamEMOUrl" | jq --raw-output ".RepositoryServers")
veeamRunningJobs=$(echo "$veeamEMOUrl" | jq --raw-output ".RunningJobs")
veeamScheduledJobs=$(echo "$veeamEMOUrl" | jq --raw-output ".ScheduledJobs")
veeamSuccessfulVmLastestStates=$(echo "$veeamEMOUrl" | jq --raw-output ".SuccessfulVmLastestStates")
veeamWarningVmLastestStates=$(echo "$veeamEMOUrl" | jq --raw-output ".WarningVmLastestStates")
veeamFailedVmLastestStates=$(echo "$veeamEMOUrl" | jq --raw-output ".FailedVmLastestStates")
##Un-comment the following echo for debugging
#echo "veeam_em_overview,host=$veeamRestServer veeamBackupServers=$veeamBackupServers,veeamProxyServers=$veeamProxyServers,veeamRepositoryServers=$veeamRepositoryServers,veeamRunningJobs=$veeamRunningJobs,veeamScheduledJobs=$veeamScheduledJobs,veeamSuccessfulVmLastestStates=$veeamSuccessfulVmLastestStates,veeamWarningVmLastestStates=$veeamWarningVmLastestStates,veeamFailedVmLastestStates=$veeamFailedVmLastestStates"
##Comment the influx write while debugging
echo "Writing veeam_em_overview to InfluxDB"
influx write \
-t "$veeamInfluxDBToken" \
-b "$veeamInfluxDBBucket" \
-o "$veeamInfluxDBOrg" \
-p s \
"veeam_em_overview,host=$veeamRestServer veeamBackupServers=$veeamBackupServers,veeamProxyServers=$veeamProxyServers,veeamRepositoryServers=$veeamRepositoryServers,veeamRunningJobs=$veeamRunningJobs,veeamScheduledJobs=$veeamScheduledJobs,veeamSuccessfulVmLastestStates=$veeamSuccessfulVmLastestStates,veeamWarningVmLastestStates=$veeamWarningVmLastestStates,veeamFailedVmLastestStates=$veeamFailedVmLastestStates"
##
# Veeam Enterprise Manager Overview. Overview of Virtual Machines
##
veeamEMUrl="https://$veeamRestServer:$veeamRestPort/api/reports/summary/vms_overview"
veeamEMOVMUrl=$(curl -X GET "$veeamEMUrl" -H "Accept:application/json" -H "X-RestSvcSessionId: $veeamXRestSvcSessionId" -H "Cookie: X-RestSvcSessionId=$veeamXRestSvcSessionId" -H "Content-Length: 0" 2>&1 -k --silent | awk 'NR==1{sub(/^\xef\xbb\xbf/,"")}1')
veeamProtectedVms=$(echo "$veeamEMOVMUrl" | jq --raw-output ".ProtectedVms")
veeamBackedUpVms=$(echo "$veeamEMOVMUrl" | jq --raw-output ".BackedUpVms")
veeamReplicatedVms=$(echo "$veeamEMOVMUrl" | jq --raw-output ".ReplicatedVms")
veeamRestorePoints=$(echo "$veeamEMOVMUrl" | jq --raw-output ".RestorePoints")
veeamFullBackupPointsSize=$(echo "$veeamEMOVMUrl" | jq --raw-output ".FullBackupPointsSize")
veeamIncrementalBackupPointsSize=$(echo "$veeamEMOVMUrl" | jq --raw-output ".IncrementalBackupPointsSize")
veeamReplicaRestorePointsSize=$(echo "$veeamEMOVMUrl" | jq --raw-output ".ReplicaRestorePointsSize")
veeamSourceVmsSize=$(echo "$veeamEMOVMUrl" | jq --raw-output ".SourceVmsSize")
veeamSuccessBackupPercents=$(echo "$veeamEMOVMUrl" | jq --raw-output ".SuccessBackupPercents")
#echo "veeam_em_overview_vms,host=$veeamRestServer veeamProtectedVms=$veeamProtectedVms,veeamBackedUpVms=$veeamBackedUpVms,veeamReplicatedVms=$veeamReplicatedVms,veeamRestorePoints=$veeamRestorePoints,veeamFullBackupPointsSize=$veeamFullBackupPointsSize,veeamIncrementalBackupPointsSize=$veeamIncrementalBackupPointsSize,veeamReplicaRestorePointsSize=$veeamReplicaRestorePointsSize,veeamSourceVmsSize=$veeamSourceVmsSize,veeamSuccessBackupPercents=$veeamSuccessBackupPercents"
##Comment the influx write while debugging
echo "Writing veeam_em_overview_vms to InfluxDB"
influx write \
-t "$veeamInfluxDBToken" \
-b "$veeamInfluxDBBucket" \
-o "$veeamInfluxDBOrg" \
-p s \
"veeam_em_overview_vms,host=$veeamRestServer veeamProtectedVms=$veeamProtectedVms,veeamBackedUpVms=$veeamBackedUpVms,veeamReplicatedVms=$veeamReplicatedVms,veeamRestorePoints=$veeamRestorePoints,veeamFullBackupPointsSize=$veeamFullBackupPointsSize,veeamIncrementalBackupPointsSize=$veeamIncrementalBackupPointsSize,veeamReplicaRestorePointsSize=$veeamReplicaRestorePointsSize,veeamSourceVmsSize=$veeamSourceVmsSize,veeamSuccessBackupPercents=$veeamSuccessBackupPercents"
##
# Veeam Enterprise Manager Overview. Overview of Job Statistics
##
veeamEMUrl="https://$veeamRestServer:$veeamRestPort/api/reports/summary/job_statistics"
veeamEMOJobUrl=$(curl -X GET "$veeamEMUrl" -H "Accept:application/json" -H "X-RestSvcSessionId: $veeamXRestSvcSessionId" -H "Cookie: X-RestSvcSessionId=$veeamXRestSvcSessionId" -H "Content-Length: 0" 2>&1 -k --silent | awk 'NR==1{sub(/^\xef\xbb\xbf/,"")}1')
veeamRunningJobs=$(echo "$veeamEMOJobUrl" | jq --raw-output ".RunningJobs")
veeamScheduledJobs=$(echo "$veeamEMOJobUrl" | jq --raw-output ".ScheduledJobs")
veeamScheduledBackupJobs=$(echo "$veeamEMOJobUrl" | jq --raw-output ".ScheduledBackupJobs")
veeamScheduledReplicaJobs=$(echo "$veeamEMOJobUrl" | jq --raw-output ".ScheduledReplicaJobs")
veeamTotalJobRuns=$(echo "$veeamEMOJobUrl" | jq --raw-output ".TotalJobRuns")
veeamSuccessfulJobRuns=$(echo "$veeamEMOJobUrl" | jq --raw-output ".SuccessfulJobRuns")
veeamWarningsJobRuns=$(echo "$veeamEMOJobUrl" | jq --raw-output ".WarningsJobRuns")
veeamFailedJobRuns=$(echo "$veeamEMOJobUrl" | jq --raw-output ".FailedJobRuns")
veeamMaxJobDuration=$(echo "$veeamEMOJobUrl" | jq --raw-output ".MaxJobDuration")
veeamMaxBackupJobDuration=$(echo "$veeamEMOJobUrl" | jq --raw-output ".MaxBackupJobDuration")
veeamMaxReplicaJobDuration=$(echo "$veeamEMOJobUrl" | jq --raw-output ".MaxReplicaJobDuration")
veeamMaxDurationBackupJobName=$(echo "$veeamEMOJobUrl" | jq --raw-output ".MaxDurationBackupJobName" | awk '{gsub(/ /,"\\ ");print}')
[[ ! -z "$veeamMaxDurationBackupJobName" ]] || veeamMaxDurationBackupJobName="None"
veeamMaxDurationReplicaJobName=$(echo "$veeamEMOJobUrl" | jq --raw-output ".MaxDurationReplicaJobName" | awk '{gsub(/ /,"\\ ");print}')
[[ ! -z "$veeamMaxDurationReplicaJobName" ]] || veeamMaxDurationReplicaJobName="None"
#echo "veeam_em_overview_jobs,host=$veeamRestServer,veeamMaxDurationBackupJobName=$veeamMaxDurationBackupJobName,veeamMaxDurationReplicaJobName=$veeamMaxDurationReplicaJobName veeamRunningJobs=$veeamRunningJobs,veeamScheduledJobs=$veeamScheduledJobs,veeamScheduledBackupJobs=$veeamScheduledBackupJobs,veeamScheduledReplicaJobs=$veeamScheduledReplicaJobs,veeamTotalJobRuns=$veeamTotalJobRuns,veeamSuccessfulJobRuns=$veeamSuccessfulJobRuns,veeamWarningsJobRuns=$veeamWarningsJobRuns,veeamFailedJobRuns=$veeamFailedJobRuns,veeamMaxJobDuration=$veeamMaxJobDuration,veeamMaxBackupJobDuration=$veeamMaxBackupJobDuration,veeamMaxReplicaJobDuration=$veeamMaxReplicaJobDuration"
##Comment the influx write while debugging
echo "Writing veeam_em_overview_jobs to InfluxDB"
influx write \
-t "$veeamInfluxDBToken" \
-b "$veeamInfluxDBBucket" \
-o "$veeamInfluxDBOrg" \
-p s \
"veeam_em_overview_jobs,host=$veeamRestServer,veeamMaxDurationBackupJobName=$veeamMaxDurationBackupJobName,veeamMaxDurationReplicaJobName=$veeamMaxDurationReplicaJobName veeamRunningJobs=$veeamRunningJobs,veeamScheduledJobs=$veeamScheduledJobs,veeamScheduledBackupJobs=$veeamScheduledBackupJobs,veeamScheduledReplicaJobs=$veeamScheduledReplicaJobs,veeamTotalJobRuns=$veeamTotalJobRuns,veeamSuccessfulJobRuns=$veeamSuccessfulJobRuns,veeamWarningsJobRuns=$veeamWarningsJobRuns,veeamFailedJobRuns=$veeamFailedJobRuns,veeamMaxJobDuration=$veeamMaxJobDuration,veeamMaxBackupJobDuration=$veeamMaxBackupJobDuration,veeamMaxReplicaJobDuration=$veeamMaxReplicaJobDuration"
##
# Veeam Enterprise Manager Repositories. Overview of Repositories
##
veeamEMUrl="https://$veeamRestServer:$veeamRestPort/api/repositories?format=Entity"
veeamEMORepoUrl=$(curl -X GET "$veeamEMUrl" -H "Accept:application/json" -H "X-RestSvcSessionId: $veeamXRestSvcSessionId" -H "Cookie: X-RestSvcSessionId=$veeamXRestSvcSessionId" -H "Content-Length: 0" 2>&1 -k --silent | awk 'NR==1{sub(/^\xef\xbb\xbf/,"")}1')
declare -i arrayrepo=0
for Kind in $(echo "$veeamEMORepoUrl" | jq -r '.Repositories[].Kind'); do
veeamRepositoryName=$(echo "$veeamEMORepoUrl" | jq --raw-output ".Repositories[$arrayrepo].Name" | awk '{gsub(/ /,"\\ ");print}')
veeamVBR=$(echo "$veeamEMORepoUrl" | jq --raw-output ".Repositories[$arrayrepo].Links[0].Name" | awk '{gsub(/ /,"\\ ");print}')
veeamRepositoryCapacity=$(echo "$veeamEMORepoUrl" | jq --raw-output ".Repositories[$arrayrepo].Capacity")
veeamRepositoryFreeSpace=$(echo "$veeamEMORepoUrl" | jq --raw-output ".Repositories[$arrayrepo].FreeSpace")
veeamRepositoryKind=$(echo "$veeamEMORepoUrl" | jq --raw-output ".Repositories[$arrayrepo].Kind")
#echo "veeam_em_overview_repositories,host=$veeamRestServer,veeamRepositoryName=$veeamRepositoryName veeamRepositoryCapacity=$veeamRepositoryCapacity,veeamRepositoryFreeSpace=$veeamRepositoryFreeSpace,veeamRepositoryBackupSize=$veeamRepositoryBackupSize"
##Comment the influx write while debugging
echo "Writing veeam_em_overview_repositories to InfluxDB"
influx write \
-t "$veeamInfluxDBToken" \
-b "$veeamInfluxDBBucket" \
-o "$veeamInfluxDBOrg" \
-p s \
"veeam_em_overview_repositories,veeamVBR=$veeamVBR,veeamRepositoryName=$veeamRepositoryName,veeamRepositoryKind=$veeamRepositoryKind veeamRepositoryCapacity=$veeamRepositoryCapacity,veeamRepositoryFreeSpace=$veeamRepositoryFreeSpace"
arrayrepo=$arrayrepo+1
done
##
# Veeam Enterprise Manager Backup Servers. Overview of Backup Repositories
##
veeamEMUrl="https://$veeamRestServer:$veeamRestPort/api/backupServers?format=Entity"
veeamEMOBackupServersUrl=$(curl -X GET "$veeamEMUrl" -H "Accept:application/json" -H "X-RestSvcSessionId: $veeamXRestSvcSessionId" -H "Cookie: X-RestSvcSessionId=$veeamXRestSvcSessionId" -H "Content-Length: 0" 2>&1 -k --silent | awk 'NR==1{sub(/^\xef\xbb\xbf/,"")}1')
declare -i arraybackupservers=0
for Name in $(echo "$veeamEMOBackupServersUrl" | jq -r '.BackupServers[].Name'); do
veeamVBR=$(echo "$veeamEMOBackupServersUrl" | jq --raw-output ".BackupServers[$arraybackupservers].Name" | awk '{gsub(/ /,"\\ ");print}')
veeamBackupServersPort=$(echo "$veeamEMOBackupServersUrl" | jq --raw-output ".BackupServers[$arraybackupservers].Port")
veeamBackupServersVersion=$(echo "$veeamEMOBackupServersUrl" | jq --raw-output ".BackupServers[$arraybackupservers].Version" | awk '{gsub(/ /,"\\ ");print}')
case $veeamBackupServersVersion in
"12.1.1.56")
veeamBackupServersVersionM="12.1.1"
;;
"12.1.0.2131")
veeamBackupServersVersionM="12.1\ GA"
;;
"12.0.0.1420 P20230718")
veeamBackupServersVersionM="12.0.0.1420\ P20230718"
;;
"12.0.0.1420 P20230412")
veeamBackupServersVersionM="12.0.0.1420\ P20230412"
;;
"12.0.0.1420 P20230223")
veeamBackupServersVersionM="12.0.0.1420\ P20230223"
;;
"12.0.0.1420")
veeamBackupServersVersionM="12.0\ GA"
;;
"12.0.0.1402")
veeamBackupServersVersionM="12.0\ RTM"
;;
"11.0.1.1261 P20220302")
veeamBackupServersVersionM="11.0a\ P20220302"
;;
"11.0.1.1261 P20211211")
veeamBackupServersVersionM="11.0a\ P20211211"
;;
"11.0.1.1261 P20211123")
veeamBackupServersVersionM="11.0a\ P20211123"
;;
"11.0.1.1261")
veeamBackupServersVersionM="11.0a\ GA"
;;
"11.0.0.837")
veeamBackupServersVersionM="11.0\ GA"
;;
"11.0.0.825")
veeamBackupServersVersionM="11.0\ RTM"
;;
"10.0.1.4854")
veeamBackupServersVersionM="10.0a\ GA"
;;
"10.0.1.4848")
veeamBackupServersVersionM="10.0a\ RTM"
;;
"10.0.0.4461")
veeamBackupServersVersionM="10.0\ GA"
;;
"10.0.0.4442")
veeamBackupServersVersionM="10.0\ RTM"
;;
"9.5.4.2866")
veeamBackupServersVersionM="9.5\ U4b\ GA"
;;
"9.5.4.2753")
veeamBackupServersVersionM="9.5\ U4a\ GA"
;;
"9.5.4.2615")
veeamBackupServersVersionM="9.5\ U4\ GA"
;;
"9.5.4.2399")
veeamBackupServersVersionM="9.5\ U4\ RTM"
;;
"9.5.0.1922")
veeamBackupServersVersionM="9.5\ U3a"
;;
"9.5.0.1536")
veeamBackupServersVersionM="9.5\ U3"
;;
"9.5.0.1038")
veeamBackupServersVersionM="9.5\ U2"
;;
"9.5.0.823")
veeamBackupServersVersionM="9.5\ U1"
;;
"9.5.0.802")
veeamBackupServersVersionM="9.5\ U1\ RC"
;;
"9.5.0.711")
veeamBackupServersVersionM="9.5\ GA"
;;
"9.5.0.580")
veeamBackupServersVersionM="9.5\ RTM"
;;
"9.0.0.1715")
veeamBackupServersVersionM="9.0\ U2"
;;
"9.0.0.1491")
veeamBackupServersVersionM="9.0\ U1"
;;
"9.0.0.902")
veeamBackupServersVersionM="9.0\ GA"
;;
"9.0.0.773")
veeamBackupServersVersionM="9.0\ RTM"
;;
"8.0.0.2084")
veeamBackupServersVersionM="8.0\ U3"
;;
"8.0.0.2030")
veeamBackupServersVersionM="8.0\ U2b"
;;
"8.0.0.2029")
veeamBackupServersVersionM="8.0\ U2a"
;;
"8.0.0.2021")
veeamBackupServersVersionM="8.0\ U2\ GA"
;;
"8.0.0.2018")
veeamBackupServersVersionM="8.0\ U2\RTM"
;;
"8.0.0.917")
veeamBackupServersVersionM="8.0\ P1"
;;
"8.0.0.817")
veeamBackupServersVersionM="8.0\ GA"
;;
"8.0.0.807")
veeamBackupServersVersionM="8.0\ RTM"
;;
esac
#echo "veeam_em_backup_servers,veeamVBR=$veeamVBR,veeamBackupServersVersion=$veeamBackupServersVersion,veeamBackupServersVersionM=$veeamBackupServersVersionM veeamBackupServersPort=$veeamBackupServersPort"
##Comment the influx write while debugging
echo "Writing veeam_em_backup_servers to InfluxDB"
influx write \
-t "$veeamInfluxDBToken" \
-b "$veeamInfluxDBBucket" \
-o "$veeamInfluxDBOrg" \
-p s \
"veeam_em_backup_servers,veeamVBR=$veeamVBR,veeamBackupServersVersion=$veeamBackupServersVersion,veeamBackupServersVersionM=$veeamBackupServersVersionM veeamBackupServersPort=$veeamBackupServersPort"
arraybackupservers=$arraybackupservers+1
done
##
# Veeam Enterprise Manager Backup Job Sessions. Overview of Backup Job Sessions
##
veeamEMUrl="https://$veeamRestServer:$veeamRestPort/api/backupSessions?format=Entity"
veeamEMJobSessionsUrl=$(curl -X GET "$veeamEMUrl" -H "Accept:application/json" -H "X-RestSvcSessionId: $veeamXRestSvcSessionId" -H "Cookie: X-RestSvcSessionId=$veeamXRestSvcSessionId" -H "Content-Length: 0" 2>&1 -k --silent | awk 'NR==1{sub(/^\xef\xbb\xbf/,"")}1' | jq '[.BackupJobSessions[] | select(.CreationTimeUTC> "'$timestart'")]')
declare -i arrayjobsessions=0
if [[ "$veeamEMJobSessionsUrl" == "[]" ]]; then
echo "There are not new veeam_em_job_sessions since $timestart"
else
for JobUid in $(echo "$veeamEMJobSessionsUrl" | jq -r '.[].JobUid'); do
veeamBackupSessionsName=$(echo "$veeamEMJobSessionsUrl" | jq --raw-output ".[$arrayjobsessions].JobName" | awk '{gsub(/ /,"\\ ");print}')
veeamVBR=$(echo "$veeamEMJobSessionsUrl" | jq --raw-output ".[$arrayjobsessions].Links[0].Name" | awk '{gsub(/ /,"\\ ");print}')
veeamBackupSessionsJobType=$(echo "$veeamEMJobSessionsUrl" | jq --raw-output ".[$arrayjobsessions].JobType")
veeamBackupSessionsJobState=$(echo "$veeamEMJobSessionsUrl" | jq --raw-output ".[$arrayjobsessions].State")
veeamBackupSessionsJobResult=$(echo "$veeamEMJobSessionsUrl" | jq --raw-output ".[$arrayjobsessions].Result")
case $veeamBackupSessionsJobResult in
Success)
jobStatus="1"
;;
Warning)
jobStatus="2"
;;
Failed)
jobStatus="3"
;;
esac
veeamBackupSessionsTime=$(echo "$veeamEMJobSessionsUrl" | jq --raw-output ".[$arrayjobsessions].CreationTimeUTC")
creationTimeUnix=$(date -d "$veeamBackupSessionsTime" +"%s")
veeamBackupSessionsTimeEnd=$(echo "$veeamEMJobSessionsUrl" | jq --raw-output ".[$arrayjobsessions].EndTimeUTC")
endTimeUnix=$(date -d "$veeamBackupSessionsTimeEnd" +"%s")
veeamBackupSessionsTimeDuration=$(($endTimeUnix-$creationTimeUnix))
#echo "veeam_em_job_sessions,veeamBackupSessionsName=$veeamBackupSessionsName,veeamVBR=$veeamVBR,veeamBackupSessionsJobType=$veeamBackupSessionsJobType,veeamBackupSessionsJobState=$veeamBackupSessionsJobState veeamBackupSessionsJobResult=$jobStatus $creationTimeUnix"
##Comment the influx write while debugging
echo "Writing veeam_em_job_sessions to InfluxDB"
influx write \
-t "$veeamInfluxDBToken" \
-b "$veeamInfluxDBBucket" \
-o "$veeamInfluxDBOrg" \
-p s \
"veeam_em_job_sessions,veeamBackupSessionsName=$veeamBackupSessionsName,veeamVBR=$veeamVBR,veeamBackupSessionsJobType=$veeamBackupSessionsJobType,veeamBackupSessionsJobState=$veeamBackupSessionsJobState veeamBackupSessionsJobResult=$jobStatus,veeamBackupSessionsTimeDuration=$veeamBackupSessionsTimeDuration $creationTimeUnix"
if [[ $arrayjobsessions = $veeamJobSessions ]]; then
break
else
arrayjobsessions=$arrayjobsessions+1
fi
done
fi
##
# Veeam Enterprise Manager Backup Job Sessions per VM. Overview of Backup Job Sessions per VM. Really useful to display if a VM it is protected or not
##
veeamEMUrl="https://$veeamRestServer:$veeamRestPort/api/backupTaskSessions?format=Entity"
veeamEMJobSessionsVMUrl=$(curl -X GET "$veeamEMUrl" -H "Accept:application/json" -H "X-RestSvcSessionId: $veeamXRestSvcSessionId" -H "Cookie: X-RestSvcSessionId=$veeamXRestSvcSessionId" -H "Content-Length: 0" 2>&1 -k --silent | awk 'NR==1{sub(/^\xef\xbb\xbf/,"")}1' | jq '[.BackupTaskSessions[] | select(.CreationTimeUTC> "'$timestart'")]')
declare -i arrayjobsessionsvm=0
if [[ "$veeamEMJobSessionsVMUrl" == "[]" ]]; then
echo "There are not new veeam_em_job_sessionsvm since $timestart"
else
for JobSessionUid in $(echo "$veeamEMJobSessionsVMUrl" | jq -r '.[].JobSessionUid'); do
veeamBackupSessionsVmDisplayName=$(echo "$veeamEMJobSessionsVMUrl" | jq --raw-output ".[$arrayjobsessionsvm].VmDisplayName" | awk '{gsub(/ /,"\\ ");print}')
veeamVBR=$(echo "$veeamEMJobSessionsVMUrl" | jq --raw-output ".[$arrayjobsessionsvm].Links[0].Name" | awk '{gsub(/ /,"\\ ");print}')
veeamBackupSessionsTotalSize=$(echo "$veeamEMJobSessionsVMUrl" | jq --raw-output ".[$arrayjobsessionsvm].TotalSize")
veeamBackupSessionsJobVMState=$(echo "$veeamEMJobSessionsVMUrl" | jq --raw-output ".[$arrayjobsessionsvm].State")
veeamBackupSessionsJobVMResult=$(echo "$veeamEMJobSessionsVMUrl" | jq --raw-output ".[$arrayjobsessionsvm].Result")
case $veeamBackupSessionsJobVMResult in
Success)
jobStatus="1"
;;
Warning)
jobStatus="2"
;;
Failed)
jobStatus="3"
;;
esac
veeamBackupSessionsVMTime=$(echo "$veeamEMJobSessionsVMUrl" | jq --raw-output ".[$arrayjobsessionsvm].CreationTimeUTC")
creationTimeUnix=$(date -d "$veeamBackupSessionsVMTime" +"%s")
veeamBackupSessionsVMTimeEnd=$(echo "$veeamEMJobSessionsVMUrl" | jq --raw-output ".[$arrayjobsessionsvm].EndTimeUTC")
endTimeUnix=$(date -d "$veeamBackupSessionsVMTimeEnd" +"%s")
veeamBackupSessionsVMDuration=$(($endTimeUnix-$creationTimeUnix))
#echo "veeam_em_job_sessionsvm,veeamBackupSessionsVmDisplayName=$veeamBackupSessionsVmDisplayName,veeamVBR=$veeamVBR,veeamBackupSessionsJobVMState=$veeamBackupSessionsJobVMState veeamBackupSessionsTotalSize=$veeamBackupSessionsTotalSize,veeamBackupSessionsJobVMResult=$jobStatus $creationTimeUnix"
##Comment the influx write while debugging
echo "Writing veeam_em_job_sessionsvm to InfluxDB"
influx write \
-t "$veeamInfluxDBToken" \
-b "$veeamInfluxDBBucket" \
-o "$veeamInfluxDBOrg" \
-p s \
"veeam_em_job_sessionsvm,veeamBackupSessionsVmDisplayName=$veeamBackupSessionsVmDisplayName,veeamVBR=$veeamVBR,veeamBackupSessionsJobVMState=$veeamBackupSessionsJobVMState veeamBackupSessionsTotalSize=$veeamBackupSessionsTotalSize,veeamBackupSessionsJobVMResult=$jobStatus,veeamBackupSessionsVMDuration=$veeamBackupSessionsVMDuration $creationTimeUnix"
arrayjobsessionsvm=$arrayjobsessionsvm+1
done
fi
##
# Veeam Enterprise Manager Replica Job Sessions. Overview of Replica Job Sessions
##
veeamEMUrl="https://$veeamRestServer:$veeamRestPort/api/replicaSessions?format=Entity"
veeamEMJobReplicaSessionsUrl="$(curl -X GET "$veeamEMUrl" -H "Accept:application/json" -H "X-RestSvcSessionId: $veeamXRestSvcSessionId" -H "Cookie: X-RestSvcSessionId=$veeamXRestSvcSessionId" -H "Content-Length: 0" 2>&1 -k --silent | awk 'NR==1{sub(/^\xef\xbb\xbf/,"")}1' | jq '[.ReplicaJobSessions[] | select(.CreationTimeUTC> "'$timestart'")]')"
declare -i arrayjobrepsessions=0
if [[ "$veeamEMJobReplicaSessionsUrl" == "[]" ]]; then
echo "There are not new veeam_em_job_sessions since $timestart"
else
for JobUid in $(echo "$veeamEMJobReplicaSessionsUrl" | jq -r '.[].JobUid'); do
veeamReplicaSessionsName=$(echo "$veeamEMJobReplicaSessionsUrl" | jq --raw-output ".[$arrayjobrepsessions].JobName" | awk '{gsub(/ /,"\\ ");print}')
veeamVBR=$(echo "$veeamEMJobReplicaSessionsUrl" | jq --raw-output ".[$arrayjobrepsessions].Links[0].Name" | awk '{gsub(/ /,"\\ ");print}')
veeamReplicaSessionsJobType=$(echo "$veeamEMJobReplicaSessionsUrl" | jq --raw-output ".[$arrayjobrepsessions].JobType")
veeamReplicaSessionsJobState=$(echo "$veeamEMJobReplicaSessionsUrl" | jq --raw-output ".[$arrayjobrepsessions].State")
veeamReplicaSessionsJobResult=$(echo "$veeamEMJobReplicaSessionsUrl" | jq --raw-output ".[$arrayjobrepsessions].Result")
case $veeamReplicaSessionsJobResult in
Success)
jobStatus="1"
;;
Warning)
jobStatus="2"
;;
Failed)
jobStatus="3"
;;
esac
veeamReplicaSessionsTime=$(echo "$veeamEMJobReplicaSessionsUrl" | jq --raw-output ".[$arrayjobrepsessions].CreationTimeUTC")
creationTimeUnix=$(date -d "$veeamReplicaSessionsTime" +"%s")
veeamReplicaSessionsTimeEnd=$(echo "$veeamEMJobReplicaSessionsUrl" | jq --raw-output ".[$arrayjobrepsessions].EndTimeUTC")
endTimeUnix=$(date -d "$veeamReplicaSessionsTimeEnd" +"%s")
veeamReplicaSessionsDuration=$(($endTimeUnix-$creationTimeUnix))
#echo "veeam_em_job_sessions,veeamReplicaSessionsName=$veeamReplicaSessionsName,veeamVBR=$veeamVBR,veeamReplicaSessionsJobType=$veeamReplicaSessionsJobType,veeamReplicaSessionsJobState=$veeamReplicaSessionsJobState veeamReplicaSessionsJobResult=$jobStatus $creationTimeUnix"
##Comment the influx write while debugging
echo "Writing veeam_em_job_sessions Replica to InfluxDB"
influx write \
-t "$veeamInfluxDBToken" \
-b "$veeamInfluxDBBucket" \
-o "$veeamInfluxDBOrg" \
-p s \
"veeam_em_job_sessions,veeamReplicaSessionsName=$veeamReplicaSessionsName,veeamVBR=$veeamVBR,veeamReplicaSessionsJobType=$veeamReplicaSessionsJobType,veeamReplicaSessionsJobState=$veeamReplicaSessionsJobState veeamReplicaSessionsJobResult=$jobStatus,veeamReplicaSessionsDuration=$veeamReplicaSessionsDuration $creationTimeUnix"
arrayjobrepsessions=$arrayjobrepsessions+1
done
fi
##
# Veeam Enterprise Manager Replica Job Sessions per VM. Overview of Replica Job Sessions per VM. Really useful to display if a VM it is protected or not
##
veeamEMUrl="https://$veeamRestServer:$veeamRestPort/api/replicaTaskSessions?format=Entity"
veeamEMJobReplicaSessionsVMUrl=$(curl -X GET "$veeamEMUrl" -H "Accept:application/json" -H "X-RestSvcSessionId: $veeamXRestSvcSessionId" -H "Cookie: X-RestSvcSessionId=$veeamXRestSvcSessionId" -H "Content-Length: 0" 2>&1 -k --silent | awk 'NR==1{sub(/^\xef\xbb\xbf/,"")}1' | jq '[.ReplicaTaskSessions[] | select(.CreationTimeUTC> "'$timestart'")]')
declare -i arrayjobrepsessionsvm=0
if [[ "$veeamEMJobReplicaSessionsVMUrl" == "[]" ]]; then
echo "There are not new veeam_em_job_sessionsvm since $timestart"
else
for JobSessionUid in $(echo "$veeamEMJobReplicaSessionsVMUrl" | jq -r '.[].JobSessionUid'); do
veeamReplicaSessionsJobUid=$(echo "$veeamEMJobReplicaSessionsVMUrl" | jq --raw-output ".[$arrayjobrepsessionsvm].JobSessionUid")
veeamReplicaSessionsJobVMState=$(echo "$veeamEMJobReplicaSessionsVMUrl" | jq --raw-output ".[$arrayjobrepsessionsvm].State")
if [[ "$veeamReplicaSessionsJobVMState" == "InProgress" ]]; then
echo "The Replica with ID:$veeamReplicaSessionsJobUid is in progress, will collect data later."
else
veeamReplicaSessionsVmDisplayName=$(echo "$veeamEMJobReplicaSessionsVMUrl" | jq --raw-output ".[$arrayjobrepsessionsvm].VmDisplayName" | awk '{gsub(/ /,"\\ ");print}')
veeamVBR=$(echo "$veeamEMJobReplicaSessionsVMUrl" | jq --raw-output ".[$arrayjobrepsessionsvm].Links[0].Name" | awk '{gsub(/ /,"\\ ");print}')
veeamReplicaSessionsTotalSize=$(echo "$veeamEMJobReplicaSessionsVMUrl" | jq --raw-output ".[$arrayjobrepsessionsvm].TotalSize")
veeamReplicaSessionsJobVMResult=$(echo "$veeamEMJobReplicaSessionsVMUrl" | jq --raw-output ".[$arrayjobrepsessionsvm].Result")
case $veeamReplicaSessionsJobVMResult in
Success)
jobStatus="1"
;;
Warning)
jobStatus="2"
;;
Failed)
jobStatus="3"
;;
esac
veeamReplicaSessionsVMTime=$(echo "$veeamEMJobReplicaSessionsVMUrl" | jq --raw-output ".[$arrayjobrepsessionsvm].CreationTimeUTC")
creationTimeUnix=$(date -d "$veeamReplicaSessionsVMTime" +"%s")
veeamReplicaSessionsVMTimeEnd=$(echo "$veeamEMJobReplicaSessionsVMUrl" | jq --raw-output ".[$arrayjobrepsessionsvm].EndTimeUTC")
endTimeUnix=$(date -d "$veeamReplicaSessionsVMTimeEnd" +"%s")
veeamReplicaSessionsVMDuration=$(($endTimeUnix-$creationTimeUnix))
#echo "veeam_em_job_sessionsvm,veeamReplicaSessionsVmDisplayName=$veeamReplicaSessionsVmDisplayName,veeamVBR=$veeamVBR,veeamReplicaSessionsJobVMState=$veeamReplicaSessionsJobVMState veeamReplicaSessionsTotalSize=$veeamReplicaSessionsTotalSize,veeamReplicaSessionsJobVMResult=$jobStatus $creationTimeUnix"
##Comment the influx write while debugging
echo "Writing veeam_em_job_sessionsvm Replica to InfluxDB"
influx write \
-t "$veeamInfluxDBToken" \
-b "$veeamInfluxDBBucket" \
-o "$veeamInfluxDBOrg" \
-p s \
"veeam_em_job_sessionsvm,veeamReplicaSessionsVmDisplayName=$veeamReplicaSessionsVmDisplayName,veeamVBR=$veeamVBR,veeamReplicaSessionsJobVMState=$veeamReplicaSessionsJobVMState veeamReplicaSessionsTotalSize=$veeamReplicaSessionsTotalSize,veeamReplicaSessionsJobVMResult=$jobStatus,veeamReplicaSessionsVMDuration=$veeamReplicaSessionsVMDuration $creationTimeUnix"
fi
arrayjobrepsessionsvm=$arrayjobrepsessionsvm+1
done
fi
##
# Veeam Enterprise Manager Backup Agent Status. Overview of the Veeam Agents. Really useful to display if an Agent it is uo to date and also the status
##
veeamEMUrl="https://$veeamRestServer:$veeamRestPort/api/agents/discoveredComputers?format=Entity"
veeamEMAgentUrl=$(curl -X GET "$veeamEMUrl" -H "Accept:application/json" -H "X-RestSvcSessionId: $veeamXRestSvcSessionId" -H "Cookie: X-RestSvcSessionId=$veeamXRestSvcSessionId" -H "Content-Length: 0" 2>&1 -k --silent | awk 'NR==1{sub(/^\xef\xbb\xbf/,"")}1')
declare -i arrayagent=0
for JobSessionUid in $(echo "$veeamEMAgentUrl" | jq -r '.DiscoveredComputers[].UID'); do
veeamAgentName=$(echo "$veeamEMAgentUrl" | jq --raw-output ".DiscoveredComputers[$arrayagent].Name" | awk '{gsub(/ /,"\\ ");print}')
veeamVBR=$(echo "$veeamEMAgentUrl" | jq --raw-output ".DiscoveredComputers[$arrayagent].Links[0].Name" | awk '{gsub(/ /,"\\ ");print}')
veeamAgentHostStatusCheck=$(echo "$veeamEMAgentUrl" | jq --raw-output ".DiscoveredComputers[$arrayagent].HostStatus")
case $veeamAgentHostStatusCheck in
"Online")
veeamAgentHostStatus="1"
;;
"Offline")
veeamAgentHostStatus="2"
;;
"Unknown")
veeamAgentHostStatus="3"
;;
esac
veeamAgentStatusCheck=$(echo "$veeamEMAgentUrl" | jq --raw-output ".DiscoveredComputers[$arrayagent].AgentStatus")
case $veeamAgentStatusCheck in
"Installed")
veeamAgentStatus="1"
;;
"Warning")
veeamAgentStatus="2"
;;
"Inaccessible")
veeamAgentStatus="3"
;;
"Not Installed")
veeamAgentStatus="4"
;;
"NotInitialized")
veeamAgentStatus="5"
;;
esac
veeamAgentVersion=$(echo "$veeamEMAgentUrl" | jq --raw-output ".DiscoveredComputers[$arrayagent].AgentVersion" | awk '{gsub(/ /,"\\ ");print}')
veeamAgentOsVersion=$(echo "$veeamEMAgentUrl" | jq --raw-output ".DiscoveredComputers[$arrayagent].OsVersion" | awk -F',' '{$3=i; print}' | awk '{gsub(/ /,"\\ ");print}')
#echo "veeam_em_agents,veeamAgentName=$veeamAgentName,veeamVBR=$veeamVBR,veeamAgentVersion=$veeamAgentVersion,veeamAgentOsVersion=$veeamAgentOsVersion veeamAgentStatus=$veeamAgentStatus,veeamAgentHostStatus=$veeamAgentHostStatus"
##Comment the influx write while debugging
echo "Writing veeam_em_agents to InfluxDB"
influx write \
-t "$veeamInfluxDBToken" \
-b "$veeamInfluxDBBucket" \
-o "$veeamInfluxDBOrg" \
-p s \
"veeam_em_agents,veeamAgentName=$veeamAgentName,veeamAgentOsVersion=$veeamAgentOsVersion,veeamVBR=$veeamVBR,veeamAgentVersion=$veeamAgentVersion veeamAgentStatus=$veeamAgentStatus,veeamAgentHostStatus=$veeamAgentHostStatus"
arrayagent=$arrayagent+1
done
##
# Veeam Enterprise Manager NAS Jobs. Overview of the NAS Jobs. Really useful to display the NAS Jobs
##
veeamEMUrl="https://$veeamRestServer:$veeamRestPort/api/nas/jobs?format=Entity"
veeamEMNASJobsUrl=$(curl -X GET "$veeamEMUrl" -H "Accept:application/json" -H "X-RestSvcSessionId: $veeamXRestSvcSessionId" -H "Cookie: X-RestSvcSessionId=$veeamXRestSvcSessionId" -H "Content-Length: 0" 2>&1 -k --silent | awk 'NR==1{sub(/^\xef\xbb\xbf/,"")}1')
declare -i arrayNASJobs=0
for JobSessionUid in $(echo "$veeamEMNASJobsUrl" | jq -r '.NASJobs[].UID'); do
veeamNASJobName=$(echo "$veeamEMNASJobsUrl" | jq --raw-output ".NASJobs[$arrayNASJobs].Name" | awk '{gsub(/ /,"\\ ");print}')
veeamVBR=$(echo "$veeamEMNASJobsUrl" | jq --raw-output ".NASJobs[$arrayNASJobs].Links[0].Name" | awk '{gsub(/ /,"\\ ");print}')
veeamNASJobShortTerm=$(echo "$veeamEMNASJobsUrl" | jq --raw-output ".NASJobs[$arrayNASJobs].StorageOptions.ShorttermRetentionPeriod")
veeamNASJobShortTermType=$(echo "$veeamEMNASJobsUrl" | jq --raw-output ".NASJobs[$arrayNASJobs].StorageOptions.ShorttermRetentionType")
#echo "veeam_em_nas_jobs,veeamNASJobName=$veeamNASJobName,veeamVBR=$veeamVBR,veeamNASJobShortTermType=$veeamNASJobShortTermType veeamNASJobShortTerm=$veeamNASJobShortTerm"
##Comment the influx write while debugging
echo "Writing veeam_em_nas_jobs to InfluxDB"
influx write \
-t "$veeamInfluxDBToken" \
-b "$veeamInfluxDBBucket" \
-o "$veeamInfluxDBOrg" \
-p s \
"veeam_em_nas_jobs,veeamNASJobName=$veeamNASJobName,veeamVBR=$veeamVBR,veeamNASJobShortTermType=$veeamNASJobShortTermType veeamNASJobShortTerm=$veeamNASJobShortTerm"
arrayNASJobs=$arrayNASJobs+1
done
##
# Veeam Enterprise Manager NAS Jobs Sessions. Overview of the NAS Jobs Sessions. Really useful to display the NAS Jobs Sessions
##
veeamEMUrl="https://$veeamRestServer:$veeamRestPort/api/nas/backupSessions?format=Entity"
veeamEMNASJobsSessionsUrl=$(curl -X GET "$veeamEMUrl" -H "Accept:application/json" -H "X-RestSvcSessionId: $veeamXRestSvcSessionId" -H "Cookie: X-RestSvcSessionId=$veeamXRestSvcSessionId" -H "Content-Length: 0" 2>&1 -k --silent | awk 'NR==1{sub(/^\xef\xbb\xbf/,"")}1'| jq '[.BackupJobSessions[] | select(.CreationTimeUTC> "'$timestart'")]')
declare -i arrayNASJobsSessions=0
if [[ "$veeamEMNASJobsSessionsUrl" == "[]" ]]; then
echo "There are not new veeam_em_nas_sessions since $timestart"
else
for JobSessionUid in $(echo "$veeamEMNASJobsSessionsUrl" | jq -r '.[].JobUid'); do
veeamNASJobName=$(echo "$veeamEMNASJobsSessionsUrl" | jq --raw-output ".[$arrayNASJobsSessions].JobName" | awk '{gsub(/ /,"\\ ");print}')
veeamVBR=$(echo "$veeamEMNASJobsSessionsUrl" | jq --raw-output ".[$arrayNASJobsSessions].Links[0].Name" | awk '{gsub(/ /,"\\ ");print}')
veeamNASJobResult=$(echo "$veeamEMNASJobsSessionsUrl" | jq --raw-output ".[$arrayNASJobsSessions].Result")
case $veeamNASJobResult in
Success)
jobStatus="1"
;;
Warning)
jobStatus="2"
;;
Failed)
jobStatus="3"
;;
esac
veeamNASJobTime=$(echo "$veeamEMNASJobsSessionsUrl" | jq --raw-output ".[$arrayNASJobsSessions].CreationTimeUTC")
creationTimeUnix=$(date -d "$veeamNASJobTime" +"%s")
veeamNASJobimeEnd=$(echo "$veeamEMNASJobsSessionsUrl" | jq --raw-output ".[$arrayNASJobsSessions].EndTimeUTC")
endTimeUnix=$(date -d "$veeamNASJobimeEnd" +"%s")
veeamNASJobDuration=$(($endTimeUnix-$creationTimeUnix))
#echo "veeam_em_nas_sessions,veeamNASJobName=$veeamNASJobName,veeamVBR=$veeamVBR veeamNASJobResult=$jobStatus $creationTimeUnix"
##Comment the influx write while debugging
echo "Writing veeam_em_nas_sessions to InfluxDB"
influx write \
-t "$veeamInfluxDBToken" \
-b "$veeamInfluxDBBucket" \
-o "$veeamInfluxDBOrg" \
-p s \
"veeam_em_nas_sessions,veeamNASJobName=$veeamNASJobName,veeamVBR=$veeamVBR veeamNASJobResult=$jobStatus,veeamNASJobDuration=$veeamNASJobDuration $creationTimeUnix"
arrayNASJobsSessions=$arrayNASJobsSessions+1
done
fi