2023-09-10

ExaWatcher custom sampler

Oracles ExaWatcher is a nice tool to sample some OS related measurements and keep them for a short period (normally some days) for later analysis. As its name indicates, it exists only on Oracles Engineered systems. A more general tool for non-Engineered Systems is OSWatcher - similar in many areas, but not in the content of this post. 

ExaWatcher collect a lot of default information about the system. But sometimes (or somewhere) additional details would be fine to be collected. Of course I can always write my own script to be scheduled in cron and then handle the results. But I am lucky: ExaWatcher provides an interface to extend it's collection: cusom samplers can be implemented easily. 

Speaking of easily, the documentation is correct, but somehow a little sparse (Or I'm just not capable of reading it, which is also likely).  

I created a script PsSwap.sh based on my previous post stored in /opt/oracle.ExaWatcher/

To use it, the documentation provides the parameter --customcmd.

-u | --customcmd 'sample_name ;; "custom_command;... " '



To include a custom collection module in the current group.

Example: --customcmd 'Lsl; "/bin/ls -l"'


My first attempt failed with a quite useless error message: 
  
/opt/oracle.ExaWatcher/ExaWatcher.sh --group --start "now" --end "never" --interval 5 --count 360 \
    --command_mode "SELECTED"   --customcmd 'ProcSwap;;"ProcSwap.sh"'

Can't exec "ProcSwap.sh": No such file or directory at /opt/oracle.ExaWatcher//ExaWatcherParserElements.pm line 2086, <gen3> line 24.
[1693909750][2023-09-05 12:29:10][WARNING][/opt/oracle.ExaWatcher/ParserExaWatcher.pl][ExaWatcherParserElements::format_custom_CMDs][] The custom command "ProcSwap.sh" is not supported by your system. It will be skipped.
It's fine to know it can not be executed, but no reason was given.
But at least I know the file and location, so after changing the code to be slightly more verbose the reason was obvious: ExaWatcher needs the scripts/binaries to execute in the $PATH (which does not contain /opt/oracle.ExaWatcher ) or the full path added. quite obvious once analysed. 
 
In the next iteration which accepted my ProcSwap sampler now I created a sample config file: bx. By analysing this sample file, I want to know how to include my ProcSwap into the default ExaWatcher.conf permanently:

/opt/oracle.ExaWatcher/ExaWatcher.sh --group --start "now" --end "never" --interval 5 --count 360 \
    --command_mode "SELECTED"   --customcmd 'ProcSwap;;"/opt/oracle.ExaWatcher/ProcSwap.sh"' --createconf bx
the result looks promising:

...
[1693909952][2023-09-05 12:32:32][INFO][/opt/oracle.ExaWatcher/ParserExaWatcher.pl][ExaWatcherParserElements::format_custom_CMDs][] CCMDInfo: ProcSwap "/opt/oracle.ExaWatcher/ProcSwap.sh". - scalar: 2

[1693909952][2023-09-05 12:32:38][INFO][/opt/oracle.ExaWatcher/ParserExaWatcher.pl][ExaWatcherParserElements::format_custom_CMDs][] ExaWatcher will automatically generate a name for custom commmand "/opt/oracle.ExaWatcher/ProcSwap.sh".
The previous custom command name "ProcSwap" will be replaced by a new name "CustomCMD0_ProcSwap".  
and also the config file contains the expected lines:

...
<Group>
<Start> now
<End> never
<Interval:s> 5
<Count> 360
<CommandMode> SELECTED
<CustomCMD> CustomCMD0_ProcSwap;;"/opt/oracle.ExaWatcher/ProcSwap.sh"

<RunEnd>

The last steps are easy: Adding the line 
<CustomCMD> ProcSwap;;"/opt/oracle.ExaWatcher/ProcSwap.sh"
to ExaWatcher.conf and restart ExaWatcher.  After ProcSwap.sh is executed once, there is a new directory in /opt/oracle.ExaWatcher/archive/CustomCMD.ExaWatcher/CustomCMD0_ProcSwap and a file there 2023_09_10_10_59_59_CustomCMD0_ProcSwap_<hostname>.dat The header of this file looks promising as it's identical to all the other data collections by ExaWatcher:

############################################################
# Starting Time:        09/10/2023 10:59:59
# Sample Interval(s):   5
# Archive Count:        360
# Collection Module:    CustomCMD0_ProcSwap
# Collection Command:   /opt/oracle.ExaWatcher/ProcSwap.sh
# Misc Info: ############################################################
zzz <09/10/2023 10:59:59> Count:0
         112 kB       1       root systemd
          12 kB     815       root lvmetad  

As always: once the method is clear, it's quite easy!

Keine Kommentare: