Page 1 of 1

How to move ups.log and utx.log to another location?

Posted: 07 Jan 2017 22:20
by Snufkin
Successfully moved (see WiKi NAS4Free) most of the log files from /var/log/ to /mnt/<gmirrow RAID>.
Only 3 files remained in /var/log/
  • ups.log
  • utx.lastlogin
  • utx.log
Their sizes are small, even ups.log grows every day by 12 kB only (1 record per 5 min).
My concern is constant updates of these files and writes to USB flash drive with embedded NAS4Free installation.

Are there any 'hidden' variables which I could insert in rc.conf WebUI and put above files with the rest of logs?

Re: How to move ups.log and utx.log to another location?

Posted: 07 Jan 2017 22:56
by raulfg3
revise NUT documentation, perhaps some auxiliary parameter can be set to define new location for log:

http://wiki.nas4free.org/doku.php?id=do ... rvices_ups

http://networkupstools.org/documentation.html

http://networkupstools.org/docs/man/upslog.html


and try nut_logfile= yourlogpath, work for me for other services like mlnet:
1.jpg

Re: How to move ups.log and utx.log to another location?

Posted: 08 Jan 2017 12:32
by Snufkin
Thank you, raulfg3 for the prompt reply.
Carefully studied all the links and found no obvious way to specify new path for log files.

According to upslog man pages log file path and name are specified among other command-line options.
And I can see it in process list

Code: Select all

/usr/local/bin/upslog -s Ippon@localhost -l /var/log/ups.log -i 300 -u root
Attempt to guess variable name failed, definition of variables nut_logfile (and just in case ups_logfile) doesn't change path and name in upslog command line option.

Assume the answer to my question required changes in the N4F code.

Re: How to move ups.log and utx.log to another location?

Posted: 08 Jan 2017 12:52
by raulfg3
sorry, but you are right.

Re: How to move ups.log and utx.log to another location?

Posted: 13 Jan 2017 09:14
by crest
Hello Snufkin,
Snufkin wrote:
08 Jan 2017 12:32
Thank you, raulfg3 for the prompt reply.
Carefully studied all the links and found no obvious way to specify new path for log files.

According to upslog man pages log file path and name are specified among other command-line options.
And I can see it in process list

Code: Select all

/usr/local/bin/upslog -s Ippon@localhost -l /var/log/ups.log -i 300 -u root
Attempt to guess variable name failed, definition of variables nut_logfile (and just in case ups_logfile) doesn't change path and name in upslog command line option.

Assume the answer to my question required changes in the N4F code.

You could try the new beta release of Extended GUI => viewtopic.php?f=71&t=6405&p=74622#p74622 which allows to include user defined logs (an example for the UPS log is included and ready for use).

Regards
crest

Re: How to move ups.log and utx.log to another location?

Posted: 15 Jan 2017 12:57
by Snufkin
crest wrote:
13 Jan 2017 09:14
You could try the new beta release of Extended GUI => viewtopic.php?f=71&t=6405&p=74622#p74622 which allows to include user defined logs (an example for the UPS log is included and ready for use).
Thank you crest, for good advice, Extended GUI is simple and straightforward way to make my own permanent log files based on temporary system files.
My original idea was to move files from temporary location in two hypothetical cases:
  • reduce size of temporary in-memory file system and get free extra RAM,
  • move constantly updated files from flash to rotational disks.
And, as I understand it, N4F still lacks feature to reassign the storage location of ALL log files using ONE global variable.

Re: How to move ups.log and utx.log to another location?

Posted: 17 Jan 2017 08:58
by crest
Hello Snufkin,

Snufkin wrote:
15 Jan 2017 12:57
crest wrote:
13 Jan 2017 09:14
You could try the new beta release of Extended GUI => viewtopic.php?f=71&t=6405&p=74622#p74622 which allows to include user defined logs (an example for the UPS log is included and ready for use).
Thank you crest, for good advice, Extended GUI is simple and straightforward way to make my own permanent log files based on temporary system files.
My original idea was to move files from temporary location in two hypothetical cases:
  • reduce size of temporary in-memory file system and get free extra RAM,
  • move constantly updated files from flash to rotational disks.

Ok, I dug a little bit in the sources and the solution is quite simple (but only for the UPS log unfortunately).
Open System > Advanced > rc.conf in the WebGUI and add a new variable

Code: Select all

name: nut_upslog_logfile
value: /mnt/YourDirectoryPath/ups.log

hit Save and Apply Changes and restart upslog in the CLI with

Code: Select all

/etc/rc.d/nut_upslog restart

You should get a similar output like this:

Code: Select all

Stopping nut_upslog.
Waiting for PIDS: 60741.
Starting nut_upslog.
Network UPS Tools upslog 2.7.4
logging status of UPS@localhost to /mnt/DATA/ups-testlog.log (300s intervals)

If you want to see the output in Diagnostics > Log just modify the user defined log file which is provided with the above mentioned beta of Extended GUI according to the value you used for the nut_upslog_logfile.

Unfortunately the described solution is not possible for the utx logs because their the path /var/log is hardcoded in the file /etc/rc.d/proftpd so if you want to change the path too than you must patch the file accordingly and restart proftpd as well. The bad thing here is that, if you use embedded installation, you must copy a patched file from a persistant location to /etc/rc.d/proftpd and restart proftpd with a postinit command which you can do in System > Advanced > Command Scripts

And, as I understand it, N4F still lacks feature to reassign the storage location of ALL log files using ONE global variable.

Thats not (totally ;) ) true, there is a global variable clog_logdir you can use in System > Advanced > rc.conf BUT, for some reasons - I suppose the idea was somehow a diffence between the file types "type" => "clog" and "type" => "plain", it is not used for all provided logs, as defined in /usr/local/www/diag_log.inc

Code: Select all

// Get the location of the log files (may be modified via rc.conf variables).
$clogdir = rc_getenv_ex("clog_logdir", $g['varlog_path']);
$rsync_client_logfile = rc_getenv_ex("rsync_client_logfile", "{$g['varlog_path']}/rsync_client.log");
$rsync_local_logfile = rc_getenv_ex("rsync_local_logfile", "{$g['varlog_path']}/rsync_local.log");
$fuppes_logfile = rc_getenv_ex("fuppes_logfile", "{$g['varlog_path']}/fuppes.log");
$minidlna_logdir = rc_getenv_ex("minidlna_logdir", "{$g['varlog_path']}");
$minidlna_logfile = "$minidlna_logdir/minidlna.log";
$mtdaapd_logfile = rc_getenv_ex("mtdaapd_logfile", "{$g['varlog_path']}/mt-daapd.log");
$proftpd_modban_logfile = rc_getenv_ex("proftpd_modban_banlog", "{$g['varlog_path']}/proftpd/ban.log");

IMHO it would be more consistent to change the initial values from e.g.

Code: Select all

$rsync_client_logfile = rc_getenv_ex("rsync_client_logfile", "{$g['varlog_path']}/rsync_client.log");

to

Code: Select all

$rsync_client_logfile = rc_getenv_ex("rsync_client_logfile", "{$clogdir}/rsync_client.log");

because if one uses the global variable clog_logdir than this would be used also for
$rsync_client_logfile, $rsync_local_logfile, $fuppes_logfile, $minidlna_logdir etc. as default.
But it is up to the devs to change the logic ...

I hope this helps a bit ;)

Regards
crest

Re: How to move ups.log and utx.log to another location?

Posted: 18 Jan 2017 18:04
by Snufkin
Sorry for late response, struggling with Intel 82574L NIC and utp (uTorrent) protocol on NAS4Free.
crest wrote:
17 Jan 2017 08:58
Ok, I dug a little bit in the sources and the solution is quite simple...
Open System > Advanced > rc.conf in the WebGUI and add a new variable

Code: Select all

name: nut_upslog_logfile
value: /mnt/YourDirectoryPath/ups.log
hit Save and Apply Changes and restart upslog in the CLI with

Code: Select all

/etc/rc.d/nut_upslog restart
You should get a similar output like this:

Code: Select all

Stopping nut_upslog.
Waiting for PIDS: 60741.
Starting nut_upslog.
Network UPS Tools upslog 2.7.4
logging status of UPS@localhost to /mnt/DATA/ups-testlog.log (300s intervals)
Everything went smoothly and exactly as you wrote, and your further explanation helps a lot to understand how it works.
Thank you very much crest, for your time spent to write this comprehensive answer.