Regular expression ammendment - database

My regular expression needs tweaking in order to insert a newline after a match is found. Does anyone know how to achieve this please?
For example, when I run:
grep -A 2 -B 6 "^Errors: [1-9]" INC0108890.txt
This returns:
Backup Set: UNIX-SSH\rmg-devweb-03\Backup of web code and configuration\rmg-asigra
Performed by: Backup Schedule: Weekdays Backup (8pm)
Started at: May 10, 2022, 8:00:01 PM
Finished at: May 10, 2022, 8:27:17 PM
Completion: Backup completed with errors.
Warnings: 0
Errors: 1
Backed up files: 1,462
Total amount: 97,617 KB
Backup Set: MySQL\rmg-db-04\Backup of MySQL Databases\rmg-asigra
Performed by: Backup Schedule: Weekdays Backup (8pm)
Started at: May 10, 2022, 8:00:01 PM
Finished at: May 10, 2022, 8:00:05 PM
Completion: Backup completed with errors and warnings.
Warnings: 1
Errors: 1
Backed up files: 0
Total amount: 0 KB
--
Backup Set: UNIX-SSH\rmg-sysint-11\Backup of /server\rmg-asigra
Performed by: Backup Schedule: Weekdays Backup (8pm)
Started at: May 10, 2022, 8:00:01 PM
Finished at: May 10, 2022, 8:17:13 PM
Completion: Backup completed with errors.
Warnings: 0
Errors: 87
Backed up files: 248
Total amount: 3,752,207 KB
However, I desire an output as follows if anyone can advise please:
Backup Set: UNIX-SSH\rmg-devweb-03\Backup of web code and configuration\rmg-asigra
Performed by: Backup Schedule: Weekdays Backup (8pm)
Started at: May 10, 2022, 8:00:01 PM
Finished at: May 10, 2022, 8:27:17 PM
Completion: Backup completed with errors.
Warnings: 0
Errors: 1
Backed up files: 1,462
Total amount: 97,617 KB
Backup Set: MySQL\rmg-db-04\Backup of MySQL Databases\rmg-asigra
Performed by: Backup Schedule: Weekdays Backup (8pm)
Started at: May 10, 2022, 8:00:01 PM
Finished at: May 10, 2022, 8:00:05 PM
Completion: Backup completed with errors and warnings.
Warnings: 1
Errors: 1
Backed up files: 0
Total amount: 0 KB
Backup Set: UNIX-SSH\rmg-sysint-11\Backup of /server\rmg-asigra
Performed by: Backup Schedule: Weekdays Backup (8pm)
Started at: May 10, 2022, 8:00:01 PM
Finished at: May 10, 2022, 8:17:13 PM
Completion: Backup completed with errors.
Warnings: 0
Errors: 87
Backed up files: 248
Total amount: 3,752,207 KB

--group-separator=$'\n' should do the trick.

Related

Calculating running (cumulative) sum with start and end dates over time

I'm looking for a way to calculate recurring revenue over time in a time plot where the X-axis is the date and Y-axis is the total amount of revenue (sum). The question we're trying to answer is "At any given point in time, what is the total amount of revenue coming in?"
Every line in the source data has an account name, subscription type (new, renewal, expansion), annual subscription amount, service start date, and service end date.
[Sample of data below]
Account
Type
Subscription Amount
Service Start
Service End
001
New
$ 1000
Jan 1, 2020
Dec 31, 2021
002
New
$ 2000
Feb 1, 2020
Jan 31, 2021
003
New
$ 3000
Apr 1, 2020
Mar 1, 2022
001
Expansion
$ 500
May 1, 2020
Dec 31, 2021
002
Renewal
$ 2500
Feb 1, 2021
Jan 31, 2023
004
New
$ 1000
Mar 1, 2021
Feb 28, 2023
002
Expansion
$ 250
Jun 1, 2021
Jan 31, 2023
001
Renewal
$ 1500
Jan 1, 2022
Dec 31, 2023
The main issue I'm running into is that when using either running sum or "cumulative" under the time plot settings panel, the total will continue running on the X-axis regardless of the service end date. This is a problem for situations like Account 002, which renews Feb 1st, 2021. Data Studio would (incorrectly) show an amount of $4500 for that account starting on Feb 1st -- where I want it to show only $2500 at that time.
Comparing what the data should be showing at any point in time vs. what actually happens:
Date
Amount I want to see
What is currently calculated
Jan 1, 2020
$ 1000
$ 1000
Feb 1, 2020
$ 3000
$ 3000
Apr 1, 2020
$ 6000
$ 6000
May 1, 2020
$ 6500
$ 6500
Feb 1, 2021
$ 7000
$ 9000
Mar 1, 2021
$ 8000
$ 10,000
Jun 1, 2021
$ 8250
$ 10,250
Jan 1, 2022
$ 8250
$ 11,750
Jan 1, 2023
$ 5250
$ 11,750
Is there a way to achieve this?
Ideally, the most elegant solution seems to be to tell the plot to only sum between dates (i.e. sum if "reported x-axis date" is between Service Start date and Service End date), but I don't know how to reference the X-axis value in a formula.
I have not yet tried blending the data but I'm thinking that may be another path forward as well?
Any help on this would be much appreciated!

SQL JOB schedule: how to skip certain month

I need a report that runs once on the following month below:
JAN,FEB,APR,MAY,JUL,AUG,OCT,NOV (essentially skipping MAR, JUN, SEP and DEC)
and this is how I do it (I had to have two schedules to achieve it: See screenshot below). and My question does my two-schedule method will get me what I need? is there a better way?
Will this still work in 2024, 2025 and so on?
thanks
The only difference between the schedule is the start date.
THE FIRST Schedule ( I am hoping this report will run on JAN APR JUL OCT)
The second Schedule: ( And the second schedule, I am hoping it will run on FEB MAY AUG NOV)
Simply have a single job that executes monthly and in the t-sql job step
if month(getdate()) in (1,2,4,5,7,8,10,11)
begin
exec...
end

Why does Redis save partial data sets?

Version: Redis 5.0.3
In redis.conf there is an option to set snapshot period. I set this period as every 5 sec if one value is changed to see the Redis performance when it dumps. I ran two application; one is redis-server and the other is redis-benchmark.
While I was watching a log, I found out some interesting thing like below.
7269:C 27 Feb 2019 14:48:39.463 * RDB: 4535 MB of memory used by copy-on-write
7257:M 27 Feb 2019 14:48:39.939 * Background saving terminated with success
7257:M 27 Feb 2019 14:48:45.085 * 10 changes in 5 seconds. Saving...
7257:M 27 Feb 2019 14:48:45.187 * Background saving started by pid 7270
7270:C 27 Feb 2019 14:49:00.313 * DB saved on disk
7270:C 27 Feb 2019 14:49:00.401 * RDB: 4535 MB of memory used by copy-on-write
7257:M 27 Feb 2019 14:49:00.882 * Background saving terminated with success
7257:M 27 Feb 2019 14:49:06.011 * 10 changes in 5 seconds. Saving...
7257:M 27 Feb 2019 14:49:06.114 * Background saving started by pid 7271
7271:C 27 Feb 2019 14:49:21.086 * DB saved on disk
7271:C 27 Feb 2019 14:49:21.173 * RDB: 4534 MB of memory used by copy-on-write
7257:M 27 Feb 2019 14:49:21.706 * Background saving terminated with success
7257:M 27 Feb 2019 14:49:27.048 * 10 changes in 5 seconds. Saving...
7257:M 27 Feb 2019 14:49:27.155 * Background saving started by pid 7273
7273:C 27 Feb 2019 14:49:42.295 * DB saved on disk
7273:C 27 Feb 2019 14:49:42.382 * RDB: 4529 MB of memory used by copy-on-write
7257:M 27 Feb 2019 14:49:42.846 * Background saving terminated with success
7257:M 27 Feb 2019 14:49:48.023 * 10 changes in 5 seconds. Saving...
7257:M 27 Feb 2019 14:49:48.126 * Background saving started by pid 7274
7274:C 27 Feb 2019 14:50:05.251 * DB saved on disk
7274:C 27 Feb 2019 14:50:05.367 * RDB: 15 MB of memory used by copy-on-write
7257:M 27 Feb 2019 14:50:05.583 * Background saving terminated with success
As you can see, the dumped data has almost same size with others and the last one is even little. The thing that I don't understand is why the size is the same and why the last one has small size. (While the redis is dumping, the client requests set operation and the last dump probably means the end of set operation and start of get operation.)
To find out the reason, I look up the code but still don't know why the number has shown like above.
If you see rdb.c in the redis package, you can find this kind of source code.
int rdbSave(char *filename, rdbSaveInfo *rsi) {
...
snprintf(tmpfile, 256, "temp-%d.rdb", (int) getpid());
fp = fopen(tmpfile, "w");
...
rdbSaveRio(...);
}
From my understanding, everytime redis dumps the in-memory data, it should overwrite the previous saved data and this data should be lager than before. However, based on the log, the size is not linearly increased and even it is decreased at the last dump.
Am I missing some part of Redis features?
Edit
According to the comment, I definitely misinterpreted the logs. However, I still have a question about the performance. When snapshotting happens and if there are private dirty memories, the system saves them into the disk. In this point, based on the Redis dump mechanism, although the system sees the private dirty memory caused by set operation and only records this number on the log, it saves the all data from the memory. It means that everytime dumping happens, the size of disk expands and I'm pretty sure that it would lead to worse performance. But, when I see the result of benchmark, I can see the same performance drop despite of increasing disk size. I wonder why this shows the same drop rate and what is going on internally.
graph
In the above graph, the blue line indicates the throughput and you can see that it drops when snapshot happens and you can also notice that even though the second drop phase saves the larger disk size than the first phase, the drop rate is the same. So, my question would be is performance only affected by the private memory saving?

sqlite3 transaction on 200 columns table takes long to complete sporadically

I am using sqlite3 as db manager for my application, developed on a rapsberry pi3.
My table is composed of around 200 columns (not so much), mostly boolean and numeric fields.
I add a (complete) record every minute. DB is accessed in a C program using transactions.
the transaction includes one insert and 6 updates (to maintain the code readable), avoiding to write a very long single insertion query.
The db file is on the filesystem (hence on the sd card) inside the home folder.
Every transsaction the db is opened, the pragmas
PRAGMA synchronous = NORMAL;
PRAGMA journal_mode = WAL;
are set and the query is performed.
I have good performance averagely but from the timing log I see a peak every once in a while.
Extract of the log is reported:
Apr 28 07:06:13 db write took 45.200000 ms
Apr 28 07:07:13 db commit took 0.302000 ms
Apr 28 07:07:13 db write took 75.858000 ms
Apr 28 07:08:13 db commit took 0.354000 ms
Apr 28 07:08:13 db write took 75.395000 ms
Apr 28 07:09:13 db commit took 0.268000 ms
Apr 28 07:09:13 db write took 40.620000 ms
Apr 28 07:10:13 db commit took 0.437000 ms
Apr 28 07:10:13 db write took 81.910000 ms
Apr 28 07:11:13 db commit took 0.205000 ms
Apr 28 07:11:13 db write took 43.315000 ms
Apr 28 07:12:13 db commit took 0.301000 ms
Apr 28 07:12:13 db write took 75.456000 ms
Apr 28 07:13:15 db commit took 1872.488000 ms <-----
Apr 28 07:13:15 db write took 1951.572000 ms <-----
Apr 28 07:14:13 db commit took 7.934000 ms
Apr 28 07:14:13 db write took 62.853000 ms
Apr 28 07:15:13 db commit took 0.274000 ms
Apr 28 07:15:13 db write took 80.568000 ms
Apr 28 07:16:13 db commit took 0.277000 ms
The arrow points to one of the time peak that are recurring (with variable periods) during the execution.
To bettere understand the situation, analyzing the benchmark I had two peaks in the last 12 hours, one is about 1 sec (not reported) and this one.
Could the time peaks happen because of filesystem activity on the sd?
Could making a different partition on the sd card have an impact on such performance?
Is there any other pragma that could protect my application from this behaviour?
Adding the pragmas has significantly improved the situation so far but I think is not acceptable yet.
Thanks for your time and patience.
Any hint is welcomed.
Regards,
mopyot
The database regularly moves the data from the write-ahead log into the actual database file; this is called checkpointing:
By default, SQLite will automatically checkpoint whenever a COMMIT occurs that causes the WAL file to be 1000 pages or more in size, or when the last database connection on a database file closes. […]
But programs that want more control can force a checkpoint using the wal_checkpoint pragma … The automatic checkpoint threshold can be changed or automatic checkpointing can be completely disabled using the wal_autocheckpoint pragma …

Oracle db stops working frequently

Recently, I faced a problem with Oracle 11g. It stops working frequently, every few hours, and respectively, must be started again. This was never happened before, it just began during last month.
Here is the content of clsc.log file
2016-10-06 07:00:14.344: [ default][2031720192]utgdv:2:ocr loc file /etc/oracle/olr.loc cannot be opened. errno 2
[ CLSE][2031720192]clse_get_crs_home: Error retrieving OLR configuration [0] [Error opening olr.loc file. No such file or directory]
Can anyone help me?
Edit: There is alert log messages like here, each time instance has stopped working (In this case, it has stopped working on Wed night and started again on Thu)
Thread 1 advanced to log sequence 35012 (LGWR switch)
Current log# 2 seq# 35012 mem# 0: /home/db/app/oracle/oradata/orcl/redo02.log
Wed Oct 05 18:53:08 2016
Thread 1 advanced to log sequence 35013 (LGWR switch)
Current log# 3 seq# 35013 mem# 0: /home/db/app/oracle/oradata/orcl/redo03.log
Wed Oct 05 19:05:08 2016
Thread 1 advanced to log sequence 35014 (LGWR switch)
Current log# 1 seq# 35014 mem# 0: /home/db/app/oracle/oradata/orcl/redo01.log
Wed Oct 05 19:15:03 2016
Thread 1 advanced to log sequence 35015 (LGWR switch)
Current log# 2 seq# 35015 mem# 0: /home/db/app/oracle/oradata/orcl/redo02.log
Thu Oct 06 06:41:11 2016
Starting ORACLE instance (normal)
LICENSE_MAX_SESSION = 0
LICENSE_SESSIONS_WARNING = 0
Picked latch-free SCN scheme 3
Using LOG_ARCHIVE_DEST_1 parameter default value as USE_DB_RECOVERY_FILE_DEST
Autotune of undo retention is turned on.
.
.
.

Resources