Esempio n. 1
0
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
###############################################################################

#required interfaces that we have to implement
from kitt.interfaces import IKittLiveProcess, IKittProcModule, implements, \
        moduleProvides
moduleProvides(IKittProcModule)

import psutil
import platform
import os

#special case optimization for file based proc
_special_case = {'Linux': '/proc', 'SunOS': '/proc', 'FreeBSD': '/proc'}
_platform = platform.system()
#file based proc that is enabled and populated
if _platform in _special_case and os.listdir(_special_case[_platform]):
    HAS_PROC_DIR = True
    PROC_DIR = _special_case[_platform]
else:
    HAS_PROC_DIR = False
    PROC_DIR = None
Esempio n. 2
0
WORK_IN_PROGRESS_MESSAGE = "[systemstats service]: this service is under development and will throw an error on load.\n"
WORK_IN_PROGRESS_MESSAGE += "This error will not affect other running services. you may ignore."
#raise NotImplementedError(WORK_IN_PROGRESS_MESSAGE)

import time
from zope.interface import Interface, Attribute
from twisted.python.failure import Failure
from twisted.internet import defer, task
from twisted.application.service import Service
from droned.logging import logWithContext, err
from droned.models.systemstats import StatBlockLoader
from droned.models.action import AdminAction

#becoming a service provider module
from kitt.interfaces import moduleProvides, IDroneDService
moduleProvides(IDroneDService) #requirement

log = logWithContext(type=SERVICENAME)

class SystemStats(Service):
    writing = defer.succeed(None)
    
    def stop_collect(self,*args):
	log("disabling all metric collection")
	for h in self.handlers:
	    h[1].disable_collect()
	
    def start_collect(self,*args):
	log("enabling metic collection")
	for h in self.handlers:
	    h[1].enable_collect()
Esempio n. 3
0
#use ``import kitt.proc *`` for methods, attributes and classes

import struct, os, platform, time, re
from kitt.interfaces import IKittProcModule, IKittProcess, \
        IKittProcessSnapshot, IKittLiveProcess, implements, moduleProvides

if platform.system() != 'SunOS':
    raise OSError("Sorry, only SunOS is supported")

_sunos_version = int(platform.release().split('.')[-1])
if _sunos_version < 10:
    raise OSError("Sorry, version %d of SunOS is not supported" % _sunos_version)

__author__ = 'Justin Venus <*****@*****.**>'

moduleProvides(IKittProcModule)

#python3 readiness
try:
   _range = xrange
except NameError:
   _range = range

PAGESIZE = os.sysconf('SC_PAGESIZE')
PROCDIR = '/proc'

stat_attribs = ('flag','nlwp','ppid','pgid','sid','uid','euid','gid', \
	'egid','addr','size','rssize','pad1','ttydev','pctcpu','pctmem','utime', \
	'stime','cutime','cstime','sigtrace','flttrace','sysentry','sysexit','dmodel', \
	'wstat','argc','argv','envp','dmodel','starttime','ctime','time','fname', \
	'cmdline','taskid','projid','nzomb','poolid','zoneid','contract')
Esempio n. 4
0
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
###############################################################################

from kitt.interfaces import moduleProvides, IDroneDService
moduleProvides(IDroneDService)  #requirement
from kitt.util import dictwrapper
import config

SERVICENAME = 'janitizer'
#default configuration cleanup logs older than 7 days
SERVICECONFIG = dictwrapper({
    'JANITIZE': {
        config.LOG_DIR: [
            ('.*.log.\d+.*', int(7 * len(config.AUTOSTART_SERVICES))),
        ],
    }
})
import os, re, time
from twisted.application.service import Service
from twisted.internet import defer, task
Esempio n. 5
0
#   limitations under the License.
###############################################################################


__author__ = "Justin Venus <*****@*****.**>"
__doc__ = """A Service to provide romeo config over droned's command port"""
from kitt.interfaces import moduleProvides, IDroneDService
from kitt.util import dictwrapper, getException
from twisted.web.resource import Resource
from twisted.web.server import NOT_DONE_YET
from twisted.web.error import NoResource
from twisted.python.failure import Failure
from droned.models.event import Event
import romeo

moduleProvides(IDroneDService)
parentService = None
service = None
SERVICENAME = 'remote_config'
SERVICECONFIG = dictwrapper({})
dependant_service = 'drone'

#output formatters
try: import simplejson as json
except ImportError:
    try: import json
    except: json = None
try: import cPickle as pickle
except ImportError:
    import pickle
from yaml import dump as yaml_dumper