- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Disk Usage/Auditing and e-mail
Categories
Company
Local Language
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
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
Community
Resources
Forums
Blogs
- 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
11-02-2000 02:28 PM
11-02-2000 02:28 PM
Disk Usage/Auditing and e-mail
for i in `cat users.dir`
do
cd /home
du -k $i | mailx -s "Weekly Disk Usage for servername" [e-mail address]
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2000 02:36 PM
11-02-2000 02:36 PM
Re: Disk Usage/Auditing and e-mail
owner=`ll -d /home/$i | awk ' {print $3} '`
If you need the real name of the person, if it is in your passwd file you could do this then:
owner2=`grep $owner /etc/passwd | awk -F: ' {print $5}'`
You could probably combine the two statements into one if you like.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2000 02:39 PM
11-02-2000 02:39 PM
Re: Disk Usage/Auditing and e-mail
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2000 09:51 PM
11-02-2000 09:51 PM
Re: Disk Usage/Auditing and e-mail
owner_email=`grep $owner /etc/passwd | awk -F: '{print $5}' | awk '{print $1"_"$2"@ham.honda.com"}'`
This statement is taking the value of the $owner variable that was set in the script in my last reply and this takes the place of owner2. This is also assuming that the users real name in the /etc/passwd file (5th field) is in the form of 'first_name last_name' with no punctuation in there. If the first name and last name are reversed just do a $2"_"$1 in the above statement.
I believe that this will give you what you want. It may not be as elegant as some of the other scripting gurus out there can do, but it should work for you. It may be possible to combine the two statements, I haven't played with that. I may do that while I'm at the office tomorrow. I'll post results here if I succeed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2000 11:52 PM
11-02-2000 11:52 PM
Re: Disk Usage/Auditing and e-mail
Why bothering grep while awk can do the job alone?
awk -v pwnam=$owner -F: '$1==pwnam {print $5}' /etc/passwd
If you want to be kind of portable don't rely on awk's -v flag though.
Not all awk versions support this flag.
Instead you would rather pass it the shell's variable owner as extra argument.
But with HP's awk it should work.
If you're keen on using Perl you could do something like this:
perl -e 'while (($user,$gcos)=(getpwent())[0,5]) {print "$gcosn" if ($user eq $ARGV[0])}' $owner
For details see POD
perldoc -f getpwent
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2000 11:59 PM
11-02-2000 11:59 PM
Re: Disk Usage/Auditing and e-mail
I always forget to extra quote backslashes in this forum!
Of course, in the Perl line it has to read
... print "$gcos\n" ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2000 01:19 AM
11-03-2000 01:19 AM
Re: Disk Usage/Auditing and e-mail
This seems more appropriate:
perl -e 'print "@{[(getpwnam($ARGV[0]))[5]]}\n"' $owner
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2000 01:32 AM
11-03-2000 01:32 AM
Re: Disk Usage/Auditing and e-mail
mail_user=$(pwget -n $i |awk -F: '{print $5}')@ham.honda.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2000 07:32 AM
11-03-2000 07:32 AM
Re: Disk Usage/Auditing and e-mail
Here's a complete script that should work for you. This includes some of Ralph's suggestions, so be sure to assign points to him too.
Rainer's suggestion will only work if the home directory name is the same as the user name, which is not always the case.
Here is the complete script:
for i in `cat users.dir`
do
cd /home
owner=`ll -d /home/$i | awk '{print $3}'`
email=`awk -v pwnam=$owner -F: '$1==pwnam {print $5}' /etc/passwd | awk '{print $1"_"$2"@ham.honda.com"}'`
du -k $i | mailx -s "Weekly Disk Usage for `uname -n`" $email
done
Hope this is what you need.