Skip to content
This repository has been archived by the owner on Jul 26, 2024. It is now read-only.

Logging Level option #319

Closed
greggitter opened this issue Apr 12, 2022 · 4 comments · Fixed by #330
Closed

Logging Level option #319

greggitter opened this issue Apr 12, 2022 · 4 comments · Fixed by #330
Assignees
Labels
enhancement New feature or request

Comments

@greggitter
Copy link

This might be more of a question than an enhancement request as there may be a way to achieve these already. My piholes are mostly static and rarely ever change. I noticed in /var/log/syslog there is quite a bit of writing indicating updates are occurring in 4.0.0 per your note, at an interval of < 5 minutes. In my situation this is overkill, even for when I make a change, I can for the most part make a white list change in two places if it's critical or run a manual sync. So I guess there are two questions, 1) can a logging level be set or can a separate log file be used for gravity-sync to minimize overloading the syslog? And 2) is there a way to reduce the frequency of updates to say once every x number of minutes rather than the default.

Thanks for providing a great product, really nice to have! :)

@vmstan
Copy link
Owner

vmstan commented Apr 12, 2022

I don't have a log level option, but you can manually decrease the frequency of replication by modifying the gravity-sync.timer file in /etc/systemd/ and reloading the systemd daemon. There should be randomly generated values for the timer and the offset in there now.

My environment is probably equally as static. I thought about including an option to be less aggressive in the timers and may still do it in the future. It seemed like everyone was always wanting replication to go faster with the old system so that's what I did.

One of the things I was attempting with the rewrite was eliminating as many options as I could get away with, and then only putting back what was needed. 😊

@vmstan vmstan self-assigned this Apr 12, 2022
@vmstan vmstan added the enhancement New feature or request label Apr 12, 2022
@greggitter
Copy link
Author

Thanks for the very quick reply, got it tested and timer mod is working (changed to one hour). I also made a change to the service file to drop the log data into its own file which for me is better as I tend to scan syslog periodically looking for anomalies. To do this, in the service section I added two lines to route the output as such, but noticed the time stamp is omitted at the beginning of each line....that might be a feature of syslog.

[Service]
Type=simple
User=pi
StandardOutput=file:/var/log/gravity-sync.log
StandardError=file:/var/log/gravity-sync.log
ExecStart=/usr/local/bin/gravity-sync

Also, I did notice some odd escape characters showing in my log output as such prior to making changes:

Apr 12 10:10:57 Rpi-1 gravity-sync[861824]: #33[0;95m∞#33[0m #33[1mInitializing Gravity Sync (4.0.0)#33[0m
Apr 12 10:10:57 Rpi-1 gravity-sync[861824]: #33[0;96m∞#33[0m Loading gravity-sync.conf#015#033[0;92m✓#33[0m Loading gravity-sync.conf
Apr 12 10:10:57 Rpi-1 gravity-sync[861824]: #33[0;96m∞#33[0m Detecting local Pi-hole installation#015#033[0;92m✓#33[0m Detecting local Pi-hole installation
Apr 12 10:10:57 Rpi-1 gravity-sync[861824]: #33[0;96m∞#33[0m Detecting remote Pi-hole installation#015#033[0;92m✓#33[0m Detecting remote Pi-hole installation
Apr 12 10:10:57 Rpi-1 gravity-sync[861824]: #33[0;96m∞#33[0m Checking on peer#015#033[0;92m✓#33[0m Gravity Sync remote peer is configured
Apr 12 10:10:57 Rpi-1 gravity-sync[861824]: #33[0;96m∞#33[0m Evaluating arguments#015#033[0;92m✓#33[0m Evaluating arguments: SMART
Apr 12 10:10:57 Rpi-1 gravity-sync[861824]: #33[0;93m»#33[0m #33[0;93mRemote Pi-hole: [email protected]#033[0m
Apr 12 10:10:57 Rpi-1 gravity-sync[861824]: #33[0;96m∞#33[0m Validating pathways to Pi-hole#015#033[0;92m✓#33[0m Validating pathways to Pi-hole
Apr 12 10:10:57 Rpi-1 gravity-sync[861824]: #33[0;96m∞#33[0m Validating pathways to DNSMASQ#015#033[0;92m✓#33[0m Validating pathways to DNSMASQ
Apr 12 10:10:57 Rpi-1 gravity-sync[861824]: #33[0;93m»#33[0m #33[0;93mStarting SMART Analysis#033[0m
Apr 12 10:10:58 Rpi-1 gravity-sync[861824]: #33[0;96m∞#33[0m Hashing the remote Gravity Database#015#033[0;92m✓#33[0m Hashing the remote Gravity Database
Apr 12 10:10:58 Rpi-1 gravity-sync[861824]: #33[0;96m∞#33[0m Comparing to the local Gravity Database#015#033[0;92m✓#33[0m Comparing to the local Gravity Database
Apr 12 10:10:58 Rpi-1 gravity-sync[861824]: #33[0;96m∞#33[0m Hashing the remote DNS Records#015#033[0;92m✓#33[0m Hashing the remote DNS Records
Apr 12 10:10:58 Rpi-1 gravity-sync[861824]: #33[0;96m∞#33[0m Comparing to the local DNS Records#015#033[0;92m✓#33[0m Comparing to the local DNS Records
Apr 12 10:10:59 Rpi-1 gravity-sync[861824]: #33[0;95m!#33[0m #33[0;95mDNS CNAMEs not detected on the local Pi-hole#033[0m
Apr 12 10:10:59 Rpi-1 gravity-sync[861824]: #33[0;95m!#33[0m #33[0;95mNo replication is required at this time#033[0m
Apr 12 10:10:59 Rpi-1 gravity-sync[861824]: #33[0;95m∞#33[0m #33[1mGravity Sync SMART exited after 2 seconds#033[0m

Again, thanks for all your time spent on cool utility.

@vmstan
Copy link
Owner

vmstan commented Apr 12, 2022

I have baked this into 4.0.2 which you can try as a beta.

Update your existing install. gravity-sync update
Then run gravity-sync beta and type origin/4.0.2 into the prompt, from the list of options.

This should get you the beta for 4.0.2 that is running on a different branch right now.

In this version you can do gravity-sync auto slow which will set the replication timers to roughly an hour, give or take. You can also try gravity-sync auto half which will do a half an hour, give or take.

Also, you can add GS_SYSLOG_REDIRECT=/full/path/to/file.log to your gravity-sync.conf file before you run the auto command, and it will add that redirect option into your service file.

@vmstan vmstan linked a pull request Apr 12, 2022 that will close this issue
@greggitter
Copy link
Author

greggitter commented Apr 13, 2022

That looks pretty good for sure. I'll test this more tomorrow...any ideas on where the escape characters are coming from. I don't see these anywhere else in syslog. Tested with two ssh clients, windows terminal and mobaXterm...same results I pasted above. Thanks!

EDIT: The escape codes are from the "Script Colors" and "Message Codes" appended to the start of each message; these are not working on my side.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants