- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- user audit scripts
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
03-24-2007 07:39 PM
03-24-2007 07:39 PM
user audit scripts
I am new to scripting. Could someone have user audit shell scripts for following purpose.
1. List of All Groups and Members of Groups.
Report should looklike
GID --- USERID----Last login date
2. List of Users with no Activity in past six months.
My OS is hp-ux 11.00.
Thanking you in advance,
Kannan
- Tags:
- passwd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2007 07:52 PM
03-24-2007 07:52 PM
Re: user audit scripts
Your request is not specific enough to provide a complete script. I will give over a few concepts.
/etc/group
This lists all groups and can be used with awk to select other information based on group.
cat /etc/group | awk '{print $1}' > file
while read -r groupname
do
grep $groupname /etc/passwd # awk can be used for refinement
done < file
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=51050
The link above connects to a treasure trove of syadmin scripts. One of them might do exactly what you want.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2007 12:15 AM
03-25-2007 12:15 AM
Re: user audit scripts
This is the quickest one you can try at:
--
for i in `awk -F: '{print $1}' /etc/passwd`
do
grep $1 /etc/passwd|cut
last -1 -R $i|grep -v wtmp|grep -v '^ *$'
done
---
and do a man last
If you finetune it with SEP's one you can almost get whatever you want.
There is an system auditing feature availabe on hp-ux also but needs good understanding.
Regards,
Rasheed Tamton.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2007 12:19 AM
03-25-2007 12:19 AM
Re: user audit scripts
The working one is below:
for i in `awk -F: '{print $1}' /etc/passwd`
do
last -1 -R $i|grep -v wtmp|grep -v '^ *$'
done
Rgds,
Rasheed Tamton.
- Tags:
- last
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2007 05:02 AM
03-25-2007 05:02 AM
Re: user audit scripts
> I am new to scripting.
Then the best way to begin is to try to _write_ something.
Look at the manpages for 'last(1)', 'listusers(1)' and 'logins(1M)'. These would be very useful in providing the data you want to satisfy your request.
You can use 'cut' or 'awk' to snip fields from either the raw group and password files or from the output of the above commands.
If you need an overview or a re-fresher for the shell, this is brief and free:
http://www.docs.hp.com/en/B2355-90046/B2355-90046.pdf
I would urge you to use the Posix shell as this is the HP-UX standard. It aligns closely with the Korn shell or even the Linux Bash shell to a large extent.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2007 10:47 PM
03-25-2007 10:47 PM
Re: user audit scripts
How do we check the Users with no activity in last 6 months.?
Also # passwd -s
Thanks,
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2007 12:03 AM
03-26-2007 12:03 AM
Re: user audit scripts
for i in `awk -F: '{print $1}' /etc/passwd`
do
last -1 $i|awk '{print $1, $4, $5}'|grep -v wtmp|grep -v '^ *$'
done
This might give you the last one login from all the users who had logged in the system.
There is an old script from Paula (below link) may be it will be useful for you.
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=39611
Reg. NIS, did you check the /etc/nsswitch.conf
May be you need to use passwd -r nis
Regards,
Rasheed Tamton.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2007 12:14 AM
03-26-2007 12:14 AM
Re: user audit scripts
Below is a DIRTY and tricky script with minor changes to the above one.
If you are really looking for a SIMPLE one it will help you for the time being.
for i in `awk -F: '{print $1}' /etc/passwd`
do
last -1 $i|awk '{print $1, $4, $5}'|grep -E 'Mar|Feb|Jan|Dec|Nov|Oct' |grep -v w
tmp|grep -v '^ *$'
done
(I just put the last six months from March backwards!!!)
Regards,
Rasheed Tamton.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2007 01:24 AM
03-26-2007 01:24 AM
Re: user audit scripts
While '/var/adm/wtmp' and 'last' is the standard vehicle for reading the binary file, the output does not include the _year_ of the entry, only the month.
A more useful mode in which to interpret 'wtmp' data is to transform the binary file into an Ascii text file:
# /usr/sbin/acct/fwtmp < /var/adm/wtmp > /tmp/wtmp
...or push the data into a pipe:
# /usr/sbin/acct/fwtmp < /var/adm/wtmp | ...
One advantage of this is that the full date (+year) is available let alone the epoch seconds timestamp.
Regards!
...JRF...
- Tags:
- fwtmp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2007 02:00 AM
03-26-2007 02:00 AM
Re: user audit scripts
thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2007 02:18 AM
03-26-2007 02:18 AM
Re: user audit scripts
Have you already searched in this forum?
check this thread: http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1006456
Hope this helps a bit.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2007 01:35 AM
04-01-2007 01:35 AM
Re: user audit scripts
Thanking you in advance,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2007 08:41 AM
04-03-2007 08:41 AM
Re: user audit scripts
For instance,
while (done==0)
finger * | awk '{ print $3,$9,$10,$11,$22,$23,$24 }' >> /finger_info
I'm not sure it would pull it in correctly, and it depende that you have finger installed. What you could do with awk is redirect all the output of finger to a file, and then use the awk getline function to read line by line, then test for the date being within 6 months and print it out to a report file.
Just thoughts, but always far different than reality.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2007 05:45 PM
04-09-2007 05:45 PM
Re: user audit scripts
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2007 07:23 PM
04-10-2007 07:23 PM
Re: user audit scripts
If you have backups of old wtmp files somewhere for the last six months - you can do like this as a workaround:
-Make a backup of the current wtmp file
- restore the old wtmp files,
rename those to different names,
and concatenate those files with the current wtmp and do the above scripts using last or finger on that.
If you want some editing on wtmp you can use :
/usr/lib/acct/fwtmp < wtmp > wtmp.txt
vi wtmp.txt
Convert back the modified wtmp.txt file back to original wtmp
(before this step make sure that you have the original backup of wtmp)
/usr/lib/acct/fwtmp -ic < wtmp.txt > wtmp
Regards,
Rasheed Tamton.