def main(): args = parse_input() if args.command == 'disks': if args.j_flag: pprint.pprint(json.dumps(inventory.get_disk_partitions(), sort_keys=True, separators=(',', ': '))) else: pprint.pprint(inventory.get_disk_partitions()) if args.command == 'network': if args.j_flag: pprint.pprint(json.dumps(network.get_network_info(), sort_keys=True, separators=(',', ': '))) elif args.r_flag: human_read.net_human(network.get_network_info()) else: pprint.pprint(network.get_network_info()) if args.command == 'cpu': if args.j_flag: pprint.pprint(json.dumps(cpu.mch_cpu(), sort_keys=True, separators=(',', ': '))) elif args.r_flag: human_read.cpu_human(cpu.mch_cpu()) else: pprint.pprint(cpu.mch_cpu()) if args.command == 'ram': if args.j_flag: pprint.pprint(json.dumps(ram.get_ram_partitions(), sort_keys=True, separators=(',', ': '))) elif args.r_flag: human_read.ram_human(ram.get_ram_partitions()) else: pprint.pprint(ram.get_ram_partitions()) if args.command == 'user': if args.j_flag: pprint.pprint(json.dumps(user.get_users(), sort_keys=True, separators=(',', ': '))) elif args.r_flag: human_read.users_human(user.get_users()) else: pprint.pprint(user.get_users())
def _eval_attributes(self, properties): # response struct _response = { 'computer': { 'hostname': self.migas_computer_name, 'ip': network.get_network_info()['ip'], 'version': self.migas_version, 'platform': platform.system(), # new for server 3.0 'pms': str(self.pms), # new for server 3.0 'user': self._graphic_user, 'user_fullname': utils.get_user_info( self._graphic_user )['fullname'] }, 'attributes': {} } # properties converted in attributes self._send_message(_('Evaluating attributes...')) for _item in properties: _response['attributes'][_item['name']] = \ self._eval_code(_item['language'], _item['code']) _info = '%s: %s' % ( _item['name'], _response['attributes'][_item['name']] ) if _response['attributes'][_item['name']].strip() != '': _operation_ok(_info) else: _operation_failed(_info) self._write_error( 'Error: property %s without value\n' % _item['name'] ) return _response
def _eval_attributes(self, properties): # response struct _response = { 'computer': { 'hostname': self.migas_computer_name, 'ip': network.get_network_info()['ip'], 'version': self.migas_version, 'platform': platform.system(), # new for server 3.0 'pms': str(self.pms), # new for server 3.0 'user': self._graphic_user, 'user_fullname': utils.get_user_info(self._graphic_user)['fullname'] }, 'attributes': {} } # properties converted in attributes self._send_message(_('Evaluating attributes...')) for _item in properties: _response['attributes'][_item['name']] = \ self._eval_code(_item['language'], _item['code']) _info = '%s: %s' % (_item['name'], _response['attributes'][_item['name']]) if _response['attributes'][_item['name']].strip() != '': _operation_ok(_info) else: _operation_failed(_info) self._write_error('Error: property %s without value\n' % _item['name']) return _response
def _get_pkt_info(pkt_data, pcap_rec_header, dl_hdr): status = PCAP_FILE_OK pkt_info = {} network_info = {} transport_info = {} app_info = {} other_info = {} #empty for now network_info = network.get_network_info(pkt_data) if 'error' not in network_info.keys(): ip_hdr_len = 20 if network_info['ip_ver'] else 40 protocol = network_info['protocol'] if network_info['ip_ver'] == 4 else network_info['next_hdr'] #skip to transport layer data transport_info = transport.get_transport_info(network_info, pkt_data[ip_hdr_len:]) if 'error' not in transport_info.keys(): #provide the port number to the application layer app_info = appl.get_appl_info(network_info, transport_info, pkt_data[ip_hdr_len:]) if 'error' in app_info.keys(): print 'appl error' status = PCAP_FILE_PKT_ERROR else: status = PCAP_FILE_PKT_ERROR else: status = PCAP_FILE_PKT_ERROR #aggregate everything in pkt_info dictionary pkt_info['meta'] = pcap_rec_header pkt_info['datalink'] = dl_hdr pkt_info['network'] = network_info pkt_info['transport'] = transport_info pkt_info['appl'] = app_info pkt_info['other'] = other_info return status, pkt_info
def main(): args = parse_input() if args.command == 'disks': if args.j_flag: pprint.pprint(json.dumps(inventory.get_disk_partitions(), sort_keys=True, separators=(',', ': '))) elif args.r_flag: pass # need to make this elif args.d_flag: flaskr.insert('disks', json.dumps(inventory.get_disk_partitions(), sort_keys=True, separators=(',', ': '))) elif args.s_flag: flaskr. retrieve('disks') else: pprint.pprint(inventory.get_disk_partitions()) if args.command == 'network': if args.j_flag: pprint.pprint(json.dumps(network.get_network_info(), sort_keys=True, separators=(',', ': '))) elif args.r_flag: human_read.net_human(network.get_network_info()) elif args.d_flag: flaskr.insert('network', json.dumps(network.get_network_info(), sort_keys=True, separators=(',', ': '))) elif args.s_flag: flaskr.retrieve('network') else: pprint.pprint(network.get_network_info()) if args.command == 'cpu': if args.j_flag: pprint.pprint(json.dumps(cpu.mch_cpu(), sort_keys=True, separators=(',', ': '))) elif args.r_flag: human_read.cpu_human(cpu.mch_cpu()) elif args.d_flag: flaskr.insert('cpu', json.dumps(cpu.mch_cpu(), sort_keys=True, separators=(',', ': '))) elif args.s_flag: flaskr.retrieve('cpu') else: pprint.pprint(cpu.mch_cpu()) if args.command == 'ram': if args.j_flag: pprint.pprint(json.dumps(ram.get_ram_partitions(), sort_keys=True, separators=(',', ': '))) elif args.r_flag: human_read.ram_human(ram.get_ram_partitions()) elif args.d_flag: flaskr.insert('ram', json.dumps(ram.get_ram_partitions(), sort_keys=True, separators=(',', ': '))) elif args.s_flag: flaskr.retrieve('ram') else: pprint.pprint(ram.get_ram_partitions()) if args.command == 'user': if args.j_flag: pprint.pprint(json.dumps(user.get_users(), sort_keys=True, separators=(',', ': '))) elif args.r_flag: human_read.users_human(user.get_users()) elif args.d_flag: flaskr.insert('user', json.dumps(user.get_users(), sort_keys=True, separators=(',', ': '))) elif args.s_flag: flaskr.retrieve('user') else: pprint.pprint(user.get_users()) if args.command == 'simple': if args.j_flag: pprint.pprint(json.dumps(simple.get_simple_info(), sort_keys=True, separators=(',', ': '))) elif args.r_flag: human_read.simple_human(simple.get_simple_info()) elif args.d_flag: flaskr.insert('simple', json.dumps(simple.get_simple_info(), sort_keys=True, separators=(',', ': '))) elif args.s_flag: flaskr.retrieve('simple') else: pprint.pprint(simple.get_simple_info()) if args.command == 'pack': str_name= '' if args.PACKAGE: str_name=args.PACKAGE pprint.pprint(pack.get_pack(str_name))
def sysnet(): data = network.get_network_info() return jsonify(data=data)