Skip to content

Commit 31c1439

Browse files
Merge pull request #246762 from Phil-Jensen/main
Change mainlog-watcher.sh example to work with RHEL
2 parents 9008b26 + 0219d2f commit 31c1439

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

articles/azure-netapp-files/azacsnap-tips.md

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ms.service: azure-netapp-files
1212
ms.workload: storage
1313
ms.tgt_pltfrm: na
1414
ms.topic: how-to
15-
ms.date: 05/04/2023
15+
ms.date: 07/30/2023
1616
ms.author: phjensen
1717
---
1818

@@ -26,12 +26,12 @@ AzAcSnap 8 introduced a new global settings file (`.azacsnaprc`) which must be l
2626

2727
Settings, which can be controlled by adding/editing the global settings file are:
2828

29-
- **MAINLOG_LOCATION** which sets the location of the "mainlog" output file, which is called `azacsnap.log` and was introduced in AzAcSnap 8. Values should be absolute paths, for example:
29+
- **MAINLOG_LOCATION** which sets the location of the "main-log" output file, which is called `azacsnap.log` and was introduced in AzAcSnap 8. Values should be absolute paths, for example:
3030
- `MAINLOG_LOCATION=/home/azacsnap/bin/logs`
3131

32-
## Mainlog parsing
32+
## Main-log parsing
3333

34-
AzAcSnap 8 introduced a new "mainlog" to provide simpler parsing of runs of AzAcSnap. The inspiration for this file is the SAP HANA backup catalog, which shows when AzAcSnap was started, how long it took, and what the snapshot name is. With AzAcSnap, this idea has been taken further to include information for each of the AzAcSnap commands, specifically the `-c` options, and the file has the following headers:
34+
AzAcSnap 8 introduced a new "main-log" to provide simpler parsing of runs of AzAcSnap. The inspiration for this file is the SAP HANA backup catalog, which shows when AzAcSnap was started, how long it took, and what the snapshot name is. With AzAcSnap, this idea has been taken further to include information for each of the AzAcSnap commands, specifically the `-c` options, and the file has the following headers:
3535

3636
```output
3737
DATE_TIME,OPERATION_NAME,STATUS,SID,DATABASE_TYPE,DURATION,SNAPSHOT_NAME,AZACSNAP_VERSION,AZACSNAP_CONFIG_FILE,VOLUME
@@ -57,7 +57,18 @@ This format makes the file parse-able with the Linux commands `watch`, `grep`, `
5757
# Monitor execution of AzAcSnap backup commands
5858
#
5959
# These values can be modified as appropriate.
60-
HEADER_VALUES_TO_EXCLUDE="AZACSNAP_VERSION,VOLUME,AZACSNAP_CONFIG_FILE"
60+
# Mainlog header fields:
61+
# 1. DATE_TIME,
62+
# 2. OPERATION_NAME,
63+
# 3. STATUS,
64+
# 4. SID,
65+
# 5. DATABASE_TYPE,
66+
# 6. DURATION,
67+
# 7. SNAPSHOT_NAME,
68+
# 8. AZACSNAP_VERSION,
69+
# 9. AZACSNAP_CONFIG_FILE,
70+
# 10. VOLUME
71+
FIELDS_TO_INCLUDE="1,2,3,4,5,6,7"
6172
SCREEN_REFRESH_SECS=2
6273
#
6374
# Use AzAcSnap global settings file (.azacsnaprc) if available,
@@ -74,6 +85,7 @@ echo "Changing current working directory to ${MAINLOG_LOCATION}"
7485
# Default MAINLOG filename.
7586
MAINLOG_FILENAME="azacsnap.log"
7687
#
88+
echo "Parsing '${MAINLOG_FILENAME}'"
7789
# High-level explanation of how commands used.
7890
# `watch` - continuously monitoring the command output.
7991
# `column` - provide pretty output.
@@ -84,16 +96,10 @@ watch -t -n ${SCREEN_REFRESH_SECS} \
8496
echo -n "Monitoring AzAcSnap @ "; \
8597
date ; \
8698
echo ; \
87-
column -N"$(head -n1 ${MAINLOG_FILENAME})" \
88-
-d -H "${HEADER_VALUES_TO_EXCLUDE}" \
89-
-s"," -t ${MAINLOG_FILENAME} \
90-
| head -n1 ; \
91-
grep -e "DATE" -e "backup" ${MAINLOG_FILENAME} \
92-
| column -N"$(head -n1 ${MAINLOG_FILENAME})" \
93-
-d -H "${HEADER_VALUES_TO_EXCLUDE}" \
94-
-s"," -t \
95-
| tail -n +2 \
96-
| tail -n 12 \
99+
cat ${MAINLOG_FILENAME} \
100+
| grep -e "DATE" -e ",backup," \
101+
| ( sleep 1; head -n1 - ; sleep 1; tail -n+2 - | tail -n20; sleep 1 ) \
102+
| cut -f${FIELDS_TO_INCLUDE} -d"," | column -s"," -t
97103
"
98104
```
99105

@@ -232,7 +238,7 @@ compress
232238
}
233239
```
234240

235-
After creating the `logrotate.conf` file, the `logrotate` command should be run regularly to archive AzAcSnap log files accordingly. Automating the `logrotate` command can be done using cron. The following output is one line of the azacsnap user's crontab, this example runs logrotate daily using the configuration file `~/logrotate.conf`.
241+
After the `logrotate.conf` file has been created, the `logrotate` command should be run regularly to archive AzAcSnap log files accordingly. Automating the `logrotate` command can be done using cron. The following output is one line of the azacsnap user's crontab, this example runs logrotate daily using the configuration file `~/logrotate.conf`.
236242

237243
```output
238244
@daily /usr/sbin/logrotate -s ~/logrotate.state ~/logrotate.conf >> ~/logrotate.log
@@ -263,7 +269,7 @@ ls -ltra ~/bin/logs
263269
The following conditions should be monitored to ensure a healthy system:
264270

265271
1. Available disk space. Snapshots slowly consume disk space based on the block-level change rate, as keeping older disk blocks are retained in the snapshot.
266-
1. To help automate disk space management, use the `--retention` and `--trim` options to automatically cleanup the old snapshots and database log files.
272+
1. To help automate disk space management, use the `--retention` and `--trim` options to automatically clean up the old snapshots and database log files.
267273
1. Successful execution of the snapshot tools
268274
1. Check the `*.result` file for the success or failure of the latest running of `azacsnap`.
269275
1. Check `/var/log/messages` for output from the `azacsnap` command.
@@ -447,7 +453,7 @@ A 'boot' snapshot can be recovered as follows:
447453
1. The customer needs to shut down the server.
448454
1. After the Server is shut down, the customer will need to open a service request that contains the Machine ID and Snapshot to restore.
449455
> Customers can open a service request via the [Azure portal](https://portal.azure.com).
450-
1. Microsoft restores the Operating System LUN using the specified Machine ID and Snapshot, and then boot the Server.
456+
1. Microsoft restores the Operating System LUN using the specified Machine ID and Snapshot, and then boots the Server.
451457
1. The customer then needs to confirm Server is booted and healthy.
452458

453459
No other steps to be performed after the restore.

0 commit comments

Comments
 (0)