Xymon Mailing List Archive search

Xymon script question

list Scot Kreienkamp
Wed, 5 Jul 2017 14:34:09 +0000
Message-Id: <user-edd4fc9c7d50@xymon.invalid>

There is a repository on xymonton.org but not much is contributed to it.  This would need some modification to work on my RH systems but it's a good start.  Thanks for sharing.


Scot Kreienkamp  | Senior Systems Engineer | La-Z-Boy Corporate
One La-Z-Boy Drive | Monroe, Michigan 48162 |  Office: XXX-XXX-XXXX |  |  Mobile: XXXXXXXXXX | Email: user-9678697f1438@xymon.invalid
-----Original Message-----
From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Jaap Winius
Sent: Wednesday, July 5, 2017 9:52 AM
To: xymon at xymon.com
Subject: Re: [Xymon] Xymon script question

Quoting Scot Kreienkamp <user-9678697f1438@xymon.invalid>:

Hi Scot,

Thanks for your reply, I'll try it out in a bit. In the mean time,
here's my script:

==========================
#!/bin/bash

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

COLUMN=Reboot   # Name of the column
COLOR=green     # By default, everything is OK
MSG="Reboot required"

RUN=$(uname -r |awk -F - '{print $1}')  # Version of the running kernel
IRF=$(find /boot -type f -name "initrd.img-$RUN-*") # Find matching
init.rd file
FMD=$(stat -c %Y $IRF)  # Modify date of init.rd file in seconds since 1970
UPT=$(cat /proc/uptime |awk -F \. '{print $1}') # Seconds of uptime,
rounded down
EPC=$(date +%s)         # Current epoch (seconds since 1970)
DIF=$(($EPC-$FMD))      # Age of init.rd file in seconds

if [ $DIF -gt $UPT ]
then
        MSG="${MSG}:

        No. Already running the latest version of Linux kernel $RUN.
        "
else
        COLOR=yellow

        LFT=$(stat -c %y $IRF |awk -F \. '{print $1}') # Last modified time
        LBT=$(who -b |awk '{print $3" "$4}') # Last boot time

        MSG="${MSG}:

        Yes. A new version of Linux kernel $RUN was installed on $LFT after
the last reboot on $LBT.
        "
fi

# Tell Xymon about it
$XYMON $XYMSRV "status $MACHINE.$COLUMN $COLOR `date`

${MSG}
"

exit 0

==========================

I have the unattended-upgrades package installed on all of the
clients, which are only set to notify me if an error occurs, so this
way I'll know when it's time to reboot any of them.

Is there a Xymon repository somewhere for scripts like this?

Cheers,

Jaap


This message is intended only for the individual or entity to which it is addressed.  It may contain privileged, confidential information which is exempt from disclosure under applicable laws.  If you are not the intended recipient, you are strictly prohibited from disseminating or distributing this information (other than to the intended recipient) or copying this information.  If you have received this communication in error, please notify us immediately by e-mail or by telephone at the above number. Thank you.