df -kh on 30+ servers using script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting df -kh on 30+ servers using script?
# 1  
Old 02-17-2010
Question df -kh on 30+ servers using script?

It feels like I have taken on to of a big task.. but I want to learn but dont know where to start.. Rome wasnt built in one day right..

I have around 30+ servers running linux/unix flavours and need to be able to do this in a script that will be a cronjob.
- ssh to all 30+ servers
- do df -kh
- save server name and result to TodaysDate.log
- check result if diskspace/partition is less then 20%
- send an email if the above is true.


Bare in mind I have never written any advanced scipt.. so this is probably simple for you h4x0rs out there..
In my head
SERVERLIST=servers.txt
SSH first hit from servers.txt
ssh user@server.lan df -kh
save result in Todaysdate.log
move to next server in list
if no more server then check todaysdate.log
if space is less then 20% then
email admin@n00badmin.com
end
Smilie

not sure I will be able to do ssh keys on every machine.. so an option would be to save the pwds in a file.. its a closed LAN.. its sounds bad I know but if I could start with that..
# 2  
Old 02-17-2010
Why dont you use Nagios for this issue? You can install Nagios one Master server that you will choose, and then install Nagios NRPE in all other 29 servers.

In Nagios, NRPE reports remote hosts status to main Nagios server and you can monitor all the Servers on the screen of Master server. Using "du -sh" or "df - kh" you can write an easy script and then put it's path in all 29 NRPE servers' NRPE config files and finaly you collect all the status of those servers. Use Active checks for this purpose. You can set check status of scripts also in config files.

You can also check results of some scripts ( which is placed in crontab) periodically by writing nagios plugin.

I know at first sight it might look so different and diffucult to you but you can do it searching..
I hope i give you a way to do it
Regards

Last edited by EAGL€; 02-17-2010 at 03:47 PM..
# 3  
Old 02-17-2010
you are correct.. we run Nagios on other systems so Im familiar with that.. but these systems are a big no no.. I cant go into what they do but we arent allowed to install Nagios on them Smilie

youre thinking is in the right way though.. Nagios was my first thought too Smilie
# 4  
Old 02-17-2010
Quote:
Originally Posted by ebolasmurf
you are correct.. we run Nagios on other systems so Im familiar with that.. but these systems are a big no no.. I cant go into what they do but we arent allowed to install Nagios on them Smilie

youre thinking is in the right way though.. Nagios was my first thought too Smilie
Yes really, once i needed to monitor 6 production servers and i did know nothing about nagios but searching and searching i learnt enough to configure considering requirements. I offered it because of monitoring is good, and once you unserstand configuration method its so usefull. Im afraid you should use ssh
Smilie

and in df -kh you can get the % column info like

Code:
df -kh | nawk '{print $(NF-1)}'

or this one give only % usage of root partition "/"
Code:
df -kh | nawk '/^\/ /{print $(NF-1)}'

and use such example values in comparision loop or loops according to critical level in requirement and go on Smilie

Last edited by EAGL€; 02-17-2010 at 04:30 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

Call one script from other script lying on different servers.

HI All, I have a requirement of execueting a Shell script on serverA, which is going to execute an application script ( Hyperian Planning script ) on serverB. Can any one please help in how to achieve this? e.g. script abc.ksh runs on serverA. internally abc.ksh call a script... (3 Replies)
Discussion started by: alok2082
3 Replies

2. Shell Programming and Scripting

Exit the script when all servers are down

Hello All, I have a script which needs to exit once it encounters that all the servers are down. In the below portion of a code the content manager is having values of server for example server A , server B. So I want the script to exit only if all the servers are down and to continue if one... (4 Replies)
Discussion started by: Vikram_Tanwar12
4 Replies

3. Shell Programming and Scripting

Script to Ping Servers

Hey, It's me again! Still trying to learn to become a better scripter on the job :) New challenge for assistance, if anyone cares to help, and its two parted! First part, I wanted to create a script at work that would ping a server that was supplied in an argument, then a count (amount of times)... (5 Replies)
Discussion started by: gkelly1117
5 Replies

4. Shell Programming and Scripting

Run a script in parts on 2 servers

Hi all, I have a task for which I need to run some commands on one server1 and then jump from the server1 (using ssh and asking user to enter login credentials manually for server2 server) to server2 and run some commands there and exit. I know the script I need here but problem is when I... (5 Replies)
Discussion started by: pat_pramod
5 Replies

5. Shell Programming and Scripting

Need bash script to ping the servers and rename the output file each time the script is ran

HI, I have a file serverlist in that all host names are placed. i have written a small script #./testping #! /bin/bash for i in `cat serverlist` do ping $i >> output.txt done so now it creates a file output.txt till here fine.. now each time i run this script the output file... (4 Replies)
Discussion started by: madhudeva
4 Replies

6. Shell Programming and Scripting

Script to login to several servers and get files

Hi ppl, I am looking out for a shell script a. That would have to login(from a main server) to say 16 servers individually. b.On each server go to a particular location, check if a particular file is generated on a date(say every sunday it gets generated and i would be interested in the latest... (8 Replies)
Discussion started by: yohasini
8 Replies

7. Shell Programming and Scripting

Help with script checking for a file in various servers

I am trying to write a script that checks whether or not, a file exists on multiple servers. My code / logic so far is: #!/usr/bin/ksh print "Enter File name to be checked" read MYFILE ssh server1 " cd /var/opt/logs ; if then ... (4 Replies)
Discussion started by: momin
4 Replies

8. Shell Programming and Scripting

script to locate servers

I am a newbie in shell scripting and I need to produce a script to work and achieve the following: 1) Look into the file /etc/defaultrouter , and store the value in it 2) If the value is a number, go to LIST and print out the second column corresponding to the value.(eg London) 3) If the... (5 Replies)
Discussion started by: ibroxy
5 Replies

9. UNIX for Advanced & Expert Users

script to ping servers

Hi , I would like to automate a script to ping all the unix servers perodically thru cronjob. Is there any script out there? If so Please give me. Thanks in advance. (2 Replies)
Discussion started by: sriny
2 Replies

10. UNIX for Dummies Questions & Answers

3 servers 1 .ksh script

system = AIX How can I explain this..... Keep in mind I do not want to login to the boxes, persay, and that I am fairly new to scripting and unix. I want to use SSH. I have a script on server1, this is where I want it to run from. I have server2 and server3, where I want the script to... (2 Replies)
Discussion started by: cml2008
2 Replies
Login or Register to Ask a Question