Artix Linux Forum

Init systems => runit => Topic started by: Surf3r on 06 December 2022, 10:30:41

Title: How can be disabled syslog-ng service at boot
Post by: Surf3r on 06 December 2022, 10:30:41

 Hello, i'm trying to stop syslog-ng service to run at boot. I don't want to remove the service but just make it to run at will only when i want to troubleshoot something that can happen to fail.

I just want when needed to 'sv start syslog-ng' or stop the service 'sv stop syslog-ng'

How this can be done as easiest possible? Tnx and have a great awesome day everybody ;)
Title: Re: How can be disabled syslog-ng service at boot
Post by: capezotte on 06 December 2022, 11:59:44
https://wiki.artixlinux.org/Main/Runit#Disable_service

Though honestly, disabling logging is just going to make troubleshooting more complicated. If you're worried about disk space, just set up log rotation.
Title: Re: How can be disabled syslog-ng service at boot
Post by: Lancia on 06 December 2022, 12:43:20
> Hello, i'm trying to stop syslog-ng service to run at boot. I don't want to remove the service but just make it to run at will only when i want to troubleshoot something that can happen to fail.
 
You do realize that if your problem happens when syslog hasn't started, starting it will not do anything since syslog wasn't there to record the problem?
Having logs from the past is invaluable, some problems may only give a warning and then have consequences that get repeated without telling you anything.
Title: Re: How can be disabled syslog-ng service at boot
Post by: Surf3r on 06 December 2022, 12:47:11
 I'm not worried about disk space but disk wear. I' don't need logs over and over about same error with the cost of shrinking my ssd lifespan. I've heard about log rotation but i'm not very used to it so i've set a cronjob, everyday at 16:00 to simply clear those log files except pacman log. Even with that i'm still having 10-25 MB of logs/day.

I have apparmor that creates constant rather huge entries in my logs that are 100% benign. When i want to check system health i can start syslog-ng for an hour or whatever time then stop it an read logs.

I've thought another way of stopping syslog service with cronjob every hour or every 6 hours but i wanted to know if there's a way of manually start that service and not at boot.
Title: Re: How can be disabled syslog-ng service at boot
Post by: Lancia on 06 December 2022, 14:04:30
> I'm not worried about disk space but disk wear.

I don't think it's that much in the grand scheme of things, especially considering how web browsers write tons of stuff to ~/.cache
Still if you're really worried about disk wear, one solution is to mount a tmpfs somewhere and tell syslog to store logs there.

> I have apparmor that creates constant rather huge entries in my logs that are 100% benign. When i want to check system health i can start syslog-ng for an hour or whatever time then stop it an read logs.

IIRC syslog has filtering capabilities.

Also https://wiki.debian.org/SSDOptimization#Mounting_SSD_filesystems
Title: Re: How can be disabled syslog-ng service at boot
Post by: gripped on 06 December 2022, 14:23:51
I don't think it's that much in the grand scheme of things, especially considering how web browsers write tons of stuff to ~/.cache
Still if you're really worried about disk wear, one solution is to mount a tmpfs somewhere and tell syslog to store logs there.
This is what I do with ~/.cache. Helps with disk wear I suppose but more importantly to me it's all cleared after every reboot and although there's a bit of a trade off due to it being rebuilt after reboots I believe it's faster afterwards, what with it being in memory. You need plenty of memory though.

@Surf3r If it's just the apparmor log that concerns you could try linking it to /dev/null. As you don't have rotation set up I don't see why that would not work. (Edit: Or just disabling it's logging in it's config file or setting the log file to /dev/null there if possible."

For the easiest way to start and stop the service you could put an alias in ~/bashrc.
eg I have
Code: [Select]
alias sx="startx"
to save myself four characters when I need to start X. Wow that's lazy  :D
Title: Re: How can be disabled syslog-ng service at boot
Post by: Lancia on 06 December 2022, 16:59:38
>to save myself four characters when I need to start X. Wow that's lazy  :D

Don't worry I'm one step above:
Code: [Select]
alias l=ls
Title: Re: How can be disabled syslog-ng service at boot
Post by: Surf3r on 06 December 2022, 20:04:33
Yeah that's a cool idea but where to send that tmpfs or ~/.cache? On an external usb stick? Cos it has to be on different device not on the main ssd or hdd I assume.
Title: Re: How can be disabled syslog-ng service at boot
Post by: gripped on 06 December 2022, 20:49:45
Yeah that's a cool idea but where to send that tmpfs or ~/.cache? On an external usb stick? Cos it has to be on different device not on the main ssd or hdd I assume.
tmpfs goes in RAM

Your /tmp may already be tmpfs ?
from /etc/fstab
Code: [Select]
tmpfs                                           /tmp            	tmpfs   		nodev,nosuid,size=16G 
A similar line
Code: [Select]
tmpfs                                           /var/log            	tmpfs   		nodev,nosuid,size=16G 
Will mount /var/log as a tmpfs. IE in memory
This is the line that mounts my ~/.cache
Code: [Select]
tmpfs                                           /home/gripped/.cache 	tmpfs   		noatime,nodev,nosuid,size=28G
Big size because yay uses it and firedragon needs a lot of space to compile.
Only as much memory as is needed will be used. If it reserves any it isn't much. So with 32GB I can have multiple 16GB tmpfs and that's not an issue unless they all want to use it all at once. In which case you'd get 'out of space' errors
Title: Re: How can be disabled syslog-ng service at boot
Post by: Surf3r on 07 December 2022, 13:44:53
 All of the above solutions worth giving a try. But i remember once when i wanted to remove that neofetch to show its head just before startx kicked in. I had to add or better said change some rc file can't remember rn what file was. I think i just need to add at the right place 'sv stop syslog-ng' and the service simply will stop hopefully.  8)
Title: Re: How can be disabled syslog-ng service at boot
Post by: gripped on 07 December 2022, 14:57:32
I think i just need to add at the right place 'sv stop syslog-ng' and the service simply will stop hopefully.  8)
I don't use runit but from looking at the wiki
Code: [Select]
sv stop syslog-ng
does stop the service. But it would hardly be an elegant or efficient process to have the service started at boot to then be almost instantly stopped again in rc.local (if it exists in runit) or similar.
I just read on the wiki that you can disable a runit service by just having a file 'down' in the right place.
https://wiki.artixlinux.org/Main/Runit#Disable_service
Seems fairly simple. Why complicate things ?
Title: Re: How can be disabled syslog-ng service at boot
Post by: Surf3r on 07 December 2022, 16:12:25
@gripped  Yep that's the way to do it, the proper way. Can't understand how i skipped that piece of runit wiki  :o

Code: [Select]
 touch /run/runit/service/service_name/down

  However if i do it that way the downside is that the boot sequence will have no logs since it never starts while letting it run just for the boot sequence one of the most important part in case system won't boot i guess would be more useful. Now another thing i don't quite know is which part writes pacman log, it's syslog-ng or pacman takes care of that part? I still need my pacman logs just in case some package takes a dump so  can downgrade it..etc :)
Title: Re: How can be disabled syslog-ng service at boot
Post by: capezotte on 07 December 2022, 17:26:00
pacman writes its own log in /var/log/pacman.log.

Though really, what you're doing is massively overengineered in comparison to just silencing apparmor, making /var/log a tmpfs or making syslog write to /run (which is RAM-backed and doesn't tax your SSD).
Title: Re: How can be disabled syslog-ng service at boot
Post by: lq on 07 December 2022, 20:37:40
Hello, i'm trying to stop syslog-ng service to run at boot. I don't want to remove the service but just make it to run at will only when i want to troubleshoot something that can happen to fail.

I would use metalog.

https://wiki.gentoo.org/wiki/Metalog
https://github.com/hvisage/metalog

Code: [Select]
pacman -R syslog-ng
pacman -S metalog-runit
Title: Re: How can be disabled syslog-ng service at boot
Post by: Surf3r on 07 December 2022, 23:14:37
That's an interesting light weight alternative. I saw it did not get an upgrade from quite some time, perhaps being such a small package but yeah worth giving it a try.
Title: Re: How can be disabled syslog-ng service at boot
Post by: Lancia on 08 December 2022, 05:51:58
If your goal is lightweightness, use busybox syslogd, can't get more lightweight than a syslog designed for embedded and low memory systems.

You can grab my OpenRC service file (https://github.com/Lancia-Greggori/lancia-utils/blob/main/openrc-services/busybox-syslogd) if you want.
Title: Re: How can be disabled syslog-ng service at boot
Post by: Surf3r on 08 December 2022, 09:56:29
Haha, nice program, cool. Who doesn't want light weight? Even if i had a thread ripper with a ton of memory and powerful graphic card i would still aim for the fastest most efficient packages. It's a brilliant philosophy  8)
Title: Re: How can be disabled syslog-ng service at boot
Post by: Lancia on 08 December 2022, 11:14:55
>It's a brilliant philosophy

Well then you'll love busybox and suckless (http://suckless.org).

Besides, busybox ain't just a syslog, theres a lot more you can replace.
Code: [Select]
$ ll --color=no /usr/local/busybox/
total  
lrwxrwxrwx base32 -> ../../bin/busybox
lrwxrwxrwx base64 -> ../../bin/busybox
lrwxrwxrwx basename -> ../../bin/busybox
lrwxrwxrwx cp -> ../../bin/busybox
lrwxrwxrwx cut -> ../../bin/busybox
lrwxrwxrwx date -> ../../bin/busybox
lrwxrwxrwx df -> ../../bin/busybox
lrwxrwxrwx diff -> ../../bin/busybox
lrwxrwxrwx dirname -> ../../bin/busybox
lrwxrwxrwx du -> ../../bin/busybox
lrwxrwxrwx egrep -> ../../bin/busybox
lrwxrwxrwx fbset -> ../../bin/busybox
lrwxrwxrwx fgrep -> ../../bin/busybox
lrwxrwxrwx grep -> ../../bin/busybox
lrwxrwxrwx head -> ../../bin/busybox
lrwxrwxrwx ln -> ../../bin/busybox
lrwxrwxrwx ls -> ../../bin/busybox
lrwxrwxrwx md5sum -> ../../bin/busybox
lrwxrwxrwx mv -> ../../bin/busybox
lrwxrwxrwx pgrep -> ../../bin/busybox
lrwxrwxrwx pwd -> ../../bin/busybox
lrwxrwxrwx seq -> ../../bin/busybox
lrwxrwxrwx sha1sum -> ../../bin/busybox
lrwxrwxrwx sha256sum -> ../../bin/busybox
lrwxrwxrwx sha3sum -> ../../bin/busybox
lrwxrwxrwx sha512sum -> ../../bin/busybox
lrwxrwxrwx sum -> ../../bin/busybox
lrwxrwxrwx syslogd -> ../../bin/busybox
lrwxrwxrwx tac -> ../../bin/busybox
lrwxrwxrwx cat -> ../../bin/busybox
lrwxrwxrwx tail -> ../../bin/busybox
lrwxrwxrwx tty -> ../../bin/busybox
lrwxrwxrwx uniq -> ../../bin/busybox
...

Put them first in your $PATH and enjoy (except make sure makepkg is run with the standard $PATH, you can do it with env PATH='/bin:/sbin' makepkg)
Title: Re: How can be disabled syslog-ng service at boot
Post by: Surf3r on 08 December 2022, 17:16:45

I don't think it's that much in the grand scheme of things, especially considering how web browsers write tons of stuff to ~/.cache

There's a setting in firefox you can change so ff will use only RAM memory. This is what shows ff in my about:cache. So in my case ff reads/writes exclusively in memory. That setting you can look for more info here (https://github.com/arkenfox/user.js/blob/master/user.js)  section DISK AVOIDANCE

"browser.cache.disk.enable"       turn it to false

(https://i.postimg.cc/MKjG2rxT/Screenshot-2022-12-08-17-17-24.png)