Repository navigation
Expand file tree
/
Copy pathveeamlpb_monitor.py
More file actions
executable file
·113 lines (84 loc) · 2.92 KB
/
Copy pathveeamlpb_monitor.py
File metadata and controls
executable file
·113 lines (84 loc) · 2.92 KB
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
#!/usr/bin/python
# -*- coding: utf-8 -*-
import veeamlpb
import os
def checkVersion():
version = veeamlpb.version.CVersion.Get()
print "veeam Agent for Linux versin ",version.ToString()
def EnumerateSession():
print "---"
print "Enumerate sessions:"
sessions = veeamlpb.session.CSessionInfoList.Get()
for sessionInfo in sessions.List():
print sessionInfo.ToString()
print "Find session by id:"
newSessionInfo = veeamlpb.session.CSessionInfo.GetById(sessionInfo.Id())
print newSessionInfo.ToString()
def EnumerateRepositories():
print "---"
print "Enumerate repositories:"
repositoryList = veeamlpb.repository.CRepositoryList.Get()
for repoInfo in repositoryList.List():
print repoInfo.ToString()
def EnumerateJobs():
print "---"
print "Enumerate jobs:"
jobs = veeamlpb.job.CJobInfoList.Get()
for jobInfo in jobs.List():
print jobInfo.ToString()
def SendXmlsessions():
print "---"
print "Session list in XML format:"
sessions = veeamlpb.session.CSessionInfoList.Get()
text = sessions.ToXml()
print text
sessionsFileName = "session_list.xml"
print "Store XML to file: ",sessionsFileName
sessionsXmlFile = open(sessionsFileName, "w")
sessionsXmlFile.write(text)
sessionsXmlFile.close()
hostname = os.uname()[1]
target = "admin@admins-host:/home/admin"
os.system("scp ./"+sessionsFileName+" "+target+"/backups/"+hostname+"/session_list.xml")
def SendMailsessions():
print "---"
print "Sending statistic to administrator:"
sessions = veeamlpb.session.CSessionInfoList.Get()
recipient = "dear.admin@company.com"
subject = "VAL status notification"
text = "Statistic:\n"
inx = 0;
successCount = 0
warningCount = 0
errorCount = 0
for sessionInfo in sessions.List():
if (sessionInfo.State() == "Success"):
successCount += 1
elif (sessionInfo.State() == "Warning"):
warningCount += 1
else:
errorCount += 1
text += str(successCount)+"/"+str(warningCount)+"/"+str(errorCount)+" Success/Warning/Error\n"
text += "Last 10 session:\n"
for sessionInfo in reversed(sessions.List()):
if inx == 10:
text += "...\n"
break;
text += str(inx)+" | "+sessionInfo.State()+" | "+sessionInfo.JobName()+" | "+sessionInfo.StartTime()+" / "+sessionInfo.FinishTime() + "\n"
inx += 1
text += "\n"
text += "--------------------------------------------------------------------------------\n"
text += " Yours sincerely, Veeam Agent for Linux Monitor\n"
print text
os.system("echo '"+text+"' | mail -s '"+subject+"' "+recipient)
def main():
checkVersion()
#EnumerateSession()
#EnumerateRepositories()
#EnumerateJobs()
SendXmlsessions()
SendMailsessions()
return 0;
result = main()
print "Complete with code",result
exit(result)