shell script
Hi.. I need a shell script, which will send mails only then when there is some problem with hard disk health, processor, when disk usage is exceeding 90% etc. Can anybody provide the basic idea regarding this?
|
Actually you can write a small PERL/PHP script.
You can call this script on demand (in any event, failure, or some issue), and trigger via shell or via command interface. You can google php email script and or perl email scripts. it is very easy. You can even create simple text based emails or advance html based emails also emails with attachments and so on. This should look like professional corporate emails. Hope this suggestion helps you. If you are too much new to shell scripts, then I suggest you to better learn php or PERL. They are more better languages than shell scripts. I agree shell scripts are very powerful, but the language constructs are too much looks old outdated format. So adapt to php/perl scripts, and call them via simple shell scripts ! |
I myself would prefer rather Perl than Php, but it's really matter of choice.
I currently don't know any name of script which have this functionality, so if there won't be any other suggestions, I recommend you writing it yourself. (It's by the way, a great practice to get into Linux/Unix). To make script of this functionality, you're going to need: 1) A way to send email. Either you can run mail server on your own computer, or use some program (possibly function of language too) to contact your (favourite) mail server. 2) A way to start this script regularly. Linux has pretty good apps in this section, take a look at some "cron" apps, my favourite is Vixie cron, and you probably have some already installed in your system. 3) A way to collect this kind of information. Information you are interested in "are not simply floating around in the system", and you are going to need specific applications and drivers to access it. Let me send you a quick list of apps I prefer: -smartmontools: Used to access SMART data of disks which support it. The specific command (file) you use to start this application vary from distribution to distribution, but here on Gentoo it's "smartctl". -df: File system disk storage usage. -lm_sensors: Collect data from sensors, like cpu or motherboard temperature, fan speeds, etc. -free: Memory/swap usage, to see if you are running out of RAM memory. You can also "pickup" "critical" level entries from system logs. Logs are usually located in /var/log/ directory. 4) All the programs specified have their own way of output, you can process it with sed or similar applications. 5) Root access. Feel free to correct/update me. Skyer |
shell script
Could you please provide me some basic idea or any url links that how can I write script for smartmontools, loadaverage, disk usage etc. So I can get mails in the event of critical isssue i.e when disk usage exceed more than 90%, HDD health is not good, if there are any problem in apache, samba etc.
Quote:
|
Well,
I myself would make this application as a shell script. It's good as interface with other programs, and provides all tools we need. You probably use Bash. You can get enough information on Bash on tlpd - http://tldp.org/LDP/Bash-Beginners-Guide/html/ So, basically: 1. Initialize/check for all stuff we need. (Internet connection, root access, etc..) 2. Start running apps which provide information we need. 3. Redirect their output to (for example) sed, process it to get only infrmation you need (numbers probably) to check. 4. Run it through set of conditions. 5. If needed, send mail. I haven't done this myself in shell script yet, but in case there won't be any program for this, you can simply use member function of some programming language, or netcat. Refer to manuals, if you need more information om respective applications. Code:
man sed Skyer |
Could this be re-inventing a wheel that already exists?
|
|
Quote:
There are THOUSANDS of scripting tutorials you can easily find via Google, along with MANY sample scripts, if you try to look. |
shell script
I have heard about naios, munin etc. So Thank you very much for your kind reply and I'll follow the documentation for nagios.
Quote:
|
All times are GMT -5. The time now is 03:19 AM. |