HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Shell Script
Operating System - HP-UX
1833838
Members
2377
Online
110063
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2002 09:27 PM
10-16-2002 09:27 PM
Shell Script
Hi,
I am writing a shell script which will give me the database free space information and alert. I am getting the following output :
ds1dbs
5000000
991156
tmpdbs
1000000
999944
c3dbs
2000000
932508
s2dbs
5000000
1860968
rootdbs
512000
8815
testdbs
4000000
1087746
My requirement is that the script will calculate the percentage for all the above database like for testdbs:
1087746/4000000*100=27.19%.
If this percentage is more then 80% then it should send a mail to me?
Can anyone help me to get started?
Thanks,
Raje.
I am writing a shell script which will give me the database free space information and alert. I am getting the following output :
ds1dbs
5000000
991156
tmpdbs
1000000
999944
c3dbs
2000000
932508
s2dbs
5000000
1860968
rootdbs
512000
8815
testdbs
4000000
1087746
My requirement is that the script will calculate the percentage for all the above database like for testdbs:
1087746/4000000*100=27.19%.
If this percentage is more then 80% then it should send a mail to me?
Can anyone help me to get started?
Thanks,
Raje.
Everything is possible
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2002 06:24 AM
10-17-2002 06:24 AM
Re: Shell Script
Raje,
You could use perl for the whole thing.
while(<>) {
chomp;
if (/^\d+$/) {
chomp($n2=<>);
$pct=100*$n2/$_;
push(@db,sprintf "%3d %s",$pct,$db) if $pct > 80;
} else {
$db=$_;
}
}
if (scalar @db) {
open(OUT,"|mailx -s 'Some databases are over 80%' youremail\@yourhome.com'");
print OUT $_,"\n" foreach @db;
close(OUT);
}
HTH
-- Rod Hills
You could use perl for the whole thing.
while(<>) {
chomp;
if (/^\d+$/) {
chomp($n2=<>);
$pct=100*$n2/$_;
push(@db,sprintf "%3d %s",$pct,$db) if $pct > 80;
} else {
$db=$_;
}
}
if (scalar @db) {
open(OUT,"|mailx -s 'Some databases are over 80%' youremail\@yourhome.com'");
print OUT $_,"\n" foreach @db;
close(OUT);
}
HTH
-- Rod Hills
There be dragons...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2002 06:35 AM
10-17-2002 06:35 AM
Re: Shell Script
Once again, just in case ...
Hello,
using shell ... cat your input to this script :
#!/usr/bin/sh
while read DBS
do
read BLOCKS
read USED
read
PERC=$(($USED \* 100 / $BLOCKS))
[ "$PERC" -gt 80 ] &&
{
echo "\n$DBS has ${PERC}% blocks used\n" | mailx -s "Free space in $DBS" phelix
}
done
And you will receive :
Date: Thu, 17 Oct 2002 09:16:30 +0200 (METDST)
From: Jean-Louis Phelix
To: phelix
Subject: Free space in tmpdbs
tmpdbs has 99% blocks used
Hello,
using shell ... cat your input to this script :
#!/usr/bin/sh
while read DBS
do
read BLOCKS
read USED
read
PERC=$(($USED \* 100 / $BLOCKS))
[ "$PERC" -gt 80 ] &&
{
echo "\n$DBS has ${PERC}% blocks used\n" | mailx -s "Free space in $DBS" phelix
}
done
And you will receive :
Date: Thu, 17 Oct 2002 09:16:30 +0200 (METDST)
From: Jean-Louis Phelix
To: phelix
Subject: Free space in tmpdbs
tmpdbs has 99% blocks used
It works for me (© Bill McNAMARA ...)
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP