#!/bin/bash # NTP monitorization plugin for Pandora FMS agent # Author: Manuel A. GulĂ­n Bejarano # Version: 1.0 # Date: 15/03/2013 # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . function help { echo -e "NTP monitorization agent plugin for Pandora FMS agent. http://pandorafms.com" echo -e "Syntax:" echo -e "\t\t$0" exit } if [ $# -ne 0 ] then help exit -1 fi # Info about ntp actual sync source - all retrieved with one query, later it's going to be appropiately parsed NTP_INFO=`ntpq -p | grep "*"` # Hostname of syncing source NTP_HOST=`echo "$NTP_INFO" | awk '{print $2}'` # Stratum of syncing source NTP_STRATUM=`echo "$NTP_INFO" | awk '{print $3}'` # Roundtrip of syncing source NTP_ROUNDTRIP=`echo "$NTP_INFO" | awk '{print $8}'` # Offset of syncing source NTP_OFFSET=`echo "$NTP_INFO" | awk '{print $9}'` # Jitter of syncing source NTP_JITTER=`echo "$NTP_INFO" | awk '{print $10}'` # Module to get the name of the current NTP source echo -e "\t" echo -e "\t" echo -e "\t" echo -e "\tasync_string" echo -e "\t0" echo -e "\t" echo -e "\t" # Module to get the stratum of the current NTP source echo -e "\t" echo -e "\t" echo -e "\t" echo -e "\tasync_data" echo -e "\tst" echo -e "\t0" echo -e "\t32" echo -e "\t4" echo -e "\t5" echo -e "\t6" echo -e "\t0" echo -e "\t" echo -e "\t" # Module to get the roundtrip delay of the current NTP source echo -e "\t" echo -e "\t" echo -e "\t" echo -e "\tgeneric_data" echo -e "\tmsec" echo -e "\t0" echo -e "\t1500" echo -e "\t1999" echo -e "\t2000" echo -e "\t0" echo -e "\t" echo -e "\t" # Module to get the offset relative to the current NTP source echo -e "\t" echo -e "\t" echo -e "\t" echo -e "\tgeneric_data" echo -e "\tmsec" echo -e "\t0" echo -e "\t1500" echo -e "\t1999" echo -e "\t2000" echo -e "\t0" echo -e "\t" echo -e "\t" # Module to get the jitter relative to the current NTP source echo -e "\t" echo -e "\t" echo -e "\t" echo -e "\tgeneric_data" echo -e "\tmsec" echo -e "\t0" echo -e "\t20" echo -e "\t49" echo -e "\t50" echo -e "\t0" echo -e "\t" echo -e "\t"