Beispiel #1
0
    def show_widget(self, page, machines=None, theid=None):
        # The data is data is pulled from the database and passed to a template.
        
        # There are three possible views we're going to be rendering to - front, bu_dashbaord and group_dashboard. If page is set to bu_dashboard, or group_dashboard, you will be passed a business_unit or machine_group id to use (mainly for linking to the right search).
        if page == 'front':
            t = loader.get_template('munkiversion/templates/front.html')
            if not machines:
                machines = Machine.objects.all()
        
        if page == 'bu_dashboard':
            t = loader.get_template('munkiversion/templates/id.html')
            if not machines:
                machines = utils.getBUmachines(theid)
        
        if page == 'group_dashboard':
            t = loader.get_template('munkiversion/templates/id.html')
            if not machines:
                machine_group = get_object_or_404(MachineGroup, pk=theid)
                machines = Machine.objects.filter(machine_group=machine_group)
        
        if machines:
            munki_info = machines.values('munki_version').annotate(count=Count('munki_version')).order_by()
        else:
            munki_info = []

        c = Context({
            'title': 'Munki Version',
            'data': munki_info,
            'theid': theid,
            'page': page
        })
        return t.render(c), 4
Beispiel #2
0
def bu_inventory(request, bu_id):
    user = request.user
    user_level = user.userprofile.level
    business_unit = get_object_or_404(BusinessUnit, pk=bu_id)
    if business_unit not in user.businessunit_set.all() and user_level != 'GA':
        print 'not letting you in ' + user_level
        return redirect(index)
    # Get the groups within the Business Unit
    machines = utils.getBUmachines(bu_id)

    inventory = []
    for machine in machines:
        for item in machine.inventoryitem_set.all():
            inventory.append(item)

    found = unique_apps(inventory)
    c = {
        'user': request.user,
        'inventory': found,
        'page': 'business_unit',
        'business_unit': business_unit,
        'request': request
    }
    return render_to_response('inventory/index.html',
                              c,
                              context_instance=RequestContext(request))
    def show_widget(self, page, machines=None, theid=None):
        # The data is data is pulled from the database and passed to a template.

        # There are three possible views we're going to be rendering to - front, bu_dashbaord and group_dashboard. If page is set to bu_dashboard, or$
        if page == 'front':
            t = loader.get_template('erikng/munkimanifest/templates/munkimanifest_front.html')
            if not machines:
                machines = Machine.objects.all()

        if page == 'bu_dashboard':
            t = loader.get_template('erikng/munkimanifest/templates/munkimanifest_id.html')
            if not machines:
                machines = utils.getBUmachines(theid)

        if page == 'group_dashboard':
            t = loader.get_template('erikng/munkimanifest/templates/munkimanifest_id.html')
            if not machines:
                machine_group = get_object_or_404(MachineGroup, pk=theid)
                machines = Machine.objects.filter(machine_group=machine_group)

        if machines:
            mmanifest = machines.values('manifest').annotate(count=Count('manifest')).order_by()
        else:
            mmanifest = []

        c = Context({
            'title': 'Munki Manifest',
            'data': mmanifest,
            'theid': theid,
            'page': page
        })
        return t.render(c), 4
Beispiel #4
0
 def show_widget(self, page, machines=None, theid=None):
     # The data is data is pulled from the database and passed to a template.
     
     # There are three possible views we're going to be rendering to - front, bu_dashbaord and group_dashboard. If page is set to bu_dashboard, or group_dashboard, you will be passed a business_unit or machine_group id to use (mainly for linking to the right search).
     if page == 'front':
         t = loader.get_template('topprocesses/templates/front.html')
         if not machines:
             machines = Machine.objects.all()
     
     if page == 'bu_dashboard':
         t = loader.get_template('topprocesses/templates/id.html')
         if not machines:
             machines = utils.getBUmachines(theid)
     
     if page == 'group_dashboard':
         t = loader.get_template('topprocesses/templates/id.html')
         if not machines:
             machine_group = get_object_or_404(MachineGroup, pk=theid)
             machines = Machine.objects.filter(machine_group=machine_group)
     
     if machines:
         try:
             info = OSQueryColumn.objects.filter(osquery_result__name='pack_sal_top_processes').filter(osquery_result__machine=machines).filter(column_name='name').values('column_data').annotate(data_count=Count('column_data')).order_by('-data_count')[:100:1]
         except:
             info = []
     else:
         info = []
     c = Context({
         'title': 'Top Processes',
         'data': info,
         'theid': theid,
         'page': page
     })
     return t.render(c), 4
Beispiel #5
0
    def show_widget(self, page, machines=None, theid=None):
        # The data is data is pulled from the database and passed to a template.
        
        # There are three possible views we're going to be rendering to - front, bu_dashbaord and group_dashboard. If page is set to bu_dashboard, or group_dashboard, you will be passed a business_unit or machine_group id to use (mainly for linking to the right search).
        if page == 'front':
            t = loader.get_template('munkiversion/templates/front.html')
            if not machines:
                machines = Machine.objects.all()
        
        if page == 'bu_dashboard':
            t = loader.get_template('munkiversion/templates/id.html')
            if not machines:
                machines = utils.getBUmachines(theid)
        
        if page == 'group_dashboard':
            t = loader.get_template('munkiversion/templates/id.html')
            if not machines:
                machine_group = get_object_or_404(MachineGroup, pk=theid)
                machines = Machine.objects.filter(machine_group=machine_group)
        
        if machines:
            munki_info = machines.values('munki_version').annotate(count=Count('munki_version')).order_by()
        else:
            munki_info = []

        c = Context({
            'title': 'Munki Version',
            'data': munki_info,
            'theid': theid,
            'page': page
        })
        return t.render(c), 4
    def show_widget(self, page, machines=None, theid=None):

        try:
            show_desktops = settings.ENCRYPTION_SHOW_DESKTOPS
        except:
            show_desktops = True

        # The data is data is pulled from the database and passed to a template.

        # There are three possible views we're going to be rendering to - front, bu_dashbaord and group_dashboard. If page is set to bu_dashboard, or group_dashboard, you will be passed a business_unit or machine_group id to use (mainly for linking to the right search).
        if page == 'front':
            if show_desktops:
                t = loader.get_template('grahamgilbert/encryption/templates/front_desktops.html')
            else:
                t = loader.get_template('grahamgilbert/encryption/templates/front_laptops.html')
            if not machines:
                machines = Machine.objects.all()

        if page == 'bu_dashboard':
            if show_desktops:
                t = loader.get_template('grahamgilbert/encryption/templates/id_desktops.html')
            else:
                t = loader.get_template('grahamgilbert/encryption/templates/id_laptops.html')
            if not machines:
                machines = utils.getBUmachines(theid)

        if page == 'group_dashboard':
            if show_desktops:
                t = loader.get_template('grahamgilbert/encryption/templates/id_desktops.html')
            else:
                t = loader.get_template('grahamgilbert/encryption/templates/id_laptops.html')
            if not machines:
                machine_group = get_object_or_404(MachineGroup, pk=theid)
                machines = Machine.objects.filter(machine_group=machine_group)

        if machines:
            laptop_ok = machines.filter(facts__fact_name='mac_encryption_enabled', facts__fact_data='true').filter(facts__fact_name='mac_laptop', facts__fact_data='mac_laptop').count()
            desktop_ok = machines.filter(facts__fact_name='mac_encryption_enabled', facts__fact_data__exact='true').filter(facts__fact_name='mac_laptop', facts__fact_data__exact='mac_desktop').count()
            laptop_alert = machines.filter(facts__fact_name='mac_encryption_enabled', facts__fact_data__exact='false').filter(facts__fact_name='mac_laptop', facts__fact_data__exact='mac_laptop').count()
            desktop_alert = machines.filter(facts__fact_name='mac_encryption_enabled', facts__fact_data__exact='false').filter(facts__fact_name='mac_laptop', facts__fact_data__exact='mac_desktop').count()
        else:
            laptop_ok = 0
            desktop_ok = 0
            laptop_alert = 0
            desktop_alert = 0

        c = Context({
            'title': 'Encryption',
            'laptop_label': 'Laptops',
            'laptop_ok_count': laptop_ok,
            'laptop_alert_count': laptop_alert,
            'desktop_ok_count': desktop_ok,
            'desktop_alert_count': desktop_alert,
            'desktop_label': 'Desktops',
            'plugin': 'Encryption',
            'theid': theid,
            'page': page
        })
        return t.render(c), 4
Beispiel #7
0
def inventory_list(request, page='front', theID=None):
    user = request.user
    title=None
    inventory_name = request.GET.get('name')
    inventory_version = request.GET.get('version', '0')
    inventory_bundleid = request.GET.get('bundleid', '')
    inventory_path = request.GET.get('path')
    inventory_bundlename = request.GET.get('bundlename','')
    
    # get a list of machines (either from the BU or the group)
    if page == 'front':
        # get all machines
        if user.userprofile.level == 'GA':
            machines = Machine.objects.all()
        else:
            machines = Machine.objects.none()
            for business_unit in user.businessunit_set.all():
                for group in business_unit.machinegroup_set.all():
                    machines = machines | group.machine_set.all()
    if page == 'bu_dashboard':
        # only get machines for that BU
        # Need to make sure the user is allowed to see this

        machines = utils.getBUmachines(theID)

    if page == 'group_dashboard' or page == 'machine_group':
        # only get machines from that group
        machine_group = get_object_or_404(MachineGroup, pk=theID)
        # check that the user has access to this
        machines = Machine.objects.filter(machine_group=machine_group)

    if page == 'machine_id':
        machines = Machine.objects.filter(id=theID)

    try:
        page = int(request.GET.get('page'))
    except:
        page = 1

    previous_id = page - 1
    next_id = page + 1
    start = (page - 1) * 25
    end = page * 25
    
    # get the InventoryItems limited to the machines we're allowed to look at
    inventory = InventoryItem.objects.filter(name=inventory_name, version=inventory_version, bundleid=inventory_bundleid, bundlename=inventory_bundlename).filter(machine=machines)[start:end]

    if len(inventory) != 25:
        # we've not got 25 results, probably the last page
        next_id = 0

    c = {'user':user, 'machines': machines, 'req_type': page, 'title': title, 'bu_id': theID, 'request':request, 'inventory_name':inventory_name, 'inventory_version':inventory_version, 'inventory_bundleid':inventory_bundleid, 'inventory_bundlename':inventory_bundlename, 'previous_id': previous_id, 'next_id':next_id, 'inventory':inventory }

    return render_to_response('inventory/overview_list_all.html', c, context_instance=RequestContext(request))
Beispiel #8
0
def inventory_list(request, page='front', theID=None):
    user = request.user
    title=None
    inventory_name = request.GET.get('name')
    inventory_version = request.GET.get('version', '0')
    inventory_bundleid = request.GET.get('bundleid', '')
    inventory_path = request.GET.get('path')
    inventory_bundlename = request.GET.get('bundlename','')

    # get a list of machines (either from the BU or the group)
    if page == 'front':
        # get all machines
        if user.userprofile.level == 'GA':
            machines = Machine.objects.all()
        else:
            machines = Machine.objects.none()
            for business_unit in user.businessunit_set.all():
                for group in business_unit.machinegroup_set.all():
                    machines = machines | group.machine_set.all()
    if page == 'bu_dashboard':
        # only get machines for that BU
        # Need to make sure the user is allowed to see this

        machines = utils.getBUmachines(theID)

    if page == 'group_dashboard' or page == 'machine_group':
        # only get machines from that group
        machine_group = get_object_or_404(MachineGroup, pk=theID)
        # check that the user has access to this
        machines = Machine.objects.filter(machine_group=machine_group)

    if page == 'machine_id':
        machines = Machine.objects.filter(id=theID)

    try:
        page = int(request.GET.get('page'))
    except:
        page = 1

    previous_id = page - 1
    next_id = page + 1
    start = (page - 1) * 25
    end = page * 25

    # get the InventoryItems limited to the machines we're allowed to look at
    inventory = InventoryItem.objects.filter(name=inventory_name, version=inventory_version, bundleid=inventory_bundleid, bundlename=inventory_bundlename).filter(machine=machines)[start:end]

    if len(inventory) != 25:
        # we've not got 25 results, probably the last page
        next_id = 0

    c = {'user':user, 'machines': machines, 'req_type': page, 'title': title, 'bu_id': theID, 'request':request, 'inventory_name':inventory_name, 'inventory_version':inventory_version, 'inventory_bundleid':inventory_bundleid, 'inventory_bundlename':inventory_bundlename, 'previous_id': previous_id, 'next_id':next_id, 'inventory':inventory }

    return render_to_response('inventory/overview_list_all.html', c, context_instance=RequestContext(request))
Beispiel #9
0
    def show_widget(self, page, machines=None, theid=None):
        # The data is data is pulled from the database and passed to a template.

        # There are three possible views we're going to be rendering to - front, bu_dashbaord and group_dashboard. If page is set to bu_dashboard, or group_dashboard, you will be passed a business_unit or machine_group id to use (mainly for linking to the right search).

        # You will be sent a machines object - if you are only operating on a collection of machines, you should use this object for performance reasons
        if page == 'front':
            t = loader.get_template('activity/templates/front.html')
            if not machines:
                machines = Machine.objects.all()

        if page == 'bu_dashboard':
            t = loader.get_template('activity/templates/id.html')
            if not machines:
                machines = utils.getBUmachines(theid)

        if page == 'group_dashboard':
            t = loader.get_template('activity/templates/id.html')
            if not machines:
                machine_group = get_object_or_404(MachineGroup, pk=theid)
                machines = Machine.objects.filter(machine_group=machine_group)

        if machines:
            checked_in_this_hour = machines.filter(
                last_checkin__gte=hour_ago).count()
            checked_in_today = machines.filter(last_checkin__gte=today).count()
            checked_in_this_week = machines.filter(
                last_checkin__gte=week_ago).count()
            inactive_for_a_month = machines.filter(
                last_checkin__range=(three_months_ago, month_ago)).count()
            inactive_for_three_months = machines.exclude(
                last_checkin__gte=three_months_ago).count()
        else:
            checked_in_this_hour = None
            checked_in_today = None
            checked_in_this_week = None
            inactive_for_a_month = None
            inactive_for_three_months = None

        c = Context({
            'title': 'Activity',
            'checked_in_this_hour': checked_in_this_hour,
            'checked_in_today': checked_in_today,
            'checked_in_this_week': checked_in_this_week,
            'inactive_for_a_month': inactive_for_a_month,
            'inactive_for_three_months': inactive_for_three_months,
            'theid': theid,
            'page': page
        })
        return t.render(c), 12
    def show_widget(self, page, machines=None, theid=None):
        # The data is data is pulled from the database and passed to a template.
        
        # There are three possible views we're going to be rendering to - front, bu_dashbaord and group_dashboard. If page is set to bu_dashboard, or group_dashboard, you will be passed a business_unit or machine_group id to use (mainly for linking to the right search).
        if page == 'front':
            t = loader.get_template('timemachine/templates/front.html')
            if not machines:
                machines = Machine.objects.all()
        
        if page == 'bu_dashboard':
            t = loader.get_template('timemachine/templates/id.html')
            if not machines:
                machines = utils.getBUmachines(theid)
        
        if page == 'group_dashboard':
            t = loader.get_template('timemachine/templates/id.html')
            if not machines:
                machine_group = get_object_or_404(MachineGroup, pk=theid)
                machines = Machine.objects.filter(machine_group=machine_group)
        
        if machines:
            time_week = int(time.time() - (86400 * 7))
            time_month = int(time.time() - (86400 * 28))

            tm_configured = machines.filter(fact__fact_name='timemachine_configured', fact__fact_data=1).count()
            tm_notconfigured = machines.filter(fact__fact_name='timemachine_configured', fact__fact_data=0).count()
            tm_recent_ok = machines.filter(fact__fact_name='timemachine_lastsnapshot', fact__fact_data__gte=time_week).count()
            tm_recent_warning = machines.filter(fact__fact_name='timemachine_lastsnapshot', fact__fact_data__lt=time_week, fact__fact_data__gte=time_month).count()
            tm_recent_error = machines.filter(fact__fact_name='timemachine_lastsnapshot', fact__fact_data__lt=time_month).count()
            tm_recent_error += machines.filter(fact__fact_name='timemachine_configured', fact__fact_data=1).exclude(fact__fact_name='timemachine_lastsnapshot').count()
        else:
            tm_configured = None
            tm_notconfigured = None
            tm_recent_ok = None
            tm_recent_warning = None
            tm_recent_error = None

        c = Context({
            'title': 'Time Machine',
            'tm_configured': tm_configured,
            'tm_notconfigured': tm_notconfigured,
            'tm_recent_ok': tm_recent_ok,
            'tm_recent_warning': tm_recent_warning,
            'tm_recent_error': tm_recent_error,
            'theid': theid,
            'page': page
        })
        return t.render(c), 4
Beispiel #11
0
    def show_widget(self, page, machines=None, theid=None):
        if page == 'front':
            t = loader.get_template('puppetstatus/templates/front.html')
            if not machines:
                machines = Machine.objects.all()
        
        if page == 'bu_dashboard':
            t = loader.get_template('puppetstatus/templates/id.html')
            if not machines:
                machines = utils.getBUmachines(theid)
            
        if page == 'group_dashboard':
            t = loader.get_template('puppetstatus/templates/id.html')
            if not machines:
                machine_group = get_object_or_404(MachineGroup, pk=theid)
                machines = Machine.objects.filter(machine_group=machine_group)
        
        if machines:
            puppet_error = machines.filter(puppet_errors__gt=0).count()
            # if there aren't any records with last checkin dates, assume puppet isn't being used
            last_checkin = machines.filter(last_puppet_run__isnull=False).count()
            checked_in_this_month = machines.filter(last_puppet_run__lte=month_ago).count()
        else:
            puppet_error = 0
            last_checkin = 0
            checked_in_this_month = 0
        
        
        if last_checkin > 0:
            size = 4
        else:
            size = 0
        
        c = Context({
            'title': 'Puppet Status',
            'error_label': 'Errors',
            'error_count': puppet_error,
            'month_label': '+ 1 Month',
            'month_count': checked_in_this_month,
            'plugin': 'PuppetStatus',
            'last_checkin_count': last_checkin,
            'theid': theid,
            'page': page
        })
        

        return t.render(c), size
    def show_widget(self, page, machines=None, theid=None):

        if page == 'front':
            t = loader.get_template('grahamgilbert/munkisyncstatus/templates/front.html')
            if not machines:
                machines = Machine.objects.all()

        if page == 'bu_dashboard':
            t = loader.get_template('grahamgilbert/munkisyncstatus/templates/id.html')
            if not machines:
                machines = utils.getBUmachines(theid)

        if page == 'group_dashboard':
            t = loader.get_template('grahamgilbert/munkisyncstatus/templates/id.html')
            if not machines:
                machine_group = get_object_or_404(MachineGroup, pk=theid)
                machines = Machine.objects.filter(machine_group=machine_group)

        if machines:
            local = machines.filter(condition__condition_name='location', condition__condition_data='Local').count()
            cloud = machines.filter(condition__condition_name='location', condition__condition_data='Cloud').count()
            out_of_sync = machines.filter(condition__condition_name='location', condition__condition_data='Out-of-sync').count()

        else:
          local = 0
          cloud = 0
          out_of_sync = 0

        size = 3
        if out_of_sync == 0:
            colour = 'info'
        else:
            colour = 'danger'
        c = Context({
            'title': 'MSU Repository',
            'local_count': local,
            'local_label': 'Local',
            'cloud_count': cloud,
            'cloud_label': 'Cloud',
            'oos_count': out_of_sync,
            'oos_label': 'Out of sync',
            'plugin': 'MunkiSyncStatus',
            'theid': theid,
            'colour': colour,
            'page': page
        })
        return t.render(c), size
Beispiel #13
0
    def show_widget(self, page, machines=None, theid=None):
        # The data is data is pulled from the database and passed to a template.
        
        # we're not linking anywhere, so the template will be the same for all
        t = loader.get_template('hardwaretypes/templates/front.html')
        if page == 'front':
            if not machines:
                machines = Machine.objects.all()
        
        if page == 'bu_dashboard':
            if not machines:
                machines = utils.getBUmachines(theid)
        
        if page == 'group_dashboard':
            if not machines:
                machine_group = get_object_or_404(MachineGroup, pk=theid)
                machines = Machine.objects.filter(machine_group=machine_group)
        
        if machines:
            machines = machines.values('machine_model').annotate(count=Count('machine_model'))
        else:
            machines = None
        
        out = []
        if machines:
            for machine in machines:
                if machine['machine_model']:
                    found = False
                    nodigits=''.join(i for i in machine['machine_model'] if i.isalpha())
                    machine['machine_model']=nodigits
                    for item in out:
                        if item['machine_model'] == machine['machine_model']:
                            item['count'] = item['count']+machine['count']
                            found = True
                            break
                    #if we get this far, it's not been seen before
                    if found == False:
                        out.append(machine)

        c = Context({
            'title': 'Hardware Types',
            'machines': out,
            'theid': theid,
            'page': page
        })
        return t.render(c), 4
Beispiel #14
0
    def show_widget(self, page, machines=None, theid=None):
        # The data is data is pulled from the database and passed to a template.
        
        # There are three possible views we're going to be rendering to - front, bu_dashbaord and group_dashboard. If page is set to bu_dashboard, or group_dashboard, you will be passed a business_unit or machine_group id to use (mainly for linking to the right search).
        
        # You will be sent a machines object - if you are only operating on a collection of machines, you should use this object for performance reasons
        if page == 'front':
            t = loader.get_template('activity/templates/front.html')
            if not machines:
                machines = Machine.objects.all()
        
        if page == 'bu_dashboard':
            t = loader.get_template('activity/templates/id.html')
            if not machines:
                machines = utils.getBUmachines(theid)
        
        if page == 'group_dashboard':
            t = loader.get_template('activity/templates/id.html')
            if not machines:
                machine_group = get_object_or_404(MachineGroup, pk=theid)
                machines = Machine.objects.filter(machine_group=machine_group)
        
        if machines:
            checked_in_this_hour = machines.filter(last_checkin__gte=hour_ago).count()
            checked_in_today = machines.filter(last_checkin__gte=today).count()
            checked_in_this_week = machines.filter(last_checkin__gte=week_ago).count()
            inactive_for_a_month = machines.filter(last_checkin__range=(three_months_ago, month_ago)).count()
            inactive_for_three_months = machines.exclude(last_checkin__gte=three_months_ago).count()
        else:
            checked_in_this_hour = None
            checked_in_today = None
            checked_in_this_week = None
            inactive_for_a_month = None
            inactive_for_three_months = None

        c = Context({
            'title': 'Activity',
            'checked_in_this_hour': checked_in_this_hour,
            'checked_in_today': checked_in_today,
            'checked_in_this_week': checked_in_this_week,
            'inactive_for_a_month': inactive_for_a_month,
            'inactive_for_three_months': inactive_for_three_months,
            'theid': theid,
            'page': page
        })
        return t.render(c), 4
Beispiel #15
0
    def show_widget(self, page, machines=None, theid=None):
        # The data is data is pulled from the database and passed to a template.

        # There are three possible views we're going to be rendering to - front, bu_dashbaord and group_dashboard. If page is set to bu_dashboard, or group_dashboard, you will be passed a business_unit or machine_group id to use (mainly for linking to the right search).
        if page == 'front':
            t = loader.get_template('plugins/traffic_lights_front.html')
            if not machines:
                machines = Machine.objects.all()

        if page == 'bu_dashboard':
            t = loader.get_template('plugins/traffic_lights_id.html')
            if not machines:
                machines = utils.getBUmachines(theid)

        if page == 'group_dashboard':
            t = loader.get_template('plugins/traffic_lights_id.html')
            if not machines:
                machine_group = get_object_or_404(MachineGroup, pk=theid)
                machines = Machine.objects.filter(machine_group=machine_group)

        if machines:
            ok = machines.filter(fact__fact_name='uptime_days',
                                 fact__fact_data__lte=1).count()
            warning = machines.filter(fact__fact_name='uptime_days',
                                      fact__fact_data__range=[1, 7]).count()
            alert = machines.filter(fact__fact_name='uptime_days',
                                    fact__fact_data__gt=7).count()
        else:
            ok = 0
            warning = 0
            alert = 0

        c = Context({
            'title': 'Uptime',
            'ok_label': '< 1 Day',
            'ok_count': ok,
            'warning_label': '< 7 Days',
            'warning_count': warning,
            'alert_label': '7 Days +',
            'alert_count': alert,
            'plugin': 'Uptime',
            'page': page,
            'theid': theid
        })
        return t.render(c), 4
Beispiel #16
0
Datei: views.py Projekt: np5/sal
def bu_inventory(request, bu_id):
    user = request.user
    user_level = user.userprofile.level
    business_unit = get_object_or_404(BusinessUnit, pk=bu_id)
    if business_unit not in user.businessunit_set.all() and user_level != 'GA':
        print 'not letting you in ' + user_level
        return redirect(index)
    # Get the groups within the Business Unit
    machines = utils.getBUmachines(bu_id)

    inventory = []
    for machine in machines:
        for item in machine.inventoryitem_set.all():
            inventory.append(item)
    
    found = unique_apps(inventory)
    c = {'user': request.user, 'inventory': found, 'page':'business_unit', 'business_unit':business_unit, 'request': request}
    return render_to_response('inventory/index.html', c, context_instance=RequestContext(request))
Beispiel #17
0
    def show_widget(self, page, machines=None, theid=None):
        # The data is data is pulled from the database and passed to a template.

        # There are three possible views we're going to be rendering to - front, bu_dashbaord and group_dashboard. If page is set to bu_dashboard, or group_dashboard, you will be passed a business_unit or machine_group id to use (mainly for linking to the right search).
        if page == 'front':
            t = loader.get_template('plugins/traffic_lights_front.html')
            if not machines:
                machines = Machine.objects.all()

        if page == 'bu_dashboard':
            t = loader.get_template('plugins/traffic_lights_id.html')
            if not machines:
                machines = utils.getBUmachines(theid)

        if page == 'group_dashboard':
            t = loader.get_template('plugins/traffic_lights_id.html')
            if not machines:
                machine_group = get_object_or_404(MachineGroup, pk=theid)
                machines = Machine.objects.filter(machine_group=machine_group)

        if machines:
            disk_ok = machines.filter(hd_percent__lt=80).count()
            disk_warning = machines.filter(
                hd_percent__range=["80", "89"]).count()
            disk_alert = machines.filter(hd_percent__gte=90).count()
        else:
            disk_ok = 0
            disk_warning = 0
            disk_alert = 0

        c = Context({
            'title': 'Disk Space',
            'ok_label': '< 80%',
            'ok_count': disk_ok,
            'warning_label': '80% +',
            'warning_count': disk_warning,
            'alert_label': '90% +',
            'alert_count': disk_alert,
            'plugin': 'DiskSpace',
            'theid': theid,
            'page': page
        })
        return t.render(c), 4
Beispiel #18
0
    def show_widget(self, page, machines=None, theid=None):
        # The data is data is pulled from the database and passed to a template.

        # There are three possible views we're going to be rendering to - front, bu_dashbaord and group_dashboard. If page is set to bu_dashboard, or group_dashboard, you will be passed a business_unit or machine_group id to use (mainly for linking to the right search).
        if page == 'front':
            t = loader.get_template('smart_status/templates/front.html')
            if not machines:
                machines = Machine.objects.all()

        if page == 'bu_dashboard':
            t = loader.get_template('smart_status/templates/id.html')
            if not machines:
                machines = utils.getBUmachines(theid)

        if page == 'group_dashboard':
            t = loader.get_template('smart_status/templates/id.html')
            if not machines:
                machine_group = get_object_or_404(MachineGroup, pk=theid)
                machines = Machine.objects.filter(machine_group=machine_group)

        if machines:
            ok = machines.filter(fact__fact_name='smart_status',
                                 fact__fact_data='Verified').count()
            warnings = machines.filter(
                fact__fact_name='smart_status',
                fact__fact_data='Not Supported').count()
            errors = machines.filter(fact__fact_name='smart_status',
                                     fact__fact_data='Failing').count()
        else:
            ok = None
            warnings = None
            errors = None

        c = Context({
            'title': 'SMART Status',
            'ok': ok,
            'warnings': warnings,
            'errors': errors,
            'page': page,
            'theid': theid
        })
        return t.render(c), 4
    def show_widget(self, page, machines=None, theid=None):

        if page == 'front':
            t = loader.get_template('thomasbergmann/hddsize/templates/front.html')
	    if not machines:
                machines = Machine.objects.all()
        if page == 'bu_dashboard':
            t = loader.get_template('thomasbergmann/hddsize/templates/id.html')
	    if not machines:
                machines = utils.getBUmachines(theid)
        if page == 'group_dashboard':
            t = loader.get_template('thomasbergmann/hddsize/templates/id.html')
	    if not machines:
                machine_group = get_object_or_404(MachineGroup, pk=theid)
                machines = Machine.objects.filter(machine_group=machine_group)

	if machines:
            hddsize_128 = machines.filter(hd_total__lte=117649480).count()
            hddsize_256 = machines.filter(hd_total__range=["117649481", "244277768"]).count()
            hddsize_512 = machines.filter(hd_total__range=["244277769", "975922975"]).count()
	    hddsize_1024 = machines.filter(hd_total__gte=975922976).count()
        else:
            hddsize_128 = 0
            hddsize_256 = 0
            hddsize_512 = 0
	    hddsize_1024 = 0

	c = Context({
            'title': 'Disk Size',
            '128_label': '128GB',
            '128_count': hddsize_128,
	    '256_label': '256GB',
            '256_count': hddsize_256,
	    '512_label': '512GB',
            '512_count': hddsize_512,
	    '1024_label': '1024GB +',
            '1024_count': hddsize_1024,
            'plugin': 'HDDSize',
	    'page': page,
            'theid': theid
        })
        return t.render(c), 4 
Beispiel #20
0
Datei: uptime.py Projekt: np5/sal
    def show_widget(self, page, machines=None, theid=None):
        # The data is data is pulled from the database and passed to a template.

        # There are three possible views we're going to be rendering to - front, bu_dashbaord and group_dashboard. If page is set to bu_dashboard, or group_dashboard, you will be passed a business_unit or machine_group id to use (mainly for linking to the right search).
        if page == 'front':
            t = loader.get_template('plugins/traffic_lights_front.html')
            if not machines:
                machines = Machine.objects.all()

        if page == 'bu_dashboard':
            t = loader.get_template('plugins/traffic_lights_id.html')
            if not machines:
                machines = utils.getBUmachines(theid)

        if page == 'group_dashboard':
            t = loader.get_template('plugins/traffic_lights_id.html')
            if not machines:
                machine_group = get_object_or_404(MachineGroup, pk=theid)
                machines = Machine.objects.filter(machine_group=machine_group)

        if machines:
            ok = machines.filter(facts__fact_name='uptime_days', facts__fact_data__lte=1).count()
            warning = machines.filter(facts__fact_name='uptime_days', facts__fact_data__range=[1,7]).count()
            alert = machines.filter(facts__fact_name='uptime_days', facts__fact_data__gt=7).count()
        else:
            ok = 0
            warning = 0
            alert = 0

        c = Context({
            'title': 'Uptime',
            'ok_label': '< 1 Day',
            'ok_count': ok,
            'warning_label': '< 7 Days',
            'warning_count': warning,
            'alert_label': '7 Days +',
            'alert_count': alert,
            'plugin': 'Uptime',
            'page': page,
            'theid': theid
        })
        return t.render(c), 4
Beispiel #21
0
    def show_widget(self, page, machines=None, theid=None):
        # The data is data is pulled from the database and passed to a template.
        
        # There are three possible views we're going to be rendering to - front, bu_dashbaord and group_dashboard. If page is set to bu_dashboard, or group_dashboard, you will be passed a business_unit or machine_group id to use (mainly for linking to the right search).
        if page == 'front':
            t = loader.get_template('plugins/traffic_lights_front.html')
            if not machines:
                machines = Machine.objects.all()
        
        if page == 'bu_dashboard':
            t = loader.get_template('plugins/traffic_lights_id.html')
            if not machines:
                machines = utils.getBUmachines(theid)
            
        if page == 'group_dashboard':
            t = loader.get_template('plugins/traffic_lights_id.html')
            if not machines:
                machine_group = get_object_or_404(MachineGroup, pk=theid)
                machines = Machine.objects.filter(machine_group=machine_group)
        
        if machines:
            disk_ok = machines.filter(hd_percent__lt=80).count()
            disk_warning = machines.filter(hd_percent__range=["80", "89"]).count()
            disk_alert = machines.filter(hd_percent__gte=90).count()
        else:
            disk_ok = 0
            disk_warning = 0
            disk_alert = 0

        c = Context({
            'title': 'Disk Space',
            'ok_label': '< 80%',
            'ok_count': disk_ok,
            'warning_label': '80% +',
            'warning_count': disk_warning,
            'alert_label': '90% +',
            'alert_count': disk_alert,
            'plugin': 'DiskSpace',
            'theid': theid,
            'page': page
        })
        return t.render(c), 4
Beispiel #22
0
    def show_widget(self, page, machines=None, theid=None):
        # The data is data is pulled from the database and passed to a template.
        
        # There are three possible views we're going to be rendering to - front, bu_dashbaord and group_dashboard. If page is set to bu_dashboard, or group_dashboard, you will be passed a business_unit or machine_group id to use (mainly for linking to the right search).
        if page == 'front':
            t = loader.get_template('status/templates/front.html')
            if not machines:
                machines = Machine.objects.all()
        
        if page == 'bu_dashboard':
            t = loader.get_template('status/templates/id.html')
            if not machines:
                machines = utils.getBUmachines(theid)
        
        if page == 'group_dashboard':
            t = loader.get_template('status/templates/id.html')
            if not machines:
                machine_group = get_object_or_404(MachineGroup, pk=theid)
                machines = Machine.objects.filter(machine_group=machine_group)
        
        if machines:
            errors = machines.filter(errors__gt=0).count()
            warnings = machines.filter(warnings__gt=0).count()
            activity = machines.filter(activity__isnull=False).count()
            all_machines = machines.count()
        else:
            errors = None
            warnings = None
            activity = None
            all_machines = None

        c = Context({
            'title': 'Status',
            'errors': errors,
            'warnings': warnings,
            'activity': activity,
            'all_machines': all_machines,
            'theid': theid,
            'page': page
        })
        return t.render(c), 4
Beispiel #23
0
    def show_widget(self, page, machines=None, theid=None):
        # The data is data is pulled from the database and passed to a template.
        
        # There are three possible views we're going to be rendering to - front, bu_dashbaord and group_dashboard. If page is set to bu_dashboard, or group_dashboard, you will be passed a business_unit or machine_group id to use (mainly for linking to the right search).
        if page == 'front':
            t = loader.get_template('smart_status/templates/front.html')
            if not machines:
                machines = Machine.objects.all()
        
        if page == 'bu_dashboard':
            t = loader.get_template('smart_status/templates/id.html')
            if not machines:
                machines = utils.getBUmachines(theid)
        
        if page == 'group_dashboard':
            t = loader.get_template('smart_status/templates/id.html')
            if not machines:
                machine_group = get_object_or_404(MachineGroup, pk=theid)
                machines = Machine.objects.filter(machine_group=machine_group)
        
        if machines:
            ok = machines.filter(fact__fact_name='smart_status', fact__fact_data='Verified').count()
            warnings = machines.filter(fact__fact_name='smart_status', fact__fact_data='Not Supported').count()
            errors = machines.filter(fact__fact_name='smart_status', fact__fact_data='Failing').count()
        else:
            ok = None
            warnings = None
            errors = None

        c = Context({
            'title': 'SMART Status',
            'ok': ok,
            'warnings': warnings,
            'errors': errors,
            'page': page,
            'theid': theid
        })
        return t.render(c), 4
Beispiel #24
0
 def show_widget(self, page, machines=None, theid=None):
     # The data is data is pulled from the database and passed to a template.
     
     # There are three possible views we're going to be rendering to - front, bu_dashbaord and group_dashboard. If page is set to bu_dashboard, or group_dashboard, you will be passed a business_unit or machine_group id to use (mainly for linking to the right search).
     if page == 'front':
         t = loader.get_template('diskerror/templates/front.html')
         if not machines:
             machines = Machine.objects.all()
     
     if page == 'bu_dashboard':
         t = loader.get_template('diskerror/templates/id.html')
         if not machines:
             machines = utils.getBUmachines(theid)
     
     if page == 'group_dashboard':
         t = loader.get_template('diskerror/templates/id.html')
         if not machines:
             machine_group = get_object_or_404(MachineGroup, pk=theid)
             machines = Machine.objects.filter(machine_group=machine_group)
     
     if machines:
         time_28days = datetime.now() - timedelta(days=28)
         time_7days = datetime.now() - timedelta(days=7)
         warnings = machines.filter(historicalfact__fact_name='diskerror', historicalfact__fact_data__gte=1, historicalfact__fact_recorded__gte=time_28days).distinct().count()
         errors = machines.filter(historicalfact__fact_name='diskerror', historicalfact__fact_data__gte=1, historicalfact__fact_recorded__gte=time_7days).distinct().count()
     else:
         warnings = None
         errors = None
 
     c = Context({
         'title': 'Disk Errors',
         'warnings': warnings,
         'errors': errors,
         'page': page,
         'theid': theid
     })
     return t.render(c), 4
	def show_widget(self, page, machines=None, theid=None):

		if page == 'front':
			t = loader.get_template('thomasbergmann/cpui5/templates/front.html')
			if not machines:
				machines = Machine.objects.all()

		if page == 'bu_dashboard':
			t = loader.get_template('thomasbergmann/cpui5/templates/id.html')
			if not machines:
				machines = utils.getBUmachines(theid)
				
		if page == 'group_dashboard':
			t = loader.get_template('thomasbergmann/cpui5/templates/id.html')
			if not machines:
				machine_group = get_object_or_404(MachineGroup, pk=theid)
				machines = Machine.objects.filter(machine_group=machine_group)

		if machines:
			cpu_info = machines.filter(cpu_type__contains='i5').values('cpu_speed').annotate(count=Count('cpu_speed')).order_by()
		else:
			cpu_info = []

		if machines:
			count_all = machines.filter(cpu_type__contains='i5').count()
		else:
			count_all = 0

		c = Context({
			'title': 'Intel Core i5',
			'data': cpu_info,
			'count_all': count_all,
			'page': page,
			'theid': theid
		})
		return t.render(c), 4 
Beispiel #26
0
    def show_widget(self, page, machines=None, theid=None):
        # The data is data is pulled from the database and passed to a template.

        # There are three possible views we're going to be rendering to - front, bu_dashbaord and group_dashboard. If page is set to bu_dashboard, or group_dashboard, you will be passed a business_unit or machine_group id to use (mainly for linking to the right search).
        if page == 'front':
            t = loader.get_template('topprocesses/templates/front.html')
            if not machines:
                machines = Machine.objects.all()

        if page == 'bu_dashboard':
            t = loader.get_template('topprocesses/templates/id.html')
            if not machines:
                machines = utils.getBUmachines(theid)

        if page == 'group_dashboard':
            t = loader.get_template('topprocesses/templates/id.html')
            if not machines:
                machine_group = get_object_or_404(MachineGroup, pk=theid)
                machines = Machine.objects.filter(machine_group=machine_group)

        if machines:
            info = OSQueryColumn.objects.filter(
                osquery_result__name='pack_sal_top_processes').filter(
                    osquery_result__machine=machines).filter(
                        column_name='name').values('column_data').annotate(
                            data_count=Count('column_data')).order_by(
                                '-data_count')[:100:1]
        else:
            info = []
        c = Context({
            'title': 'Top Processes',
            'data': info,
            'theid': theid,
            'page': page
        })
        return t.render(c), 4
    def widget_content(self, page, machines=None, theid=None):
        try:
          authorised_admins = settings.AUTHORISED_ADMINS
        except:
          authorised_admins = []
        # root will always be an admin (or it should!)
        if 'root' not in authorised_admins:
          authorised_admins.extend(['root'])
        if page == 'front':
            t = loader.get_template('grahamgilbert/unauthorisedadmins/templates/front.html')
            if not machines:
                machines = Machine.objects.all()

        if page == 'bu_dashboard':
            t = loader.get_template('grahamgilbert/unauthorisedadmins/templates/id.html')
            if not machines:
                machines = utils.getBUmachines(theid)

        if page == 'group_dashboard':
            t = loader.get_template('grahamgilbert/unauthorisedadmins/templates/id.html')
            if not machines:
                machine_group = get_object_or_404(MachineGroup, pk=theid)
                machines = Machine.objects.filter(machine_group=machine_group)

        if machines:
          unwanted = []
          facts = Fact.objects.filter(fact_name='mac_admin_users').prefetch_related('machine')
          for fact in facts:
            if fact.fact_data == "":
              fact_list.remove(item)
              break
            # split the fact data into a list
            fact_list = fact.fact_data.split(', ')
            # for each item that's not root in fact data, see if it's in the list
            for allowed_admin in authorised_admins:
              for item in fact_list:
                if str(item) == str(allowed_admin):
                  fact_list.remove(item)
                  break
            if len(fact_list) == 0:
              unwanted.append(fact.machine)
              #machines = machines.exclude(id=fact.machine.id)
            # if the list has a lenght of 0, remove the machine from the machines result
          # remove machines that don't have any fact data
          machines = machines.exclude(id__in=[o.id for o in unwanted])
          machines = machines.filter(facts__fact_name='mac_admin_users')
          count = machines.count()
        else:
          count = 0

        if count == 0:
          size = 0
        else:
          size = 3

        if count == 1:
          label = "Admin"
        else:
          label = "Admins"

        c = Context({
            'title': 'Admin Users',
            'count': count,
            'plugin': 'UnauthorisedAdmins',
            'theid': theid,
            'page': page,
            'label': label
        })
        return t.render(c)
Beispiel #28
0
    def show_widget(self, page, machines=None, theid=None):
        # The data is data is pulled from the database and passed to a template.

        # There are three possible views we're going to be rendering to - front, bu_dashbaord and group_dashboard. If page is set to bu_dashboard, or group_dashboard, you will be passed a business_unit or machine_group id to use (mainly for linking to the right search).
        if page == 'front':
            t = loader.get_template('timemachine/templates/front.html')
            if not machines:
                machines = Machine.objects.all()

        if page == 'bu_dashboard':
            t = loader.get_template('timemachine/templates/id.html')
            if not machines:
                machines = utils.getBUmachines(theid)

        if page == 'group_dashboard':
            t = loader.get_template('timemachine/templates/id.html')
            if not machines:
                machine_group = get_object_or_404(MachineGroup, pk=theid)
                machines = Machine.objects.filter(machine_group=machine_group)

        if machines:
            time_week = int(time.time() - (86400 * 7))
            time_month = int(time.time() - (86400 * 28))

            tm_configured = machines.filter(
                fact__fact_name='timemachine_configured',
                fact__fact_data=1).count()
            tm_notconfigured = machines.filter(
                fact__fact_name='timemachine_configured',
                fact__fact_data=0).count()
            tm_recent_ok = machines.filter(
                fact__fact_name='timemachine_lastsnapshot',
                fact__fact_data__gte=time_week).count()
            tm_recent_warning = machines.filter(
                fact__fact_name='timemachine_lastsnapshot',
                fact__fact_data__lt=time_week,
                fact__fact_data__gte=time_month).count()
            tm_recent_error = machines.filter(
                fact__fact_name='timemachine_lastsnapshot',
                fact__fact_data__lt=time_month).count()
            tm_recent_error += machines.filter(
                fact__fact_name='timemachine_configured',
                fact__fact_data=1).exclude(
                    fact__fact_name='timemachine_lastsnapshot').count()
        else:
            tm_configured = None
            tm_notconfigured = None
            tm_recent_ok = None
            tm_recent_warning = None
            tm_recent_error = None

        c = Context({
            'title': 'Time Machine',
            'tm_configured': tm_configured,
            'tm_notconfigured': tm_notconfigured,
            'tm_recent_ok': tm_recent_ok,
            'tm_recent_warning': tm_recent_warning,
            'tm_recent_error': tm_recent_error,
            'theid': theid,
            'page': page
        })
        return t.render(c), 4