Sunday Dec 13, 2009

Twitter as a sysadmin tool?

After the disk failures I have suffered I have decided to start using twitter monitor the health of my home server and network as this is easier to pick up than on my phone email. Also it provides a nice log.

Using a modified version of the command line twitter script http://blogs.sun.com/sandip/entry/tweeting_from_command_line_using modified so that it will read the account information from a file. I have changed the standard script I have for watching the system to use twitter rather than email to notify me of issues. It posts to the twitter account "syslogathome" which I now follow, you can too but I'm sure you won't want to.

My script to check things is here.

#!/bin/ksh

export PATH=/usr/sbin:/usr/bin

function tweet
{
        echo tweeting $1
        /usr/local/bin/tweet.py "$1"
}
function tweet_services
{
        typeset zone="$1 "
        if [[ "$1" != "global" ]]
        then
                typeset zl="pfexec zlogin $1 "
        else
                typeset zl=""
        fi
        ${zl}svcs -x | nawk '/\^svc:/ { s=$0 } /\^Reason:/ { print s,$0 }' | while read line
        do
                tweet "$zone$line"
        done
}
function tweet_zfs
{
        zpool list -H -o name,health | while read zfs state
        do
                [[ "$state" != "ONLINE" ]] && tweet "$zfs $state"
        done
}
function tweet_disks
{
        export IFS="    "
        kstat -p -m sderr -s "Predictive Failure Analysis" | while read err value
        do
                (( $value != 0 )) && tweet "$err     $value"
        done
}
function tweet_net
{
        typeset speed=$(dladm show-linkprop -co VALUE -p speed nge0)
        if (( $speed != 1000 ))
        then
                tweet "network running in degraded state $speed" 
        fi
}
function tweet_phone
{
        if ! ping phone 1 > /dev/null 2>&1
        then
                tweet "Phone is not responding"
        fi
}

for zone in $(zoneadm list)
do
        tweet_services $zone
done
tweet_zfs
tweet_disks
tweet_net
tweet_phone
About

This is the old blog of Chris Gerhard. It has mostly moved to http://chrisgerhard.wordpress.com

Search

Archives
« April 2014
MonTueWedThuFriSatSun
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today