Snmp daemon recovery

Fujitsu.Servers.PRIMERGY.Linux.SnmpManagement.Recovery (Recovery)

Recovers the snmp daemon process using a shell script (start/restart if necessary)

Element properties:

TargetFujitsu.Servers.PRIMERGY.Linux.SnmpManagement
MonitorFujitsu.Servers.PRIMERGY.Linux.snmp.ShellScript.LessThan.ThreeState.Monitor
Reset MonitorFalse
RemotableTrue
Timeout300
CategoryCustom
Enabledtrue
AccessibilityPublic

Member Modules:

ID Module Type TypeId RunAs 
InvokeWA WriteAction Fujitsu.Servers.PRIMERGY.Linux.ShellScript.WriteAction Default

Source Code:

<Recovery ID="Fujitsu.Servers.PRIMERGY.Linux.SnmpManagement.Recovery" Accessibility="Public" Enabled="true" Target="Fujitsu.Servers.PRIMERGY.Linux.SnmpManagement" Monitor="Fujitsu.Servers.PRIMERGY.Linux.snmp.ShellScript.LessThan.ThreeState.Monitor" ResetMonitor="false" ExecuteOnState="Error" Remotable="true" Timeout="300">
<Category>Custom</Category>
<WriteAction ID="InvokeWA" TypeID="Fujitsu.Servers.PRIMERGY.Linux.ShellScript.WriteAction">
<TargetSystem>$Target/Property[Type="Fujitsu.Servers.PRIMERGY.Linux.ManagementClientSoftware"]/NetworkName$</TargetSystem>
<ShScriptName>SnmpRecovery.sh</ShScriptName>
<ShScriptBody>#!/bin/sh
# Fujitsu
# Copyright 2014-2019 FUJITSU LIMITED
#
# SnmpRecovery.sh - script to start/restart SNMP daemon

SCRIPTLOG="/tmp/Fujitsu/$0.log"

# arguments check
DBG=`echo $1 | awk '{print tolower($0)}'`
[ "$DBG" = "dbg" ] &amp;&amp; echo "Running $0 in debug mode"

# In DEBUG mode: generate some files under "/tmp" to see, the script is running
if [ "$DBG" = "dbg" ]
then
mkdir -p /tmp/Fujitsu/
tail $SCRIPTLOG 2&gt;/dev/null &gt; $SCRIPTLOG.bk
mv -f $SCRIPTLOG.bk $SCRIPTLOG
echo "$0 V__MP_VERSION__ last ran at `date`" &gt;&gt; $SCRIPTLOG
fi

EECD=`whereis eecd | awk 'NF&gt;1{print $2}'`
if [ "$EECD" = "" ]
then
# either not a system from FUJITSU or no ServerView agents installed - do nothing!
[ "$DBG" = "dbg" ] &amp;&amp; echo "Not a system from FUJITSU or ServerView Agents not installed."
exit 0
fi

# test that SNMP is installed
SNMP=`whereis snmpd | awk 'NF&gt;1{print $2}'`
if [ "$SNMP" = "" ]
then
echo "SNMP is *NOT* installed! Cannot recover."
exit 0
fi
[ "$DBG" = "dbg" ] &amp;&amp; echo "SNMP is installed at: $SNMP"

SERVICE=`ls -1 /etc/init.d/ /usr/lib/systemd/system/ 2&gt;/dev/null | grep -i snmp | sed "s/.service//" | head -n 1`
# check if SNMP is running
SNMPRUNNING=`ps -A | grep -i '[s]nmpd'`
if [ "$SNMPRUNNING" = "" ]
then
echo "SNMP is not running, starting"
service $SERVICE start
exit 0
fi
[ "$DBG" = "dbg" ] &amp;&amp; echo "SNMP is running"

# check if SNMP is listening
SNMPLISTENING=`netstat -nlu | grep 161 | wc -l`
if [ $SNMPLISTENING -lt 1 ]
then
echo "SNMP is not listening, restarting"
service $SERVICE restart
exit 0
fi
[ "$DBG" = "dbg" ] &amp;&amp; echo "SNMP is listening"
[ "$DBG" = "dbg" ] &amp;&amp; echo "Nothing to do"

exit 0
</ShScriptBody>
<ScriptArguments>3_chars_DBG_for_DEBUG</ScriptArguments>
<Timeout>60</Timeout>
<UserName>$RunAs[Name="Unix!Microsoft.Unix.PrivilegedAccount"]/UserName$</UserName>
<Password>$RunAs[Name="Unix!Microsoft.Unix.PrivilegedAccount"]/Password$</Password>
</WriteAction>
</Recovery>