Monitor Linux

Discussion in 'Programming/Scripts' started by darkcodec, Sep 27, 2019.

  1. darkcodec

    darkcodec New Member

    Inside my isolated local LAN I have one Linux box working as a deployment host (Orchestrator) Monitoring multiple Linux boxes Box1, Box2....Boxn. On the deployment Linux box, i have installed smstools to send me sms.
    I want to build a script placed on the deployment host to monitor specific process on each linux box, and give me on daily basis SMS messages which kind on process running.

    for host in $(cat /home/operator/shellscripts/host.txt)
    echo -n > /home/operator/shellscripts/$host.txt
    for process in $(cat /home/operator/shellscripts/process.txt)
    ssh $host "ps ax | grep $process | grep -v grep" > /home/operator/shellscripts/$host.txt
    if [[ -s /home/operator/$host.txt ]] ; then
    echo $process is running in $host
    echo $process is not running in $host
    fi ;

    in the host, file stated all hosts IP's I need to monitor

    in the process.txt stated all process i need to monitor on each box (for example i have to look if NTP and HTTP working on the fist host X.X.X.X) and so on

    ntp http
    oracle cluster
    https http

    in the phonelist.txt stated all numbers of whitelisted operators, they should be notified about all hosts
    009XXXXXXXXXXXX #op1
    009yyyyyyyyyyyy #op2
    009zzzzzzzzzzzz #op3

    in the authen.txt stated the username/password of the operator to login via ssh on each server, each server has its own authentication credential.
    operator1 password1 #box1
    operator2 password2 #box2

    The output should be like this inside the SMS
    named, http running in x.x.x.x (OK)
    https not runnning in x.x.x.x
    mysql running in y.y.y.y (OK)

Share This Page