Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- awk '
- BEGIN {
- FULL="'$1'"
- FS=":";
- FMT="%-16s %-20s %-28s %20s %16s\n";
- print "User Summary for ""'$HOSTNAME'\n";
- "df -TB 1 | sed -n '"'2 p'"' | awk '"'{ print \$5 }'"'" |getline DISKTOTAL;
- printf(FMT , "NAME", "LAST LOGIN", "HOME", "DISK USAGE", "SHELL");
- printf(FMT , "===========", "================", "========================", "===================", $
- }{
- if ($NF != "/sbin/nologin" || FULL == "-a") {
- if (!$2 == "")
- NOPASS = NOPASS $1;
- NPCNT += NPCNT;
- DISKUSE == 0;
- "du -b " $6 " | sed -n '"'\$p'"' | awk '"'{ print \$1 }'"'" |getline DISKUSE;
- if (DISKUSE != "0") {
- TOTALUSE += DISKUSE;
- DISK = ((DISKUSE / DISKTOTAL) * 100);
- if (DISK < .01)
- DISK = .01;
- DISK = sprintf(" (%.2f\%)", DISK);
- DISKUSE = int(DISKUSE / 1024) "kb";
- } else {
- DISKUSE = "-- ";
- DISK = "";
- }
- "last -n 1 " $1 " | sed -n '"'1 p'"' | awk '"'{ print \$4,\$5,\$6,\$7 }'"'" |getline NLAST;
- if (index(NLAST, ":") == 0)
- NLAST=" --"
- printf(FMT, $1, NLAST, $6,DISKUSE DISK, $7);
- CNT++;
- }
- }
- END {
- printf("\n%s Displayed Users are using %sMB / %sMB disk space\n", CNT, int((TOTALUSE / 1024)
- / 1024$
- printf("There are %d Users without passwords", NPCNT);
- if (NPCNT > 0)
- printf(":\n %s\n", NOPASS);
- }' /etc/passwd 2>/dev/null;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement