HOWTO INFORMATIQUE
Cette page donne des réponses à diverses questions informatique
Voir aussi
ComputerScience
WIKI
Voir aussi
InformationAboutThisTwiki
Tutoriel :
TWikiTutorial
Niveau Utilisateur
Créer un raccourci vers une icône :
Par exemple, créer

comme raccourci de l'icône TODO :
Editer
TWikiPreferences
* Set TD = http://planetowiki.irap.omp.eu/pub/TWiki/TWikiDocGraphics/todo.gif
* Set DO =
Commentaire
Html comment =
Twiki comment = # comment
Voir ce qui change sur le site
Pour savoir ce qui a changé (en ordre chronologique) sur le web Team, consulter cette page :
WebChanges
Changements survenus sur le web "twiki" :
WebChanges
on peut aussi s'inscrire sur cette page pour recevoir les changements du web Team par email :
WebNotify
Contribuer (enrichir le site)
Vous êtes vivement encouragés à contribuer au contenu de ce site.
Pour modifier n'importe quelle page du site :
- cliquez sur bouton "Edit", faites vos modifs, puis cliquez sur le bouton "Save".
- si vous êtes plus à l'aise avec la souris, cliquez plutot sur le bouton "WYSIWYG"
Faire une copie (de sauvegarde) d'un Web (pour consultation offline) :
- Grace au plugin PublishContrib, on peut obtenir une copie du Web à tout instant (attention, cette copie est READ ONLY, ce n'est plus un wiki, mais juste des pages web).
- Pour publier la version courante du Web, aller sur le topic PublishWeb, et cliquer sur le bouton "Publish" (en milieu de page). Par défaut, c'est l'option "zip" qui est sélectionnée, ce qui crée un zip du Web.
- Il suffit maintenant de cliquer en bas de la page générée par la requete, sur le lien "Published To: NomduWeb.zip", pour télécharger ce zip (L'accès à cette adresse est protégé pour que seuls les personnes enregistrées puissent y acceder)
- Dézipper et cliquer sur la page WebHome.html. Le résultat n'est pas très joli, mais le contenu y est...
- Un historique de la dernière publication se trouve dans le topic PublishContribHistory (utile pour voir si tout s'est bien passé)
Mise à jour d'une pièce attachée (remarque) :
Il vaut mieux utiliser des noms de fichier assez génériques (par exemple FDD.pdf au lieu de FF_v1.4.pdf) ainsi on peut mettre à jour un document sans changer son nom et les liens vers ce fichier
Insérer une icone:
%Y% |
|
%TD% ou %ICONURL{todo}% |
|
%DO% ou %ICONURL{done}% |
|
%CL% ou %ICONURL{closed}% |
|
Pour en savoir plus:
TWikiDocGraphics#Status_flag_LED_tag_icons
RACCOURCIS PRATIQUES
- Liste de tous les users twiki enregistrés : UserList
Niveau Administrateur
Voir aussi
InformationAboutThisTwiki
IDL
Conseils pour bien documenter son code
- Voir conseils généraux (Michael Galloy) "A style guide" : styleguide.pdf
Je livre ici une synthèse des conseils de Michael Galloy pour bien documenter un code IDL (Lire "A style guide" pour la version complète avec justifications) :
1. General principles
1. Code is for humans.
2. Do not mix styles.
3. Avoid redundancy.
4. Use an easy to maintain style.
2. Layout
1. Layout should enhance the logical structure of the code.
2. Use two spaces (not tabs) per indentation level.
3. Use a maximum line length of 79 characters.
4. Write code in paragraphs.
Example:
function mg_sample, nValues, nIndices, seed=seed
compile_opt strictarr
; get random nIndices by finding the indices of the smallest
; nIndices in an array of random values
values = randomu(seed, nValues)
; our random values are uniformly distributed, so ideally
; the nIndices smallest values are in the first bin of the
; below histogram
nBins = nValues / nIndices
h = histogram(values, nbins=nBins, reverse_indices=ri)
; the candidates for being in the first nIndices will live in
; bins 0..bin
nCandidates = 0L
for bin = 0L, nBins - 1L do begin
nCandidates += h[bin]
if (nCandidates ge nIndices) then break
endfor
; get the candidates and sort them
candidates = ri[ri[0] : ri[bin + 1L] - 1L]
sortedCandidates = sort(values[candidates])
; return the first nIndices of them
return, (candidates[sortedCandidates])[0:nIndices-1L]
end
5. Insert two blank lines between routines.
One blank line separates "paragraphs"; two blank lines separate "sections."
3. Comments
1. Document intent.
2. Keep comments up to date with the code.
3. For a short comment, use a phrase with lowercase first letter and no period. For longer comments, use all
normal grammar rules.
5. Write a complete header for each routine.
Use comments between ;+ and ;- before the routine. Document the purpose of the routine, the return value (if
a function), and side effects of the routine (which you should strive to eliminate). Each parameter should be
documented with whether it is an input and/or output, optional or required, data type expected, default value (if
any) and a description of its purpose.
For example, the below is an IDLdoc formatted header for the routine listed above:
;+
; Get nIndices random indices for an array of size nValues (do
; not repeat an index).
;
; :Returns: lonarr(nIndices)
;
; :Params:
; nValues : in, required, type=long
; size of array to choose indices from
; nIndices : in, required, type=long
; number of indices needed
;
; :Keywords:
; seed : in, out, optional, type=long or lonarr(36)
; seed to use for random number generation, a new seed
; will be output
;-
function mg_sample, nValues, nIndices, seed=seed
6. Indent a comment along with the code it's documenting.
7. Document paragraph by paragraph.
Each paragraph of code may need a comment to document its purpose, but inside a paragraph use only end-of-line
comments to comment particular lines.
It can be helpful to write the comments first, providing an outline of the code to write.
ex of end-of-line comment :
if (event.type eq 2) then begin ; type 2 = motion events
9. Don't repeat the code in the comments.
Don't document the obvious.
10. Don't add extra comments for convoluted code; improve the code.
Don't document bad code—rewrite it. (Kernighan and Plauger, The Elements of Programming Style)
4. Statement formatting
1. Use lowercase for reserved words, operators, and compile_opt option names.
For example, use:
compile_opt strictarr
if (not done) then readf, lun, line
2. Use only one statement per line.
Multiple commands can be entered on one line using the & to separate them. This can be useful on the command
line, but don't use it for code in files: routines, batch files, or main-level programs. For example, don't write:
a = 1 & b = 2
3. Prefer begin/end blocks unless the entire statements fits on one line.
For example, for a single short statement in a compound statement, use:
for i = 0, 10 do print, i
For a multiple statement block, write:
for i = 0, 10 do begin
j = i^2
print, j
endfor
For a single, long statement, use:
for i = 0, 10 do begin
print, i, format='("The index is ", I0, ".")'
end
But never write:
for i = 0, 10 do $
print, i, format='("The index is ", I0, ".")'
The same holds for each case of a case or switch statement:
Statement formatting
6
case uname of
'tlb': resize_widget, event.x, event.y
'draw': begin
if (event.type ne 2) then return ; type 2 = motion events
(*pstate).x = event.x
(*pstate).y = event.y
end
else:
endcase
4. Use specific end statements for the ending a block: endif, endwhile, endrep, endcase, and endswitch.
Using the appropriate end statement lets the IDL compiler help catch structural errors in the code.
There are no specific end statements for each case of a case or switch statement or the end of a routine or mainlevel
program, so just use end.
5. Define structures one field per line unless the entire definition can fit on one line.
For example, use:
point = { x: 0.0, y:0.0 }
state = { x: 0.0, $
y: 0.0, $
pdata: ptr_new(), $ ; image data
drawId: 0L $ ; window identifier
}
Defining each field on its own line allows for individual fields to be found more easily and to be documented on
the same line they are defined on.
6. Add one space around most operators.
Normal arithmetic operators should have one space before and after them, for example:
slope = (y0 - y1) / (x0 - x1)
There are many exceptions to this rule. Don't put spaces around -> for method invocation or = for keyword use
(but do for = for assignment). Don't put extra spaces around ()'s or []'s in any of their uses, but do add an extra
space inside {}'s. Examples:
tvscl, im, true=1
bin = arr[r[r[i]:r[i + 1] - 1]]
point = { x: 0.0, y: 0.0 }
Don't add extra spaces in order to align values. For example, do:
x = 1
y = 2
longer = 3
instead of
x = 1
y = 2
longer = 3
7. Use single quotes for strings.
Both single and double quoted strings are allowed in IDL. Use only single quoted strings to avoid clashing with
the strange octal value notation that uses double quotes,
Statement formatting
7
age = "22 years"
is a syntax error because
age = "22
defines age to be 22 in octal (18 in decimal). The additional years" in the previous statement is not understood
by the IDL parser.
Use double single quotes if you need a single quote. For example,
sign = 'Eat at Joe''s'
8. Don't mix the bitwise operators and, or, and not with the logical operators &&, ||, and ~.
Always use and, or, and not for all bitwise operations. For logical operations, either use the bitwise operators
or (if using IDL 6.0 or later) use the logical operators &&, ||, and ~ along with the logical_predicate option to
compile_opt.
9. Use capital letters to indicate the type of constant, use lowercase to indicate base of integers.
Use 0L not 0l because "l" (lowercase letter el) looks like "1" (integer one). Use '5'o and '5'x, not '5'O and
'5'X.
Create constants of the correct type instead of creating a variable of the incorrect type and having IDL convert
it. Though IDL will automatically convert it, that adds some overhead and, more importantly, obscures the type
of the variable for readers of the code.
10. Use square brackets for array indices.
Use
compile_opt strictarr
in each routine to prevent issues with IDL confusing arrays and functions calls.
11. Indent continuation lines of routine declarations and calls with the first argument.
For example, do:
pro mgitopadapthistequal::getProperty, clip=clip, $
nregions=nregions, $
top=top, $
_ref_extra=e
12. Indent continuation lines of assignment statements to the right of the =.
For example,
self.eyeEccentricity = n_elements(eye_eccentricity) eq 0 $
? 0.5 $
: eye_eccentricity
13. Indent continuation lines of looping and conditional statements with the condition.
For example,
if (arg_present(sdev) $
|| arg_present(variance) $
|| arg_present(skewness) $
Variables
8
|| arg_present(kurtosis)) then begin
This can often be rewritten more clearly with the use of some variables that hold sections of the full expression.
14. Use labels sparingly for goto and ON_IOERROR statements.
Use lowercase short names for labels. Indent labels with surrounding code. Place the label on its own line.
For example,
on_ioerror, io_problem
openr, lun, filename, /get_lun
arr = fltarr(100)
readu, lun, arr
free_lun, lun
return, arr
io_problem:
print, err_string
5. Variables
1. Use good variable names.
Think for a while. A thesaurus can be a valuable tool for finding the right name. Shorter names are acceptable
if the variable is used only in a small section of code (such as a loop variable). Do use the standard names for
common variables: state, pState, event, and tlb.
2. Variable names should be in camel case.
Camel case uppercases the first letter of each word in the name except for the first letter.
Uppercase each letter in an abbreviation that appears in a variable name unless it starts the name, i.e.
noaaWeatherURL.
Prefix a local variable with "my" when it mirrors a parameter, but has possibly been modified with a default
value. Prefix the name with "n" for variables that hold counts, "o" for object references, "p" for pointers, "id" for
iTools identifiers.
Examples that follow this convention,
myParam
nFiles
oModel
pState
idPlot
3. Prefer pointers, objects, and passing local variables over common blocks or system variables.
Occasionally there is a reason to use common blocks or system variables, but you should have a good argument
for it.
When using direct graphics, prefer using graphics keywords of the plotting routines over setting system
variables directly.
Routines
9
4. Define common blocks and named structures in only one location.
Define the variables in a common block only once in a batch file. Include that file where needed.
map_proj_init_commonblock.pro is an example of this.
Define a named structure using automatic structure definition. For example, define MG_Point in a routine
named MG_POINT__DEFINE in a file named mg_point__define.pro.
6. Routines
1. For any file containing IDL code, filenames should always be in lower case and use the ".pro" extension.
Lowercase filenames reduce cross-platform issues. IDL will automatically find code that is in files using the
".pro" extension (provided it follows the other conventions listed in below).
2. Each file should include only one routine called from outside the file.
Each file should contain only one routine called from outside that file. Add the ".pro" extension to the routine
name of the externally called routine to get the filename. For example, the routine MG_LINEAR_FUNCTION
should be in a file named mg_linear_function.pro. If there are multiple routines in the file, make sure the
externally called routine is last in the file. Following this rule will insure that IDL automatically finds and
compiles all code necessary (provided the files are in the IDL path or current directory). The names of the
helper routines in the same file should be prefixed with the entire name of the external routine, such as
MG_LINEAR_FUNCTION_HELPER.
A prominent exception to this rule is the case of class definition files which should include all the methods of
the class, many of which could be called from outside the file. IDL will still find the methods automatically if
done following the style rules in the section on object-oriented programming.
3. Routine names should be lower case, begin with a short organization prefix, and separate words with
underscores.
The prefix indicates the individual or group responsible for the code. It is usually the initials of the individual or
orgranization. Limit to two or three letters. Don't use the "IDL", "RSI", "ITT", "cw", "it", or empty prefixes.
For example, here are some names following this style:
mg_linear_function
mg_itbrowser
mg_sample
4. Routines should fit on one screen.
It is much easier to understand a routine when it can viewed in its entirety. An exception are routines with case
statements where there are many short cases.
5. Keywords should always be optional for the caller; positional parameters should generally be required.
Keywords should either be an optional input with a reasonable default value or an extra output (i.e. not the
main purpose of the routine). This allows new users of the routine to focus on the few positional parameters and
examine the more numerous keywords as needed when the default values are not appropriate for them.
6. Keyword names should be lowercase and separate words with underscores.
Object-oriented programming
10
For example,
filename
ntests
eye_separation
left_image
7. Always use the full keyword name when calling the routine.
The same abbreviations which are so handy when typing at the commandline become quite cryptic when written
in a file and examined years later. They may even be ambiguous if new versions of the code they call have
been released (with more keywords) in the meantime. Using the full name prevents ambiguity and increases the
readability.
8. If the purpose of a routine is to return a value, use a function, otherwise use a procedure.
If the main purpose of the routine is to perform some action (besides a query), but incidentally needs to return
a value use a procedure with an output keyword. In general, use a function when it would be useful to chain
together multiple calls in one expression.
Avoid the C-style status as the function return value.
9. Status and error codes should be returned via keyword.
Often this means that a function needs to return a null or impossible value if an error occurs during execution.
For example, WHERE returns -1 when there are no matching elements of the given array.
10. Setup firewalls for error handling as appropriate to the application.
Data that crosses a firewall should be checked carefully for correctness. There should always be a firewall
around the entire program for data coming in (from files, network, or user). Other firewalls should be added as
appropriate to the application: some may require a firewall around each routine, others between "packages", and
others may require no other firewalls besides the outside wall.
Use
on_error, 2
in simple, short routines when you become confident that the only errors occurring in the routine are from bad
inputs.
7. Object-oriented programming
In addition to the other rules, there are a few extra guidelines for writing object-oriented code.
1. Class names should begin with a prefix indicating organization and a code indicating the class' area of use.
Each word should be capitalized
Use the same prefix as given to normal routine names; avoid "IDL", "ITT", "RSI", and the empty prefix.
Codes already in use by IDL: an (analysis), com (COM), db (database), ex (example), ff (file format), gr
(graphics), it (iTools), sys (system), net (network), and _ (general use). Make use of the existing codes and
make up new ones as necessary.
Object-oriented programming
11
The examples,
MGgrWindow3D
MGffTemplate
MGutTestCase
use the codes gr and ff already in use by IDL, but creates a new code ut (for unit testing) because none is
provided.
Use all caps for abbreviations in class names, as in
IDLnetURL.
2. Put all the methods and the routine defining the instance variables for a class into a single file.
For the definition of
MGexClass, the file should be named mgexclass__define.pro. The last routine in this file
should be MGEXCLASS__DEFINE and should define the instance variables for the class (i.e. create a named
structure with name
MGexClass).
Define only one structure/class name in the __DEFINE routine.
3. Method names should be a verb phrase in camel case.
For example, here are some method names following these conventions:
getProperty
setProperty
add
findTestNames
runTest
reportTestResult
Use the conventions that are used by the IDL library classes. For example, use the GETPROPERTY and
SETPROPERTY scheme of procedures to handle getting and setting properties of a class.
4. Begin "protected" methods' names with a underscore.
For example,
MGexSomeClass::_helperMethod
is a helper method called by other methods in
MGexSomeClass, but should not be called from outside of
MGexSomeClass.
Because IDL has no mechanism for limiting who can call a method, the underscore merely indicates that only
that class and its subclasses should call that method. This gives a visual cue to the caller without enforcing the
protection. Outside callers can still call this method, but at least they have been warned.
5. Beware of multiple inheritance.
Use multiple inheritance as a last resort. Prefer delegation for one of the parent classes i.e. make the new class
contain the secondary parent class as an instance variable.
Reference
Listed below are some references that provided inspiration for the rules included in this style guide.
[Custom99] Custom Visuals. “IDL Style Guide”. www.customvisuals.com/IDL_Style.html. 1999.
Object-oriented programming
12
[Fanning03] David Fanning. Coyote's Guide to IDL Programming. www.dfanning.com. “IDL Style Guide”. 2003.
[ITTVIS07] ITT Visual Information Solutions. www.ittvis.com. “One Proposal for an IDL Coding Standard”. Tech
Tip 4120. 2007.
[KernPlauger78] Brian W. Kernighan and P. J. Plauger. The Elements of Programming Style. 2nd edition. 1978.
[McConnell04] Steve
McConnell. Code Complete. 2nd edition. 2004.
[Rossum01] Python Enhancement Proposals. www.python.org/dev/peps. Guido van Rossum and Barry Warsaw.
“Python PEP-8: Style Guide for Python”. 2001.
IdlDoc : générateur de documentation pour IDL
home:
http://idldoc.idldev.com/
download:
http://idldoc.idldev.com/wiki/Downloads
tutoriel:
http://idldoc.idldev.com/wiki/GettingStarted
Installation: (NB: sur hyperion, c'est déjà installé sous /usr/local/itt/idldoc/idldoc)
1) Download
2) Copier et dézipper dans un dossier de mon choix (ex : D:/idldoc/idldoc-3.3)
3) Ajouter le chemin vers idldoc dans le IDL_PATH (Fenêtre/Preferences/IDL/Chemins/Insérer (puis Appliquer)
Utilisation:
Pour générer la doc avec idldoc :
IDL> idldoc, root='C:\Users\Etienne\IDLWorkspace80\monprojet\trunk\src', output='C:\Users\Etienne\IDLWorkspace80\monprojet\trunk\doc'
Puis, 2clic sur index.html
Enregistrer une image dans un fichier
; envoi vers fichier postscript
set_plot, 'ps'
; éventuellement donner un nom
device, filename='toto.ps'
plot, findgen(2)
; retour à l'affichage sur écran
device, /close
set_plot, 'x'
PHP
Afficher un bloc de code html dans php (ou tout autre texte long) :
http://forum.webrankinfo.com/petite-astuce-pour-afficher-simplement-code-html-t32812.html
LINUX
Niveau Utilisateur
SED (substitution de texte)
Pleins d'exemples ici :
http://sed.sourceforge.net/sed1line_fr.html
- remplacer tutu par toto, mais seulement des lignes 3 à 6 :
cat monfichier.txt | sed -e 3,6"s/tutu/toto/" >| monfichiertemp.txt
- remplacer tutu par toto, mais seulement entre les lignes "titi" et "toto" :
/titi/,/toto/s/tutu/toto/
ou encore :
sed -e "/$debut/,/$fin/"'s#HostId="t3://.*\n#HostId="t3://'"$WLS_ADM_HOST:$PORT\"/" < "$file1" > "$file2"
GREP (recherche textuelle)
Afficher uniquement les lignes de commentaire:
egrep '^#' fichier
Ne pas afficher les lignes de commentaire:
egrep -v '^#' fichier
N'afficher que les lignes utiles (tout sauf commentaires et lignes vides) :
egrep -v '^(#|$)' fichier
RSYNC
Sauvegarder (de façon incrémentielle) des répertoires du poste A vers le poste B :
1) Depuis A...
A#> rsync -avz /rep/rep1 /rep/rep2 B:/rep/
option -v = verbose
attention aux slashes '/' :
/rep/rep1 écrit un répertoire rep1 sur B
/rep/rep1/ écrit directement le contenu du répertoire rep1 sur B
2) ... ou Depuis B
rsync -avz A:/rep/rep1 A:/rep/rep2 ./rep
FIND
Supprimer tous les répertoires CVS/ dans toute une arborescence (à partir du répertoire courant) :
find . -name "CVS" -exec \rm -r {} \; > /dev/null 2>&1
Combien de fichiers dans un répertoire (y-compris les sous-rep) :
find rep | wc -l
Affecter des droits spécifiques à certains éléments d'un répertoire (tout le contenu, y-compris sous-dossiers) :
dossiers:
find /home/jsmith/awstats/ -type d | xargs chmod 0755
fichiers:
find /home/jsmith/awstats/ -type f | xargs chmod 0644
fichiers perl:
find /home/jsmith/awstats/ -type f -name *.pl | xargs chmod 0755
Forwarder les mails du serveur
Par exemple, je veux forwarder mes mails de
pallier@planetoweb.cesr.fr vers ma boite cesr ou encore ma boite perso :
cd ~
créer un fichier ".forward" contenant mon adresse cesr ou perso
S'il s'agit de forwarder les mails adressés à
root@planetoweb.cesr.fr, on peut utiliser la même solution, mais on peut aussi
ajouter cette ligne tout à la fin du fichier /etc/aliases
root:
etienne.pallier@cesr.fr
Rechercher un fichier (dans une hiérarchie de répertoires)
find . -name filename_searched
Rechercher un mot dans un ou plusieurs fichiers
- rechercher "mot" dans les fichiers idl du répertoire courant
grep "mot" *.pro
- rechercher "mot" dans tous les fichiers du répertoire courant
grep -i "mot" .
L'option "-i" permet de ne pas tenir compte de la casse
- rechercher "mot" dans tous les fichiers du répertoire courant ainsi que dans tous les sous-rep (récursif) :
grep -r -i "mot" .
Faire une action sur un ensemble de dossiers et fichiers
Depuis répertoire courant, supprimer tous les dossiers "CVS" (récursivement) :
find . -name CVS -exec rm -rf {} \;
Créer un alias
Exemple : quand on tape "l" ça fera "ls -l"
alias l="ls -l"
Cette ligne doit être placée dans votre ~/.bashrc
Configurer mon environnement
Pour les configurations perso, les placer dans son ~/.bash_profile (ce script appelle ~/.bashrc qui doit contenir les alias et fonctions)
Mettre les configurations générales dans /etc/profile.d/profile_etienne.sh (elles seront ainsi valables pour TOUS les users du serveur)
Ce fichier est automatiquement lu par /etc/profile au démarrage d'une session
Imprimer sur linux
Pour installer l'imprimante "sprinter", voir
SprinterPrinter
Pour faire de cette imprimante l'imprimante par défaut, ajouter cette ligne dans votre ~/.bash_profile :
export PRINTER=sprinter (mettre le nom de votre imprimante à la place de "sprinter")
Pour imprimer du texte, on peut utiliser les utilitaires "a2ps" ou "enscript"
Visualiser des images (jpeg, ps, ...) en mode console
display
Note : display permet aussi de convertir une image d'un format vers un autre (enregistrer sous...)
Voir aussi "xv" et "gthumb"
Convertir une image d'un format vers un autre
PS to PDF : ps2pdf
Voir aussi l'utilitaire convert
En mode interactif, On peut aussi utiliser display (voir ci-dessus)
Niveau Administrateur
LOGS
/var/log
auth.log ou secure (sur Redhat)
Outil de visualisation graphique des logs : gnome-system-log
logrotate
/etc/logrotate.conf
/etc/logrotate.d/
Forcer une rotation :
sudo logrotate -f /etc/logrotate.conf
==> new file "messages", "messages" devient "messages1", "messages1" devient "messages2"...
logwatch
by default, runs daily on yesterday's logs (/etc/cron.daily/0logwatch qui pointe sur /usr/share/logwatch/scripts/logwatch.pl), includes all services, and sends a mail to root
Configuration locale :
- Générale : /usr/share/logwatch/default.conf/logwatch.conf
- Locale : /etc/logwatch/conf/logwatch.conf
Exemples :
info sur l'activité sshd d'aujourd'hui :
logwatch --service sshd --range=Today
Plus de détails :
logwatch --service sshd --range=Today --detail=Medium (ou High)
Pour créer un fichier au lieu d'un mail : --save=logwatch.today
Bonne config de logwatch.conf :
Range=All (au lieu de "Yesterday")
Detail=High
Archives=Yes (ajoute les logs des semaines précédentes, pas seulement le log en cours)
Equivalent commande : --range=All --archives
Exemple de config sur planetoweb (aug 2010) :
Création d'une config locale /etc/logwatch/conf/logwatch.conf :
Range = All
Detail = High
Archives = Yes
Output = html
Save = /var/www/html/servers/planetoweb/logwatch.html
Résultat sur
http://planetoweb/servers/planetoweb/logwatch.html
swatch
http://www.linux-mag.com/id/7807
yum install swatch
[root@planetoweb planetoweb]# rpm -ql swatch
/usr/bin/swatch
/usr/lib/perl5/vendor_perl/5.8.8/Swatch
/usr/lib/perl5/vendor_perl/5.8.8/Swatch/Actions.pm
/usr/lib/perl5/vendor_perl/5.8.8/Swatch/Threshold.pm
/usr/lib/perl5/vendor_perl/5.8.8/Swatch/Throttle.pm
/usr/lib/perl5/vendor_perl/5.8.8/auto/Swatch
/usr/lib/perl5/vendor_perl/5.8.8/auto/Swatch/Actions
/usr/lib/perl5/vendor_perl/5.8.8/auto/Swatch/Actions/autosplit.ix
/usr/share/doc/swatch-3.2.1
/usr/share/doc/swatch-3.2.1/CHANGES
/usr/share/doc/swatch-3.2.1/COPYING
/usr/share/doc/swatch-3.2.1/COPYRIGHT
/usr/share/doc/swatch-3.2.1/KNOWN_BUGS
/usr/share/doc/swatch-3.2.1/README
/usr/share/doc/swatch-3.2.1/examples
/usr/share/doc/swatch-3.2.1/examples/SendMail.pm
/usr/share/doc/swatch-3.2.1/tools
/usr/share/doc/swatch-3.2.1/tools/reswatch
/usr/share/doc/swatch-3.2.1/tools/swatch_oldrc2newrc
/usr/share/man/man1/swatch.1.gz
/usr/share/man/man3/Swatch::Actions.3pm.gz
/usr/share/man/man3/Swatch::Threshold.3pm.gz
/usr/share/man/man3/Swatch::Throttle.3pm.gz
/usr/share/doc/swatch
Créer un startup script : vi /etc/init.d/swatch
#!/bin/sh
# Simple Log Watcher Program
case "$1" in
'start')
/usr/bin/swatch --daemon --config-file=/etc/swatch.conf --tail-file=/var/log/auth.log --pid-file=/var/run/swatch.pid
;;
'stop')
PID=`cat /var/run/swatch.pid`
kill $PID
;;
*)
echo "Usage: $0 { start | stop }"
;;
esac
exit 0
chmod 755 /etc/init.d/swatch
Make sure swatch starts automatically at my runlevels :
# ln -s /etc/init.d/swatch /etc/rc2.d/S99swatch
# ln -s /etc/init.d/swatch /etc/rc3.d/S99swatch
# ln -s /etc/init.d/swatch /etc/rc5.d/S99swatch
Créer un fichier de conf /etc/swatch.conf :
watchfor /invalid|repeated|incomplete/
echo
write khess
mail addresses=khess@localhost, subject=Authentication Problems
/etc/init.d/swatch start ==> créer un pid dans /var/run/swatch.pid et un fichier /root/.swatch_script.xxxx (avec xxxx = pid - 2)
SSH, config plus stricte
vi /etc/ssh/sshd_config
Port 22 : on pourrait mettre ici un autre port, genre 2010, histoire de brouiller les pirates...
PermitRootLogin? no
LoginGraceTime? 2m
changed to :
LoginGraceTime? 30
/etc/init.d/sshd restart
Surveiller un serveur
last reboot
lastlog
dmesg
lspci
/var/log/messages
/var/log/boot.log
Voir aussi section suivante (test des disques)
Tester les disques durs
Occupation disques : df -h
[root@hyperion home]# df -h
Sys. de fich. Tail. Occ. Disp. %Occ. Monté sur
/dev/sda3 178G 63G 106G 38% /
/dev/sdb1 2,7T 1,4T 1,3T 52% /data
/dev/sda1 99M 29M 65M 31% /boot
tmpfs 24G 4,0K 24G 1% /dev/shm
cat /proc/partitions
cat /etc/mtab
cat /proc/mounts (equivalent de la commande "mount")
cat /proc/scsi/scsi
Voir aussi si messages d'erreur disques dans /var/log/messsages
Tester aussi la commande dmesg (equivalent à /var/log/dmesg)
Yum
Annuler l'information sur les updates disponibles :
/etc/init.d/yum-updatesd stop
su -c 'chkconfig --level 2345 yum-updatesd off'
Every other workaround seems to only kill yum-updatesd for runlevel 5.
Try yum update after that.
Keep in mind that you will no longer be informed that there updates available and as such you will need to check periodically with
yum check-update
Quels sont les packages commençant par "mesa-" installés + à installer ? --> yum list mesa-*
Samba
Créer un new user "toto" : sbmpasswd -a toto
Mettre à jour le pass de "toto" : smbpasswd toto
Est-ce que samba est à l'écoute ? : service smb status
Redémarrer samba : service smb restart
Depuis le poste client windows :
clic droit sur Poste de Travail / Créer un lecteur réseau / "\\nom_du_serveur\mon_nom"
Corriger un bug sur Mac Leopard (pas sur Tiger) : samba ne suit pas les liens qui vont vers un disque différent
Pour corriger ce bug, il suffit d'ajouter cette ligne dans la partie "[global]" du smb.conf :
unix extensions = no
WINDOWS
Migrer de Windows XP vers Windows 7
Il faut acheter la licence Microsoft. La démarche dépend de la marque du PC.
Pour un hp : aller sur le site hp et rechercher "windows upgrade"
Modèles éligibles :
http://h41112.www4.hp.com/promo/win7web/fr/fr/eligmodels.html
http://welcome.hp.com/country/fr/fr/mda/windows7/upgrade/which_version.html?jumpid=reg_R1002_FRFR
http://h41112.www4.hp.com/promo/win7web/fr/fr/
Envoyer des mails avec Outlook quand on n'est pas au CESR
1) "Creuser" un tunnel avec Putty
Créer une nouvelle session que vous appelerez par exemple "tunnel_mail_cesr",
et qui créera un tunnel entre le port local 9025 et le port SMTP (25) du serveur de mail cesr (fw-in.cesr.fr).
La procédure est décrite sur la faq informatique du cesr :
http://www1.cesr.fr/intranet/informatique/faq/ssh-tunnels/ssh.htm#_Toc150503764
(Exemple 1, cas numéro 2)
Il faudra lancer cette session (et la garder ouverte en tâche de fond) avant d'envoyer un mail
2) Configurer votre client mail Outlook
- Menu Outils/Paramètres du compte
- Clic sur bouton "Modifier"
- Dans le champ "Serveur de courrier sortant (SMTP)", remplacer "mailhost.cesr.fr" par "localhost"
- Clic sur bouton "Paramètres supplémentaires...", clic sur onglet "Options avancées"
- Dans le champ "Serveur Sortant (SMTP)", remplacer "25" par "9025"
Bien sûr, il faut tout remettre en place quand on revient au cesr (en fait, on pourrait aussi fonctionner en permanence avec le tunnel, même au CESR...)
Synchroniser Outlook 2007 Calendar et Google Calendar
http://content.techrepublic.com.com/2346-10877_11-191016.html
Installer un serveur X sur Windows pour afficher les fenêtres graphiques de linux
On propose d'utiliser Xming qui est un serveur X gratuit pour Windows
Il suffit d'éxécuter Xming avant de lancer une session graphique via putty (ou autre shell)
Installation :
http://sourceforge.net/projects/xming
Cliquer sur Download
1) Installer Xming
2) Installer Xming-fonts (surtout nécessaire pour Emacs)
--
EtiennePallier - 25 Dec 2009