cli icon indicating copy to clipboard operation
cli copied to clipboard

`treehouses log ram [on|off]` 40M memory for log files (fixes #807)

Open LordJashin32 opened this issue 5 years ago • 5 comments

https://github.com/treehouses/builder/pull/717

  • [x] - updated to use builder log2ram package instead
root@treehouses:~/cli# ./cli.sh log ram
log2ram is off
root@treehouses:~/cli# df -h | grep log2ram
root@treehouses:~/cli# ./cli.sh log ram on jjjj
Error: Too many arguments.

Usage: cli.sh log [0|1|2|3|4|show|max|ram [on|off]]

Example:
  cli.sh log
      log 0: log is disabled

  cli.sh log 0
      log 0: log disabled

  cli.sh log 1
      log 1: level set to Info

  cli.sh log 2
      log 2: level set to Info and Warning

  cli.sh log 3
      log 3: level set to Info, Warning, and Error

  cli.sh log 4
      log 4: level set to Info, Warning, Error, and Debug

  cli.sh log show
      Shows the default 6 lines of log which is at (/var/log/syslog)
      @treehouses/cli: temperature fahrenheit

  cli.sh log show 5
      Shows 5 lines of log which is at (/var/log/syslog)
      @treehouses/cli: temperature fahrenheit

  cli.sh log max
      log X: level set to max

  cli.sh log ram
      log2ram is off
  force logs to be stored in ram and only writes to disk on shutdown
  https://github.com/azlux/log2ram
  Stores logs in 40M (Megabytes) in mount point in memory

  cli.sh log ram on
      Successfully started log2ram

  cli.sh log ram off
      Successfully stopped log2ram

root@treehouses:~/cli# ./cli.sh log ram on
Successfully started log2ram
root@treehouses:~/cli# df -h | grep log2ram
log2ram          40M  3.8M   37M  10% /var/log
root@treehouses:~/cli# ./cli.sh log ram on
Successfully started log2ram
root@treehouses:~/cli# df -h | grep log2ram
log2ram          40M  3.8M   37M  10% /var/log
root@treehouses:~/cli# ./cli.sh log ram off
Sucessfully stopped log2ram
root@treehouses:~/cli# df -h | grep log2ram

LordJashin32 avatar May 16 '20 04:05 LordJashin32

Is the only way to enable and disable this to install and uninstall every time?

kjong avatar May 16 '20 04:05 kjong

Is the only way to enable and disable this to install and uninstall every time?

Yeah basically. The package doesn't really give much more than what the install does:

root@treehouses:~/test1/cli# log2ram --help
Usage: log2ram {start|stop|write}

write doesn't even give an output message when i run it. And i can't tell if it ran from from df -h

LordJashin32 avatar May 16 '20 05:05 LordJashin32

moved to log.sh

root@treehouses:~/cli# ./cli.sh log ram
log2ram is on
root@treehouses:~/cli# ./cli.sh log ram on
Successfully enabled log2ram, please reboot
root@treehouses:~/cli# ./cli.sh log ram on dfds
Error: Too many arguments.

Usage: cli.sh log [0|1|2|3|4|show|max|ram [on|off]]

Example:
  cli.sh log
      log 0: log is disabled

  cli.sh log 0
      log 0: log disabled

  cli.sh log 1
      log 1: level set to Info

  cli.sh log 2
      log 2: level set to Info and Warning

  cli.sh log 3
      log 3: level set to Info, Warning, and Error

  cli.sh log 4
      log 4: level set to Info, Warning, Error, and Debug

  cli.sh log show
      Shows the default 6 lines of log which is at (/var/log/syslog)
      @treehouses/cli: temperature fahrenheit

  cli.sh log show 5
      Shows 5 lines of log which is at (/var/log/syslog)
      @treehouses/cli: temperature fahrenheit

  cli.sh log max
      log X: level set to max

  cli.sh log ram
      log2ram is off
  force logs to be stored in ram and only writes to disk on shutdown
  https://github.com/azlux/log2ram
  Stores logs in 40M (Megabytes) in mount point in memory

  cli.sh log ram on
      Successfully enabled log2ram, please reboot

  cli.sh log ram off
      Successfully disabled log2ram

root@treehouses:~/cli# ./cli.sh log ram off
Sucessfully disabled log2ram
root@treehouses:~/cli# ./cli.sh log ram
log2ram is off
root@treehouses:~/cli# ./cli.sh log ram on
Successfully enabled log2ram, please reboot
root@treehouses:~/cli# ./cli.sh log ram
log2ram is off
root@treehouses:~/cli#

LordJashin32 avatar May 18 '20 17:05 LordJashin32

@LordJashin32 nice one, but on second thought this is something for builder ... at least in parts

dogi avatar May 20 '20 08:05 dogi

updated for builder package instead. Test results are in main post up top @LordJashin32

LordJashin32 avatar May 20 '20 22:05 LordJashin32