forked from bsbforever/wechat_monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path:
40 lines (40 loc) · 2.33 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
#coding=utf-8
from django.core.management.base import BaseCommand
from oracle.models import oraclelist
from oracle.models import oraclestatus
import os
import time
import types
from oracle.monitor.getoracleinfo import *
from oracle.monitor.sendmail import *
nowtime=str(time.time()).split('.')[0]
class Command(BaseCommand):
def handle(self, *args, **options):
oraclestatus.objects.all().delete()
ip=oraclelist.objects.all().order_by('tnsname')
for i in ip:
if i.monitor_type==1:
ipaddress1=i.ipaddress
username=i.username
password=i.password
port=i.port
tnsname1=i.tnsname
try:
send_mail(to_list,'Oracle Monitor Exception Occured',content)
print content
break
else:
dbsize=getdbsize(cursor)
tbstatus=getspace(cursor)
oracle_info=check_info(cursor)
sga_size=get_sga_size(cursor)
cursor.close()
db.close()
if oraclestatus.objects.filter(ipaddress=ipaddress1):
status=oraclestatus.objects.filter(ipaddress=ipaddress1)
status.update(**{'tnsname':tnsname1,'ipaddress':ipaddress1,'jobstatus':jobstatus,'alertstatus':alertstatus,'dbsize':dbsize,'tbstatus':tbstatus,'invalid_object':invalid_object,'mv_compile_state':mv_compile_state,'host_name':oracle_info[0],'version':oracle_info[1],'startup_time':oracle_info[2],'status':oracle_info[3],'archiver':oracle_info[4],'sga_size':sga_size})
else:
createtnsname=oraclestatus(ipaddress=ipaddress1)
createtnsname.save()
status=oraclestatus.objects.filter(ipaddress=ipaddress1)
status.update(**{'tnsname':tnsname1,'ipaddress':ipaddress1,'jobstatus':jobstatus,'alertstatus':alertstatus,'dbsize':dbsize,'tbstatus':tbstatus,'invalid_object':invalid_object,'mv_compile_state':mv_compile_state,'host_name':oracle_info[0],'version':oracle_info[1],'startup_time':oracle_info[2],'status':oracle_info[3],'archiver':oracle_info[4],'sga_size':sga_size})