This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Django settings for azionmanager project. | |
# -*- encoding: utf-8 -*- | |
import os | |
import sys | |
PROJECT_PATH = os.path.dirname(os.path.abspath(__file__)) | |
DATABASES = { | |
'default': { | |
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Django settings for azionmanager project. | |
# -*- encoding: utf-8 -*- | |
import os | |
import sys | |
PROJECT_PATH = os.path.dirname(os.path.abspath(__file__)) | |
DATABASES = { | |
'default': { | |
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.x_severity = None # Log event severity (DEBUG, INFO, WARN, ERROR, FATAL) | |
self.x_category = None # Log event category (server, vhost, application, session, stream) | |
self.x_event = None # Log event (see table below) | |
self.tz_ = None # Time zone of log event | |
self.date_ = None # Ex.: '2013-01-29' | |
self.time_ = None # Ex.: '10:00:05' | |
self.c_client_id = None # Client ID number assigned by the server to the connection | |
self.c_ip = None # Client connection IP address | |
self.c_port = None # Client connection port | |
self.cs_bytes = None # Total number of bytes transferred from client to server (accumulative) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def queryset(self, request): | |
qs = super(NetworksAdmin, self).queryset(request) | |
try: | |
ip = request.GET['q'] | |
tmp = ipaddr.IPAddress(ip).packed | |
qs = qs.filter(netmin__lte=ip, netmax__gte=ip) | |
#print len(qs) | |
for q in qs: | |
print q |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class IPField(models.Field): | |
__metaclass__ = models.SubfieldBase | |
description = 'IP Field' | |
def get_db_prep_value(self, value, connection, prepared=False): | |
value = super(IPField, self | |
).get_db_prep_value(value, connection, prepared) | |
if value is not None: | |
tmp = ipaddr.IPAddress(value) | |
if ':' in value: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import httplib | |
__author__ = 'charles.sartori' | |
from django.contrib.contenttypes.models import ContentType | |
from django.test import TestCase | |
from django.contrib.auth.models import User | |
from mockito import mock, any, when | |
from model_mommy import mommy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#admin.py | |
def save_model(self, request, obj, form, change): | |
""" | |
Add the admin user to a special model attribute for reference after save | |
""" | |
#obj._history_user = request.user | |
from cuser.middleware import CuserMiddleware | |
CuserMiddleware.set_user(request.user) | |
super(SimpleHistoryAdmin, self).save_model(request, obj, form, change) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#forms.py | |
class ContactsEscalationForm(forms.ModelForm): | |
class Meta: | |
Model = ContactsEscalation | |
exclude = ('dt_cancel',) | |
#models.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######## LOG CONF ############# | |
logFolder = "/var/log/azion/" | |
logFileSize = 10000000 #10MB in bytes | |
#number of log files before rotate | |
logRotate = 10 | |
# loglevel: info, warning, error, critical, debug #KEEP MINIMUN LOG LEVEL critical for monitoring propose | |
loglevel = "debug" | |
def logMaker(logFile, logName = "Default"): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _parsedData(self, context): | |
totalmbs_miss = 0 | |
total_hits_miss = 0 | |
total_mbs = int(self.bytes_sent) | |
if self.upstream_cache_status in ['MISS', 'EXPIRED']: | |
totalmbs_miss = total_mbs | |
total_hits_miss = 1 | |
my_key = (self.date, self.hour, self.client_id, self.type, context.hostname) |