So as we’re implementing our Cloverleaf, one of the things I’ve noticed they don’t really do well is log control. Most of their controls are size and number of files based, and there is no time-based controls. What we’re trying to do is keep logs for x number of days, then purge them. I’ve been whipping up a fairly straightforward TCL script that should do this, but I’ve noticed there are commands that are available “inside” the engine instance, and some that are only available “outside” of the engine instance. Let’s take a look at the current set up of the code (It’s not complete, so bear with me, still have quite a lot to flesh out, probably a lot that can be made to work easier/better):
As a note, I have “Log History” enabled in each individual site, so it creates the “LogHistory” folder in the process folder, and dates them when the process restarts. I’m also wanting to add a DAILY cycle to this, then remove the older files.
[code]#TCL script to force all processes to cycle logs, then delete logs older than a set number of days.
set clearDays 10
set hciRoot ${::env(HCIROOT)}
set servIniPort [open ${hciRoot}/server/server.ini]
set servIniList [split [read $servIniPort] \n]
#puts $servIniList
close $servIniPort
set environs [lsearch -regexp -inline $servIniList “^environs=”]
#puts $environs
set siteList [split [lindex [split $environs =] 1] “;”]
#puts $siteList
foreach sitePath $siteList {
set site [lindex [split $sitePath /] end]
exec [${hciRoot}/bin/hcisetenv -site $site]
netconfig load ${sitePath}/NetConfig
set procList [netcofig get process list]
#puts “Process List: $procList”
#foreach process $procList {
# puts “Will runn hcicmd -p $process -c \”.output_cycle\””
# #hcicmd -p $process -c “. output_cycle”
#}
#exec [find ${sitePath}/exec/processes -maxdepth 3 -mtime $clearDays -type f -name *.log]
#exec [find ${sitePath}/exec/processes -maxdepth 3 -mtime $clearDays -type f -name *.err]
}[/code]
Essentially I’m trying to do the following:
So all of this is to say, I find it odd you can do certain things inside a TCL/Engine instance, and certain things outside of it. I would write this in bash, but I don’t want to keep calling a TCL script to do other things. Some of the things I’ve noticed you can NOT do “inside” of a TCL script: setsite (or call the hcisetenv directly). The main thing I’ve notice you can’t do “outside” of a TCL script is the really fun one I found: netconfig. I’m using ‘netconfig get process list’ and will probably start using other things from this as it’s become a pretty useful tool to get data from the NetConfig file itself.
So all of that to say, is there an easier way to do this? I’d rather avoid having to do a scheduler event inside of each site, I’d rather have this globally. I can manually move the files for each site, but I would like to keep using the tools as much as possible, as it writes the header out when you cycle the output. I could cycle the output in a bash script, but then I lose my easy access to the ‘netconfig’ extension (and calling a TCL script is slow and I don’t want to do that over and over). Am I missing something or am I going to have to just write around certain aspects? (Losing the log cycle would be my choice).