How to create shell script based monitor for Linux servrs in SCOM for CPU and Drive usage?

Pradeep shunmugam 1 Reputation point

Hello All,

I am new to SCOM. I am working on creating custom monitor for Linux servers using below Shell script.

df -H | grep -vE '^Filesystem|tmpfs|cdrom'  | awk '{ print FNR "\t " $0 }' | awk '{ print $1 " " $6 " " $2 }'

top -b -n2 -d1 | grep "Cpu(s)" | tail -n1 | awk '{print $2}' | awk -F. '{print $1}'

Drive alert using Threshold:

df -H | grep -vE '^Filesystem|tmpfs|cdrom'  | awk '{ print FNR "\t " $0 }' | awk '{ print $1 " " $6 " " $2 }' | while read -r output;
do  snum=$(echo "$output" | awk '{print $1}' )  usep=$(echo "$output" | awk '{ print $2}' | cut -d'%' -f1 )  partition=$(echo "$output" | awk '{ print $3 }' )  if [ $usep -ge 40 ]; then    echo $usep       fi

Using script "Drive alert using Threshold:",I am receiving only one alert even multiple drive/mountpoints have disk space greater than 40%. I have to receive alerts for each drive when it exceeds the threshold based on our organization requirement.

The default monitor allows us to have alert only for one threshold. We have to receive alert whenever threshold exceeds 70% , 85% and 95%.
Can someone please help me to create customized monitor for Linux CPU and Drive?

Thanks in advance.


Operations Manager
Operations Manager
A family of System Center products that provide infrastructure monitoring, help ensure the predictable performance and availability of vital applications, and offer comprehensive monitoring for datacenters and cloud, both private and public.
1,442 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. SChalakov 10,371 Reputation points MVP

    HI Pradeep (@Pradeep shunmugam ),

    I would encourage you to ask this in a Linux related forum. You have way better chances of getting a proper answer there, as here most of the people answering the threads are SCOM exeperts, but not necessarily Linux experts.
    SCOM will be able to either execute the script locally on your Linux systeme as exampled here and then get the data back to SCOM (never nmmind the version of SCOM from the article, the approach is exactly the same in the current SCOM versions, the GUI also):

    SCOM 2012 – Linux Two-State Monitor With “Script In Script”

    or you can paste the script directly from SCOM as shown here:

    SCOM 2016 – What’s New UNIX/Linux Series: Monitors And Rules Running (Any) Script E.G. Perl

    I hope I was able to help.


    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
    Stoyan Chalakov

    0 comments No comments

  2. Pradeep shunmugam 1 Reputation point

    Hello Stoyan,

    Thanks for your help.

    The shell script command line is working fine in Linux servers. But while using this in SCOM script based monitor for Linux server, we are not getting alerts for valid thresholds.
    I believe, I miss something in SCOM monitor. Hence I asked in SCOM forum.
    If possible, please help me to fix this.

    Please note that I followed the same document which you shared in your reply.


    0 comments No comments

  3. Bob Cornelissen 251 Reputation points MVP

    For the disk threshold monitoring... If you want separate alerts for each disk, you will have to target the monitor at the Linux Disks (not the linux server). And make sure your command uses the name of the targeted disk (you could pass the script a parameter of the targeted disk name). That way, each disk has its own health state and they can separately go into another state and alert.

    For the multiple thresholds. We can only do 2-state and 3-state monitors. So green-red (or green-yellow) and green-yellow-red. meaning thats two thresholds at most. You had 3 thresholds in your question, which will not be possible in that case.

    0 comments No comments

  4. Pradeep shunmugam 1 Reputation point

    Hello Bob,

    Thanks for your help.

    I will try this in our environment and will update here.

    Pradeep S.

    0 comments No comments