Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 436946 - Hacking on the CVS slacker report script
Summary: Hacking on the CVS slacker report script
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Infrastructure
Classification: Unclassified
Component: Other (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Infrastructure
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-02 09:17 UTC by Dirkjan Ochtman (RETIRED)
Modified: 2013-01-06 17:45 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirkjan Ochtman (RETIRED) gentoo-dev 2012-10-02 09:17:45 UTC
Is it in a repository somewhere? I'd like to take a stab at making it a tad more actionable.
Comment 1 Alec Warner (RETIRED) archtester gentoo-dev Security 2012-10-07 02:07:40 UTC
(In reply to comment #0)
> Is it in a repository somewhere? I'd like to take a stab at making it a tad
> more actionable.

antarus@a01 ~/code/checkouts/cfengine $ cat ./files/usr/local/sbin/vcs/slackers.sh
#!/bin/bash
# - blame solar

exempt_accessibility=""
exempt_docs=""
exempt_extra="hparker"
exempt_forums="amne kallamej deathwing00 earthwings maedhros neddyseagoon desultory jmbsvicetto kernelsensei mark_alec pilla pjp think4urs11 tomk klieber"
exempt_infra="robbat2 kingtaco armin76 darkside idl0r tampakrap craig antarus a3li ferringb"
exempt_pr="dberkholz dabbott"
exempt_services="gbackup gplanet gmanual gweb gmirror forums distfiles glsr gcfengine"
exempt_types="accessibility docs extra forums infra pr services"

raw_exempt=""
exempt=""
for ty in ${exempt_types} ; do
        n="exempt_$ty"
  raw_exempt="${exempt} ${!n}"
  for nick in ${!n} ; do
    exempt="${exempt} ^${nick}:${ty}"
  done
done

function checkexempt() {
  nick="$1"
  tmp="${exempt//*^${nick}:/${nick}:}"
  tmp="${tmp// *}"
  [ -n "${tmp}" ] && echo "(ex:$tmp)   "
}

time_2months_ago=$(date +%s -d '2 months ago' -u)
time_now=$(date +%s -d 'now' -u)
mkdir -p /tmp/slackers/
outfile="/tmp/slackers/as_of_${time_now}"
infile=/var/cvsroot/CVSROOT/history

/usr/local/sbin/find-slackers.py -t "${time_2months_ago}" -a 'AMR' ${infile} >${outfile}
# format is:
# commits:name:timestamp:roles+

rm -f ${outfile}.mail
echo "-----------------------------------------------------------------------------" >>${outfile}.mail.header
echo "This data is auto generated, take results with a grain of salt.              " >>${outfile}.mail.header
echo '(ex:NICK:GROUP) = $NICK exempt in $GROUP                                     ' >>${outfile}.mail.header
echo "COMMITS  NAME   LAST    BUGCOUNT RETIRE_BUG ROLES                            " >>${outfile}.mail.header
echo "-----------------------------------------------------------------------------" >>${outfile}.mail.header

for entry in $(/usr/bin/getent passwd | /bin/grep /home/ | /usr/bin/cut -d : -f 1,6 | /usr/bin/sort | /usr/bin/uniq); do
        user=$(echo $entry | cut -d : -f 1)
        home=$(echo $entry | cut -d : -f 2)
        [[ ! -e ${home}/.ssh/authorized_keys ]] && continue

        buf="$(grep ":${user}:" ${outfile})"

        if [[ "$buf" != "" ]]; then
                tmp="${buf}"
                rawlasttime="$(echo "${tmp}" |cut -d: -f1)"
                commits="$(echo "${tmp}" |cut -d: -f2)"
                name="$(echo "${tmp}" |cut -d: -f3)"
                bugcount="$(echo "${tmp}" |cut -d: -f4)"
                retirebug="$(echo "${tmp}" |cut -d: -f5)"
                roles="$(echo "${tmp}" |cut -d: -f6-)"

                if [ "$rawlasttime" == "0" ]; then
                  lasttime="unknown"
                else
                  lasttime="$(date -d "@${rawlasttime}" +'%Y-%m-%dT%H:%MZ' 2>/dev/null)"
                fi
                [ -z "$lasttime" ] && lasttime="bad:$rawlasttime"
                exm="$(checkexempt $name)"

                /usr/bin/printf '%7s %-15s %18s   %s %s %s%s\n' "$commits" "$name" "$lasttime" "$bugcount" "$retirebug" "$exm" "$roles"
        fi
done  |/usr/bin/sort -n >>${outfile}.mail.body
/bin/cat ${outfile}.mail.{header,body} >${outfile}.mail

#exit 0

mail \
        -c infrastructure@gentoo.org,retirement@gentoo.org \
        -s "CVS Slacker alert v3 $(date -u +%Y%m%d)" \
        recruiters@gentoo.org \
        <${outfile}.mail

#vim:et ts=2 sw=2:
Comment 2 Alec Warner (RETIRED) archtester gentoo-dev Security 2013-01-06 17:45:39 UTC
I guess fixed? If you have any patches let me know.

-A