Please avoid previous script take below as the updated script.
I have tried to run a bash script in a host which is added in the checkmk
.
path of the script : /usr/lib/check_mk_agent/local
and the script is
!/bin/bash
host=hostname -I
result1=$(mysql -u root -N<<<“SELECT MEMBER_STATE FROM performance_schema.replication_group_members where MEMBER_HOST=’$host’;”)
#result=echo $result1 | sed 's/ *$//g'
if [[ “$result1” == “ONLINE” ]];
then
result=“ONLINE”
else
result=$result1
fi
if [[ “$result” == “ONLINE” ]];
then
status=0
statustxt=“Replication status - OK” #echo “OK”
elif [[ “$result” == “RECOVERY” ]];
then
status=1
statustxt=“Replication status - WARNING”
else
status=2
statustxt=“Replication status - CRITICAL”
echo “From Critical Condition”
fi
echo “$status GROUP_REPLICATION - $statustxt”
Above is the script and output its giving 0 status but in checkmk its showing as critical status .
Please avoid early post . Please run this script and check an et me know any further changes to be done. When i am running the script i am getting 0 status but in checkmk its showing critical. Here i am just taking the member_state (online,offline,warning) of a server from a table in mysql and updating the status in the checkmk and its written in /usr/lib/check_mk_agent/local.
Please help me why the status ot reflecting properly n checkmk , its showing critical only
x.sh: line 16: syntax error near unexpected token `then'
x.sh: line 16: `then'
Also, the variable $result1 is never used and $result is never set.
I’d say there is no way the script you posted is giving status 0. It simply doesn’t run.
The line result=echo $result1 | sed 's/ *$//g' needs either backticks or $(…). In the original post it had backticks, what’s why it rendered as literal text.
The CRIT case won’t work because of the echo "…" line. It will upset checkmk to find a line that doesn’t look like 0 name - text.
root@uat: /usr/lib/check_mk_agent/local# bash replication_status
0 GROUP_REPLICATION - Replication status - OK
I am getting the output as this
but in checkmk its showing critical only
Can you please let me know why is it so.
and one does this self written check need to be kept in local or inside plugin since in local after sometime this local checkmk service is moving to vanished service and mentioning status as “UNKNOWN”
result1=$(mysql -u root -N<<<“SELECT MEMBER_STATE FROM performance_schema.replication_group_members where MEMBER_HOST=’$host’;”)
is giving correct value as “online” without column name
and i am getting the output while running this bash file as
0 GROUP_REPLICATION - Replication status - OK
but in checkmk its showing critical
cna you please help me where i am lagging . any further changes to be done. And this check i have done in local . So after few hours in checkmk its moving dis service as unknown and vanised service. So where i need to move this self written check so that it wont move to vanished service.
Its not resolved
Please let me know if we keep our customised script under check_mk_agent/plugins/ why its not getting reflected in the checkmk server with the output