Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Required cpu , memory, df output in mail for multiple servers Post 303041705 by yash_message on Monday 2nd of December 2019 09:27:43 AM
Old 12-02-2019
Required cpu , memory, df output in mail for multiple servers

I have prepared script which will collect cpu, memory and df out out for multiple server and send in one mail, but my script only run in one server, and when I send to mail, it shows in text format. it should be show actual format.
if any one can help , that would be very grateful.

script ---------------

Code:
#!/bin/sh
echo "############################################################## $(hostname) ##########################################"
echo "#Memory Status ------------>>"
free -m | awk 'NR==2{printf "Memory Usage: %s/%sMB (%.2f%%)\n", $3,$2,$3*100/$2 }'
echo "#CPU Uses ------------>>"
top -bn1 | grep load | awk '{printf "CPU Load: %.2f\n", $(NF-2)}'

echo "#Disk Uses ------------>>"
df -Ph | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5,$1 }' | while read output;
do
  echo $output
  used=$(echo $output | awk '{print $1}' | sed s/%//g)
  partition=$(echo $output | awk '{print $2}')
  if [ $used -ge 60 ]; then
 #echo "The partition \"$partition\" on $(hostname) has used $used% at $(date)" | mail -s "Disk Space Alert: $used% Used On $(hostname)" mail@email.com
  echo "The partition \"$partition\" Please check, Its reached 80% --------->>>>>  $used% "
  fi
done

Output....................

#Memory Status ------------>>
Memory Usage: 000/00000MB (13.57%)
#CPU Uses ------------>>
CPU Load: 0.01
#Disk Uses ------------>>
10% /dev/mapper/rootvg-rootlv
10% /dev/mapper/rootvg-usrlv
10% /dev/mapper/rootvg-optlv
10% /dev/mapper/rootvg-varlv
10% /dev/mapper/rootvg-tmplv
10% /dev/sdy1
10% /dev/mapper/rootvg-homelv
10% /dev/sdz1
10% /dev/mapper/rootvg-data
10% /dev/mapper/rootvg-var_loglv


Last edited by Neo; 12-02-2019 at 10:38 AM.. Reason: Code Tags Please See YT Video on this: https://youtu.be/4BuPvWJV__k
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

e-mail client supporting HTTP mail servers

Hi all I want to know, is there any e-mail client in linux which supports HTTP mail servers. i am using fedora2. as far as investigated or tried I only find POP or IMAP mail server configuration in mozilla mail, ximian and there were no option such as HTTP. I can easily see my e-mail while i am... (0 Replies)
Discussion started by: babayeve
0 Replies

2. UNIX for Dummies Questions & Answers

cpu, memory and virtual memory usage

Hi All, Does anyone know what the best commands in the UNIX command line are for obtaining this info: current CPU usage memory usage virtual memory usage preferably with date and time parameters too? thanks ocelot (4 Replies)
Discussion started by: ocelot
4 Replies

3. UNIX for Advanced & Expert Users

Script to access multiple linux servers to get system details such as CPU usage

Hi Is there any shell script that accesses multiple linux servers to get details such as CPU usage, RAM used etc. The access of the servers must be parallel not serial in the sense it must ping all the servers at a time to get information.The script has to be triggered from a host system and get... (7 Replies)
Discussion started by: mssrivatsa
7 Replies

4. Shell Programming and Scripting

Need a script to run on multiple mail servers..

Hello, I am a Unix newbie and I need a script in which I can run a command on multiple servers at work. The command is to start a storage process and I am sick of doing it manually on all servers.. Here's the command: /opt/bss/bin/snmptable -CB -v2c -c P67LzuBm hostname hrStorageTable... (4 Replies)
Discussion started by: kinyyy
4 Replies

5. AIX

Monitor Physical CPU usage on multiple servers

Hello, Looking for some help. I am trying to gather data at each server showing when the physical CPU is being used the most based on a weekly timeframe. I know this data can be seen through NMON but with multiple servers in our environment it could take a real long time. is there a easier... (4 Replies)
Discussion started by: audis$
4 Replies

6. Shell Programming and Scripting

script to mail monitoring output if required or redirect output to log file

Below script perfectly works, giving below mail output. BUT, I want to make the script mail only if there are any D-Defined/T-Transition/B-Broken State WPARs and also to copy the output generated during monitoring to a temporary log file, which gets cleaned up every week. Need suggestions. ... (4 Replies)
Discussion started by: aix_admin_007
4 Replies

7. Shell Programming and Scripting

Shell Code required -Output in Multiple Rows to be in single row separated by Commas -

Hola Greetings Experts , I have records spreaded across multiple lines. in attached log.txt i want output to be in 1 line like this below Atached as Output.txt. In brief Output related to 1 line is spreaded across multiple row I wanted it to be in 1 row . Please opem the file in notepad... (4 Replies)
Discussion started by: manishK
4 Replies

8. UNIX for Dummies Questions & Answers

CPU and Memory Statistics Collection Across Many Servers

Hello geeks once again, many thanks for help in times past, you guys are awesome! But am here again, but now this is way heavy for me. Find below for my challenge: *** I need to collect CPU & RAM stats across 26 servers. *** I don't have the luxury of deploying an NMS, if I had it would... (3 Replies)
Discussion started by: infinitydon
3 Replies

9. Shell Programming and Scripting

Send multiple HTML output in one mail

HI, I have two scripts which is sending the mail in html format. Script 1: 1.IFILE=/home/home01/Report.csv if #Checks if file exists and readable then if awk -F, '{ T += $13 } END { exit(!T) }' ${IFILE} then awk -F, 'BEGIN{ c=split("3,4,8,9,13", col) print "To:... (0 Replies)
Discussion started by: Vivekit82
0 Replies

10. Shell Programming and Scripting

Required formatted output on mail for disk utilization

Hi Experts, Could you pls help with below query I have written below script to capture disk utilization and then send the output on mail. But getting unformated output on mail #!/bin/bash echo "Hi Sur,">dfoutput.csv printf '\n' >>dfoutput.csv echo "Please find BAYSQUAR2 filesystem... (4 Replies)
Discussion started by: as7951
4 Replies
HOBBIT-MAILACK(8)					      System Manager's Manual						 HOBBIT-MAILACK(8)

NAME
hobbit-mailack - permit acknowledging alerts via e-mail SYNOPSIS
hobbit-mailack --env=FILENAME [--debug] DESCRIPTION
hobbit-mailack normally runs as an input mail-filter for the hobbit user, e.g. by being called from the xymon users' procmailrc(5) file. hobbit-mailack recognizes e-mails that are replies to hobbitd_alert(8) mail alerts, and converts the reply mail into an acknowledge message that is sent to the Xymon system. This permits an administrator to acknowledge an alert via e-mail. ADDING INFORMATION TO THE REPLY MAIL
By default, an acknowledgment is valid for 1 hour. If you know in advance that solving the problem is going to take longer, you can change this by adding delay=DURATION to the subject of your mail reply or on a line in the reply message. Duration is in minutes, unless you add a trailing 'h' (for 'hours'), 'd' (for 'days') or 'w' (for 'weeks'). You can also include a message that will show up on the status-page together with the acknowledgment, e.g. to provide an explanation for the issue or some other information to the users. You can either put it at the end of the subject line as msg=Some random text, or you can just enter it in the e-mail as the first non-blank line of text in the mail (a "delay=N" line is ignored when looking for the message text). USE WITH PROCMAIL
To setup hobbit-mailack, create a .procmailrc file in the xymon-users home-directory with the following contents: DEFAULT=$HOME/Mailbox LOGFILE=$HOME/procmail.log :0 | $HOME/server/bin/hobbit-mailack --env=$HOME/server/etc/hobbitserver.cfg USE WITH QMAIL
If you are using Qmail to deliver mail locally, you can run hobbit-mailack directly from a .qmail file. Setup the xymon-users .qmail file like this: | $HOME/server/bin/hobbit-mailack --env=$HOME/server/etc/hobbitserver.cfg OPTIONS
--env=FILENAME Load environment from FILENAME, usually hobbitserver.cfg. --debug Dont send a message to hobbitd, but dump the message to stdout. SEE ALSO
hobbitd_alert(8), hobbitd(8), xymon(7) Xymon Version 4.2.3: 4 Feb 2009 HOBBIT-MAILACK(8)
All times are GMT -4. The time now is 08:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy