Ignorar Links de Navegao | |
Sair do Modo de Exibio de Impresso | |
Guia de administração do sistema: gerenciamento de recursos do Oracle Solaris Containers e Oracle Solaris Zones Oracle Solaris 10 1/13 Information Library (Português (Brasil)) |
Parte I Gerenciamento de Recursos
1. Introdução ao gerenciador de recursos do Solaris 10
2. Projetos e tarefas (visão geral)
3. Administração de projetos e tarefas
4. Contabilidade estendida (Visão geral)
5. Administração da contabilidade estendida (tarefas)
Administração do recurso de contabilidade estendida (Mapa de tarefas)
Uso da funcionalidade da contabilidade estendida
Como ativar a contabilidade estendida para processos, tarefas e fluxos
Como ativar a contabilidade estendida com um script de inicialização
Como exibir o status da contabilidade estendida
Como visualizar recursos de contabilidade disponíveis
Como desativar a contabilidade de processo, tarefa e fluxo
Uso da interface Perl para libexacct
Como imprimir recursivamente o conteúdo de um objeto exacct
Como criar um novo registro de grupo e gravá-lo em um arquivo
6. Controles de Recursos (Visão Geral)
7. Administração de controles de recursos (Tarefas)
8. Fair share scheduler (visão geral)
9. Administração do fair share scheduler (tarefas)
10. Controle da memória física usando o resource capping daemon (visão geral)
11. Administração do resource capping daemon (tarefas)
12. Pools de recursos (Visão geral)
13. Criação e administração de pools de recursos (Tarefas)
14. Exemplo de configuração de gerenciamento de recurso
15. Funcionalidade do controle de recursos no Console de gerenciamento Solaris
16. Introdução ao Solaris Zones
17. Configuração de zona não global (Visão geral)
18. Planejamento e configuração de zonas não globais (Tarefas)
19. Sobre instalação, parada, clonagem e desinstalação de zonas não globais (Visão geral)
20. Instalação, inicialização, parada, desinstalação e clonagem de zonas não globais (Tarefas)
21. Login na zona não global (Visão geral)
22. Login em zonas não globais (Tarefas)
23. Movendo e migrando zonas não globais (Tarefas)
24. Oracle Solaris 10 9/10: migrando de um sistema Oracle Solaris físico para uma zona (Tarefas)
25. Sobre pacotes e patches em um sistema do Oracle Solaris com zonas instaladas (Visão geral)
27. Administração do Oracle Solaris Zones (Visão geral)
28. Administração do Oracle Solaris Zones (Tarefas)
29. Atualização de um sistema Oracle Solaris 10 com zonas não globais instaladas
30. Soluções diversas de problemas do Oracle Solaris Zones
Parte III 1x}Zonas não nativas
31. Sobre zonas não nativas e zonas não nativas do Linux
32. Planejamento da configuração da zona não nativa lx (Visão geral)
33. Configuração de zonas não nativas lx (Tarefas)
36. Login em zonas não nativas lx (Tarefas)
37. Movendo e migrando zonas não nativas lx (Tarefas)
38. Administração e execução de aplicativos em zonas não nativas lx (Tarefas)
Use o código a seguir para imprimir recursivamente o conteúdo de um objeto exacct . Observe que esta capacidade é fornecida pela biblioteca como a função Sun::Solaris::Exacct::Object::dump(). Esta capacidade também está disponível através da função de conveniência ea_dump_object().
sub dump_object { my ($obj, $indent) = @_; my $istr = ' ' x $indent; # # Retrieve the catalog tag. Because we are # doing this in an array context, the # catalog tag will be returned as a (type, catalog, id) # triplet, where each member of the triplet will behave as # an integer or a string, depending on context. # If instead this next line provided a scalar context, e.g. # my $cat = $obj->catalog()->value(); # then $cat would be set to the integer value of the # catalog tag. # my @cat = $obj->catalog()->value(); # # If the object is a plain item # if ($obj->type() == &EO_ITEM) { # # Note: The '%s' formats provide s string context, so # the components of the catalog tag will be displayed # as the symbolic values. If we changed the '%s' # formats to '%d', the numeric value of the components # would be displayed. # printf("%sITEM\n%s Catalog = %s|%s|%s\n", $istr, $istr, @cat); $indent++; # # Retrieve the value of the item. If the item contains # in turn a nested exacct object (i.e., an item or # group),then the value method will return a reference # to the appropriate sort of perl object # (Exacct::Object::Item or Exacct::Object::Group). # We could of course figure out that the item contained # a nested item orgroup by examining the catalog tag in # @cat and looking for a type of EXT_EXACCT_OBJECT or # EXT_GROUP. # my $val = $obj->value(); if (ref($val)) { # If it is a nested object, recurse to dump it. dump_object($val, $indent); } else { # Otherwise it is just a 'plain' value, so # display it. printf("%s Value = %s\n", $istr, $val); } # # Otherwise we know we are dealing with a group. Groups # represent contents as a perl list or array (depending on # context), so we can process the contents of the group # with a 'foreach' loop, which provides a list context. # In a list context the value method returns the content # of the group as a perl list, which is the quickest # mechanism, but doesn't allow the group to be modified. # If we wanted to modify the contents of the group we could # do so like this: # my $grp = $obj->value(); # Returns an array reference # $grp->[0] = $newitem; # but accessing the group elements this way is much slower. # } else { printf("%sGROUP\n%s Catalog = %s|%s|%s\n", $istr, $istr, @cat); $indent++; # 'foreach' provides a list context. foreach my $val ($obj->value()) { dump_object($val, $indent); } printf("%sENDGROUP\n", $istr); } }
Use este script para criar um novo registro de grupo e gravá-lo em um arquivo chamado /tmp/exacct.
#!/usr/bin/perl use strict; use warnings; use Sun::Solaris::Exacct qw(:EXACCT_ALL); # Prototype list of catalog tags and values. my @items = ( [ &EXT_STRING | &EXC_DEFAULT | &EXD_CREATOR => "me" ], [ &EXT_UINT32 | &EXC_DEFAULT | &EXD_PROC_PID => $$ ], [ &EXT_UINT32 | &EXC_DEFAULT | &EXD_PROC_UID => $< ], [ &EXT_UINT32 | &EXC_DEFAULT | &EXD_PROC_GID => $( ], [ &EXT_STRING | &EXC_DEFAULT | &EXD_PROC_COMMAND => "/bin/rec" ], ); # Create a new group catalog object. my $cat = ea_new_catalog(&EXT_GROUP | &EXC_DEFAULT | &EXD_NONE) # Create a new Group object and retrieve its data array. my $group = ea_new_group($cat); my $ary = $group->value(); # Push the new Items onto the Group array. foreach my $v (@items) { push(@$ary, ea_new_item(ea_new_catalog($v->[0]), $v->[1])); } # Open the exacct file, write the record & close. my $f = ea_new_file('/tmp/exacct', &O_RDWR | &O_CREAT | &O_TRUNC) || die("create /tmp/exacct failed: ", ea_error_str(), "\n"); $f->write($group); $f = undef;
Use o script Perl a seguir para imprimir o conteúdo de um arquivo exacct.
#!/usr/bin/perl use strict; use warnings; use Sun::Solaris::Exacct qw(:EXACCT_ALL); die("Usage is dumpexacct <exacct file>\n") unless (@ARGV == 1); # Open the exact file and display the header information. my $ef = ea_new_file($ARGV[0], &O_RDONLY) || die(error_str()); printf("Creator: %s\n", $ef->creator()); printf("Hostname: %s\n\n", $ef->hostname()); # Dump the file contents while (my $obj = $ef->get()) { ea_dump_object($obj); } # Report any errors if (ea_error() != EXR_OK && ea_error() != EXR_EOF) { printf("\nERROR: %s\n", ea_error_str()); exit(1); } exit(0);
Esta é uma saída de exemplo produzida ao se executar Sun::Solaris::Exacct::Object->dump() no arquivo criado em Como criar um novo registro de grupo e gravá-lo em um arquivo.
Creator: root Hostname: localhost GROUP Catalog = EXT_GROUP|EXC_DEFAULT|EXD_NONE ITEM Catalog = EXT_STRING|EXC_DEFAULT|EXD_CREATOR Value = me ITEM Catalog = EXT_UINT32|EXC_DEFAULT|EXD_PROC_PID Value = 845523 ITEM Catalog = EXT_UINT32|EXC_DEFAULT|EXD_PROC_UID Value = 37845 ITEM Catalog = EXT_UINT32|EXC_DEFAULT|EXD_PROC_GID Value = 10 ITEM Catalog = EXT_STRING|EXC_DEFAULT|EXD_PROC_COMMAND Value = /bin/rec ENDGROUP