Ignorer les liens de navigation | |
Quitter l'aperu | |
Administration Oracle Solaris : Oracle Solaris Zones, Oracle Solaris 10 Zones et gestion des ressources Oracle Solaris 11 Information Library (Français) |
Partie I Gestion des ressources Oracle Solaris
1. Introduction à la gestion des ressources
2. Projets et tâches (présentation)
3. Administration des projets et des tâches
4. Comptabilisation étendue (présentation)
5. Administration de la comptabilisation étendue (tâches)
Administration de l'utilitaire de comptabilisation étendue (liste des tâches)
Utilisation de la fonctionnalité de comptabilisation étendue
Activation de la comptabilisation étendue des flux, processus, tâches et composants réseau
Affichage de l'état de la comptabilisation étendue
Affichage des ressources de comptabilisation disponibles
Désactivation de la comptabilisation des processus, des tâches, des flux et de gestion de réseau
Utilisation de l'interface Perl pour accéder à libexacct
Affichage récursif du contenu d'un objet exacct
Création et écriture d'un enregistrement de groupe dans un fichier
6. Contrôles des ressources (présentation)
7. Administration des contrôles des ressources (tâches)
8. Ordonnanceur FSS (présentation)
9. Administration de l'ordonnanceur FSS (tâches)
10. Contrôle de la mémoire physique à l'aide du démon de limitation des ressources (présentation)
11. Administration du démon de limitation des ressources (tâches)
12. Pools de ressources (présentation)
13. Création et administration des pools de ressources (tâches)
14. Exemple de configuration de la gestion des ressources
Partie II Oracle Solaris Zones
15. Introduction à Oracle Solaris Zones
16. Configuration des zones non globales (présentation)
17. Planification et configuration de zones non globales (tâches)
20. Connexion à une zone non globale (présentation)
21. Connexion à une zone non globale (tâches)
22. A propos des migrations de zones et de l'outil zonep2vchk
23. Migration de systèmes Oracle Solaris et migration de zones non globales (tâches)
25. Administration d'Oracle Solaris Zones (présentation)
26. Administration d'Oracle Solaris Zones (tâches)
27. Configuration et administration de zones immuables
28. Dépannage des problèmes liés à Oracle Solaris Zones
Partie III Oracle Solaris 10 Zones
29. Introduction à Oracle Solaris 10 Zones
30. Evaluation d'un système Oracle Solaris 10 et création d'une archive
32. Configuration de la zone marquée solaris10
33. Installation de la zone marquée solaris10
34. Initialisation d'une zone, connexion et migration de zone
Servez-vous du code suivant pour afficher de façon récursive le contenu d'un objet exacct . Notez que cette fonctionnalité est assurée par la bibliothèque en tant que fonction Sun::Solaris::Exacct::Object::dump(). Elle est également disponible par le biais de la fonction de convenance 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); } }
Servez-vous de ce script pour définir un nouvel enregistrement de groupe et l'écrire dans un fichier nommé /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;
Servez-vous du code Perl suivant pour afficher le contenu d'un fichier 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);
Voici un exemple de la sortie obtenue en appliquant Sun::Solaris::Exacct::Object->dump() au fichier créé dans la section Création et écriture d'un enregistrement de groupe dans un fichier.
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