#!/bin/bash # mdmcertcheck.sh is the script for checking a cert status # author mikedmorto 2021 year export LC_ALL="" export LANG="en_US.UTF-8" VERSION="0.1" CERTLIST="certlist.cfg" JSON="" ##### PARAMETERS##### METRIC="$1" ITEM="$2" case "$METRIC" in discovery) #records from the config file RECS=`cat $CERTLIST | awk -F: '/^[^#]/ { print $1 }' | grep -e "^cert=.*" | cut -f 2 -d "="` JSON="{ \"data\":[" # append data for REC_I in ${RECS}; do JSON=${JSON}" {\"{#CERT}\":\"${REC_I}\"}," done # delete last simbol and add the end JSON=${JSON::-1} JSON=${JSON}"]}" echo ${JSON} exit 0 ;; script.version) echo $VERSION ;; help) echo "please use these params { discovery script.version }" ;; *) echo "" ;; esac