Revision 46cc0fd3
Added by Alexis Mousset over 6 years ago
share/commands/agent-factory-reset | ||
---|---|---|
# @man +
|
||
# @man *-c*: run the agent without color output
|
||
# @man +
|
||
# @man *-T*: display timing information
|
||
# @man +
|
||
# @man *-r*: run the agent with raw output
|
||
# @man +
|
||
# @man *-R*: run the agent in completely unparsed mode, with no return code of 1 in case of error. A little faster.
|
||
... | ... | |
QUIET=false
|
||
FORCE=0
|
||
|
||
while getopts "iIvdqcf" opt; do
|
||
while getopts "iIvdqcTf" opt; do
|
||
case $opt in
|
||
i|I|v|d)
|
||
VERBOSE=true
|
||
... | ... | |
c)
|
||
clear_colors
|
||
;;
|
||
T)
|
||
TIMING=1
|
||
;;
|
||
f)
|
||
FORCE=1
|
||
;;
|
share/commands/agent-inventory | ||
---|---|---|
# @man +
|
||
# @man *-c*: run the agent without color output
|
||
# @man +
|
||
# @man *-T*: display timing information
|
||
# @man +
|
||
# @man *-r*: run the agent with raw output
|
||
# @man +
|
||
# @man *-R*: run the agent in completely unparsed mode, with no return code of 1 in case of error. A little faster.
|
share/commands/agent-run | ||
---|---|---|
# @man +
|
||
# @man *-c*: run the agent without color output
|
||
# @man +
|
||
# @man *-T*: display timing information
|
||
# @man +
|
||
# @man *-r*: run the agent with raw output
|
||
# @man +
|
||
# @man *-R*: run the agent in completely unparsed mode, with no return code of 1 in case of error. A little faster.
|
||
... | ... | |
# Ignore disable-agent flag
|
||
FORCE=0
|
||
|
||
while getopts "uiIvdqwrRmcb:D:f" opt; do
|
||
while getopts "uiIvdqwrRmcTb:D:f" opt; do
|
||
case $opt in
|
||
u)
|
||
UPDATE=true
|
||
... | ... | |
clear_colors
|
||
UPDATE_OPTIONS="${UPDATE_OPTIONS} -c"
|
||
;;
|
||
T)
|
||
TIMING=1
|
||
;;
|
||
r)
|
||
SUMMARY_ONLY=1
|
||
DISPLAY_INFO=1
|
share/commands/remote-run | ||
---|---|---|
# @man +
|
||
# @man *-c*: run the agent without color output
|
||
# @man +
|
||
# @man *-T*: display timing information
|
||
# @man +
|
||
# @man *-r*: run the agent with raw output
|
||
# @man +
|
||
# @man *-R*: run the agent in completely unparsed mode, with no return code of 1 in case of error. A little faster.
|
||
... | ... | |
fi
|
||
}
|
||
|
||
while getopts "iIvdqwrRmcb:D:j:at:u:C:" opt; do
|
||
while getopts "iIvdqwrRmcTb:D:j:at:u:C:" opt; do
|
||
case $opt in
|
||
i|I)
|
||
VERBOSITY="-I ${INFO_CLASS}"
|
||
... | ... | |
c)
|
||
clear_colors
|
||
;;
|
||
T)
|
||
TIMING=1
|
||
;;
|
||
r)
|
||
SUMMARY_ONLY=1
|
||
DISPLAY_INFO=1
|
share/lib/cfengine_parsing.sh | ||
---|---|---|
FULL_STRINGS=0
|
||
# Prefix lines with hostname
|
||
MULTIHOST=0
|
||
# Timing information
|
||
TIMING=0
|
||
|
||
UUID=$(cat /opt/rudder/etc/uuid.hive 2>/dev/null)
|
||
[ $? -ne 0 ] && UUID="Not yet configured"
|
||
... | ... | |
|
||
PRETTY="awk -v info=\"\${DISPLAY_INFO}\" -v full_strings=\"\${FULL_STRINGS}\" -v summary_only=\"\${SUMMARY_ONLY}\" -v quiet=\"\${QUIET}\" -v multiline=\"\${MULTILINE}\" -v multihost=\"\${MULTIHOST}\" \
|
||
-v green=\"\${GREEN}\" -v darkgreen=\"\${DARKGREEN}\" -v red=\"\${RED}\" -v yellow=\"\${YELLOW}\" -v magenta=\"\${MAGENTA}\" -v normal=\"\${NORMAL}\" -v white=\"\${WHITE}\" -v cyan=\"\${CYAN}\" \
|
||
-v dblue=\"\${DBLUE}\" -v dgreen=\"\${DGREEN}\" -v has_fflush=\"\${AWK_FFLUSH}\" ${AWK_OPTS} -f ${PRETTY_FILTER}"
|
||
-v dblue=\"\${DBLUE}\" -v dgreen=\"\${DGREEN}\" -v timing=\"\${TIMING}\" -v has_fflush=\"\${AWK_FFLUSH}\" ${AWK_OPTS} -f ${PRETTY_FILTER}"
|
share/lib/reports.awk | ||
---|---|---|
"date +%s.%N" | getline starttime;
|
||
# needed to be able to call the same command a second time
|
||
close("date +%s.%N");
|
||
# Initialize timer to allow computing time taken for parsing the policies
|
||
timer()
|
||
}
|
||
|
||
# We need it because length() only exists in gawk
|
||
... | ... | |
return k;
|
||
}
|
||
|
||
function timer() {
|
||
"date +%s.%N" | getline component_end_time;
|
||
close("date +%s.%N");
|
||
tmp_time = component_end_time - component_begin_time;
|
||
component_begin_time = component_end_time;
|
||
return tmp_time
|
||
}
|
||
|
||
function print_count_offset(offset, marker, color, count, text) {
|
||
for (c=0; c<offset; c++) {
|
||
printf " ";
|
||
... | ... | |
printf "%s%-10.10s ", normal, hostname;
|
||
}
|
||
|
||
if (timing) {
|
||
if (mode != "") {
|
||
printf "%6.2fs ", component_time;
|
||
} else {
|
||
printf "%6.6s ", "";
|
||
}
|
||
}
|
||
|
||
if (full_strings) {
|
||
printf "%s%-7.7s%s %s%-13.13s%s ", mode_color[mode], mode, normal, state_color[result], result, normal;
|
||
} else {
|
||
... | ... | |
|
||
function print_report_multiline() {
|
||
printf "%s%s%s: %s\n", state_color[result], state, normal, message;
|
||
|
||
if (timing) {
|
||
if (mode != "") {
|
||
printf "%s%s%6.2fs%-74.74s%s\n", white , "-- Time: ", component_time, " " padding_dash, normal;
|
||
}
|
||
}
|
||
|
||
printf "%s%-80.80s%s\n", white, "-- Mode: " mode " " padding_dash, normal;
|
||
|
||
... | ... | |
|
||
# Wait for the StartRun to display the config id
|
||
if (key == "StartRun") {
|
||
if (timing) {
|
||
parsing_time = timer();
|
||
printf "Parsing time: %.2fs\n", parsing_time;
|
||
}
|
||
printf "%s\n\n", message;
|
||
next
|
||
}
|
||
... | ... | |
{
|
||
if (component == "start")
|
||
{
|
||
if (timing) {
|
||
parsing_time = timer();
|
||
printf "Parsing time: %.2fs\n", parsing_time;
|
||
}
|
||
printf "Start execution with config [%s]\n\n", key;
|
||
next
|
||
}
|
||
... | ... | |
mode = "";
|
||
}
|
||
|
||
# Compute time
|
||
if (mode != "" && timing) {
|
||
component_time = timer();
|
||
} else {
|
||
component_time = ""
|
||
}
|
||
|
||
#### 4/ Check report type
|
||
|
||
if (state == "result_success") {
|
||
... | ... | |
printf "%-10.10s ", "Hostname";
|
||
}
|
||
|
||
if (timing) {
|
||
printf "%8.8s", "Time "
|
||
}
|
||
|
||
if (full_strings) {
|
||
printf "%-7.7s ", "Mode";
|
||
} else {
|
||
... | ... | |
}
|
||
}
|
||
|
||
printf "execution time: %.2fs\n", endtime - starttime, endtime, starttime;
|
||
printf "Execution time: %.2fs\n", endtime - starttime;
|
||
|
||
printf "%s%-80.80s%s\n", white, padding, normal;
|
||
|
Also available in: Unified diff
Fixes #9163: Add an option to add timing information to the agent run