Compare commits
125 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a47aa1862 | ||
|
|
0d2cd05d78 | ||
|
|
d82e092f67 | ||
|
|
cea287fb1e | ||
|
|
0eb1584e0e | ||
|
|
b26f1c679f | ||
|
|
0180e31523 | ||
|
|
64c96f39f5 | ||
|
|
1ab4f35373 | ||
|
|
8c87dad21d | ||
|
|
4e7683aee2 | ||
|
|
2832bd82e8 | ||
|
|
4c38e73cdf | ||
|
|
037fe33241 | ||
|
|
3305644b75 | ||
|
|
6f89b71f0d | ||
|
|
ac700397f3 | ||
|
|
2b250a2dd1 | ||
|
|
4adc04dcd8 | ||
|
|
d79f757a48 | ||
|
|
7419a241a7 | ||
|
|
9ce67a29e2 | ||
|
|
96ce9c7c12 | ||
|
|
586f0e211e | ||
|
|
d5b1cc6ee1 | ||
|
|
ba36501983 | ||
|
|
71f5f43153 | ||
|
|
abfe5af25d | ||
|
|
806deb1bed | ||
|
|
772f56a0c7 | ||
|
|
a63254eeae | ||
|
|
22232d89e3 | ||
|
|
e58a87826d | ||
|
|
dfb45fe9bb | ||
|
|
d6440e05e3 | ||
|
|
5ce6a49263 | ||
|
|
920f6bca1d | ||
|
|
4ad0376ddf | ||
|
|
da4bc80fad | ||
|
|
a2aaffcd86 | ||
|
|
6c198f807e | ||
|
|
7aaf4dc860 | ||
|
|
a1eb5ca51a | ||
|
|
2fc36734d9 | ||
|
|
b3f7817819 | ||
|
|
7be3142a28 | ||
|
|
1c62d6b3d5 | ||
|
|
d65ec2457d | ||
|
|
74151c3d59 | ||
|
|
45b8b6179f | ||
|
|
0ad1bd7040 | ||
|
|
45a67a6e61 | ||
|
|
b8ab331b10 | ||
|
|
8be1dca641 | ||
|
|
902f7e8423 | ||
|
|
8db0bd13d3 | ||
|
|
60a51ee98d | ||
|
|
a4f31f44a8 | ||
|
|
a2d95dd682 | ||
|
|
b646a0c12c | ||
|
|
b2104c6a1d | ||
|
|
54e620fc72 | ||
|
|
a99dbf20a0 | ||
|
|
98534e827a | ||
|
|
41e9097f99 | ||
|
|
436f12020a | ||
|
|
fb1c136904 | ||
|
|
c143a4d25d | ||
|
|
a2f09f1275 | ||
|
|
57d57273e1 | ||
|
|
98f57a6bc2 | ||
|
|
5713cfbe22 | ||
|
|
7b1c4a5114 | ||
|
|
09167bbf89 | ||
|
|
0f7a788c6b | ||
|
|
2be3bf6552 | ||
|
|
fbfc441577 | ||
|
|
b3270d5e08 | ||
|
|
02ddef481d | ||
|
|
b3ba6414ff | ||
|
|
11d0b89490 | ||
|
|
b2ddf8945f | ||
|
|
f34d4cbcaa | ||
|
|
ca1afbbad6 | ||
|
|
50c3afd85c | ||
|
|
0933917e87 | ||
|
|
ad8b5c9221 | ||
|
|
b71f09f5c5 | ||
|
|
3f34713c52 | ||
|
|
31041145bf | ||
|
|
b2b7bc120b | ||
|
|
673814a4c6 | ||
|
|
7971f53c4d | ||
|
|
97b27fd03b | ||
|
|
b32838edea | ||
|
|
3188a33462 | ||
|
|
6ad8a6028c | ||
|
|
3053b830eb | ||
|
|
8f52a24f1a | ||
|
|
006e08066c | ||
|
|
00c8ad528e | ||
|
|
482c80a6eb | ||
|
|
b9b67f8b2b | ||
|
|
0d0b0d8de4 | ||
|
|
21b3ccaf18 | ||
|
|
670ed6c2b8 | ||
|
|
a5752dde60 | ||
|
|
86d66b6255 | ||
|
|
8900c8bcfc | ||
|
|
fe3688483e | ||
|
|
f49a4fe72b | ||
|
|
1b3814261c | ||
|
|
cc07ea4a2c | ||
|
|
2c4333077f | ||
|
|
e59dc7eb32 | ||
|
|
aa22f4ed54 | ||
|
|
36a655bbbf | ||
|
|
a4bcab409a | ||
|
|
24089d76a0 | ||
|
|
0a11a0fb78 | ||
|
|
8d02a42628 | ||
|
|
11a88408ef | ||
|
|
163c3b7fe9 | ||
|
|
a4bc29b998 | ||
|
|
2d51059e6c |
1
.env.local
Normal file
1
.env.local
Normal file
@@ -0,0 +1 @@
|
||||
export EXPDP_DIR="/u04/expdp"
|
||||
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# fichier avec les variables d'environnement
|
||||
.env
|
||||
AGENTS.md
|
||||
chat_gemin_db_report.md
|
||||
DOCUMENTATION.md
|
||||
GEMINI.md
|
||||
LEGENDE_COMMANDES.md
|
||||
67
README.md
67
README.md
@@ -1,31 +1,62 @@
|
||||
# DB Report
|
||||
|
||||
Exemple de script qui génère un rapport html avec quelques infos de la base, les fichiers, les logs et les sauvegardes
|
||||
Génère des rapports HTML détaillés sur la configuration d'un serveur et de ses bases de données Oracle.
|
||||
|
||||
## Fonctionnalités
|
||||
|
||||
- Génération d'un rapport de configuration pour le serveur hôte.
|
||||
- Collecte automatique des bases de données Oracle en cours d'exécution.
|
||||
- Génération d'un rapport HTML structuré et détaillé pour chaque base de données.
|
||||
- Support pour les instances ASM et les PDBs (Pluggable Databases).
|
||||
- Scripts modulaires pour une personnalisation facile.
|
||||
|
||||
## Prérequis
|
||||
|
||||
- Système Linux/Unix avec Bash.
|
||||
- Oracle Database installé et configuré (avec `sqlplus` et `oraenv`).
|
||||
- Permissions pour exécuter des requêtes SQL en tant que `sysdba`.
|
||||
|
||||
## Installation
|
||||
|
||||
## Sous Linux
|
||||
```bash
|
||||
git clone https://github.com/Yacine31/db_report
|
||||
cd db_report
|
||||
sh -x rapport_bdd.sh
|
||||
# Copier le fichier d'exemple de configuration (optionnel)
|
||||
cp .env.local .env
|
||||
# Éditer .env si nécessaire (e.g., pour personnaliser OUTPUT_DIR)
|
||||
```
|
||||
|
||||
il est possible de générer plusieurs CSV avec la commande :
|
||||
## Utilisation
|
||||
|
||||
```bash
|
||||
sh rapport_bdd_csv.sh
|
||||
# Exécuter le script principal
|
||||
bash rapport_bdd.sh
|
||||
```
|
||||
Un ensemble de fichiers CSV est généré sous format zip
|
||||
|
||||
## Sortie
|
||||
|
||||
## Sous Windows
|
||||
Télécharger le zip ici : [https://github.com/Yacine31/db_report/archive/refs/heads/main.zip](https://github.com/Yacine31/db_report/archive/refs/heads/main.zip)
|
||||
Le script génère deux types de rapports dans le répertoire `output/YYYYMMDD/`:
|
||||
|
||||
- Décompresser dans c:\db_report
|
||||
- Exécuter le script rapport_bdd.cmd
|
||||
1. **Rapport Serveur** : Un rapport unique contenant les informations de configuration du système d'exploitation.
|
||||
- Nom du fichier : `Rapport_{hostname}_{timestamp}.html`
|
||||
|
||||
2. **Rapports Base de Données** : Un rapport détaillé pour chaque instance de base de données Oracle détectée.
|
||||
- Nom du fichier : `Rapport_{hostname}_{SID}_{timestamp}.html`
|
||||
|
||||
Un script de synthèse (`summary.sh`) est également exécuté pour agréger certaines données des différentes bases.
|
||||
|
||||
## Structure du projet
|
||||
|
||||
- `rapport_bdd.sh` : Script principal qui orchestre la génération du rapport serveur et des rapports de base de données.
|
||||
- `sh/` : Scripts Bash pour la collecte des informations système (utilisés pour le rapport serveur).
|
||||
- `sql/` : Requêtes SQL pour les données de base de données.
|
||||
- `html/` : Templates HTML pour l'en-tête et le pied de page des rapports.
|
||||
- `asm/` : Scripts SQL spécifiques aux instances ASM.
|
||||
- `summary/` : Scripts SQL utilisés par le script de synthèse.
|
||||
- `summary.sh` : Script d'agrégation des rapports.
|
||||
|
||||
## Personnalisation
|
||||
|
||||
- Modifiez `.env` pour changer le répertoire de sortie.
|
||||
- Ajoutez des scripts dans `sh/` ou `sql/` pour étendre les rapports.
|
||||
|
||||
Ou avec GIT :
|
||||
Installer git [https://git-scm.com/download/win](https://git-scm.com/download/win)
|
||||
```cmd
|
||||
cd /d c:\
|
||||
git clone https://github.com/Yacine31/db_report
|
||||
cd db_report
|
||||
rapport_bdd.cmd
|
||||
```
|
||||
|
||||
@@ -1,53 +1,50 @@
|
||||
PRO <h2>Configuratiom ASM</h2>
|
||||
|
||||
SELECT
|
||||
dg.name,
|
||||
dg.state,
|
||||
dg.type,
|
||||
dg.total_mb,
|
||||
dg.free_mb,
|
||||
dg.usable_file_mb,
|
||||
compatibility,
|
||||
dg.database_compatibility
|
||||
SELECT /* db-html-report */
|
||||
DG.NAME,
|
||||
DG.STATE,
|
||||
DG.TYPE,
|
||||
DG.TOTAL_MB,
|
||||
DG.FREE_MB,
|
||||
DG.USABLE_FILE_MB,
|
||||
COMPATIBILITY,
|
||||
DG.DATABASE_COMPATIBILITY
|
||||
FROM
|
||||
v$asm_diskgroup dg;
|
||||
|
||||
V$ASM_DISKGROUP DG;
|
||||
-- Viewing disks in disk groups with V$ASM_DISK
|
||||
|
||||
SELECT
|
||||
dg.name "Disk Grp Name",
|
||||
a.name "Name",
|
||||
a.failgroup,
|
||||
a.path,
|
||||
a.os_mb,
|
||||
a.total_mb,
|
||||
a.free_mb,
|
||||
a.cold_used_mb,
|
||||
a.header_status,
|
||||
a.mode_status,
|
||||
a.state,
|
||||
a.redundancy,
|
||||
to_char(a.create_date, 'DD/MM/YYYY HH24:MI') "Create Date"
|
||||
SELECT /* db-html-report */
|
||||
DG.NAME "Disk Grp Name",
|
||||
A.NAME "Name",
|
||||
A.FAILGROUP,
|
||||
A.PATH,
|
||||
A.OS_MB,
|
||||
A.TOTAL_MB,
|
||||
A.FREE_MB,
|
||||
A.COLD_USED_MB,
|
||||
A.HEADER_STATUS,
|
||||
A.MODE_STATUS,
|
||||
A.STATE,
|
||||
A.REDUNDANCY,
|
||||
TO_CHAR(A.CREATE_DATE, 'DD/MM/YYYY HH24:MI') "Create Date"
|
||||
FROM
|
||||
v$asm_disk a,
|
||||
v$asm_diskgroup dg
|
||||
V$ASM_DISK A,
|
||||
V$ASM_DISKGROUP DG
|
||||
WHERE
|
||||
a.group_number = dg.group_number
|
||||
A.GROUP_NUMBER = DG.GROUP_NUMBER
|
||||
ORDER BY
|
||||
dg.name,
|
||||
a.name
|
||||
;
|
||||
DG.NAME,
|
||||
A.NAME;
|
||||
|
||||
-- Viewing disk group clients with V$ASM_CLIENT
|
||||
|
||||
SELECT
|
||||
dg.name AS diskgroup,
|
||||
c.instance_name AS instance,
|
||||
db_name AS dbname,
|
||||
software_version AS software,
|
||||
compatible_version AS compatible
|
||||
SELECT /* db-html-report */
|
||||
DG.NAME AS DISKGROUP,
|
||||
C.INSTANCE_NAME AS INSTANCE,
|
||||
DB_NAME AS DBNAME,
|
||||
SOFTWARE_VERSION AS SOFTWARE,
|
||||
COMPATIBLE_VERSION AS COMPATIBLE
|
||||
FROM
|
||||
v$asm_diskgroup dg,
|
||||
v$asm_client c
|
||||
V$ASM_DISKGROUP DG,
|
||||
V$ASM_CLIENT C
|
||||
WHERE
|
||||
dg.group_number = c.group_number;
|
||||
DG.GROUP_NUMBER = C.GROUP_NUMBER;
|
||||
@@ -1,10 +1,13 @@
|
||||
prompt <h2>Les dernières erreurs ASM (Les 30 derniers jours et les 50 dernières lignes)</h2>
|
||||
|
||||
-- set pages 99
|
||||
select to_char(ORIGINATING_TIMESTAMP, 'DD-MM-YYYY HH-MM-SS') "Date", message_text "Message"
|
||||
FROM X$DBGALERTEXT
|
||||
WHERE originating_timestamp > systimestamp - 30
|
||||
AND regexp_like(message_text, '(ORA-)')
|
||||
AND rownum <=50
|
||||
order by originating_timestamp desc;
|
||||
|
||||
SELECT /* db-html-report */
|
||||
TO_CHAR(ORIGINATING_TIMESTAMP, 'DD-MM-YYYY HH-MM-SS') "Date",
|
||||
MESSAGE_TEXT "Message"
|
||||
FROM
|
||||
X$DBGALERTEXT
|
||||
WHERE
|
||||
ORIGINATING_TIMESTAMP > SYSTIMESTAMP - 30
|
||||
AND REGEXP_LIKE(MESSAGE_TEXT, '(ORA-)')
|
||||
AND ROWNUM <=50
|
||||
ORDER BY
|
||||
ORIGINATING_TIMESTAMP DESC;
|
||||
@@ -1 +0,0 @@
|
||||
SET PAGES 999 FEEDBACK OFF MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP OFF
|
||||
@@ -1,11 +0,0 @@
|
||||
# Info systeme
|
||||
Get-WmiObject Win32_ComputerSystem | Select-Object Manufacturer, Model, TotalPhysicalMemory
|
||||
|
||||
# Lister les espaces disques
|
||||
Get-Volume | Format-Table -AutoSize
|
||||
|
||||
# lister les bases en cours d'exécution
|
||||
net start | find /i "OracleService"
|
||||
|
||||
# lister les listener en cours d'exécution
|
||||
net start | find /i "TNSListener"
|
||||
55
html/00_html_header.html
Normal file
55
html/00_html_header.html
Normal file
@@ -0,0 +1,55 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
||||
<!-- $Header: DB Report -->
|
||||
<!-- Author: yacine.oumghar@axiome.io -->
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<title>Rapport de Base Oracle</title>
|
||||
|
||||
|
||||
<style type="text/css">
|
||||
body { font:12pt; font-family: 'Inter', 'Roboto', 'Helvetica Neue', Arial, sans-serif; background-color: #f9f9f9; padding: 20px; color: #333; }
|
||||
h1 { font-size:16pt; font-weight:bold; color:#336699; border-bottom:1px solid #336699; margin-top:0pt; margin-bottom:0pt; padding:0px 0px 0px 0px; }
|
||||
h2 { font-size:14pt; font-weight:bold; color:#336699; margin-top:10pt; margin-bottom:0pt; }
|
||||
h3 { font-size:14pt; font-weight:normal; color:#336699; margin-top:4pt; margin-bottom:0pt; }
|
||||
p { line-height: 1.0; margin-bottom: 1.2em; }
|
||||
pre { display: inline-block; background-color: #f8f8f8; border: 1px solid #ccc; padding: 1em; overflow-x: auto; font-family: 'Fira Code', 'Cascadia Code', 'JetBrains Mono', 'Roboto Mono', 'Source Code Pro', monospace; font-size: 0.9em; line-height: 1.2; color: #333; white-space: pre-wrap; word-break: break-all; }
|
||||
a {color:#663300; }
|
||||
table { font-size:10pt; border-collapse: collapse; margin: 10px 0; background-color: #fff; empty-cells:show; white-space:nowrap; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
|
||||
li { font-size:10pt; color:black; padding-left:4px; padding-right:4px; padding-bottom:2px; }
|
||||
tr { color:black; background:white; }
|
||||
tr:hover { color:white; background:#0066CC; }
|
||||
tr.main { color:black; background:white; }
|
||||
tr.main:hover { color:black; background:white; }
|
||||
tr.selected { background-color: #d1eaff !important; }
|
||||
td { padding: 1px 5px; border: 1px solid #ddd; }
|
||||
th { background-color: #0066CC; color: white; font-weight:normal; cursor: pointer; }
|
||||
th:hover { background-color: #0066AA; }
|
||||
th.asc::after { content: " 🔼"; }
|
||||
th.desc::after { content: " 🔽"; }
|
||||
td.c { text-align:center; }
|
||||
font.n { font-size:10pt; font-style:italic; color:#336699; }
|
||||
font.f { font-size:10pt; color:#999999; border-top:1px solid #336699; margin-top:30pt; }
|
||||
.highlight { background: red; }
|
||||
.pct_warning { background: yellowgreen; }
|
||||
.pct_error { background: red; }
|
||||
/* Style pour les couleurs conditionnelles */
|
||||
.orange { background-color: #ff9800; }
|
||||
.red { background-color: #f44336; }
|
||||
/* Alignement des cellules numériques à droite */
|
||||
.numeric { text-align: right; }
|
||||
.error-block {
|
||||
background-color: #ffe0e0; /* Light red background */
|
||||
color: #cc0000; /* Dark red text */
|
||||
border: 1px solid #cc0000; /* Red border */
|
||||
padding: 0.8em;
|
||||
margin: 0.5em 0;
|
||||
font-weight: bold;
|
||||
white-space: pre-wrap; /* Preserve whitespace and wrap long lines */
|
||||
word-break: break-all;
|
||||
}
|
||||
a[href="#top"] { position: fixed; bottom: 20px; right: 20px; background: #336699; color: white; padding: 10px; text-decoration: none; border-radius: 5px; }
|
||||
</style>
|
||||
|
||||
144
html/99_html_footer.html
Normal file
144
html/99_html_footer.html
Normal file
@@ -0,0 +1,144 @@
|
||||
|
||||
<br />
|
||||
</body>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const getCellValue = (tr, idx) => tr.children[idx].innerText || tr.children[idx].textContent;
|
||||
|
||||
const comparer = (idx, asc) => (a, b) => {
|
||||
const v1 = getCellValue(asc ? a : b, idx).replace(',', '.');
|
||||
const v2 = getCellValue(asc ? b : a, idx).replace(',', '.');
|
||||
return !isNaN(v1) && !isNaN(v2) ? parseFloat(v1) - parseFloat(v2) : v1.localeCompare(v2);
|
||||
};
|
||||
|
||||
// 🎯 Configuration des règles de colorisation
|
||||
const rules = [
|
||||
{
|
||||
keywords: ["percent_used", "% used", "utilisation", "%"],
|
||||
thresholds: [
|
||||
{ min: 90, color: "#fecaca", text: "#991b1b" }, // rouge
|
||||
{ min: 80, color: "#fef08a", text: "#92400e" }, // jaune
|
||||
{ min: 0, color: "#bbf7d0", text: "#065f46" } // vert
|
||||
]
|
||||
},
|
||||
{
|
||||
keywords: ["status"], // 👈 règle pour la colonne STATUS
|
||||
matchText: "FAILED", // mot-clé à détecter
|
||||
style: { // style à appliquer si trouvé
|
||||
color: "#fff",
|
||||
backgroundColor: "#dc2626", // rouge foncé
|
||||
fontWeight: "bold"
|
||||
}
|
||||
},
|
||||
{
|
||||
keywords: ["status"], // 👈 règle pour la colonne STATUS
|
||||
matchText: "COMPLETED", // mot-clé à détecter
|
||||
style: { // style à appliquer si trouvé
|
||||
backgroundColor: "#bbf7d0", // vert
|
||||
fontWeight: "bold"
|
||||
}
|
||||
},
|
||||
{
|
||||
keywords: ["account_status"], // 👈 règle pour la colonne STATUS
|
||||
matchText: "OPEN", // mot-clé à détecter
|
||||
style: { // style à appliquer si trouvé
|
||||
backgroundColor: "#bbf7d0", // vert
|
||||
fontWeight: "bold"
|
||||
}
|
||||
}
|
||||
// Tu peux ajouter d’autres règles ici si besoin
|
||||
];
|
||||
|
||||
// 🎨 Appliquer les règles de coloration dynamiquement
|
||||
const colorizeDynamicColumns = () => {
|
||||
document.querySelectorAll("table").forEach(table => {
|
||||
const rows = table.querySelectorAll("tr");
|
||||
if (rows.length === 0) return;
|
||||
|
||||
const headerRow = rows[0];
|
||||
const ths = headerRow.querySelectorAll("th");
|
||||
|
||||
rules.forEach(rule => {
|
||||
let targetIndex = -1;
|
||||
ths.forEach((th, index) => {
|
||||
const text = th.textContent.trim().toLowerCase();
|
||||
const match = rule.keywords.some(keyword => text.includes(keyword));
|
||||
if (match && targetIndex === -1) {
|
||||
targetIndex = index;
|
||||
}
|
||||
});
|
||||
|
||||
if (targetIndex !== -1) {
|
||||
rows.forEach((row, i) => {
|
||||
if (i === 0) return; // skip header
|
||||
|
||||
const cell = row.children[targetIndex];
|
||||
if (!cell) return;
|
||||
|
||||
const rawText = cell.textContent.trim();
|
||||
const numeric = parseFloat(rawText.replace('%', '').replace(',', '.'));
|
||||
|
||||
if (rule.matchText) {
|
||||
if (rawText.toUpperCase().includes(rule.matchText.toUpperCase())) {
|
||||
Object.entries(rule.style).forEach(([prop, val]) => {
|
||||
cell.style[prop] = val;
|
||||
});
|
||||
}
|
||||
} else if (!isNaN(numeric)) {
|
||||
for (const threshold of rule.thresholds) {
|
||||
if (numeric >= threshold.min) {
|
||||
cell.style.backgroundColor = threshold.color;
|
||||
cell.style.color = threshold.text;
|
||||
cell.style.fontWeight = 'bold';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// alignement à droite si numérique
|
||||
if (!isNaN(numeric)) {
|
||||
cell.classList.add("numeric");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// ➕ Appliquer alignement numérique à toutes les cellules numériques
|
||||
const alignNumericCells = () => {
|
||||
document.querySelectorAll('table tr:nth-child(n+2)').forEach(row => {
|
||||
Array.from(row.children).forEach(cell => {
|
||||
const value = parseFloat(cell.textContent.replace(',', '.'));
|
||||
if (!isNaN(value)) {
|
||||
cell.classList.add('numeric');
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// 🔁 Tri au clic sur les entêtes
|
||||
document.querySelectorAll('table th').forEach(th => {
|
||||
th.addEventListener('click', () => {
|
||||
const table = th.closest('table');
|
||||
const tbody = table.querySelector('tbody') || table;
|
||||
const rows = Array.from(tbody.querySelectorAll('tr:nth-child(n+2)'));
|
||||
const index = Array.from(th.parentNode.children).indexOf(th);
|
||||
const asc = !th.classList.contains('asc');
|
||||
table.querySelectorAll('th').forEach(th => th.classList.remove('asc', 'desc'));
|
||||
th.classList.toggle('asc', asc);
|
||||
th.classList.toggle('desc', !asc);
|
||||
rows.sort(comparer(index, asc)).forEach(row => tbody.appendChild(row));
|
||||
|
||||
// Recoloriser après le tri (au cas où les lignes changent de position)
|
||||
colorizeDynamicColumns();
|
||||
});
|
||||
});
|
||||
|
||||
// 🚀 Initialisation
|
||||
colorizeDynamicColumns();
|
||||
alignNumericCells();
|
||||
});
|
||||
</script>
|
||||
</html>
|
||||
@@ -1,32 +0,0 @@
|
||||
@echo off
|
||||
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
for /f "tokens=*" %%r in ('net start ^| find /i "OracleService"') do (
|
||||
set "ORACLE_SID=%%r"
|
||||
set "ORACLE_SID=!ORACLE_SID:~13!"
|
||||
set HTML_FILE=Rapport_%COMPUTERNAME%_!ORACLE_SID!_%DATE:~6,4%%DATE:~3,2%%DATE:~0,2%.html
|
||||
set TMP_SQLFILE="tmp_sqlfile.sql"
|
||||
set DATE_JOUR=%DATE:~6,4%%DATE:~3,2%%DATE:~0,2%
|
||||
|
||||
type sql\00_html_header.html > !HTML_FILE!
|
||||
echo ^<h1^>Rapport de base de donnees^</h1^> >> !HTML_FILE!
|
||||
echo ^<h2^>Date : !DATE_JOUR!^</h2^> >> !HTML_FILE!
|
||||
echo ^<h2^>Hostname : %COMPUTERNAME%^</h2^> >> !HTML_FILE!
|
||||
echo ^<h2^>Base de donnees : !ORACLE_SID!^</h2^> >> !HTML_FILE!
|
||||
echo ^<br^><br^> >> !HTML_FILE!
|
||||
|
||||
echo ^<h1^>Configuration de la base de donnees !ORACLE_SID! ^</h1^> >> !HTML_FILE!
|
||||
for %%f in (sql\*.sql) do (
|
||||
echo SET PAGES 999 FEEDBACK OFF MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP OFF > !TMP_SQLFILE!
|
||||
echo WHENEVER SQLERROR CONTINUE >> !TMP_SQLFILE!
|
||||
type %%f >> !TMP_SQLFILE!
|
||||
echo. >> !TMP_SQLFILE!
|
||||
echo EXIT >> !TMP_SQLFILE!
|
||||
echo Execution du script %%f
|
||||
call sqlplus -S / as sysdba @!TMP_SQLFILE! >> !HTML_FILE!
|
||||
)
|
||||
|
||||
type sql\99_html_footer.html >> !HTML_FILE!
|
||||
echo Rapport de la base !ORACLE_SID! dans le fichier html : !HTML_FILE!
|
||||
)
|
||||
223
rapport_bdd.sh
223
rapport_bdd.sh
@@ -1,65 +1,180 @@
|
||||
#!/bin/bash
|
||||
# Script de génération de rapports HTML pour les bases de données Oracle.
|
||||
# Collecte des informations système, ASM, PDBs et configurations via scripts Bash/SQL.
|
||||
|
||||
# Stoppe le script en cas d'erreur (erreurs, variables non définies, pipes échoués)
|
||||
set -euo pipefail
|
||||
|
||||
source sh/utils.sh
|
||||
|
||||
# --- Configuration initiale ---
|
||||
# Définit les variables globales et charge la configuration utilisateur.
|
||||
# Définit la langue pour les commandes (évite les problèmes de locale)
|
||||
export LANG=en_US
|
||||
DATETIME=`date +%Y%m%d%H%M`
|
||||
HNAME=$(hostname)
|
||||
OUTPUT_DIR=output/$(date +%Y%m%d)
|
||||
mkdir -p ${OUTPUT_DIR}
|
||||
# Génère un timestamp pour nommer les fichiers
|
||||
timestamp="$(date +%Y%m%d%H%M)"
|
||||
# Récupère le nom d'hôte du serveur
|
||||
hostname="$(hostname)"
|
||||
|
||||
for r in $(ps -eaf | grep pmon | egrep -v 'grep|ASM|APX1' | cut -d '_' -f3)
|
||||
do
|
||||
export ORAENV_ASK=NO
|
||||
export ORACLE_SID=$r
|
||||
export HTML_FILE=${OUTPUT_DIR}/Rapport_${HNAME}_${ORACLE_SID}_${DATETIME}.html
|
||||
. oraenv -s > /dev/null
|
||||
# Charge la configuration depuis .env si le fichier existe
|
||||
if [ -f .env ]; then
|
||||
# shellcheck source=.env
|
||||
source .env
|
||||
fi
|
||||
|
||||
cat sql/00_html_header.html >> ${HTML_FILE}
|
||||
DATE_JOUR=$(date +"%d/%m/%Y %Hh%M")
|
||||
echo "<h1>Rapport de base de données ${ORACLE_SID} sur le serveur $HNAME </h1>
|
||||
<h2>Date : ${DATE_JOUR}</h2>
|
||||
<h2>Hostname : $HNAME</h2>
|
||||
<h2>Base de données : ${ORACLE_SID}</h2>" >> ${HTML_FILE}
|
||||
echo "<br><br>" >> ${HTML_FILE}
|
||||
|
||||
# execution des scripts shell
|
||||
echo "<h1>Configuration système</h1>" >> ${HTML_FILE}
|
||||
for f in sh/*.sh
|
||||
do
|
||||
/bin/sh $f >> ${HTML_FILE}
|
||||
done
|
||||
# Définit le répertoire de sortie (peut être surchargé par la variable OUTPUT_DIR dans .env)
|
||||
output_dir_base="${OUTPUT_DIR:-"output"}"
|
||||
output_dir="${output_dir_base}/$(date +%Y%m%d)"
|
||||
|
||||
echo "<br><br>" >> ${HTML_FILE}
|
||||
# --- Définitions des fonctions ---
|
||||
# Contient les fonctions utilitaires pour logging et exécution de scripts.
|
||||
|
||||
# Si ASM, on exécute les scripts ASM
|
||||
if [ $(ps -ef | grep pmon | grep ASM | wc -l) -gt 0 ]; then
|
||||
echo "<h1>Configuration de l'instance ASM</h1>" >> ${HTML_FILE}
|
||||
for f in asm/*.sql
|
||||
do
|
||||
# sed '1 s/^/SET PAGES 999 FEEDBACK OFF MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP OFF\n/' $f | sqlplus -s / as sysdba >> ${HTML_FILE}
|
||||
cat asm/sql_header.txt $f | sqlplus -s / as sysdba >> ${HTML_FILE}
|
||||
done
|
||||
fi
|
||||
# Fonction: execute_scripts
|
||||
# Description: Exécute une série de scripts (Bash ou SQL) et ajoute leur sortie au rapport HTML.
|
||||
# Vérifie d'abord si des scripts correspondent au pattern.
|
||||
# Paramètres:
|
||||
# $1 (section_title) - Titre de la section dans le rapport HTML.
|
||||
# $2 (script_pattern) - Chemin vers les scripts (e.g., "sh/*.sh").
|
||||
# $3 (script_type) - Type de script : "sh" pour Bash, "sql" pour SQL.
|
||||
# $4 (sql_header_file) - Fichier d'en-tête SQL (optionnel, utilisé seulement pour "sql").
|
||||
# Exemple : execute_scripts "Configuration système" "sh/*.sh" "sh"
|
||||
execute_scripts() {
|
||||
local section_title="$1"
|
||||
local script_pattern="$2"
|
||||
local script_type="$3"
|
||||
local sql_header_file="${4:-}"
|
||||
|
||||
# execution des scripts sql
|
||||
echo "<h1>Configuration de la base de données ${ORACLE_SID}</h1>" >> ${HTML_FILE}
|
||||
for f in sql/*.sql
|
||||
do
|
||||
# sed '1 s/^/SET PAGES 999 FEEDBACK OFF MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP OFF\n/' $f | sqlplus -s / as sysdba >> ${HTML_FILE}
|
||||
cat sql/sql_header.txt $f | sqlplus -s / as sysdba >> ${HTML_FILE}
|
||||
done
|
||||
# Vérifie s'il y a des fichiers correspondants au pattern pour éviter les erreurs
|
||||
# Utilise ls au lieu de find pour compatibilité, avec shellcheck désactivé pour SC2012
|
||||
# shellcheck disable=SC2012
|
||||
# if [ -z "$(ls -1 "${script_pattern}" 2>/dev/null)" ]; then
|
||||
# log_info "Aucun script trouvé pour le pattern '${script_pattern}', section ignorée."
|
||||
# return
|
||||
# fi
|
||||
|
||||
sed -i 's/<table.*>$/<table class="table table-striped">/g' ${HTML_FILE}
|
||||
echo "<h1>"${section_title}"</h1>" >> "${html_report_file}"
|
||||
# Boucle sur chaque script correspondant au pattern
|
||||
for script_file in ${script_pattern}; do
|
||||
log_info "Exécution du script : ${script_file}"
|
||||
case "${script_type}" in
|
||||
sh)
|
||||
# Exécute le script Bash et ajoute sa sortie au rapport
|
||||
bash "${script_file}" >> "${html_report_file}"
|
||||
;;
|
||||
sql)
|
||||
# Concatène l'en-tête SQL avec le script et l'exécute via sqlplus
|
||||
cat "${sql_header_file}" "${script_file}" | sqlplus -s / as sysdba >> "${html_report_file}"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
echo "<br><br>" >> "${html_report_file}"
|
||||
echo "<p><a href=\"#top\">Retour en haut de page</a></p>" >> "${html_report_file}"
|
||||
} # execute_scripts
|
||||
|
||||
cat sql/99_html_footer.html >> ${HTML_FILE}
|
||||
|
||||
# coloriage des mots clé en rouge ou en vert
|
||||
for txt in INVALID FAILED NOARCHIVELOG OFFLINE MOUNTED
|
||||
do
|
||||
sed -i "s#<td>${txt}</td>#<td style='color: red; background-color: yellow;'>${txt}</td>#g" ${HTML_FILE}
|
||||
done
|
||||
# --- Script principal ---
|
||||
# Orchestre la génération des rapports pour chaque base de données détectée.
|
||||
|
||||
for txt in COMPLETED
|
||||
do
|
||||
sed -i "s#<td>${txt}</td>#<td style='color: white; background-color: green;'>${txt}</td>#g" ${HTML_FILE}
|
||||
done
|
||||
# Crée le répertoire de sortie si nécessaire
|
||||
mkdir -p "${output_dir}"
|
||||
|
||||
echo Rapport dans le fichier html : ${HTML_FILE}
|
||||
done
|
||||
#--------------- LES SERVEURS
|
||||
log_info "Début de la génération des rapports pour le serveur : "${hostname}""
|
||||
|
||||
# Définit le nom du fichier HTML du rapport
|
||||
html_report_file="${output_dir}/Rapport_"${hostname}"_"${timestamp}".html"
|
||||
|
||||
# Copie l'en-tête HTML et ajoute l'ancre pour le lien "retour en haut"
|
||||
cat html/00_html_header.html > "${html_report_file}"
|
||||
echo '<div id="top"></div>' >> "${html_report_file}"
|
||||
|
||||
# Génère la date formatée pour l'affichage dans le rapport
|
||||
current_date="$(date +"%d/%m/%Y %Hh%M")"
|
||||
{
|
||||
echo "<h1>Rapport de configuration du serveur "${hostname}"</h1>"
|
||||
echo "<h2>Date : "${current_date}"</h2>"
|
||||
echo "<h2>Hostname : "${hostname}"</h2>"
|
||||
echo "<br><br>"
|
||||
} >> "${html_report_file}"
|
||||
|
||||
# Exécute les scripts de collecte d'informations via la fonction execute_scripts
|
||||
execute_scripts "Configuration système" "sh/*.sh" "sh"
|
||||
|
||||
# Ajoute le pied de page HTML au rapport
|
||||
cat html/99_html_footer.html >> "${html_report_file}"
|
||||
log_info "Rapport généré : "${html_report_file}""
|
||||
#---------------
|
||||
|
||||
#--------------- LES BASES
|
||||
# Détecte les bases de données Oracle en cours d'exécution
|
||||
# Exclut les instances ASM et APX pour se concentrer sur les bases utilisateur
|
||||
database_sids="$(ps -eaf | grep pmon | egrep -v 'grep|ASM|APX1' | cut -d '_' -f3 || true)"
|
||||
|
||||
if [ -z "${database_sids}" ]; then
|
||||
echo "[WARN] Aucune base de données Oracle détectée. Fin du script."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
log_info "Début de la génération des rapports pour les bases : "${database_sids}""
|
||||
|
||||
for database_sid in ${database_sids}; do
|
||||
# Désactive les prompts d'oraenv et définit la base courante
|
||||
export ORAENV_ASK=NO
|
||||
export ORACLE_SID="${database_sid}"
|
||||
|
||||
log_info "Traitement de la base de données : "${ORACLE_SID}""
|
||||
# Configure l'environnement Oracle pour la base actuelle
|
||||
# shellcheck source=/dev/null
|
||||
. oraenv -s > /dev/null
|
||||
|
||||
# Définit le nom du fichier HTML du rapport
|
||||
html_report_file="${output_dir}/Rapport_"${hostname}"_"${ORACLE_SID}"_"${timestamp}".html"
|
||||
|
||||
# --- Génération du rapport HTML pour cette base ---
|
||||
# Initialise le fichier HTML avec l'en-tête et les infos générales.
|
||||
|
||||
# Copie l'en-tête HTML et ajoute l'ancre pour le lien "retour en haut"
|
||||
cat html/00_html_header.html > "${html_report_file}"
|
||||
echo '<div id="top"></div>' >> "${html_report_file}"
|
||||
|
||||
# Génère la date formatée pour l'affichage dans le rapport
|
||||
current_date="$(date +"%d/%m/%Y %Hh%M")"
|
||||
{
|
||||
echo "<h1>Rapport de base de données "${ORACLE_SID}" sur le serveur "${hostname}"</h1>"
|
||||
echo "<h2>Date : "${current_date}"</h2>"
|
||||
echo "<h2>Hostname : "${hostname}"</h2>"
|
||||
echo "<h2>Base de données : "${ORACLE_SID}"</h2>"
|
||||
echo "<br><br>"
|
||||
} >> "${html_report_file}"
|
||||
|
||||
# # Exécute les scripts de collecte d'informations via la fonction execute_scripts
|
||||
# execute_scripts "Configuration système" "sh/*.sh" "sh"
|
||||
|
||||
# Si une instance ASM est détectée, exécute les scripts ASM
|
||||
if [ "$(ps -ef | grep pmon | grep ASM | wc -l)" -gt 0 ]; then
|
||||
execute_scripts "Configuration de l'instance ASM" "asm/*.sql" "sql" "sql/sql_header.txt"
|
||||
fi
|
||||
|
||||
# Si la base est un CDB (Container Database), exécute les scripts pour les PDBs
|
||||
if [ "$(/bin/sh sql/cdb/is_CDB.sh | tail -1)" = "YES" ]; then
|
||||
execute_scripts "Informations sur les PDBs" "sql/cdb/*.sql" "sql" "sql/sql_header.txt"
|
||||
fi
|
||||
|
||||
execute_scripts "Configuration de la base de données "${ORACLE_SID}"" "sql/*.sql" "sql" "sql/sql_header.txt"
|
||||
|
||||
# Ajoute le pied de page HTML au rapport
|
||||
cat html/99_html_footer.html >> "${html_report_file}"
|
||||
|
||||
log_info "Rapport généré : "${html_report_file}""
|
||||
done
|
||||
#---------------
|
||||
|
||||
# Une fois tous les rapports générés, exécute le script de synthèse pour agréger les données
|
||||
log_info "Exécution du script de synthèse."
|
||||
export OUTPUT_DIR="${output_dir}"
|
||||
export DATETIME="${timestamp}"
|
||||
export HNAME="${hostname}"
|
||||
bash summary.sh
|
||||
|
||||
log_info "Fin du script."
|
||||
@@ -1,59 +0,0 @@
|
||||
DATETIME=$(date +%Y%m%d_%H%M)
|
||||
HNAME=$(hostname)
|
||||
DATE_REP=$(date +%Y_%m_%d)
|
||||
|
||||
ID_CLIENT=$1
|
||||
|
||||
if [ "x${ID_CLIENT}" == "x" ]
|
||||
then
|
||||
echo "$0 ID_CLIENT"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for r in $(ps -eaf | grep pmon | egrep -v 'grep|ASM|APX1' | cut -d '_' -f3)
|
||||
do
|
||||
export ORAENV_ASK=NO
|
||||
export ORACLE_SID=$r
|
||||
|
||||
# OUTPUT_DIR=output/${HNAME}/${ORACLE_SID}/${DATE_REP}
|
||||
OUTPUT_DIR=${ID_CLIENT}/${HNAME}/${ORACLE_SID}/${DATE_REP}
|
||||
mkdir -p ${OUTPUT_DIR}
|
||||
|
||||
# export CSV_FILE=${OUTPUT_DIR}/Rapport_${HNAME}_${ORACLE_SID}_${DATETIME}.csv
|
||||
. oraenv -s > /dev/null
|
||||
|
||||
DATE_JOUR=$(date +"%d/%m/%Y %Hh%M")
|
||||
|
||||
# execution des scripts shell
|
||||
for f in sh/*.sh
|
||||
do
|
||||
CSV_FILE=${OUTPUT_DIR}/$(basename $f | sed 's/.sh$/.csv/g')
|
||||
/bin/sh $f > ${CSV_FILE}
|
||||
done
|
||||
|
||||
# Si ASM, on exécute les scripts ASM
|
||||
if [ $(ps -ef | grep pmon | grep ASM | wc -l) -gt 0 ]; then
|
||||
for f in asm/*.sql
|
||||
do
|
||||
CSV_FILE=${OUTPUT_DIR}/$(basename $f | sed 's/.sql$/.csv/g')
|
||||
sed '1 s/^/SET PAGES 999 FEEDBACK OFF MARKUP CSV ON SPOOL ON PREFORMAT OFF ENTMAP OFF\n/' $f | grep -v "^prompt" | sqlplus -s / as sysdba > ${CSV_FILE}
|
||||
done
|
||||
fi
|
||||
|
||||
# execution des scripts sql
|
||||
echo "<h1>Configuration de la base de données ${ORACLE_SID}</h1>" >> ${CSV_FILE}
|
||||
for f in sql/*.sql
|
||||
do
|
||||
CSV_FILE=${OUTPUT_DIR}/$(basename $f | sed 's/.sql$/.csv/g')
|
||||
sed '1 s/^/SET PAGES 999 FEEDBACK OFF MARKUP CSV ON SPOOL ON PREFORMAT OFF ENTMAP OFF\n/' $f | grep -v "^prompt" | sqlplus -s / as sysdba > ${CSV_FILE}
|
||||
done
|
||||
|
||||
# suppression du zip s'il existe déjà
|
||||
rm -f ${ID_CLIENT}_${HNAME}_${ORACLE_SID}_${DATE_REP}.zip 2>/dev/null
|
||||
# compression pour récupérer la totalité en zip
|
||||
zip -r ${ID_CLIENT}_${HNAME}_${ORACLE_SID}_${DATE_REP}.zip ${OUTPUT_DIR} 1>/dev/null
|
||||
|
||||
echo Les fichiers CSV sont dans le répertoire : ${OUTPUT_DIR}
|
||||
echo Pour récupérer les fichiers dans un seul zip : ${ID_CLIENT}_${HNAME}_${ORACLE_SID}_${DATE_REP}.zip
|
||||
done
|
||||
|
||||
133
sh/09_os_info.sh
133
sh/09_os_info.sh
@@ -1,118 +1,81 @@
|
||||
# faire des commandes pour AIX et pour Linux
|
||||
#!/bin/bash
|
||||
|
||||
# Importe les fonctions utilitaires
|
||||
source "$(dirname "$0")/utils.sh"
|
||||
|
||||
# --- Script principal ---
|
||||
|
||||
os_type=$(uname -s)
|
||||
|
||||
echo "<h2>Bases de données en cours d'exécution :</h2>"
|
||||
echo "<pre>"
|
||||
ps -ef | grep pmon | grep -v grep
|
||||
echo "</pre>"
|
||||
|
||||
echo "<h2>Listeners en cours d'exécution :</h2>"
|
||||
echo "<pre>"
|
||||
ps -ef | grep tnslsnr| grep -v grep
|
||||
echo "</pre>"
|
||||
|
||||
echo "<h2>Statut des listeners :</h2>"
|
||||
ps -ef | grep tnslsnr| grep -v grep | while read l
|
||||
do
|
||||
# Récupérer le chemin du binaire tnslsnr à partir de la sortie de ps
|
||||
binary_path=$(echo $l | awk '{print $8}' | sed 's#/bin/tnslsnr##')
|
||||
# Extraire le nom du listener
|
||||
listener_name=$(echo $l | awk '{print $9}')
|
||||
# Construire la commande lsnrctl status
|
||||
lsnrctl_command="$binary_path/bin/lsnrctl status $listener_name"
|
||||
# exécuter la commande
|
||||
echo "<br><pre>"
|
||||
echo $lsnrctl_command
|
||||
echo export TNS_ADMIN=$binary_path/network/admin
|
||||
export TNS_ADMIN=$binary_path/network/admin
|
||||
eval "$lsnrctl_command"
|
||||
echo "</pre><br>"
|
||||
done
|
||||
|
||||
echo "<h2>Uptime :</h2>"
|
||||
echo "<pre>"
|
||||
uptime
|
||||
echo "</pre>"
|
||||
print_h2 "Uptime"
|
||||
run_and_print "uptime"
|
||||
|
||||
case "$os_type" in
|
||||
AIX)
|
||||
echo "<h2>Espace disque (lsfs) :</h2>"
|
||||
echo "<pre>"
|
||||
lsfs
|
||||
echo "</pre>"
|
||||
print_h2 "Espace disque (lsfs)"
|
||||
run_and_print "lsfs"
|
||||
;;
|
||||
Linux)
|
||||
echo "<h2>Contenu du fichier /etc/fstab :</h2>"
|
||||
echo "<pre>"
|
||||
cat /etc/fstab | egrep -v '^#|^$'
|
||||
echo "</pre>"
|
||||
print_h2 "Contenu du fichier /etc/fstab"
|
||||
run_and_print "cat /etc/fstab | egrep -v '^#|^$'"
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "<h2>Contenu du contab du compte oracle :</h2>"
|
||||
echo "<pre>"
|
||||
crontab -l
|
||||
echo "</pre>"
|
||||
print_h2 "Contenu du contab du compte oracle"
|
||||
run_and_print "crontab -l"
|
||||
|
||||
echo "<h2>Limites de l'utilisateur "oracle" (ulimit -a) :</h2>"
|
||||
echo "<pre>"
|
||||
ulimit -a | sort
|
||||
echo "</pre>"
|
||||
print_h2 "Limites de l'utilisateur (ulimit -a)"
|
||||
run_and_print "ulimit -a | sort"
|
||||
|
||||
# espace disque en fonction de l'OS
|
||||
case "$os_type" in
|
||||
AIX)
|
||||
echo "<h2>Espace disque (df -g) :</h2>"
|
||||
echo "<pre>"
|
||||
df -g
|
||||
echo "</pre>"
|
||||
print_h2 "Espace disque (df -g)"
|
||||
run_and_print "df -g"
|
||||
;;
|
||||
Linux)
|
||||
echo "<h2>Espace disque (df -h) :</h2>"
|
||||
echo "<pre>"
|
||||
df -h
|
||||
echo "</pre>"
|
||||
print_h2 "Espace disque (df -h)"
|
||||
run_and_print "df -h"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
case "$os_type" in
|
||||
Linux)
|
||||
echo "<h2>Liste des disques disponibles (lsblk) :</h2>"
|
||||
echo "<pre>"
|
||||
lsblk
|
||||
echo "</pre>"
|
||||
print_h2 "Liste des disques disponibles (lsblk)"
|
||||
run_and_print "lsblk"
|
||||
|
||||
echo "<h2>Taille mémoire en Mo (free -m) :</h2>"
|
||||
echo "<pre>"
|
||||
free -m
|
||||
echo "</pre>"
|
||||
print_h2 "Taille mémoire en Mo (free -m)"
|
||||
run_and_print "free -m"
|
||||
|
||||
echo "<h2>Caractéristiques CPU (lscpu) :</h2>"
|
||||
echo "<pre>"
|
||||
lscpu
|
||||
echo "</pre>"
|
||||
print_h2 "Caractéristiques CPU (lscpu)"
|
||||
run_and_print "lscpu"
|
||||
|
||||
echo "<h2>Les 50 dernières erreur dans /var/log/messages :</h2>"
|
||||
if sudo -l &> /dev/null ; then
|
||||
# L'utilisateur a les droits sudo. on continue
|
||||
echo "<pre>"
|
||||
sudo cat /var/log/messages | egrep -i 'error|failed' | tail -50
|
||||
echo "</pre>"
|
||||
else
|
||||
echo "<pre>"
|
||||
echo "L'utilisateur n'a les droits pour lire les fichiers log."
|
||||
echo "</pre>"
|
||||
fi
|
||||
print_h2 "Statistiques VM (vmstat 2 20)"
|
||||
run_and_print "vmstat 2 20"
|
||||
|
||||
print_h2 "Top 10 processus par utilisation CPU (ps --width 150)"
|
||||
run_and_print "ps -eo pid,user,%cpu,%mem,vsz,rss,tty,stat,start,time,command --sort=-%cpu --width 1000 | head -n 17 | cut -c 1-180"
|
||||
|
||||
print_h2 "Derniers messages du noyau (dmesg -T | tail -n 30)"
|
||||
if sudo -ln &> /dev/null; then
|
||||
run_and_print "sudo dmesg -T | tail -n 30"
|
||||
else
|
||||
echo "<pre>L'utilisateur n'a pas les droits sudo pour exécuter dmesg.</pre>"
|
||||
fi
|
||||
|
||||
print_h2 "Les 30 dernières erreurs dans /var/log/messages"
|
||||
if sudo -ln &> /dev/null; then
|
||||
run_and_print "sudo cat /var/log/messages | egrep -i 'error|failed' | tail -30"
|
||||
else
|
||||
echo "<pre>L'utilisateur n'a pas les droits sudo pour lire les fichiers log.</pre>"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$os_type" in
|
||||
AIX)
|
||||
echo "<h2>Configuration système (prtconf) :</h2>"
|
||||
echo "<pre>"
|
||||
prtconf
|
||||
echo "</pre>"
|
||||
print_h2 "Configuration système (prtconf)"
|
||||
run_and_print "prtconf"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
@@ -1,25 +1,61 @@
|
||||
# /etc/oratab
|
||||
echo "<h2>Contenu du fichier /etc/oratab :</h2>"
|
||||
echo "<pre>"
|
||||
cat /etc/oratab | egrep -v "^$|^#"
|
||||
echo "</pre>"
|
||||
#!/bin/bash
|
||||
|
||||
# inventory.xml
|
||||
echo "<h2>Contenu du fichier Inventory.xml :</h2>"
|
||||
echo "<pre>"
|
||||
ORA_INVENTORY=$(cat /etc/oraInst.loc | grep inventory_loc | cut -d= -f2)
|
||||
cat $ORA_INVENTORY/ContentsXML/inventory.xml | grep "<HOME NAME=" | awk '{print $2 " " $3}'
|
||||
echo "</pre>"
|
||||
# Importe les fonctions utilitaires
|
||||
source "$(dirname "$0")/utils.sh"
|
||||
|
||||
# opatch
|
||||
echo "<h2>Niveau de patch des ORACLE_HOME (opatch lspatches) :</h2>"
|
||||
cat /etc/oratab | egrep -v "^$|^#" | cut -d: -f2 | sort -u | while read oh
|
||||
do
|
||||
echo "<pre>"
|
||||
echo "ORACLE_HOME="$oh
|
||||
echo ""
|
||||
export ORACLE_HOME=$oh
|
||||
$oh/OPatch/opatch lspatches
|
||||
echo "</pre><br>"
|
||||
# --- Script principal ---
|
||||
|
||||
print_h2 "Contenu du fichier /etc/oratab"
|
||||
run_and_print "cat /etc/oratab | egrep -v '^$|^#'"
|
||||
|
||||
print_h2 "Contenu du fichier Inventory.xml"
|
||||
# On s'assure que le fichier oraInst.loc existe et est lisible
|
||||
if [ -r /etc/oraInst.loc ]; then
|
||||
ORA_INVENTORY=$(grep inventory_loc /etc/oraInst.loc | cut -d= -f2)
|
||||
if [ -n "${ORA_INVENTORY}" ] && [ -r "${ORA_INVENTORY}/ContentsXML/inventory.xml" ]; then
|
||||
run_and_print "grep '<HOME NAME=' ${ORA_INVENTORY}/ContentsXML/inventory.xml | awk '{print \$2 \" \" \$3}'"
|
||||
else
|
||||
echo "<pre>Impossible de lire le fichier inventory.xml ou chemin non trouvé.</pre>"
|
||||
fi
|
||||
else
|
||||
echo "<pre>Fichier /etc/oraInst.loc non trouvé.</pre>"
|
||||
fi
|
||||
|
||||
print_h2 "Niveau de patch des ORACLE_HOME (opatch lspatches)"
|
||||
if [ -r "${ORA_INVENTORY}/ContentsXML/inventory.xml" ]; then
|
||||
# Utilise un `while read` pour plus de robustesse que `cat ... | while`
|
||||
while read -r line; do
|
||||
# Ignore les lignes vides ou commentées
|
||||
[[ "$line" =~ ^# ]] || [ -z "$line" ] && continue
|
||||
|
||||
oh=$(echo "$line" | cut -d: -f2 | sort -u)
|
||||
if [ -d "$oh" ]; then
|
||||
export ORACLE_HOME=$oh
|
||||
run_and_print "\"$oh/OPatch/opatch\" lspatches"
|
||||
fi
|
||||
done < <(grep -oP 'LOC="\K[^"]+' ${ORA_INVENTORY}/ContentsXML/inventory.xml)
|
||||
else
|
||||
echo "<pre>Fichier ${ORA_INVENTORY}/ContentsXML/inventory.xml non trouvé.</pre>"
|
||||
fi
|
||||
|
||||
print_h2 "Bases de données en cours d'exécution"
|
||||
run_and_print "ps -ef | grep pmon | grep -v grep"
|
||||
|
||||
print_h2 "Listeners en cours d'exécution"
|
||||
run_and_print "ps -ef | grep tnslsnr | grep -v grep"
|
||||
|
||||
# Boucle pour le statut du listener, car elle est plus complexe
|
||||
# ps -ef | grep tnslsnr | egrep -i " LISTENER |${ORACLE_SID}" | grep -v grep | while read -r l; do
|
||||
# On parcours tous les listener qui tournent sur le serveur pour afficher leur statut
|
||||
ps -ef | grep tnslsnr | grep -v grep | while read -r l; do
|
||||
binary_path=$(echo "$l" | perl -lne 'print $1 if /(\S*tnslsnr\S*)/' | sed 's#/bin/tnslsnr##')
|
||||
listener_name=$(echo "$l" | perl -lne 'print $1 if /\btnslsnr\s+(\S+)/' | sed 's/tnslsnr //')
|
||||
|
||||
if [ -n "$binary_path" ] && [ -n "$listener_name" ]; then
|
||||
export TNS_ADMIN="$binary_path/network/admin"
|
||||
export ORACLE_HOME="$binary_path"
|
||||
print_h2 "Statut du listener : ${listener_name}"
|
||||
lsnrctl_command="$binary_path/bin/lsnrctl status $listener_name"
|
||||
run_and_print "$lsnrctl_command"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Importe les fonctions utilitaires
|
||||
source "$(dirname "$0")/utils.sh"
|
||||
|
||||
# --- Script principal ---
|
||||
|
||||
# script à exécuter si seulement dbvctl existe et une instance avec le nom de service dbv existe aussi
|
||||
|
||||
count=$(ps -ef | grep dbvctl | grep -v grep | grep ${ORACLE_SID} | wc -l)
|
||||
count=$(ps -ef | grep dbvctl | grep -v grep | grep "${ORACLE_SID}" | wc -l)
|
||||
|
||||
if [ $count -gt 0 ]; then
|
||||
if [ "$count" -gt 0 ]; then
|
||||
|
||||
echo "<h1>Configuration DBVisit</h1>"
|
||||
# les process dbvisit en cours
|
||||
echo "<h2>Process DBVisit en cours d'exécution</h2>"
|
||||
echo "<pre>"
|
||||
ps -ef | grep dbvctl | grep -v grep
|
||||
echo "</pre>"
|
||||
print_h2 "Process DBVisit en cours d'exécution"
|
||||
run_and_print "ps -ef | grep dbvctl | grep -v grep"
|
||||
|
||||
# on récupère le chemin de l'executable dbvctl
|
||||
export DBV_HOME=$(dirname $(ps -ef | grep dbvctl | grep -v grep | awk '{print $8}' | sort -u))
|
||||
export DBV_HOME=$(dirname "$(ps -ef | grep dbvctl | grep -v grep | awk '{print $8}' | sort -u)")
|
||||
# si les exacutables sont lancé avec ./dbvctl, le résultat retourné est .
|
||||
# dans ce cas on remplace par la valeur par défaut : /usr/dbvisit/standby
|
||||
if [ "$DBV_HOME" = "." ]; then
|
||||
@@ -20,18 +24,13 @@ if [ $count -gt 0 ]; then
|
||||
export DBV_HOME="/usr/dbvisit/standby"
|
||||
fi
|
||||
|
||||
# statut de la base de données
|
||||
echo "<h2>Statut de la base : ${ORACLE_SID} sur le serveur $(hostname)</h2>"
|
||||
echo "<pre>"
|
||||
${DBV_HOME}/dbvctl -d ${ORACLE_SID} -o status
|
||||
echo "</pre>"
|
||||
print_h2 "Statut de la base : ${ORACLE_SID} sur le serveur $(hostname)"
|
||||
run_and_print "${DBV_HOME}/dbvctl -d ${ORACLE_SID} -o status"
|
||||
|
||||
# on récupère le statut de la base pour exécuter la commande sur la base primaire
|
||||
db_prim=$(${DBV_HOME}/dbvctl -d ${ORACLE_SID} -o status | grep -i "read write" | wc -l)
|
||||
if [ ${db_prim} -gt 0 ]; then
|
||||
echo "<h2>Rapport de GAP DBVisit pour la base ${ORACLE_SID}</h2>"
|
||||
echo "<pre>"
|
||||
${DBV_HOME}/dbvctl -d ${ORACLE_SID} -i
|
||||
echo "</pre>"
|
||||
db_prim=$("${DBV_HOME}/dbvctl" -d "${ORACLE_SID}" -o status | grep -i "read write" | wc -l)
|
||||
if [ "${db_prim}" -gt 0 ]; then
|
||||
print_h2 "Rapport de GAP DBVisit pour la base ${ORACLE_SID}"
|
||||
run_and_print "${DBV_HOME}/dbvctl -d ${ORACLE_SID} -i"
|
||||
fi
|
||||
fi
|
||||
23
sh/30_crs.sh
23
sh/30_crs.sh
@@ -1,16 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Importe les fonctions utilitaires
|
||||
source "$(dirname "$0")/utils.sh"
|
||||
|
||||
# --- Script principal ---
|
||||
|
||||
# script à exécuter si couche grid/crs
|
||||
|
||||
count=$(ps -ef | grep ohasd | grep -v grep | wc -l)
|
||||
|
||||
if [ $count -gt 0 ]; then
|
||||
if [ "$count" -gt 0 ]; then
|
||||
|
||||
echo "<h2>Services CRS</h2>"
|
||||
# les process dbvisit en cours
|
||||
print_h2 "Services CRS"
|
||||
|
||||
# BIN_DIR=$(dirname $(ps -ef | grep ohasd.bin | grep -v grep | egrep -o '/.*ohasd\.bin'))
|
||||
# la commande egrep -o ne fonctionne pas sous AIX
|
||||
# on utilise donc la commande suivante avec awk
|
||||
BIN_DIR=$(dirname $(ps -ef | grep ohasd.bin | grep -v grep | awk '{ match($0, /\/.*ohasd\.bin/); print substr($0, RSTART, RLENGTH) }'))
|
||||
BIN_DIR=$(dirname "$(ps -ef | grep ohasd.bin | grep -v grep | awk '{ match($0, /\/.*ohasd\.bin/); print substr($0, RSTART, RLENGTH) }')")
|
||||
# explication de la commande awk :
|
||||
# - match($0, /\/.*ohasd\.bin/): Cette partie de la commande awk recherche la première occurrence
|
||||
# de la séquence "/.*ohasd.bin" dans la ligne.
|
||||
@@ -18,7 +24,10 @@ if [ $count -gt 0 ]; then
|
||||
# la position RSTART (où la correspondance commence) jusqu'à la longueur RLENGTH de la correspondance.
|
||||
# - Le résultat sera la portion de la chaîne entre le premier / et le mot "ohasd.bin".
|
||||
# - la commande dirname retourne le répertoire qui sera utilisé dans BIN_DIR
|
||||
echo "<pre>"
|
||||
${BIN_DIR}/crsctl status res -t
|
||||
echo "</pre>"
|
||||
|
||||
if [ -n "$BIN_DIR" ] && [ -x "$BIN_DIR/crsctl" ]; then
|
||||
run_and_print "${BIN_DIR}/crsctl status res -t"
|
||||
else
|
||||
echo "<pre>Impossible de trouver le répertoire d'installation CRS ou crsctl n'est pas exécutable.</pre>"
|
||||
fi
|
||||
fi
|
||||
47
sh/local/check_expdp_log.sh
Normal file
47
sh/local/check_expdp_log.sh
Normal file
@@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
# script pour vérifier les logs des fichiers datapump et voir si des erreurs sont présentes
|
||||
|
||||
# Importe les fonctions utilitaires
|
||||
source "$(dirname "$0")/../utils.sh"
|
||||
|
||||
# --- Script principal ---
|
||||
|
||||
# EXPDP_DIR="/u04/backup" : la variable d'environnement est chargée depuis le fichier .env
|
||||
|
||||
CURRENT_DATE=$(date +%Y_%m) # date au format 2025_04
|
||||
|
||||
print_h2 "Vérification des logs des exports Datapump"
|
||||
|
||||
# vérifier si une erreur ORA- est pésente dans les fichiers logs
|
||||
echo "<h3>Vérification de la présence d'erreurs dans les logs :</h3>"
|
||||
|
||||
if [ -z "${EXPDP_DIR}" ]; then
|
||||
echo "<pre>La variable EXPDP_DIR n'est pas définie. Impossible de vérifier les logs Datapump.</pre>"
|
||||
elif [ ! -d "${EXPDP_DIR}" ]; then
|
||||
echo "<pre>Le répertoire EXPDP_DIR ('${EXPDP_DIR}') n'existe pas ou n'est pas accessible.</pre>"
|
||||
else
|
||||
RESULT=$(find "${EXPDP_DIR}" -iname "export_*.log" -exec grep -H "ORA-" "{}" \;)
|
||||
if [ -z "$RESULT" ]; then
|
||||
echo "<pre>Aucune erreur ORA- détectée dans les fichiers logs du mois ${CURRENT_DATE}.</pre>"
|
||||
else
|
||||
echo "<pre>$RESULT</pre>"
|
||||
fi
|
||||
|
||||
# afficher les dernières lignes des fichiers log pour voir les les exports se sont bien déroulés
|
||||
echo "<h3>Affichage des 10 premières et 10 dernières lignes des fichiers logs :</h3>"
|
||||
# préparation de la commande find : définition de la fonction d'affichage plus lisible
|
||||
show_log_excerpt() {
|
||||
local file="$1"
|
||||
echo "<br><b>--- ${file} ---</b> " # affiche le nom du fichier en gras
|
||||
echo "<pre>"
|
||||
head -10 "$file" # affiche les 10 première lignes dans le bloc PRE
|
||||
echo "</pre><pre>"
|
||||
tail -10 "$file" # affiche les 10 dernières lignes dans le bloc PRE
|
||||
echo "</pre>"
|
||||
}
|
||||
# export pour rendre la fonction accessible à bash -c
|
||||
export -f show_log_excerpt
|
||||
|
||||
# find appelle la fonction en lui passant $0 comme paramètre
|
||||
find "${EXPDP_DIR}" -iname "export_*.log" -exec bash -c 'show_log_excerpt "$0"' {} \;
|
||||
fi
|
||||
44
sh/utils.sh
Normal file
44
sh/utils.sh
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Fichier de fonctions utilitaires pour les scripts de rapport
|
||||
|
||||
# Fonction: log_info
|
||||
# Description: Affiche un message d'information dans les logs avec un timestamp.
|
||||
# Paramètres:
|
||||
# $1 - Le message à afficher.
|
||||
log_info() {
|
||||
echo "[INFO] $(date +'%Y-%m-%d %H:%M:%S') - ${1}"
|
||||
}
|
||||
|
||||
# Affiche un titre H2
|
||||
print_h2() {
|
||||
echo "<h2>$1</h2>"
|
||||
}
|
||||
|
||||
# Exécute une commande et affiche sa sortie dans une balise <pre>
|
||||
# Si la commande échoue, elle affiche un message d'erreur mis en évidence.
|
||||
run_and_print() {
|
||||
local cmd="$1"
|
||||
local cmd_html
|
||||
|
||||
# Échapper les caractères HTML pour un affichage sûr
|
||||
cmd_html=$(echo "${cmd}" | sed 's/&/\&/g; s/</\</g; s/>/\>/g')
|
||||
|
||||
echo "<br><pre>"
|
||||
# Affiche la commande échappée en rouge et gras
|
||||
echo "<b style=\"color:red;\">${cmd_html}</b>"
|
||||
|
||||
# Ajoute une ligne vide pour la séparation
|
||||
echo ""
|
||||
|
||||
# Exécute la commande originale, redirige stderr vers stdout pour tout capturer
|
||||
if output=$(eval "${cmd}" 2>&1); then
|
||||
echo "$output"
|
||||
else
|
||||
echo "<div class=\"error-block\">"
|
||||
echo "ERREUR: La commande a échoué avec le message suivant :"
|
||||
echo "$output"
|
||||
echo "</div>"
|
||||
fi
|
||||
echo "</pre>"
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
||||
<!-- $Header: DB Report -->
|
||||
<!-- Author: yacine.oumghar@axiome.io -->
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<title>Rapport Base Oracle</title>
|
||||
|
||||
<style type="text/css">
|
||||
body {font:12pt Arial,Helvetica,Geneva,sans-serif; color:black; background:white;}
|
||||
h1 {font-size:16pt; font-weight:bold; color:#336699; border-bottom:1px solid #336699; margin-top:0pt; margin-bottom:0pt; padding:0px 0px 0px 0px;}
|
||||
h2 {font-size:14pt; font-weight:bold; color:#336699; margin-top:10pt; margin-bottom:0pt;}
|
||||
h3 {font-size:12pt; font-weight:bold; color:#336699; margin-top:4pt; margin-bottom:0pt;}
|
||||
pre {font:10pt monospace,Monaco,"Courier New",Courier; display: inline-block; padding: 10px; border: 1px solid #000; border-radius: 5px; background-color: #f5f5f5; overflow: auto;}
|
||||
|
||||
a {color:#663300;}
|
||||
table {font-size:10pt; border-collapse:collapse; empty-cells:show; white-space:nowrap; border:1px solid #336699;}
|
||||
li {font-size:10pt; color:black; padding-left:4px; padding-right:4px; padding-bottom:2px;}
|
||||
th {font-weight:bold; color:white; background:#0066CC; padding-left:4px; padding-right:4px; padding-bottom:2px;}
|
||||
tr {color:black; background:white;}
|
||||
tr:hover {color:white; background:#0066CC;}
|
||||
tr.main {color:black; background:white;}
|
||||
tr.main:hover {color:black; background:white;}
|
||||
td {vertical-align:top; border:1px solid #336699;padding-left: 5px;padding-right: 5px;}
|
||||
td.c {text-align:center;}
|
||||
font.n {font-size:10pt; font-style:italic; color:#336699;}
|
||||
font.f {font-size:10pt; color:#999999; border-top:1px solid #336699; margin-top:30pt;}
|
||||
div.google-chart {width:&&edb360_chart_width.; height:500px;}
|
||||
.highlight {background: red;}
|
||||
.pct_warning {background: yellowgreen;}
|
||||
.pct_error {background: red}
|
||||
</style>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
prompt <h2>System Information</h2>
|
||||
WITH /* 1a.1 */
|
||||
rac AS (SELECT /*+ MATERIALIZE NO_MERGE */ COUNT(*) instances, CASE COUNT(*) WHEN 1 THEN 'Single-instance' ELSE COUNT(*)||'-node RAC cluster' END db_type FROM gv$instance),
|
||||
rac AS (select /* db-html-report */ /*+ MATERIALIZE NO_MERGE */ COUNT(*) instances, CASE COUNT(*) WHEN 1 THEN 'Single-instance' ELSE COUNT(*)||'-node RAC cluster' END db_type FROM gv$instance),
|
||||
hrac AS (SELECT /*+ MATERIALIZE NO_MERGE */ CASE 1 WHEN 1 THEN ' (historically Single-instance in AWR)' ELSE ' (historicly 1-node RAC cluster in AWR)' END db_type
|
||||
FROM rac WHERE TO_CHAR(RAC.instances)<>1),
|
||||
mem AS (SELECT /*+ MATERIALIZE NO_MERGE */ SUM(value) target FROM gv$system_parameter2 WHERE name = 'memory_target'),
|
||||
@@ -39,14 +39,6 @@ CASE WHEN sga.target > 0 THEN 'SGA ' ||TRIM(TO_CHAR(ROUND(sga.target / POWER(2
|
||||
CASE WHEN pga.target > 0 THEN 'PGA ' ||TRIM(TO_CHAR(ROUND(pga.target / POWER(2,30), 1), '999,990.0'))||' GB, ' END||
|
||||
CASE WHEN mem.target > 0 THEN 'AMM' ELSE CASE WHEN sga.target > 0 THEN 'ASMM' ELSE 'MANUAL' END END
|
||||
FROM mem, sga, pga
|
||||
-- UNION ALL
|
||||
-- SELECT 'Hardware:', 'Unknown' FROM dual
|
||||
-- UNION ALL
|
||||
-- SELECT 'Storage:','' FROM DUAL WHERE '' IS NOT NULL
|
||||
-- UNION ALL
|
||||
-- SELECT 'Storage Version:','' FROM DUAL WHERE '' IS NOT NULL
|
||||
-- UNION ALL
|
||||
-- SELECT 'Processor:', 'Common KVM processor' FROM DUAL
|
||||
UNION ALL
|
||||
SELECT 'Physical CPUs:', core.cnt||' cores'||CASE WHEN rac.instances > 0 THEN ', on '||rac.db_type END FROM rac, core
|
||||
UNION ALL
|
||||
|
||||
@@ -1,25 +1,8 @@
|
||||
prompt <h2>Taille de la base de données :</h2>
|
||||
-- set head off
|
||||
-- col "Database Size" format 99,999.99
|
||||
-- select 'Database Size (Go) : ' || (
|
||||
-- SELECT ROUND(SUM(TAILLE_BYTES)/1024/1024/1024,2) "Database Size" FROM
|
||||
-- (
|
||||
-- SELECT SUM(FILE_SIZE_BLKS*BLOCK_SIZE) TAILLE_BYTES FROM V$CONTROLFILE
|
||||
-- UNION ALL
|
||||
-- SELECT SUM(BYTES) FROM V$TEMPFILE
|
||||
-- UNION ALL
|
||||
-- SELECT SUM(BYTES) FROM V$DATAFILE
|
||||
-- UNION ALL
|
||||
-- SELECT SUM(MEMBERS*BYTES) FROM V$LOG
|
||||
-- UNION ALL
|
||||
-- SELECT BYTES FROM V$STANDBY_LOG SL, V$LOGFILE LF WHERE SL.GROUP# = LF.GROUP#
|
||||
-- )
|
||||
-- )
|
||||
-- from dual;
|
||||
|
||||
WITH
|
||||
sizes AS (
|
||||
SELECT /*+ MATERIALIZE NO_MERGE */ /* 1f.60 */
|
||||
select /* db-html-report */ /*+ MATERIALIZE NO_MERGE */ /* 1f.60 */
|
||||
'Data' file_type,
|
||||
SUM(bytes) bytes
|
||||
FROM v$datafile
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
prompt <h2>Database/Instance Status</h2>
|
||||
alter session set nls_date_format='YYYY/MM/DD HH24:MI:SS';
|
||||
|
||||
SELECT 'DATABASE_NAME' AS property, name AS value FROM gv$database
|
||||
select /* db-html-report */ 'DATABASE_NAME' AS property, name AS value FROM gv$database
|
||||
UNION ALL
|
||||
SELECT 'DATABASE_ROLE' AS property, DATABASE_ROLE AS value FROM gv$database
|
||||
UNION ALL
|
||||
|
||||
@@ -1,2 +1,6 @@
|
||||
prompt <h2>Database/Version</h2>
|
||||
select * from v$version;
|
||||
|
||||
select /* db-html-report */
|
||||
*
|
||||
FROM
|
||||
V$VERSION;
|
||||
@@ -1,2 +1,13 @@
|
||||
prompt <h2>Paramèters de la base de données : </h2>
|
||||
select NAME, DISPLAY_VALUE, DESCRIPTION, UPDATE_COMMENT from v$parameter where ISDEFAULT='FALSE' order by name;
|
||||
|
||||
select /* db-html-report */
|
||||
NAME,
|
||||
DISPLAY_VALUE,
|
||||
DESCRIPTION,
|
||||
UPDATE_COMMENT
|
||||
FROM
|
||||
GV$PARAMETER
|
||||
WHERE
|
||||
ISDEFAULT='FALSE'
|
||||
ORDER BY
|
||||
NAME;
|
||||
@@ -1,3 +1,3 @@
|
||||
prompt <h2>Paramètres NLS au niveau de la base de données :</h2>
|
||||
select * from nls_database_parameters order by parameter;
|
||||
|
||||
select /* db-html-report */ * from gv$nls_parameters order by PARAMETER ;
|
||||
@@ -1,6 +1,6 @@
|
||||
prompt <h2>Database supplemental logging :</h2>
|
||||
|
||||
select 'force_logging' as property, force_logging as value from v$database
|
||||
select /* db-html-report */ 'force_logging' as property, force_logging as value from v$database
|
||||
union all
|
||||
select 'supplemental_log_data_min' as property, supplemental_log_data_min as value from v$database
|
||||
union all
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
prompt <h2>Fonctionnalités installées dans la base de données (DBA_REGISTRY) :</h2>
|
||||
SELECT *
|
||||
FROM dba_registry
|
||||
|
||||
select /* db-html-report */
|
||||
*
|
||||
FROM
|
||||
DBA_REGISTRY
|
||||
ORDER BY
|
||||
comp_id;
|
||||
|
||||
|
||||
|
||||
COMP_ID;
|
||||
@@ -1,10 +1,11 @@
|
||||
prompt <h2>Resource Limit (GV$RESOURCE_LIMIT)</h2>
|
||||
SELECT
|
||||
|
||||
select /* db-html-report */
|
||||
*
|
||||
FROM
|
||||
gv$resource_limit
|
||||
GV$RESOURCE_LIMIT
|
||||
WHERE
|
||||
resource_name IN ( 'processes', 'sessions' )
|
||||
RESOURCE_NAME IN ( 'processes', 'sessions' )
|
||||
ORDER BY
|
||||
resource_name,
|
||||
inst_id;
|
||||
RESOURCE_NAME,
|
||||
INST_ID;
|
||||
@@ -1,7 +1,7 @@
|
||||
prompt <h2>Memory Information</h2>
|
||||
WITH
|
||||
system_parameter AS (
|
||||
SELECT inst_id,
|
||||
select /* db-html-report */ inst_id,
|
||||
name,
|
||||
value
|
||||
FROM gv$system_parameter2
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
prompt <h2>Les 50 dernières opérations de Resize de la mémoire :</h2>
|
||||
alter session set nls_date_format='YYYY/MM/DD HH24:MI:SS';
|
||||
SELECT *
|
||||
FROM gv$memory_resize_ops
|
||||
where rownum <=50
|
||||
ORDER BY
|
||||
inst_id,
|
||||
start_time DESC,
|
||||
component;
|
||||
|
||||
ALTER SESSION SET NLS_DATE_FORMAT='YYYY/MM/DD HH24:MI:SS';
|
||||
|
||||
select /* db-html-report */
|
||||
*
|
||||
FROM
|
||||
GV$MEMORY_RESIZE_OPS
|
||||
WHERE
|
||||
ROWNUM <=50
|
||||
ORDER BY
|
||||
INST_ID,
|
||||
START_TIME DESC,
|
||||
COMPONENT;
|
||||
@@ -1,4 +1,19 @@
|
||||
prompt <h2>SGA Target Advice</h2>
|
||||
select * from gv$sga_target_advice;
|
||||
|
||||
select /* db-html-report */
|
||||
*
|
||||
FROM
|
||||
GV$SGA_TARGET_ADVICE;
|
||||
|
||||
prompt <h2>PGA Target Advice</h2>
|
||||
select * from gv$pga_target_advice;
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
GV$PGA_TARGET_ADVICE;
|
||||
|
||||
prompt <h2>Memory Target Advice</h2>
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
GV$MEMORY_TARGET_ADVICE;
|
||||
@@ -1,40 +1,4 @@
|
||||
prompt <h2>Détail des tablespaces : </h2>
|
||||
COL TABLESPACE_NAME FORMAT A20 HEAD "Nom Tablespace"
|
||||
COL PCT_OCCUPATION_THEORIQUE FORMAT 990.00 HEAD "% Occup"
|
||||
COL TAILLE_MIB FORMAT 99999990.00 HEAD "Taille MB"
|
||||
COL TAILLE_MAX_MIB FORMAT 99999990.00 HEAD "Taille max MB"
|
||||
COL TAILLE_OCCUPEE_MIB FORMAT 99999990.00 HEAD "Espace occupé MiB"
|
||||
-- WITH TS_FREE_SPACE AS
|
||||
-- (select tablespace_name, file_id, sum(bytes) FREE_O from dba_free_space group by tablespace_name, file_id
|
||||
-- ), TEMP_ALLOC AS
|
||||
-- (select tablespace_name, file_id, sum(bytes) USED_O from v$temp_extent_map group by tablespace_name, file_id
|
||||
-- )
|
||||
-- SELECT
|
||||
-- TABLESPACE_NAME,
|
||||
-- SUM(TAILLE_MIB) TAILLE_MIB,
|
||||
-- SUM(TAILLE_MAX_MIB) TAILLE_MAX_MIB,
|
||||
-- SUM(TAILLE_OCCUPEE_MIB) TAILLE_OCCUPEE_MIB,
|
||||
-- ROUND(SUM(TAILLE_OCCUPEE_MIB)*100/SUM(GREATEST(TAILLE_MAX_MIB,TAILLE_MIB)),2) PCT_OCCUPATION_THEORIQUE
|
||||
-- FROM
|
||||
-- (
|
||||
-- SELECT D.FILE_NAME, D.TABLESPACE_NAME, D.BYTES/1024/1024 TAILLE_MIB, DECODE(D.AUTOEXTENSIBLE,'NO',D.BYTES,D.MAXBYTES)/1024/1024 TAILLE_MAX_MIB,
|
||||
-- (D.BYTES-FO.FREE_O)/1024/1024 TAILLE_OCCUPEE_MIB
|
||||
-- FROM
|
||||
-- DBA_DATA_FILES D, TS_FREE_SPACE FO
|
||||
-- WHERE
|
||||
-- D.TABLESPACE_NAME=FO.TABLESPACE_NAME
|
||||
-- AND D.FILE_ID=FO.FILE_ID
|
||||
-- UNION ALL
|
||||
-- SELECT T.FILE_NAME, T.TABLESPACE_NAME, T.BYTES/1024/1024 TAILLE_MIB, DECODE(T.AUTOEXTENSIBLE,'NO',T.BYTES,T.MAXBYTES)/1024/1024 TAILLE_MAX_MIB,
|
||||
-- (TA.USED_O)/1024/1024 TAILLE_OCCUPEE_MIB
|
||||
-- FROM
|
||||
-- DBA_TEMP_FILES T, TEMP_ALLOC TA
|
||||
-- WHERE
|
||||
-- T.TABLESPACE_NAME=TA.TABLESPACE_NAME
|
||||
-- AND T.FILE_ID=TA.FILE_ID
|
||||
-- )
|
||||
-- GROUP BY TABLESPACE_NAME
|
||||
-- ORDER BY TABLESPACE_NAME;--
|
||||
|
||||
COL TABLESPACE_NAME FORMAT A20 HEAD "Tablespace"
|
||||
COL alloc FORMAT 99999999.00 HEAD "Allocated MB"
|
||||
@@ -42,10 +6,12 @@ COL used FORMAT 99999999.00 HEAD "Used MB"
|
||||
COL free FORMAT 99999999.00 HEAD "Free MB"
|
||||
COL max FORMAT 99999999.00 HEAD "MaxSize MB"
|
||||
COL Pct_Used FORMAT 999.00 HEAD "% Used"
|
||||
COL nb_of_file FORMAT 999 HEAD "Nbr Of Files"
|
||||
|
||||
select
|
||||
select /* db-html-report */
|
||||
a.tablespace_name,
|
||||
t.bigfile,
|
||||
a.nb_of_file,
|
||||
a.bytes_alloc/1024/1024 alloc,
|
||||
(a.bytes_alloc - nvl(b.bytes_free, 0))/1024/1024 used,
|
||||
(nvl(b.bytes_free, 0))/1024/1024 free,
|
||||
@@ -55,6 +21,7 @@ from
|
||||
(
|
||||
select
|
||||
f.tablespace_name,
|
||||
count(*) as nb_of_file,
|
||||
sum(f.bytes) bytes_alloc,
|
||||
sum(decode(f.autoextensible, 'YES', f.maxbytes, 'NO', f.bytes)) maxbytes
|
||||
from
|
||||
@@ -79,6 +46,7 @@ union all
|
||||
select
|
||||
h.tablespace_name,
|
||||
dt.bigfile,
|
||||
count(*) as nb_of_file,
|
||||
(sum(h.bytes_free + h.bytes_used))/1024/1024 alloc,
|
||||
(sum(nvl(p.bytes_used, 0)))/1024/1024 used,
|
||||
(sum((h.bytes_free + h.bytes_used) - nvl(p.bytes_used, 0)))/1024/1024 free,
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
prompt <h2>Détail des datafiles : </h2>
|
||||
|
||||
|
||||
COL file_id HEAD "File ID"
|
||||
COL file_name HEAD "Datafile"
|
||||
COL tablespace_name FORMAT A20 HEAD "Tablespace"
|
||||
|
||||
COL file_size_mb FORMAT 999999999.00 HEAD "File Size MB"
|
||||
COL space_used_mb FORMAT 999999999.00 HEAD "Space Used MB"
|
||||
COL space_free_mb FORMAT 999999999.00 HEAD "Space Free MB"
|
||||
COL maxsize_mb FORMAT 999999999.00 HEAD "Max Size MB"
|
||||
COL percent_used FORMAT 999.00 HEAD "% Used"
|
||||
|
||||
COL autoextensible FORMAT A15 HEAD "Auto Extensible"
|
||||
COL status head "Status"
|
||||
COL online_status format a15 head "Online Status"
|
||||
|
||||
select
|
||||
d.file_id,
|
||||
d.file_name,
|
||||
d.tablespace_name,
|
||||
a.bytes_alloc/1024/1024 file_size_mb,
|
||||
(a.bytes_alloc - nvl(b.bytes_free, 0))/1024/1024 space_used_mb,
|
||||
nvl(b.bytes_free, 0)/1024/1024 space_free_mb,
|
||||
a.maxbytes/1024/1024 maxsize_mb,
|
||||
round((a.bytes_alloc - nvl(b.bytes_free, 0)) / a.maxbytes * 100,2) percent_used,
|
||||
d.autoextensible,
|
||||
d.status,
|
||||
d.online_status
|
||||
from
|
||||
(
|
||||
select
|
||||
f.file_id,
|
||||
sum(f.bytes) bytes_alloc,
|
||||
sum(decode(f.autoextensible, 'YES', f.maxbytes, 'NO', f.bytes)) maxbytes
|
||||
from dba_data_files f group by file_id
|
||||
) a,
|
||||
(
|
||||
select
|
||||
f.file_id,
|
||||
sum(f.bytes) bytes_free
|
||||
from dba_free_space f group by file_id
|
||||
) b,
|
||||
dba_data_files d
|
||||
where
|
||||
a.file_id = b.file_id (+) and d.file_id=a.file_id
|
||||
order by
|
||||
d.file_name
|
||||
;
|
||||
59
sql/20b_tablespaces.sql
Normal file
59
sql/20b_tablespaces.sql
Normal file
@@ -0,0 +1,59 @@
|
||||
prompt <h2>Détail des tablespaces (dans toutes les PDB si la base est CDB) : </h2>
|
||||
|
||||
COL NAME FORMAT A20 HEAD "DB/PDB NAME"
|
||||
COL TABLESPACE_NAME FORMAT A20 HEAD "Tablespace"
|
||||
COL alloc_mb FORMAT 99999999.00 HEAD "Allocated MB"
|
||||
COL used_mb FORMAT 99999999.00 HEAD "Used MB"
|
||||
COL free_mb FORMAT 99999999.00 HEAD "Free MB"
|
||||
COL max_mb FORMAT 99999999.00 HEAD "MaxSize MB"
|
||||
COL Pct_Used FORMAT 999.00 HEAD "% Used"
|
||||
COL nbr_of_files FORMAT 999 HEAD "Nbr Of Files"
|
||||
COL BIGFILE FORMAT A8 HEAD "Bigfile"
|
||||
|
||||
select /* db-html-report */
|
||||
a.con_id,
|
||||
c.NAME,
|
||||
a.tablespace_name,
|
||||
t.bigfile,
|
||||
a.nbr_of_files,
|
||||
a.bytes_alloc/1024/1024 alloc_mb,
|
||||
(a.bytes_alloc - nvl(b.bytes_free, 0))/1024/1024 used_mb,
|
||||
(nvl(b.bytes_free, 0))/1024/1024 free_mb,
|
||||
maxbytes/1024/1024 Max_mb,
|
||||
(a.bytes_alloc - nvl(b.bytes_free, 0)) / maxbytes * 100 Pct_Used
|
||||
from
|
||||
(
|
||||
select
|
||||
f.con_id,
|
||||
f.tablespace_name,
|
||||
count(*) as nbr_of_files,
|
||||
sum(f.bytes) bytes_alloc,
|
||||
sum(decode(f.autoextensible, 'YES', f.maxbytes, 'NO', f.bytes)) maxbytes
|
||||
from
|
||||
cdb_data_files f
|
||||
group by
|
||||
con_id, tablespace_name
|
||||
) a,
|
||||
(
|
||||
select
|
||||
f.con_id,
|
||||
f.tablespace_name,
|
||||
sum(f.bytes) bytes_free
|
||||
from
|
||||
cdb_free_space f
|
||||
group by
|
||||
con_id, tablespace_name
|
||||
) b,
|
||||
v$containers c,
|
||||
cdb_tablespaces t
|
||||
where
|
||||
a.con_id = b.con_id
|
||||
and a.con_id = c.con_id(+)
|
||||
and a.con_id = t.con_id
|
||||
and a.tablespace_name = b.tablespace_name (+)
|
||||
and a.tablespace_name = t.tablespace_name
|
||||
order by
|
||||
a.con_id,
|
||||
c.NAME,
|
||||
a.tablespace_name
|
||||
;
|
||||
96
sql/20c_datafile.sql
Normal file
96
sql/20c_datafile.sql
Normal file
@@ -0,0 +1,96 @@
|
||||
prompt <h2>CDB/PDB - Détail des datafiles : </h2>
|
||||
|
||||
COL con_id HEAD "CON ID"
|
||||
COL pdb_name HEAD "PDB Name"
|
||||
COL file_id HEAD "File ID"
|
||||
COL file_name HEAD "Datafile"
|
||||
COL tablespace_name FORMAT A20 HEAD "Tablespace"
|
||||
|
||||
COL file_size_mb FORMAT 999999999.00 HEAD "File Size MB"
|
||||
COL space_used_mb FORMAT 999999999.00 HEAD "Space Used MB"
|
||||
COL space_free_mb FORMAT 999999999.00 HEAD "Space Free MB"
|
||||
COL maxsize_mb FORMAT 999999999.00 HEAD "Max Size MB"
|
||||
COL percent_used FORMAT 999.00 HEAD "% Used"
|
||||
|
||||
COL autoextensible FORMAT A15 HEAD "Auto Extensible"
|
||||
COL status head "Status"
|
||||
COL online_status format a15 head "Online Status"
|
||||
|
||||
WITH
|
||||
-- Sous-requête pour les fichiers de données dans une CDB
|
||||
cdb_files AS (
|
||||
-- cdb_files.sql
|
||||
select /* db-html-report */
|
||||
p.con_id AS pdb_id,
|
||||
p.pdb_name AS pdb_name,
|
||||
d.file_id,
|
||||
d.tablespace_name,
|
||||
d.file_name,
|
||||
a.bytes_alloc/1024/1024 AS file_size_mb,
|
||||
(a.bytes_alloc - NVL(b.bytes_free, 0))/1024/1024 AS space_used_mb,
|
||||
NVL(b.bytes_free, 0)/1024/1024 AS space_free_mb,
|
||||
a.maxbytes/1024/1024 AS maxsize_mb,
|
||||
ROUND((a.bytes_alloc - NVL(b.bytes_free, 0)) / a.maxbytes * 100, 2) AS percent_used,
|
||||
d.autoextensible,
|
||||
d.status,
|
||||
d.online_status
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
f.file_id,
|
||||
SUM(f.bytes) AS bytes_alloc,
|
||||
SUM(DECODE(f.autoextensible, 'YES', f.maxbytes, 'NO', f.bytes)) AS maxbytes
|
||||
FROM cdb_data_files f GROUP BY file_id
|
||||
) a
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
f.file_id,
|
||||
SUM(f.bytes) AS bytes_free
|
||||
FROM cdb_free_space f GROUP BY file_id
|
||||
) b ON a.file_id = b.file_id
|
||||
JOIN cdb_data_files d ON a.file_id = d.file_id
|
||||
RIGHT JOIN cdb_pdbs p ON d.con_id = p.pdb_id
|
||||
WHERE
|
||||
(SELECT cdb FROM v$database) = 'YES'
|
||||
ORDER BY p.pdb_id, d.tablespace_name, d.file_name
|
||||
),
|
||||
-- Sous-requête pour les fichiers de données dans une non-CDB
|
||||
non_cdb_files AS (
|
||||
-- non_cdb_files.sql
|
||||
SELECT
|
||||
NULL AS pdb_id,
|
||||
NULL AS pdb_name,
|
||||
d.file_id,
|
||||
d.tablespace_name,
|
||||
d.file_name,
|
||||
a.bytes_alloc/1024/1024 AS file_size_mb,
|
||||
(a.bytes_alloc - NVL(b.bytes_free, 0))/1024/1024 AS space_used_mb,
|
||||
NVL(b.bytes_free, 0)/1024/1024 AS space_free_mb,
|
||||
a.maxbytes/1024/1024 AS maxsize_mb,
|
||||
ROUND((a.bytes_alloc - NVL(b.bytes_free, 0)) / a.maxbytes * 100, 2) AS percent_used,
|
||||
d.autoextensible,
|
||||
d.status,
|
||||
d.online_status
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
f.file_id,
|
||||
SUM(f.bytes) AS bytes_alloc,
|
||||
SUM(DECODE(f.autoextensible, 'YES', f.maxbytes, 'NO', f.bytes)) AS maxbytes
|
||||
FROM dba_data_files f GROUP BY file_id
|
||||
) a
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
f.file_id,
|
||||
SUM(f.bytes) AS bytes_free
|
||||
FROM dba_free_space f GROUP BY file_id
|
||||
) b ON a.file_id = b.file_id
|
||||
JOIN dba_data_files d ON a.file_id = d.file_id
|
||||
-- WHERE
|
||||
-- (SELECT cdb FROM v$database) = 'NO'
|
||||
ORDER BY d.tablespace_name, d.file_name
|
||||
)
|
||||
-- Requête finale combinant les résultats des sous-requêtes
|
||||
SELECT * FROM cdb_files
|
||||
UNION ALL
|
||||
SELECT * FROM non_cdb_files;
|
||||
25
sql/20d_tempfile.sql
Normal file
25
sql/20d_tempfile.sql
Normal file
@@ -0,0 +1,25 @@
|
||||
prompt <h2>Détail des tempfile : </h2>
|
||||
|
||||
COL con_id HEAD "CON ID"
|
||||
COL name HEAD "PDB Name"
|
||||
COL file_id HEAD "File ID"
|
||||
COL tablespace_name FORMAT A20 HEAD "Tablespace"
|
||||
COL file_name HEAD "Tempfile"
|
||||
COL status head "Status"
|
||||
COL file_size_mb FORMAT 999999999.00 HEAD "File Size MB"
|
||||
COL maxsize_mb FORMAT 999999999.00 HEAD "Max Size MB"
|
||||
COL autoextensible FORMAT A15 HEAD "Auto Extensible"
|
||||
|
||||
select
|
||||
t.con_id,
|
||||
c.name,
|
||||
t.file_id,
|
||||
t.tablespace_name,
|
||||
t.file_name,
|
||||
t.status,
|
||||
round(t.bytes/1024/1024) file_size_mb,
|
||||
round(t.maxbytes/1024/1024) maxsize_mb,
|
||||
t.autoextensible
|
||||
from cdb_temp_files t, v$containers c
|
||||
where t.con_id = c.con_id
|
||||
order by t.con_id, t.file_id, t.file_name;
|
||||
18
sql/20e_undo.sql
Normal file
18
sql/20e_undo.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
prompt <h3>Détail du tablespace UNDO : </h3>
|
||||
|
||||
select /* db-html-report */
|
||||
a.tablespace_name,
|
||||
a.file_id,
|
||||
a.bytes / 1024 / 1024 AS size_mb,
|
||||
a.autoextensible,
|
||||
b.bytes_free / 1024 / 1024 AS free_mb,
|
||||
(a.bytes - b.bytes_free) / 1024 / 1024 AS used_mb,
|
||||
ROUND(((a.bytes - b.bytes_free) / a.bytes) * 100, 2) AS pct_used
|
||||
FROM
|
||||
dba_data_files a
|
||||
JOIN
|
||||
(SELECT file_id, SUM(bytes) AS bytes_free
|
||||
FROM dba_free_space
|
||||
GROUP BY file_id) b
|
||||
ON a.file_id = b.file_id
|
||||
WHERE a.tablespace_name like 'UNDO%';
|
||||
@@ -1,2 +1,6 @@
|
||||
prompt <h2>Existance de blocks corrompus :</h2>
|
||||
select * from v$database_block_corruption;
|
||||
|
||||
select /* db-html-report */
|
||||
*
|
||||
FROM
|
||||
V$DATABASE_BLOCK_CORRUPTION;
|
||||
@@ -1,13 +1,12 @@
|
||||
prompt <h2>Fichiers de journalisation (Redolog) :</h2>
|
||||
alter session set nls_date_format='YYYY/MM/DD HH24:MI:SS';
|
||||
|
||||
SELECT
|
||||
ALTER SESSION SET NLS_DATE_FORMAT='YYYY/MM/DD HH24:MI:SS';
|
||||
|
||||
select /* db-html-report */
|
||||
*
|
||||
FROM
|
||||
v$log
|
||||
V$LOG
|
||||
ORDER BY
|
||||
group#,
|
||||
thread#,
|
||||
sequence#;
|
||||
|
||||
|
||||
GROUP#,
|
||||
THREAD#,
|
||||
SEQUENCE#;
|
||||
@@ -3,7 +3,7 @@ alter session set nls_date_format='YYYY/MM/DD HH24:MI:SS';
|
||||
|
||||
COL MEMBER FORMAT A90 WRAPPED
|
||||
BREAK ON GROUP# SKIP 1 ON THREAD# ON SEQUENCE# ON TAILLE_MIB ON "STATUS(ARCHIVED)"
|
||||
SELECT
|
||||
select /* db-html-report */
|
||||
'OnlineLog' t,
|
||||
g.group#,
|
||||
g.thread#,
|
||||
|
||||
@@ -31,7 +31,7 @@ col 23 for 999
|
||||
col 24 for 999
|
||||
|
||||
|
||||
select to_char(first_time, 'YYYY/MM/dd') "Date",
|
||||
select /* db-html-report */ to_char(first_time, 'YYYY/MM/dd') "Date",
|
||||
count(1) "Total",
|
||||
sum(decode(to_char(first_time, 'hh24'),'00',1,0)) "00",
|
||||
sum(decode(to_char(first_time, 'hh24'),'01',1,0)) "01",
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
prompt <h2>Taille des redolog par jour :</h2>
|
||||
select
|
||||
to_char(first_time, 'YYYY/MM/dd') "Jour",
|
||||
count(*) "Nbr de fichiers",
|
||||
ROUND(sum(BLOCKS*BLOCK_SIZE)/1024/1024, 0) "Taille_Mo"
|
||||
from v$archived_log
|
||||
where first_time > systimestamp - 30
|
||||
group by to_char(first_time, 'YYYY/MM/dd')
|
||||
order by to_char(first_time, 'YYYY/MM/dd')
|
||||
;
|
||||
|
||||
select /* db-html-report */
|
||||
TO_CHAR(FIRST_TIME, 'YYYY/MM/dd') "Jour",
|
||||
COUNT(*) "Nbr de fichiers",
|
||||
ROUND(SUM(BLOCKS*BLOCK_SIZE)/1024/1024, 0) "Taille_Mo"
|
||||
FROM
|
||||
V$ARCHIVED_LOG
|
||||
WHERE
|
||||
FIRST_TIME > SYSTIMESTAMP - 30
|
||||
GROUP BY
|
||||
TO_CHAR(FIRST_TIME, 'YYYY/MM/dd')
|
||||
ORDER BY
|
||||
TO_CHAR(FIRST_TIME, 'YYYY/MM/dd');
|
||||
@@ -1,11 +1,36 @@
|
||||
prompt <h2>Fast Recovery Area Usage</h2>
|
||||
select 'Taille FRA MiB' as property, p.value / 1024 / 1024 as value from
|
||||
v$parameter p WHERE name = 'db_recovery_file_dest_size'
|
||||
union all
|
||||
select 'Espace utilise MiB' as property, round((p.value * tot_pct / 100) / 1024 / 1024, 0) as value from
|
||||
( SELECT SUM(percent_space_used) tot_pct FROM v$flash_recovery_area_usage ) , V$PARAMETER P
|
||||
WHERE name = 'db_recovery_file_dest_size'
|
||||
union all
|
||||
select 'Pourcentage utilise' as property, tot_pct as value from
|
||||
( SELECT SUM(percent_space_used) tot_pct FROM v$flash_recovery_area_usage )
|
||||
;
|
||||
|
||||
select /* db-html-report */
|
||||
'Taille FRA MiB' AS PROPERTY,
|
||||
P.VALUE / 1024 / 1024 AS VALUE
|
||||
FROM
|
||||
V$PARAMETER P
|
||||
WHERE
|
||||
NAME = 'db_recovery_file_dest_size'
|
||||
UNION
|
||||
ALL
|
||||
SELECT
|
||||
'Espace utilise MiB' AS PROPERTY,
|
||||
ROUND((P.VALUE * TOT_PCT / 100) / 1024 / 1024, 0) AS VALUE
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
SUM(PERCENT_SPACE_USED) TOT_PCT
|
||||
FROM
|
||||
V$FLASH_RECOVERY_AREA_USAGE
|
||||
) ,
|
||||
V$PARAMETER P
|
||||
WHERE
|
||||
NAME = 'db_recovery_file_dest_size'
|
||||
UNION
|
||||
ALL
|
||||
SELECT
|
||||
'Pourcentage utilise' AS PROPERTY,
|
||||
TOT_PCT AS VALUE
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
SUM(PERCENT_SPACE_USED) TOT_PCT
|
||||
FROM
|
||||
V$FLASH_RECOVERY_AREA_USAGE
|
||||
) ;
|
||||
@@ -1,2 +1,2 @@
|
||||
prompt <h2>Fast Recovery Area Usage</h2>
|
||||
SELECT * FROM V$FLASH_RECOVERY_AREA_USAGE;
|
||||
select /* db-html-report */ * FROM V$FLASH_RECOVERY_AREA_USAGE;
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
prompt <h2>Les dernières erreurs de la base de données (Les 30 derniers jours et les 50 dernières lignes)</h2>
|
||||
|
||||
-- set pages 99
|
||||
select to_char(ORIGINATING_TIMESTAMP, 'DD-MM-YYYY HH-MM-SS') "Date", message_text "Message"
|
||||
FROM X$DBGALERTEXT
|
||||
WHERE originating_timestamp > systimestamp - 30
|
||||
AND regexp_like(message_text, '(ORA-)')
|
||||
AND rownum <=50
|
||||
order by originating_timestamp desc;
|
||||
|
||||
select /* db-html-report */
|
||||
TO_CHAR(ORIGINATING_TIMESTAMP, 'DD-MM-YYYY HH24:MM:SS') "Date",
|
||||
MESSAGE_TEXT "Message"
|
||||
FROM
|
||||
X$DBGALERTEXT
|
||||
WHERE
|
||||
ORIGINATING_TIMESTAMP > SYSTIMESTAMP - 30
|
||||
AND REGEXP_LIKE(MESSAGE_TEXT, '(ORA-)')
|
||||
AND ROWNUM <=50
|
||||
ORDER BY
|
||||
ORIGINATING_TIMESTAMP DESC;
|
||||
@@ -1,2 +1,6 @@
|
||||
prompt <h2>Configuration RMAN: pramètres modifiés :</h2>
|
||||
select * from V$RMAN_CONFIGURATION;
|
||||
|
||||
select /* db-html-report */
|
||||
*
|
||||
FROM
|
||||
V$RMAN_CONFIGURATION;
|
||||
@@ -1,33 +1,30 @@
|
||||
prompt <h2>Les dernières sauvegardes RMAN (30 derniers jours/50 dernières lignes)</h2>
|
||||
alter session set nls_date_format='DD/MM/YYYY HH24:MI:SS' ;
|
||||
-- set linesize 250 heading off;
|
||||
-- set heading on pagesize 999;
|
||||
-- column status format a25;
|
||||
-- column input_bytes_display format a12;
|
||||
-- column output_bytes_display format a12;
|
||||
-- column device_type format a10;
|
||||
|
||||
SELECT
|
||||
b.SESSION_KEY "Session Key",
|
||||
b.input_type "Type",
|
||||
to_char(b.start_time, 'DD-MM-YYYY HH24:MI') "Start Time",
|
||||
to_char(b.end_time, 'DD-MM-YYYY HH24:MI') "End Time",
|
||||
to_char(trunc(sysdate) + numtodsinterval(ELAPSED_SECONDS, 'second'),'hh24:mi:ss') "Duration",
|
||||
b.output_device_type "Device Type",
|
||||
b.input_bytes_display "Input Bytes",
|
||||
b.output_bytes_display "Output Bytes",
|
||||
ALTER SESSION SET NLS_DATE_FORMAT='DD/MM/YYYY HH24:MI:SS';
|
||||
|
||||
select /* db-html-report */
|
||||
B.SESSION_KEY "Session Key",
|
||||
B.INPUT_TYPE "Type",
|
||||
TO_CHAR(B.START_TIME, 'DD-MM-YYYY HH24:MI') "Start Time",
|
||||
TO_CHAR(B.END_TIME, 'DD-MM-YYYY HH24:MI') "End Time",
|
||||
TO_CHAR(TRUNC(SYSDATE) + NUMTODSINTERVAL(ELAPSED_SECONDS, 'second'), 'hh24:mi:ss') "Duration",
|
||||
B.OUTPUT_DEVICE_TYPE "Device Type",
|
||||
B.INPUT_BYTES_DISPLAY "Input Bytes",
|
||||
B.OUTPUT_BYTES_DISPLAY "Output Bytes",
|
||||
CASE
|
||||
WHEN b.status = 'FAILED' THEN
|
||||
'<span class="highlight">' || b.status || '</span>'
|
||||
WHEN B.STATUS = 'FAILED' THEN
|
||||
'<span class="highlight">'
|
||||
|| B.STATUS
|
||||
|| '</span>'
|
||||
ELSE
|
||||
b.status
|
||||
END "Status"
|
||||
B.STATUS
|
||||
END "Status"
|
||||
FROM
|
||||
v$rman_backup_job_details b
|
||||
V$RMAN_BACKUP_JOB_DETAILS B
|
||||
WHERE
|
||||
b.start_time > ( sysdate - 30 )
|
||||
B.START_TIME > ( SYSDATE - 30 )
|
||||
AND ROWNUM <= 50
|
||||
ORDER BY
|
||||
b.SESSION_KEY desc;
|
||||
-- b.start_time DESC;
|
||||
B.SESSION_KEY DESC;
|
||||
|
||||
-- b.start_time DESC;
|
||||
@@ -1,5 +1,9 @@
|
||||
prompt <h2>SYSAUX Occupants</h2>
|
||||
SELECT /*+ NO_MERGE */
|
||||
v.*, ROUND(v.space_usage_kbytes / POWER(10,6), 3) space_usage_gbs
|
||||
FROM v$sysaux_occupants v
|
||||
ORDER BY 1;
|
||||
|
||||
select /* db-html-report */ /*+ NO_MERGE */
|
||||
V.*,
|
||||
ROUND(V.SPACE_USAGE_KBYTES / POWER(10, 6), 3) SPACE_USAGE_GBS
|
||||
FROM
|
||||
V$SYSAUX_OCCUPANTS V
|
||||
ORDER BY
|
||||
1;
|
||||
@@ -1,18 +1,19 @@
|
||||
prompt <h2>DBA Users </h2>
|
||||
set pages 999
|
||||
ALTER SESSION SET NLS_DATE_FORMAT ='YYYY/MM/DD HH24:MI';
|
||||
SELECT
|
||||
x.username,
|
||||
x.user_id,
|
||||
x.account_status,
|
||||
x.lock_date,
|
||||
x.expiry_date,
|
||||
x.default_tablespace,
|
||||
x.temporary_tablespace,
|
||||
x.created,
|
||||
x.profile,
|
||||
x.password_versions
|
||||
FROM dba_users x
|
||||
ORDER BY x.username
|
||||
;
|
||||
|
||||
ALTER SESSION SET NLS_DATE_FORMAT ='YYYY/MM/DD HH24:MI';
|
||||
|
||||
select /* db-html-report */
|
||||
X.USERNAME,
|
||||
X.USER_ID,
|
||||
X.ACCOUNT_STATUS,
|
||||
X.LOCK_DATE,
|
||||
X.EXPIRY_DATE,
|
||||
X.DEFAULT_TABLESPACE,
|
||||
X.TEMPORARY_TABLESPACE,
|
||||
X.CREATED,
|
||||
X.PROFILE,
|
||||
X.PASSWORD_VERSIONS
|
||||
FROM
|
||||
DBA_USERS X
|
||||
ORDER BY
|
||||
X.USERNAME;
|
||||
@@ -1,2 +1,9 @@
|
||||
prompt <h2>DBA_Profiles </h2>
|
||||
select * from DBA_Profiles order by profile, resource_name;
|
||||
|
||||
select /* db-html-report */
|
||||
*
|
||||
FROM
|
||||
DBA_PROFILES
|
||||
ORDER BY
|
||||
PROFILE,
|
||||
RESOURCE_NAME;
|
||||
@@ -1,16 +1,16 @@
|
||||
prompt <h2>Taille des objets par schéma (Mo):</h2>
|
||||
select
|
||||
ds.owner "Owner",
|
||||
round(sum(ds.bytes) / 1024 / 1024) "Schema Size MB",
|
||||
du.default_tablespace "Default Tablespace"
|
||||
from
|
||||
dba_segments ds,
|
||||
dba_users du
|
||||
where
|
||||
ds.OWNER = du.USERNAME
|
||||
group by
|
||||
ds.owner,
|
||||
du.default_tablespace
|
||||
order by
|
||||
ds.owner
|
||||
;
|
||||
|
||||
select /* db-html-report */
|
||||
DS.OWNER "Owner",
|
||||
ROUND(SUM(DS.BYTES) / 1024 / 1024) "Schema Size MB",
|
||||
DU.DEFAULT_TABLESPACE "Default Tablespace"
|
||||
FROM
|
||||
DBA_SEGMENTS DS,
|
||||
DBA_USERS DU
|
||||
WHERE
|
||||
DS.OWNER = DU.USERNAME
|
||||
GROUP BY
|
||||
DS.OWNER,
|
||||
DU.DEFAULT_TABLESPACE
|
||||
ORDER BY
|
||||
DS.OWNER;
|
||||
@@ -1,29 +1,39 @@
|
||||
-- Qui est connecté à la base :
|
||||
prompt <h2>Sessions Aggregate per User and Type</h2>
|
||||
WITH x as (
|
||||
SELECT COUNT(*),
|
||||
--con_id,
|
||||
username,
|
||||
inst_id,
|
||||
type,
|
||||
server,
|
||||
status,
|
||||
state
|
||||
FROM gv$session
|
||||
GROUP BY
|
||||
--con_id,
|
||||
username,
|
||||
inst_id,
|
||||
type,
|
||||
server,
|
||||
status,
|
||||
state
|
||||
|
||||
WITH X AS (
|
||||
select /* db-html-report */
|
||||
COUNT(*),
|
||||
--con_id,
|
||||
USERNAME,
|
||||
INST_ID,
|
||||
TYPE,
|
||||
SERVER,
|
||||
STATUS,
|
||||
STATE
|
||||
FROM
|
||||
GV$SESSION
|
||||
GROUP BY
|
||||
--con_id,
|
||||
USERNAME,
|
||||
INST_ID,
|
||||
TYPE,
|
||||
SERVER,
|
||||
STATUS,
|
||||
STATE
|
||||
)
|
||||
SELECT x.*
|
||||
--,c.name con_name
|
||||
FROM x
|
||||
--LEFT OUTER JOIN v$containers c ON c.con_id = x.con_id
|
||||
ORDER BY
|
||||
SELECT
|
||||
X.*
|
||||
--,c.name con_name
|
||||
FROM
|
||||
X
|
||||
--LEFT OUTER JOIN v$containers c ON c.con_id = x.con_id
|
||||
ORDER BY
|
||||
1 DESC,
|
||||
--x.con_id,
|
||||
x.username, x.inst_id, x.type, x.server, x.status, x.state;
|
||||
--x.con_id,
|
||||
X.USERNAME,
|
||||
X.INST_ID,
|
||||
X.TYPE,
|
||||
X.SERVER,
|
||||
X.STATUS,
|
||||
X.STATE;
|
||||
@@ -1,30 +1,41 @@
|
||||
prompt <h2>Sessions Aggregate per Module and Action</h2>
|
||||
WITH x AS (
|
||||
SELECT COUNT(*),
|
||||
--con_id,
|
||||
module,
|
||||
action,
|
||||
inst_id,
|
||||
type,
|
||||
server,
|
||||
status,
|
||||
state
|
||||
FROM gv$session
|
||||
GROUP BY
|
||||
--con_id,
|
||||
module,
|
||||
action,
|
||||
inst_id,
|
||||
type,
|
||||
server,
|
||||
status,
|
||||
state
|
||||
|
||||
WITH X AS (
|
||||
select /* db-html-report */
|
||||
COUNT(*),
|
||||
--con_id,
|
||||
MODULE,
|
||||
ACTION,
|
||||
INST_ID,
|
||||
TYPE,
|
||||
SERVER,
|
||||
STATUS,
|
||||
STATE
|
||||
FROM
|
||||
GV$SESSION
|
||||
GROUP BY
|
||||
--con_id,
|
||||
MODULE,
|
||||
ACTION,
|
||||
INST_ID,
|
||||
TYPE,
|
||||
SERVER,
|
||||
STATUS,
|
||||
STATE
|
||||
)
|
||||
SELECT x.*
|
||||
--,c.name con_name
|
||||
FROM x
|
||||
--LEFT OUTER JOIN v$containers c ON c.con_id = x.con_id
|
||||
ORDER BY
|
||||
1 DESC,
|
||||
--x.con_id,
|
||||
x.module, x.action, x.inst_id, x.type, x.server, x.status, x.state;
|
||||
SELECT
|
||||
X.*
|
||||
--,c.name con_name
|
||||
FROM
|
||||
X
|
||||
--LEFT OUTER JOIN v$containers c ON c.con_id = x.con_id
|
||||
ORDER BY
|
||||
1 DESC,
|
||||
--x.con_id,
|
||||
X.MODULE,
|
||||
X.ACTION,
|
||||
X.INST_ID,
|
||||
X.TYPE,
|
||||
X.SERVER,
|
||||
X.STATUS,
|
||||
X.STATE;
|
||||
@@ -1,9 +1,23 @@
|
||||
prompt <h2>Who is connected ? </h2>
|
||||
|
||||
set pages 999 lines 200
|
||||
col PROGRAM for a35
|
||||
col MACHINE for a20
|
||||
col OSUSER for a10
|
||||
alter session set nls_date_format='YYYY/MM/DD HH24:MI:SS';
|
||||
select OSUSER, MACHINE, PROGRAM, STATE, LOGON_TIME, EVENT from v$session order by LOGON_TIME asc;
|
||||
|
||||
col PROGRAM for a35
|
||||
|
||||
col MACHINE for a20
|
||||
|
||||
col OSUSER for a10
|
||||
|
||||
ALTER SESSION SET NLS_DATE_FORMAT='YYYY/MM/DD HH24:MI:SS';
|
||||
|
||||
select /* db-html-report */
|
||||
OSUSER,
|
||||
MACHINE,
|
||||
PROGRAM,
|
||||
STATE,
|
||||
LOGON_TIME,
|
||||
EVENT
|
||||
FROM
|
||||
V$SESSION
|
||||
ORDER BY
|
||||
LOGON_TIME ASC;
|
||||
@@ -1,3 +1,13 @@
|
||||
prompt <h2>Invalid objects</h2>
|
||||
select owner, count(*) "invalid objects" FROM dba_objects WHERE status <> 'VALID' group by owner order by owner;
|
||||
exit
|
||||
|
||||
select /* db-html-report */
|
||||
OWNER,
|
||||
COUNT(*) "invalid objects"
|
||||
FROM
|
||||
DBA_OBJECTS
|
||||
WHERE
|
||||
STATUS <> 'VALID'
|
||||
GROUP BY
|
||||
OWNER
|
||||
ORDER BY
|
||||
OWNER;
|
||||
|
||||
@@ -1,26 +1,31 @@
|
||||
prompt <h2>Les objets par utilisateur</h2>
|
||||
select * from
|
||||
(
|
||||
select owner, object_type ,count(*) as object_count from dba_objects
|
||||
where owner not in ('ANONYMOUS','APEX_180200','APEX_INSTANCE_ADMIN_USER','APEX_PUBLIC_USER','APPQOSSYS','AUDSYS','CTXSYS','DBSFWUSER','DBSNMP','DIP','DVF','DVSYS','FLOWS_FILES','GGSYS','GSMADMIN_INTERNAL','GSMCATUSER','GSMUSER','LBACSYS','MDDATA','MDSYS','OJVMSYS','OLAPSYS','ORACLE_OCM','ORDDATA','ORDPLUGINS','ORDSYS','OUTLN','REMOTE_SCHEDULER_AGENT','SI_INFORMTN_SCHEMA','SYS','SYS$UMF','SYSBACKUP','SYSDG','SYSKM','SYSRAC','SYSTEM','WMSYS','XDB','XS$NULL')
|
||||
group by owner, object_type order by owner, object_type
|
||||
)
|
||||
pivot
|
||||
|
||||
select /* db-html-report */
|
||||
*
|
||||
FROM
|
||||
(
|
||||
max(object_count)
|
||||
for object_type in (
|
||||
'TABLE',
|
||||
'VIEW',
|
||||
'INDEX',
|
||||
'FUNCTION',
|
||||
'LOB',
|
||||
'PACKAGE',
|
||||
'PROCEDURE',
|
||||
'TRIGGER',
|
||||
'SYNONYM'
|
||||
)
|
||||
)
|
||||
order by owner
|
||||
;
|
||||
|
||||
|
||||
SELECT
|
||||
OWNER,
|
||||
OBJECT_TYPE,
|
||||
COUNT(*) AS OBJECT_COUNT
|
||||
FROM
|
||||
DBA_OBJECTS
|
||||
WHERE
|
||||
OWNER NOT IN ('ANONYMOUS', 'APEX_180200', 'APEX_INSTANCE_ADMIN_USER', 'APEX_PUBLIC_USER', 'APPQOSSYS', 'AUDSYS', 'CTXSYS', 'DBSFWUSER', 'DBSNMP', 'DIP', 'DVF', 'DVSYS', 'FLOWS_FILES', 'GGSYS', 'GSMADMIN_INTERNAL', 'GSMCATUSER', 'GSMUSER', 'LBACSYS', 'MDDATA', 'MDSYS', 'OJVMSYS', 'OLAPSYS', 'ORACLE_OCM', 'ORDDATA', 'ORDPLUGINS', 'ORDSYS', 'OUTLN', 'REMOTE_SCHEDULER_AGENT', 'SI_INFORMTN_SCHEMA', 'SYS', 'SYS$UMF', 'SYSBACKUP', 'SYSDG', 'SYSKM', 'SYSRAC', 'SYSTEM', 'WMSYS', 'XDB', 'XS$NULL')
|
||||
GROUP BY
|
||||
OWNER,
|
||||
OBJECT_TYPE
|
||||
ORDER BY
|
||||
OWNER,
|
||||
OBJECT_TYPE
|
||||
) PIVOT ( MAX(OBJECT_COUNT) FOR OBJECT_TYPE IN ( 'TABLE',
|
||||
'VIEW',
|
||||
'INDEX',
|
||||
'FUNCTION',
|
||||
'LOB',
|
||||
'PACKAGE',
|
||||
'PROCEDURE',
|
||||
'TRIGGER',
|
||||
'SYNONYM' ) )
|
||||
ORDER BY
|
||||
OWNER;
|
||||
@@ -1,2 +1,9 @@
|
||||
prompt <h2>Statut des jobs autotask </h2>
|
||||
select client_name, status,attributes,service_name from dba_autotask_client;
|
||||
|
||||
select /* db-html-report */
|
||||
CLIENT_NAME,
|
||||
STATUS,
|
||||
ATTRIBUTES,
|
||||
SERVICE_NAME
|
||||
FROM
|
||||
DBA_AUTOTASK_CLIENT;
|
||||
@@ -1,40 +0,0 @@
|
||||
-- SCRIPT - to Set the 'SESSION_CACHED_CURSORS' and 'OPEN_CURSORS' Parameters Based on Usage (Doc ID 208857.1)
|
||||
prompt <h2>Sessions and Cursors usage </h2>
|
||||
select
|
||||
'session_cached_cursors' parameter,
|
||||
lpad(value, 5) value,
|
||||
decode(value, 0, ' n/a', to_char(100 * used / value, '990') || '%') usage
|
||||
from
|
||||
(
|
||||
select max(s.value) used
|
||||
from v$statname n, v$sesstat s
|
||||
where
|
||||
n.name = 'session cursor cache count'
|
||||
and s.statistic# = n.statistic#
|
||||
),
|
||||
(
|
||||
select value
|
||||
from v$parameter
|
||||
where name = 'session_cached_cursors'
|
||||
)
|
||||
union all
|
||||
select
|
||||
'open_cursors',
|
||||
lpad(value, 5),
|
||||
to_char(100 * used / value, '990') || '%'
|
||||
from
|
||||
(
|
||||
select max(sum(s.value)) used
|
||||
from v$statname n, v$sesstat s
|
||||
where
|
||||
n.name in ('opened cursors current') and
|
||||
s.statistic# = n.statistic#
|
||||
group by s.sid
|
||||
),
|
||||
(
|
||||
select value
|
||||
from v$parameter
|
||||
where name = 'open_cursors'
|
||||
)
|
||||
;
|
||||
|
||||
55
sql/35a_get_cursor_usage.sql
Normal file
55
sql/35a_get_cursor_usage.sql
Normal file
@@ -0,0 +1,55 @@
|
||||
-- SCRIPT - to Set the 'SESSION_CACHED_CURSORS' and 'OPEN_CURSORS' Parameters Based on Usage (Doc ID 208857.1)
|
||||
prompt <h2>Sessions and Cursors usage </h2>
|
||||
|
||||
select /* db-html-report */
|
||||
'session_cached_cursors' PARAMETER,
|
||||
LPAD(VALUE, 5) VALUE,
|
||||
DECODE(VALUE, 0, ' n/a', TO_CHAR(100 * USED / VALUE, '990')
|
||||
|| '%') USAGE
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
MAX(S.VALUE) USED
|
||||
FROM
|
||||
V$STATNAME N,
|
||||
V$SESSTAT S
|
||||
WHERE
|
||||
N.NAME = 'session cursor cache count'
|
||||
AND S.STATISTIC# = N.STATISTIC#
|
||||
),
|
||||
(
|
||||
SELECT
|
||||
VALUE
|
||||
FROM
|
||||
V$PARAMETER
|
||||
WHERE
|
||||
NAME = 'session_cached_cursors'
|
||||
)
|
||||
UNION
|
||||
ALL
|
||||
SELECT
|
||||
'open_cursors',
|
||||
LPAD(VALUE, 5),
|
||||
TO_CHAR(100 * USED / VALUE, '990')
|
||||
|| '%'
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
MAX(SUM(S.VALUE)) USED
|
||||
FROM
|
||||
V$STATNAME N,
|
||||
V$SESSTAT S
|
||||
WHERE
|
||||
N.NAME IN ('opened cursors current')
|
||||
AND S.STATISTIC# = N.STATISTIC#
|
||||
GROUP BY
|
||||
S.SID
|
||||
),
|
||||
(
|
||||
SELECT
|
||||
VALUE
|
||||
FROM
|
||||
V$PARAMETER
|
||||
WHERE
|
||||
NAME = 'open_cursors'
|
||||
);
|
||||
8
sql/35b_cursors_count.sql
Normal file
8
sql/35b_cursors_count.sql
Normal file
@@ -0,0 +1,8 @@
|
||||
prompt <h2>Curseurs par Session (sans les users SYS, SYSTEM, SYSMAN)</h2>
|
||||
|
||||
select /* db-html-report */ c.sid, s.username, count(*) open_cursors
|
||||
from gv$open_cursor c, gv$session s
|
||||
where s.sid = c.sid
|
||||
and s.username is not null and s.username not like 'SYS%'
|
||||
group by c.sid, s.username
|
||||
;
|
||||
@@ -1,7 +1,14 @@
|
||||
prompt <h2>Failed scheduled jobs </h2>
|
||||
SELECT owner, job_name, job_type, state, TRUNC(start_date) SDATE, TRUNC(next_run_date) NXTRUN, failure_count
|
||||
FROM dba_scheduler_jobs
|
||||
WHERE failure_count <> 0;
|
||||
|
||||
|
||||
|
||||
select /* db-html-report */
|
||||
OWNER,
|
||||
JOB_NAME,
|
||||
JOB_TYPE,
|
||||
STATE,
|
||||
TRUNC(START_DATE) SDATE,
|
||||
TRUNC(NEXT_RUN_DATE) NXTRUN,
|
||||
FAILURE_COUNT
|
||||
FROM
|
||||
DBA_SCHEDULER_JOBS
|
||||
WHERE
|
||||
FAILURE_COUNT <> 0;
|
||||
@@ -1,41 +1,53 @@
|
||||
prompt <h2>Table Statistics Summary</h2>
|
||||
alter session set nls_date_format='YYYY/MM/DD HH24:MI:SS';
|
||||
WITH x as (
|
||||
SELECT /*+ NO_MERGE */
|
||||
--con_id,
|
||||
owner,
|
||||
object_type,
|
||||
COUNT(*) type_count,
|
||||
SUM(DECODE(last_analyzed, NULL, 1, 0)) not_analyzed,
|
||||
SUM(DECODE(stattype_locked, NULL, 0, 1)) stats_locked,
|
||||
SUM(DECODE(stale_stats, 'YES', 1, 0)) stale_stats,
|
||||
SUM(num_rows) sum_num_rows,
|
||||
MAX(num_rows) max_num_rows,
|
||||
SUM(blocks) sum_blocks,
|
||||
MAX(blocks) max_blocks,
|
||||
MIN(last_analyzed) min_last_analyzed,
|
||||
MAX(last_analyzed) max_last_analyzed,
|
||||
MEDIAN(last_analyzed) median_last_analyzed,
|
||||
PERCENTILE_DISC(0.75) WITHIN GROUP (ORDER BY last_analyzed) last_analyzed_75_percentile,
|
||||
PERCENTILE_DISC(0.90) WITHIN GROUP (ORDER BY last_analyzed) last_analyzed_90_percentile,
|
||||
PERCENTILE_DISC(0.95) WITHIN GROUP (ORDER BY last_analyzed) last_analyzed_95_percentile,
|
||||
PERCENTILE_DISC(0.99) WITHIN GROUP (ORDER BY last_analyzed) last_analyzed_99_percentile
|
||||
FROM dba_tab_statistics s
|
||||
WHERE table_name NOT LIKE 'BIN$%' -- bug 9930151 reported by brad peek
|
||||
AND NOT EXISTS (
|
||||
SELECT /*+ NO_MERGE */ NULL
|
||||
FROM dba_external_tables e
|
||||
WHERE e.owner = s.owner
|
||||
--AND e.con_id = s.con_id
|
||||
AND e.table_name = s.table_name)
|
||||
GROUP BY
|
||||
--con_id,
|
||||
owner, object_type
|
||||
|
||||
ALTER SESSION SET NLS_DATE_FORMAT='YYYY/MM/DD HH24:MI:SS';
|
||||
|
||||
WITH X AS (
|
||||
select /* db-html-report */ /*+ NO_MERGE */
|
||||
--con_id,
|
||||
OWNER,
|
||||
OBJECT_TYPE,
|
||||
COUNT(*) TYPE_COUNT,
|
||||
SUM(DECODE(LAST_ANALYZED, NULL, 1, 0)) NOT_ANALYZED,
|
||||
SUM(DECODE(STATTYPE_LOCKED, NULL, 0, 1)) STATS_LOCKED,
|
||||
SUM(DECODE(STALE_STATS, 'YES', 1, 0)) STALE_STATS,
|
||||
SUM(NUM_ROWS) SUM_NUM_ROWS,
|
||||
MAX(NUM_ROWS) MAX_NUM_ROWS,
|
||||
SUM(BLOCKS) SUM_BLOCKS,
|
||||
MAX(BLOCKS) MAX_BLOCKS,
|
||||
MIN(LAST_ANALYZED) MIN_LAST_ANALYZED,
|
||||
MAX(LAST_ANALYZED) MAX_LAST_ANALYZED,
|
||||
MEDIAN(LAST_ANALYZED) MEDIAN_LAST_ANALYZED,
|
||||
PERCENTILE_DISC(0.75) WITHIN GROUP (ORDER BY LAST_ANALYZED) LAST_ANALYZED_75_PERCENTILE,
|
||||
PERCENTILE_DISC(0.90) WITHIN GROUP (ORDER BY LAST_ANALYZED) LAST_ANALYZED_90_PERCENTILE,
|
||||
PERCENTILE_DISC(0.95) WITHIN GROUP (ORDER BY LAST_ANALYZED) LAST_ANALYZED_95_PERCENTILE,
|
||||
PERCENTILE_DISC(0.99) WITHIN GROUP (ORDER BY LAST_ANALYZED) LAST_ANALYZED_99_PERCENTILE
|
||||
FROM
|
||||
DBA_TAB_STATISTICS S
|
||||
WHERE
|
||||
TABLE_NAME NOT LIKE 'BIN$%' -- bug 9930151 reported by brad peek
|
||||
AND NOT EXISTS (
|
||||
SELECT /*+ NO_MERGE */
|
||||
NULL
|
||||
FROM
|
||||
DBA_EXTERNAL_TABLES E
|
||||
WHERE
|
||||
E.OWNER = S.OWNER
|
||||
--AND e.con_id = s.con_id
|
||||
AND E.TABLE_NAME = S.TABLE_NAME
|
||||
)
|
||||
GROUP BY
|
||||
--con_id,
|
||||
OWNER,
|
||||
OBJECT_TYPE
|
||||
)
|
||||
SELECT x.*
|
||||
--,c.name con_name
|
||||
FROM x
|
||||
--LEFT OUTER JOIN v$containers c ON c.con_id = x.con_id
|
||||
ORDER BY
|
||||
--x.con_id,
|
||||
owner, object_type;
|
||||
SELECT
|
||||
X.*
|
||||
--,c.name con_name
|
||||
FROM
|
||||
X
|
||||
--LEFT OUTER JOIN v$containers c ON c.con_id = x.con_id
|
||||
ORDER BY
|
||||
--x.con_id,
|
||||
OWNER,
|
||||
OBJECT_TYPE;
|
||||
@@ -1,10 +1,11 @@
|
||||
prompt <h2>Dictionary Stats / Fixed Objects Stats</h2>
|
||||
|
||||
SELECT
|
||||
to_char(max(end_time),'dd/mm/yyyy hh24:mi') latest, operation
|
||||
select /* db-html-report */
|
||||
TO_CHAR(MAX(END_TIME), 'dd/mm/yyyy hh24:mi') LATEST,
|
||||
OPERATION
|
||||
FROM
|
||||
dba_optstat_operations
|
||||
DBA_OPTSTAT_OPERATIONS
|
||||
WHERE
|
||||
operation in ('gather_dictionary_stats', 'gather_fixed_objects_stats')
|
||||
OPERATION IN ('gather_dictionary_stats', 'gather_fixed_objects_stats')
|
||||
GROUP BY
|
||||
operation;
|
||||
OPERATION;
|
||||
15
sql/39_feature_usage_statistics.sql
Normal file
15
sql/39_feature_usage_statistics.sql
Normal file
@@ -0,0 +1,15 @@
|
||||
prompt <h2>Les options utilisée (à partir de DBA_FEATURE_USAGE_STATISTICS): </h2>
|
||||
|
||||
ALTER SESSION SET NLS_DATE_FORMAT='YYYY/MM/DD HH24:MI:SS';
|
||||
|
||||
select /* db-html-report */
|
||||
NAME,
|
||||
LAST_USAGE_DATE,
|
||||
DETECTED_USAGES,
|
||||
DESCRIPTION
|
||||
FROM
|
||||
DBA_FEATURE_USAGE_STATISTICS
|
||||
WHERE
|
||||
DETECTED_USAGES>0
|
||||
ORDER BY
|
||||
NAME;
|
||||
@@ -1,6 +1,12 @@
|
||||
prompt <h2>Liste des jobs dans : dba_jobs </h2>
|
||||
alter session set nls_date_format='YYYY/MM/DD HH24:MI:SS';
|
||||
SELECT * FROM dba_jobs;
|
||||
|
||||
prompt <h2>Liste des derniers jobs dans : CDB_SCHEDULER_JOB_LOG </h2>
|
||||
|
||||
ALTER SESSION SET NLS_DATE_FORMAT='YYYY/MM/DD HH24:MI:SS';
|
||||
|
||||
select /* db-html-report */
|
||||
* from
|
||||
(
|
||||
select log_date, owner, job_name, status
|
||||
from CDB_SCHEDULER_JOB_LOG
|
||||
order by log_date desc
|
||||
) where rownum <= 20
|
||||
;
|
||||
21
sql/41_sql_stat.sql
Normal file
21
sql/41_sql_stat.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
prompt <h2>Top SQL</h2>
|
||||
|
||||
select /* db-html-report */
|
||||
* from (
|
||||
select
|
||||
a.inst_id,
|
||||
a.sql_id,
|
||||
-- to_char(numtodsinterval(a.elapsed_time/ 1000000, 'SECOND'), 'HH24:MI') as elapsed,
|
||||
to_char(trunc(sysdate) + numtodsinterval(a.elapsed_time/ 1000000, 'SECOND'), 'HH24:MI:SS') as elapsed,
|
||||
substrb(replace(a.sql_text,'',' '),1,55) as sql_text,
|
||||
a.buffer_gets, -- Lecture en memoire
|
||||
a.disk_reads, -- Lecture sur disque
|
||||
round(a.physical_read_bytes /1024/1024) as physical_read_MB,
|
||||
a.executions,
|
||||
a.rows_processed,
|
||||
to_char(a.last_active_time, 'DD/MM/YYYY HH24:MI:SS') as last_active_time, -- Last time the statistics of a contributing cursor were updated
|
||||
b.module
|
||||
from gv$sqlstats a, gv$sql b
|
||||
where a.sql_id=b.sql_id
|
||||
order by a.elapsed_time desc
|
||||
) where rownum <= 25;
|
||||
@@ -1,21 +0,0 @@
|
||||
|
||||
<br />
|
||||
</body>
|
||||
|
||||
<script>
|
||||
function colorerMots(element) {
|
||||
const tds = document.querySelectorAll("td");
|
||||
for (const td of tds) {
|
||||
const text = td.textContent;
|
||||
const motsACouleur = ["Error", "Failed", "COMPLETED"];
|
||||
for (const mot of motsACouleur) {
|
||||
text = text.replace(mot, `<span style="color: red; background-color: yellow;">${mot}</span>`);
|
||||
}
|
||||
td.textContent = text;
|
||||
}
|
||||
}
|
||||
|
||||
colorerMots(element);
|
||||
|
||||
</script>
|
||||
</html>
|
||||
20
sql/cdb/01_show_pdbs.sql
Normal file
20
sql/cdb/01_show_pdbs.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
prompt <h2>Liste des PLuggables Databases</h2>
|
||||
|
||||
col application_root for a25
|
||||
col application_pdb for a25
|
||||
col application_seed for a25
|
||||
|
||||
select /* db-html-report */
|
||||
p.con_id,
|
||||
p.dbid,
|
||||
p.name,
|
||||
p.open_mode,
|
||||
p.restricted,
|
||||
p.open_time,
|
||||
p.application_root,
|
||||
p.application_pdb,
|
||||
p.application_seed
|
||||
FROM
|
||||
v$pdbs p
|
||||
ORDER BY
|
||||
con_id;
|
||||
7
sql/cdb/is_CDB.sh
Normal file
7
sql/cdb/is_CDB.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
#! /bin/sh
|
||||
|
||||
# Retourne YES ou NO selon que la base est une CDB ou non
|
||||
echo "
|
||||
SET PAGES 999 FEEDBACK OFF HEAD OFF
|
||||
select cdb from v\$database;
|
||||
exit" | sqlplus -s / as sysdba
|
||||
84
summary.sh
Normal file
84
summary.sh
Normal file
@@ -0,0 +1,84 @@
|
||||
#!/bin/bash
|
||||
#------------------------------------------------------------------------------
|
||||
# Ce script exécute des sql pour fournir une vue global de certains aspect de la base
|
||||
# tous les datafiles, toutes les sauvegardes, toutes les erreur dans alertlog, ...
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Importe les fonctions utilitaires
|
||||
# Le chemin est relatif au script appelant (rapport_bdd.sh)
|
||||
source "$(dirname "$0")/sh/utils.sh"
|
||||
|
||||
# Les variables DATETIME, HNAME, OUTPUT_DIR, et l'environnement .env sont déjà gérés par rapport_bdd.sh
|
||||
# On s'assure que OUTPUT_DIR est défini
|
||||
: "${OUTPUT_DIR:?OUTPUT_DIR not set by calling script}"
|
||||
: "${DATETIME:?DATETIME not set by calling script}"
|
||||
: "${HNAME:?HNAME not set by calling script}"
|
||||
|
||||
log_info "Début de l'exécution des scripts de synthèse."
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Execution des scripts sql de synthèse
|
||||
#------------------------------------------------------------------------------
|
||||
for sqlfile in summary/*.sql
|
||||
do
|
||||
# on prepare le fichier output
|
||||
FILENAME=$(basename "$sqlfile" | cut -d_ -f2)
|
||||
BASENAME="${FILENAME%.*}"
|
||||
HTML_FILE="${OUTPUT_DIR}/Summary_${BASENAME}_${HNAME}_${DATETIME}.html"
|
||||
|
||||
log_info "Génération du rapport de synthèse SQL pour ${FILENAME} dans ${HTML_FILE}"
|
||||
|
||||
# insertion du header HTML
|
||||
cat html/00_html_header.html > "${HTML_FILE}"
|
||||
|
||||
for sid in $(ps -eaf | grep pmon | egrep -v 'grep|ASM|APX1' | cut -d '_' -f3)
|
||||
do
|
||||
export ORAENV_ASK=NO
|
||||
export ORACLE_SID="$sid"
|
||||
# shellcheck source=/dev/null
|
||||
. oraenv -s > /dev/null
|
||||
|
||||
# ajout du nom de la base
|
||||
echo "<h3>Base de données : ${sid}</h3>" >> "${HTML_FILE}"
|
||||
# ajouter le resultat du script sql dans la page html
|
||||
# Utilise le sql_header.txt standard
|
||||
cat sql/sql_header.txt "$sqlfile" | sqlplus -s / as sysdba >> "${HTML_FILE}"
|
||||
done
|
||||
|
||||
# insertion du footer HTML
|
||||
cat html/99_html_footer.html >> "${HTML_FILE}"
|
||||
log_info "Rapport synthèse pour ${FILENAME} généré."
|
||||
echo "<p><a href=\"#top\">Retour en haut de page</a></p>" >> "${HTML_FILE}"
|
||||
done
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# exécution des scripts dans sh/local si présents
|
||||
#------------------------------------------------------------------------------
|
||||
LOCAL_DIR="sh/local"
|
||||
|
||||
if [ -d "$LOCAL_DIR" ]; then
|
||||
log_info "Détection du dossier local : ${LOCAL_DIR}"
|
||||
for shfile in "${LOCAL_DIR}"/*.sh
|
||||
do
|
||||
[ -f "$shfile" ] || continue
|
||||
# on prépare le fichier output
|
||||
FILENAME=$(basename "$shfile")
|
||||
BASENAME="${FILENAME%.*}"
|
||||
HTML_FILE="${OUTPUT_DIR}/Summary_${BASENAME}_${HNAME}_${DATETIME}.html"
|
||||
log_info "Génération du rapport de synthèse Shell pour ${FILENAME} dans ${HTML_FILE}"
|
||||
# insertion du header HTML
|
||||
cat html/00_html_header.html > "${HTML_FILE}"
|
||||
# Exécution du script local en utilisant run_and_print
|
||||
print_h2 "Résultat du script : ${FILENAME}" >> "${HTML_FILE}"
|
||||
# Le script shfile lui-même doit être exécuté, et il contient déjà ses propres print_h2/run_and_print
|
||||
# Donc, on l'exécute directement.
|
||||
bash "$shfile" >> "${HTML_FILE}"
|
||||
# insertion du footer HTML
|
||||
cat html/99_html_footer.html >> "${HTML_FILE}"
|
||||
log_info "Rapport synthèse pour ${FILENAME} généré."
|
||||
echo "<p><a href=\"#top\">Retour en haut de page</a></p>" >> "${HTML_FILE}"
|
||||
done
|
||||
else
|
||||
log_info "Aucun script local détecté dans ${LOCAL_DIR}."
|
||||
fi
|
||||
log_info "Fin de l'exécution des scripts de synthèse."
|
||||
93
summary/20_datafile.sql
Normal file
93
summary/20_datafile.sql
Normal file
@@ -0,0 +1,93 @@
|
||||
COL con_id HEAD "con_id"
|
||||
COL pdb_id HEAD "pdb_id"
|
||||
COL pdb_name HEAD "pdb_name"
|
||||
COL file_id HEAD "file_id"
|
||||
COL file_name HEAD "file_name"
|
||||
COL tablespace_name FORMAT A20 HEAD "tablespace"
|
||||
|
||||
COL file_size_mb FORMAT 999999999.00 HEAD "file_size_mb"
|
||||
COL percent_used FORMAT 999.00 HEAD "percent_used"
|
||||
COL space_used_mb FORMAT 999999999.00 HEAD "space_used_mb"
|
||||
COL space_free_mb FORMAT 999999999.00 HEAD "space_free_mb"
|
||||
COL maxsize_mb FORMAT 999999999.00 HEAD "maxsize_mb"
|
||||
|
||||
COL autoextensible FORMAT A15 HEAD "autoextensible"
|
||||
COL status head "status"
|
||||
COL online_status format a15 head "online_status"
|
||||
|
||||
WITH
|
||||
-- Sous-requête pour les fichiers de données dans une CDB
|
||||
cdb_files AS (
|
||||
-- cdb_files.sql
|
||||
SELECT
|
||||
p.con_id AS pdb_id,
|
||||
p.pdb_name AS pdb_name,
|
||||
d.file_id,
|
||||
d.tablespace_name,
|
||||
d.file_name,
|
||||
a.bytes_alloc/1024/1024 AS file_size_mb,
|
||||
ROUND((a.bytes_alloc - NVL(b.bytes_free, 0)) / a.maxbytes * 100, 2) AS percent_used,
|
||||
(a.bytes_alloc - NVL(b.bytes_free, 0))/1024/1024 AS space_used_mb,
|
||||
NVL(b.bytes_free, 0)/1024/1024 AS space_free_mb,
|
||||
a.maxbytes/1024/1024 AS maxsize_mb,
|
||||
d.autoextensible,
|
||||
d.status,
|
||||
d.online_status
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
f.file_id,
|
||||
SUM(f.bytes) AS bytes_alloc,
|
||||
SUM(DECODE(f.autoextensible, 'YES', f.maxbytes, 'NO', f.bytes)) AS maxbytes
|
||||
FROM cdb_data_files f GROUP BY file_id
|
||||
) a
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
f.file_id,
|
||||
SUM(f.bytes) AS bytes_free
|
||||
FROM cdb_free_space f GROUP BY file_id
|
||||
) b ON a.file_id = b.file_id
|
||||
JOIN cdb_data_files d ON a.file_id = d.file_id
|
||||
RIGHT JOIN cdb_pdbs p ON d.con_id = p.pdb_id
|
||||
WHERE
|
||||
(SELECT cdb FROM v$database) = 'YES'
|
||||
ORDER BY p.pdb_id, d.tablespace_name, d.file_name
|
||||
),
|
||||
-- Sous-requête pour les fichiers de données dans une non-CDB
|
||||
non_cdb_files AS (
|
||||
-- non_cdb_files.sql
|
||||
SELECT
|
||||
NULL AS pdb_id,
|
||||
NULL AS pdb_name,
|
||||
d.file_id,
|
||||
d.tablespace_name,
|
||||
d.file_name,
|
||||
a.bytes_alloc/1024/1024 AS file_size_mb,
|
||||
ROUND((a.bytes_alloc - NVL(b.bytes_free, 0)) / a.maxbytes * 100, 2) AS percent_used,
|
||||
(a.bytes_alloc - NVL(b.bytes_free, 0))/1024/1024 AS space_used_mb,
|
||||
NVL(b.bytes_free, 0)/1024/1024 AS space_free_mb,
|
||||
a.maxbytes/1024/1024 AS maxsize_mb,
|
||||
d.autoextensible,
|
||||
d.status,
|
||||
d.online_status
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
f.file_id,
|
||||
SUM(f.bytes) AS bytes_alloc,
|
||||
SUM(DECODE(f.autoextensible, 'YES', f.maxbytes, 'NO', f.bytes)) AS maxbytes
|
||||
FROM dba_data_files f GROUP BY file_id
|
||||
) a
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
f.file_id,
|
||||
SUM(f.bytes) AS bytes_free
|
||||
FROM dba_free_space f GROUP BY file_id
|
||||
) b ON a.file_id = b.file_id
|
||||
JOIN dba_data_files d ON a.file_id = d.file_id
|
||||
ORDER BY d.tablespace_name, d.file_name
|
||||
)
|
||||
-- Requête finale combinant les résultats des sous-requêtes
|
||||
SELECT * FROM cdb_files
|
||||
UNION ALL
|
||||
SELECT * FROM non_cdb_files;
|
||||
69
summary/21_tablespaces.sql
Normal file
69
summary/21_tablespaces.sql
Normal file
@@ -0,0 +1,69 @@
|
||||
prompt <h3>Détail des tablespaces : </h3>
|
||||
|
||||
COL TABLESPACE_NAME FORMAT A20 HEAD "tablespace"
|
||||
COL BIGFILE FORMAT A10 HEAD "bigfile"
|
||||
COL alloc FORMAT 99999999.00 HEAD "allocated_mb"
|
||||
COL used FORMAT 99999999.00 HEAD "used_mb"
|
||||
COL free FORMAT 99999999.00 HEAD "free_mb"
|
||||
COL max FORMAT 99999999.00 HEAD "maxsize_mb"
|
||||
COL Pct_Used FORMAT 999.00 HEAD "percent_used"
|
||||
|
||||
select
|
||||
a.tablespace_name,
|
||||
t.bigfile,
|
||||
a.bytes_alloc/1024/1024 alloc,
|
||||
(a.bytes_alloc - nvl(b.bytes_free, 0))/1024/1024 used,
|
||||
(nvl(b.bytes_free, 0))/1024/1024 free,
|
||||
maxbytes/1024/1024 Max,
|
||||
(a.bytes_alloc - nvl(b.bytes_free, 0)) / maxbytes * 100 Pct_Used
|
||||
from
|
||||
(
|
||||
select
|
||||
f.tablespace_name,
|
||||
sum(f.bytes) bytes_alloc,
|
||||
sum(decode(f.autoextensible, 'YES', f.maxbytes, 'NO', f.bytes)) maxbytes
|
||||
from
|
||||
dba_data_files f
|
||||
group by
|
||||
tablespace_name
|
||||
) a,
|
||||
(
|
||||
select
|
||||
f.tablespace_name,
|
||||
sum(f.bytes) bytes_free
|
||||
from
|
||||
dba_free_space f
|
||||
group by
|
||||
tablespace_name
|
||||
) b,
|
||||
dba_tablespaces t
|
||||
where
|
||||
a.tablespace_name = b.tablespace_name (+)
|
||||
and b.tablespace_name = t.tablespace_name
|
||||
union all
|
||||
select
|
||||
h.tablespace_name,
|
||||
dt.bigfile,
|
||||
(sum(h.bytes_free + h.bytes_used))/1024/1024 alloc,
|
||||
(sum(nvl(p.bytes_used, 0)))/1024/1024 used,
|
||||
(sum((h.bytes_free + h.bytes_used) - nvl(p.bytes_used, 0)))/1024/1024 free,
|
||||
(sum(f.maxbytes))/1024/1024 max,
|
||||
(sum(h.bytes_free + h.bytes_used) - sum((h.bytes_free + h.bytes_used) - nvl(p.bytes_used, 0))) / sum(f.maxbytes) Pct_Used
|
||||
from
|
||||
sys.v_$temp_space_header h,
|
||||
sys.v_$temp_extent_pool p,
|
||||
dba_temp_files f,
|
||||
dba_tablespaces dt
|
||||
where
|
||||
p.file_id(+) = h.file_id
|
||||
and p.tablespace_name(+) = h.tablespace_name
|
||||
and f.file_id = h.file_id
|
||||
and f.tablespace_name = h.tablespace_name
|
||||
and h.tablespace_name = dt.tablespace_name
|
||||
group by
|
||||
h.tablespace_name,
|
||||
dt.contents,
|
||||
dt.bigfile
|
||||
order by
|
||||
1
|
||||
;
|
||||
13
summary/22_alertlog_errors.sql
Normal file
13
summary/22_alertlog_errors.sql
Normal file
@@ -0,0 +1,13 @@
|
||||
prompt <h3>Les dernières erreurs de la base de données (Les 30 derniers jours et les 50 dernières lignes)</h3>
|
||||
|
||||
SELECT
|
||||
TO_CHAR(ORIGINATING_TIMESTAMP, 'DD-MM-YYYY HH24:MM:SS') "Date",
|
||||
MESSAGE_TEXT "Message"
|
||||
FROM
|
||||
X$DBGALERTEXT
|
||||
WHERE
|
||||
ORIGINATING_TIMESTAMP > SYSTIMESTAMP - 30
|
||||
AND REGEXP_LIKE(MESSAGE_TEXT, '(ORA-)')
|
||||
AND ROWNUM <=50
|
||||
ORDER BY
|
||||
ORIGINATING_TIMESTAMP DESC;
|
||||
28
summary/23_rman_backup.sql
Normal file
28
summary/23_rman_backup.sql
Normal file
@@ -0,0 +1,28 @@
|
||||
prompt <h3>Les dernières sauvegardes RMAN (30 derniers jours/50 dernières lignes)</h3>
|
||||
|
||||
ALTER SESSION SET NLS_DATE_FORMAT='DD/MM/YYYY HH24:MI:SS';
|
||||
|
||||
SELECT
|
||||
B.SESSION_KEY "Session Key",
|
||||
B.INPUT_TYPE "Type",
|
||||
TO_CHAR(B.START_TIME, 'DD-MM-YYYY HH24:MI') "Start Time",
|
||||
TO_CHAR(B.END_TIME, 'DD-MM-YYYY HH24:MI') "End Time",
|
||||
TO_CHAR(TRUNC(SYSDATE) + NUMTODSINTERVAL(ELAPSED_SECONDS, 'second'), 'hh24:mi:ss') "Duration",
|
||||
B.OUTPUT_DEVICE_TYPE "Device Type",
|
||||
B.INPUT_BYTES_DISPLAY "Input Bytes",
|
||||
B.OUTPUT_BYTES_DISPLAY "Output Bytes",
|
||||
CASE
|
||||
WHEN B.STATUS = 'FAILED' THEN
|
||||
'<span class="highlight">'
|
||||
|| B.STATUS
|
||||
|| '</span>'
|
||||
ELSE
|
||||
B.STATUS
|
||||
END "Status"
|
||||
FROM
|
||||
V$RMAN_BACKUP_JOB_DETAILS B
|
||||
WHERE
|
||||
B.START_TIME > ( SYSDATE - 30 )
|
||||
AND ROWNUM <= 50
|
||||
ORDER BY
|
||||
B.SESSION_KEY DESC;
|
||||
Reference in New Issue
Block a user