I'm new with Geneos and would like to know how to show the output of our existing script which is previously used in Nagios. We're planning to use the toolkit plugin and not sure what will be the commands to use to be able to see result in active console.
Requirement - check the log if there is session timeout and it will alert OK if grep is equal 20 then Warning alert if less or greater than 20.
Output in Geneos:
column_title - TIMEOUT CHECK, STATUS
row_result - THE_FILE, OK: Session Timeout is 20
Here's our sample script:
#!/bin/ksh
OK=0
WARNING=1
CRITICAL=2
THE_FILE=/target/directory/web.txt
TIMEOUT=`grep "<session-timeout>" $THE_FILE | awk -F'>' '{print $2}' | awk -F'>' '{print $1}'
if [$TIMEOUT -eq 20 ]; then
echo "OK: Session Timeout is $TIMEOUT"
exit $OK
else
echo "WARNING: Session Timeout is $TIMEOUT"
exit $WARNING
fi
Thanks!
You can use the same script (adding the header) and adding it to Geneos. But I highly recommend you to use a FKM sampler, and check this log file using Geneos directly.
Hope this helps you.
Related
I have used MediaInfo before to extract information in a shell script in CygWin.
#!/bin/bash
IFS=$'\n'; for file in $(ls *.mp3 /.mp3 ); do count="C:/Program Files/MediaInfo/MediaInfo.exe" $file | grep "Bit rate mode" | grep "Variable" | wc -l; if [ $count -gt 0 ]; then echo $file VBR; fi done
For some reason, it no longer outputs to stdout. It displays the data in a window. Is there some command line flag tp force stdout?
You use the Graphical Interface (GUI) version of MediaInfo, you need to use the Command Line Interface (CLI) version of MediaInfo.
See the different download options in the MediaInfo Windows download page.
The SAM CLI function to tail the logs is AWESOME. However, I find the formatting to be too verbose most of the time. The default formatting looks like this:
2021/12/13/[$LATEST]c87a125640ed4c66907f22c1d83ca63e 2021-12-13T13:11:09.388000 2021-12-13T13:11:09.388Z 1f99a541-76d7-494f-8f07-3f3e8397eedf INFO small change
but I want to have the option to just print out the message without the log stream and timestamp information so it just looks like this:
INFO small change
Is there a way to pass in a formatting string for the log statements?
You can use awk to only print the 5th and 6th column.
Try:
sam logs -n MyLambdaFunction --tail | awk '{print $5 " " $6}';
Demo:
output="2021/12/13/[$LATEST]c87a125640ed4c66907f22c1d83ca63e 2021-12-13T13:11:09.388000 2021-12-13T13:11:09.388Z 1f99a541-76d7-494f-8f07-3f3e8397eedf INFO small change";
echo $output | awk '{print $5 " " $6}';
Output:
INFO small
I ran the below-mentioned jq command and my putty session became inactive. however, I can still see the process running using the "top" command.
Does jq --stream run in background by default?
jq -cn --stream '
fromstream(1|truncate_stream(inputs | select(.[0][0] == "userActivities") | del(.[0][0])))
| select(.localDate[0:7] == "2018-10")
' 2018-10-01T21_45_56Z_triplem-baas_data.json > October_2018_triplem_events.json
Does jq --stream run in background by default?
No.
The --stream option is usually only used for very large JSON texts, so if that is the case here, then it might take a long while for the job to finish. If you want to verify that progress is being made, consider adding one or more debug statements: each debug is like . but copies its input value to STDERR before passing the value along.
Sometimes it pays to be a bit devious with debug, as illustrated in this variant of your program:
jq -cn --stream '
fromstream(1|truncate_stream(inputs | select(.[0][0] == "userActivities") | del(.[0][0])))
| (.localDate|debug) as $debug
| select(.localDate[0:7] == "2018-10")
' 2018-10-01T21_45_56Z_triplem-baas_data.json > October_2018_triplem_events.json
I am by no means a programmer. I'll put that right out there. However, I'm trying to write a script that writes fstab entries after grabbing uuid data. This is in a OpenWRT environment on my router. My goal:
Grab uuid info using awk, like:
blkid /dev/sdb2 | awk -F'UUID="|"' '{print $2}'
Send the full uuid output to the end of this command:
uci set fstab.#mount[-1].uuid=
Execute that command with the correct uuid.
This command writes that uuid to the correct place in fstab. How can this be accomplished in a bash-script?
Thanks,
KG
You can either execute the command from within awk (using system(...)), or from within the shell (using uci set fstab.#mount[-1].uuid=$(blkid ...)).
I can't test it with the uci command but I believe this should do what you need.
bblkid /dev/sda1 | uci set fstab.#mount[-1].uuid=$( awk -F'UUID="|"' '{print $2}' )
Edit: this would probably be better.
uci set fstab.#mount[-1].uuid=$( bblkid /dev/sda1 | awk -F'UUID="|"' '{print $2}' )
Edit 2: little bit shorter but should get the same result. Promise this is the last one
uci set fstab.#mount[-1].uuid=$( bblkid /dev/sda1 | tr -d UUID=\" )
The above options didn't work quite right.
What if I have this in fstab:
option uuid 'hotdog'
I want to replace the word "hotdog" with the output of the uuid from this command:
On my router that output looks like:
root#OpenWrt:/etc/config# blkid /dev/sdb2 | awk -F'UUID="|"' '{print $2}'
8618b8fe-93a9-488c-a901-0df30898c82e
or
root#OpenWrt:/etc/config# block info | grep sdb2
/dev/sdb2: UUID="8618b8fe-93a9-488c-a901-0df30898c82e" NAME="EXT_JOURNAL" VERSION="1.0" TYPE="ext4"
I want to then replace the word hotdog with the random uuid, and keep the semi-colons. Keep in mind that the uuid will change each time I format that partition.
I'm starting the job by issuing this request
/POST /jenkins/job/jobName/build
but it returns nothing. I want to get the build number that just has started.
Although late , posting an answer so it can benefit any other seekers :
We can get the latest/current build no. using the following API :
<JENKINS_URI>/job/<JOB_NAME>/lastBuild/buildNumber
This will provide the current executing or the last successful build.
Example :
curl -X GET <JENKINS_URI>/<JOB_NAME>/lastBuild/buildNumber --user <user>:<key>
o/p : 20
This is how i do it, First trigger the Job with the rest api call. From this call's response, get the queue location. And using this queue location, fetch the build number. The build number will not be generated immediately, thats why the while loop.
JENKINS_EMAIL=<Email>
JENKINS_TOKEN=<API Key>
JENKINS_URL=<Jenkins Server URL>
JENKINS_JOB=<JOB>
# Trigger Job and get queue location
location=$(curl -X POST -s -I -u $JENKINS_EMAIL:$JENKINS_TOKEN "${JENKINS_URL}${JENKINS_JOB}/buildWithParameters?pass=ok" | grep location | awk '{ print $NF }')
location2=${location//[$'\t\r\n']}
# Wait till build number is generated
while true ; do
buildnumber=$(curl -X GET -s -u $JENKINS_EMAIL:$JENKINS_TOKEN "${location2}api/json" | jq '.executable.number')
if [[ $buildnumber != "null" ]]; then
echo "Build Started. Build number is : "$buildnumber"
break
else
echo "Still in Queue"
sleep 1
fi
done
Jenkins - How to access BUILD_NUMBER environment variable
use ${BUILD_NUMBER} to get the current build.
already extensive answers are available in stack overflow. kindly surf it before raising the question.