# for debugging, capture "mail -H" output in /tmp/watrous # then "awk -f ~/mailx-H.awk /tmp/watrous | awk -f screenmail.awk DEBUG=1 | more" #BEGIN { NINE = 9 ; TEN = 10 ; ELEVEN = 11 ; TWELVE = 12 } # At 100, the first two fields merge #NR == 100 { NINE = 8 ; TEN = 9 ; ELEVEN = 10 ; TWELVE = 11 } { if (DEBUG1) { # uncomment this for more debugging # print NF,$0 } for (i=5;i<=NF;i++) { if (index($i,":")) break } NINE = i + 2; TEN = NINE + 1; ELEVEN = TEN + 1; TWELVE = ELEVEN + 1; THIRTEEN = TWELVE + 1; FOURTEEN = THIRTEEN + 1; FIFTEEN = FOURTEEN + 1; TWO = NINE - 7; THREE = TWO + 1; if (SUMWATROUS && index($THREE,"watrous@")==1) nwatrous++ else if (NF == ELEVEN && $TEN == "status") nstatus++ else if (NF == TWELVE && $NINE " " $TEN == "Couldn't run") ncouldntrun++ else if (NF == TWELVE && $NINE " " $TEN == "Output from") noutputfrom++ else if (NF == TEN && $NINE == "Cron") noutputfrom++ else if (NF == ELEVEN && $NINE == "Cron") noutputfrom++ else if (NF == ELEVEN && $NINE == "LogWatch") nlogwatch++ else if (NF == ELEVEN && $NINE == "Logwatch") nlogwatch++ else if (NF == TWELVE && $NINE == "newgroup") nnewgroup++ else if (NF == TWELVE && $TEN == "newgroup") nnewgroup++ else if (NF == ELEVEN && $NINE == "Newsgroup") nnewgrp++ else if (NF == TWELVE && $NINE == "rmgroup") nrmgroup++ else if (NF == TWELVE && $NINE == "yeslog") nyeslog++ else if (NF == FIFTEEN && $NINE == "Warning:") nwarning++ else if (NF == TWELVE && $NINE " " $TEN == "Bad header") nbadheader++ else if (NF == TWELVE && $NINE " " $TEN == "Returned mail:") nreturnedmail++ else if (NF == ELEVEN && $TEN == "dmesg") ndmesg++ else if ((NF == NINE || NF == TEN || NF == ELEVEN) && $TEN ~ /config/) nconfiguration++ else if (NF == ELEVEN && $TEN == "Startup") nstartup++ else if (NF == TWELVE && $TEN == "Startup") nstartup++ else if ((NF == NINE || NF == TEN) && $NINE ~ /.etc.fst/) nfstab++ else if (NF == TEN && $NINE ~ /.etc.issue/) nissue++ else if (NF == TEN && $NINE ~ /.etc.resolv/) nresolv++ else if (NF == NINE && $NINE ~ /.etc.resolv/) nresolv++ else if (NF == ELEVEN && $NINE " " $TEN == "Legacy DNS") nldns++ else if (NF == TWELVE && $NINE " " $TEN == "Legacy DNS") nldns++ else if (NF == ELEVEN && $TEN == "DNS") ndns++ else if (NF == TWELVE && $TEN == "DNS") ndns++ else if (NF == TWELVE && $ELEVEN ~ /.etc.hosts/) nhosts++ else if (NF == THIRTEEN && $NINE " " $TEN " " $ELEVEN == "Problem with NFS") nnfsprobs++ else if (NF == TWELVE && $NINE " " $TEN " " $ELEVEN == "Problems in NTP") nntpprobs++ else if (NF == ELEVEN && $TEN == "grub.conf") ngrub++ else if (NF == TEN && $TEN == "grub.conf") ngrub++ else if (NF == TWELVE && $NINE == "\"sudo") nsudo++ else if (NF == ELEVEN && $TEN == "chkconfig") nchkconfig++ else if (NF == TWELVE && $TEN == "chkconfig") nchkconfig++ else if (NF == ELEVEN && $TEN == "smartd.conf") nsmartdconf++ else if (NF == ELEVEN && $TEN == "systemctl") nsystemctl++ else if (NF == TEN && $TEN ~ /systemct/) nsystemctl++ else if (NF == ELEVEN && $NINE " " $TEN " " $ELEVEN == "Changes for /usr/bin/ssh") nsshchgs++ else if ($0 ~ /\[ASTRO\]/) nastro++ else if (NF == TEN && $NINE ~ /.etc.nssw/) nnsswitch++ else if (NF == NINE && $NINE ~ /.etc.nssw/) nnsswitch++ else if (NF == ELEVEN && $NINE " " $TEN " " $ELEVEN == "check-sys-stuff -v differ") ncssd++ else if (NF == TEN && $NINE ~ /.etc.xinetd/) nxinetd++ else if (NF == NINE && $NINE ~ /.etc.xinetd/) nxinetd++ else if ((NF == TEN || NF == ELEVEN) && $NINE ~ /.dev/ && $TEN ~ /fil/) ndev++ else if (NF == THIRTEEN && $NINE == "Warning:" && $TEN == "could" && $ELEVEN == "not" && $TWELVE == "send") nwcns++ else if (NF == ELEVEN && $NINE == "NetID" && $TEN == "Change" && $ELEVEN == "Confirmation") nic++ else if (NF == NINE && $NINE ~ /:.etc.servi/) nes++ else if (NF == TEN && $NINE ~ /:.etc.services/) nes++ else if ((NF == ELEVEN || NF == TEN) && $TEN ~ /cpuinf/) ncpui++ else if ((NF == TWELVE ) && $NINE == "Test" && $TEN == "message" && $ELEVEN == "from") ntmf++ else if (NF == TEN && $NINE ~ /:.etc.group/) neg++ else if (NF == NINE && $NINE ~ /:.etc.gro/) neg++ else if (NF == NINE && $NINE ~ /:.etc.ssh.ssh/) nssh++ else if ((NF == ELEVEN || NF == TWELVE) && $TEN == "Root" && $ELEVEN ~ /cr/) nrc++ else if (NF == THIRTEEN && $NINE == "logging" && $TEN == "to" && $ELEVEN == "spock" && $TWELVE == "on") ltso++ else if (NF == ELEVEN && $NINE == "Account" && $TEN == "removal" && $ELEVEN == "(lcsr-gra") arg++ else if (NF == ELEVEN && $NINE == "Account" && $TEN == "removal" && $ELEVEN == "(dcs-ilab") ari++ else if ((NF == NINE || NF == TEN) && $NINE ~ /dmideco/) ndmi++ else if (NF == TWELVE && $NINE ~ /dmidecode/) ndmi++ else if ((NF == NINE || NF == TEN) && $NINE ~ /:deviceQuery/) ndevq++ else if ((NF == NINE) && $NINE ~ /etc.sss/) sssd++ else if ((NF == NINE || NF == TEN) && $NINE ~ /etc.sud/) sudoc++ else if ((NF == TWELVE) && $TEN == "dpkg") dpkg++ else if ((NF == NINE || NF == TEN) && $NINE ~ /etc.nslc/) nslcd++ else if ((NF == ELEVEN || NF == TWELVE) && $NINE == "fix-hostname") nfh++ else if ((NF == TWELVE) && $NINE == "MegaCli" && $TEN == "differences") nmd++ else if (NF == TEN && $NINE ~ /:.etc.passwd/) nep++ else if (NF == NINE && $NINE ~ /:.etc.pas/) nep++ else if ((NF == ELEVEN) && $TEN == "group" && $ELEVEN ~ /diff/) ngd++ else if ((NF == TEN) && $TEN ~ /group/) ngd++ else if ((NF == TEN) && $NINE == "watch-subnets" && $TEN == "output") nwso++ else if ((NF == ELEVEN) && $TEN == "alternatives") nad++ else if ((NF == TEN) && $TEN ~ /alterna/) nad++ # else if (NF == TWELVE && $TEN " " $ELEVEN == "snap list" && $TWELVE ~ /di/) sld++ else if (NF == TWELVE && $TEN " " $ELEVEN == "snap list") sld++ else if ((NF == TEN || NF == ELEVEN) && $NINE " " $TEN == "oom-killer messages" ) oom++ else if ((NF == TWELVE) && $NINE " " $TEN " " $ELEVEN == "Out of memory" ) oom++ else if ((NF == ELEVEN || NF == TWELVE) && $TEN " " $ELEVEN == "inxi -FZ" ) inxi++ else if ((NF == TWELVE) && $NINE " " $TEN " " $ELEVEN == "tune2fs -l differences" ) tld++ else if ((NF == TEN) && $NINE ~ /uname/ && $TEN ~ /diff/ ) und++ else if ((NF == NINE) && $NINE ~ /cs:.freespace/ ) fl++ else if ((NF == TEN) && $NINE ~ /cs:.freespace.local/ ) fl++ else if ((NF == ELEVEN) && $NINE " " $TEN " " $ELEVEN == "results of './distribute-" ) rod++ else if ((NF == THIRTEEN) && $NINE " " $TEN " " $ELEVEN == "NIC Link messages" ) nlm++ else if ((NF == TWELVE) && $NINE " " $TEN " " $ELEVEN " " $TWELVE == "Changes in passwd entries" ) cip++ else if ((NF == TWELVE) && $NINE " " $TEN " " $ELEVEN == "Problems in DNS" ) pid++ else if ((NF == TEN || NF == TWELVE) && $NINE " " $TEN == "lcsrdrop messages" ) ld++ else if (((NF == TEN) || (NF == ELEVEN)) && $TEN ~ /postfix/ ) pd++ else if ((NF == TEN || NF == TWELVE) && $NINE " " $TEN == "killjob messages" ) kj++ else if ((NF == TEN) && $NINE " " $TEN == "accounts messages" ) am++ else if ((NF == TWELVE) && $NINE " " $TEN == "NIC mentions" ) nm++ else if ((NF == ELEVEN) && $ELEVEN == "'./maintain-IP" ) mi++ else if ((NF == TWELVE) && $NINE " " $TEN " " $ELEVEN == "mailq and/or sendmail" ) maos++ else if ((NF == TEN) && $TEN ~ /sbin.eth/ ) etd++ else if ((NF == TEN || NF == ELEVEN) && $TEN == "lspci") lspd++ else if (NF == TWELVE && $NINE " " $TEN == "Slow backups") sb++ else if ((NF == NINE) && $NINE ~ /:.etc.ldap/ ) ldc++ else if (NF == TWELVE && $TEN " " $ELEVEN == "rpm -qa") rq++ else if ((NF == TEN) && $TEN ~ /smartd/ ) sdc++ else if ((NF == NINE) && $NINE ~ /http/ ) wpd++ else if ((NF == NINE) && $NINE ~ /:.etc.lsb/ ) lsb++ else if ((NF == NINE || NF == TEN) && $NINE ~ /:.etc.os-rel/ ) osr++ else if ((NF == ELEVEN) && $TEN == "aliases" && $ELEVEN ~ /diff/) ali++ else if ((NF == ELEVEN) && $ELEVEN ~ /watch-flaky/) wf++ # Special case for down switch in Hill Center; 12/23/20 else if ((NF == ELEVEN) && $NINE ~ /h4.*\.cs/ &&$TEN " " $ELEVEN == "is DOWN") iD++ else if ((NF == ELEVEN) && $NINE == "klaatu" &&$TEN " " $ELEVEN == "is DOWN") iD++ else if ((NF == ELEVEN) && $NINE == "stefi" &&$TEN " " $ELEVEN == "is DOWN") iD++ else if (NF == TWELVE && $NINE " " $TEN == "Read-only messages") rom++ else if ((NF == NINE || NF == TEN || NF == ELEVEN) && $NINE ~ /bin.nvid/) nvd++ else if ((NF == NINE || NF == TEN || NF == ELEVEN) && $NINE ~ /nvidia/) nvdd++ else if ((NF == ELEVEN) && $NINE " " $TEN == "Results of" && $ELEVEN ~ /distribute/ ) dc++ else if ((NF == NINE || NF == TEN) && $NINE ~ /rsyslog/ ) rs++ # these are paired, at least on addition else if ((NF == TWELVE) && $NINE " " $TEN == "atq differences" ) atqj++ else if ((NF == TWELVE) && $TEN " " $ELEVEN == "atjob differences" ) atqj++ else if ((NF == ELEVEN) && $NINE " " $TEN == "Undelivered Mail" ) {um++} else if ((NF == NINE) && $NINE ~ /coresysadmins,/ ) {cs++} # *** else { if(DEBUG) { print NF,$0; if (NF == NINE) print "NF = NINE"; if (NF == TEN) print "NF = TEN"; if (NF == ELEVEN) print "NF = ELEVEN"; if (NF == TWELVE) print "NF = TWELVE"; if (NF == THIRTEEN) print "NF = THIRTEEN"; if (NF == FOURTEEN) print "NF = FOURTEEN"; if (NF == FIFTEEN) print "NF = FIFTEEN"; if (NF >= NINE) print "NINE =",$NINE; if (NF >= TEN) print "TEN =",$TEN; if (NF >= ELEVEN) print "ELEVEN =",$ELEVEN; if (NF >= TWELVE) print "TWELVE =",$TWELVE; if (NF >= THIRTEEN) print "THIRTEEN =",$THIRTEEN; if (NF >= FOURTEEN) print "FOURTEEN =",$FOURTEEN; if (NF >= FIFTEEN) print "FIFTEEN =",$FIFTEEN; } other[++nothers] = $0 } } END { if (NR) { if (nwatrous > 0) ntypes++ if (nstatus > 0) ntypes++ if (ncouldntrun > 0) ntypes++ if (noutputfrom > 0) ntypes++ if (nlogwatch > 0) ntypes++ if (nnewgroup > 0) ntypes++ if (nnewgrp > 0) ntypes++ if (nrmgroup > 0) ntypes++ if (nyeslog > 0) ntypes++ if (nwarning > 0) ntypes++ if (nbadheader > 0) ntypes++ if (nreturnedmail > 0) ntypes++ if (nastro > 0) ntypes++ if (nothers > 0) ntypes++ if (ntypes > 1) printf "(%d MESSAGES) ",NR if (nwatrous) printf "%d messages from me; ",nwatrous if (nstatus) printf "%d status; ",nstatus if (nnewgroup) printf "%d newgroup; ",nnewgroup if (nnewgrp) printf "%d newsgroup; ",nnewgrp if (nrmgroup) printf "%d rmgroup; ",nrmgroup if (nyeslog) printf "%d yeslog; ",nyeslog if (nwarning) printf "%d warnings; ",nwarning if (ncouldntrun) printf "%d Couldn't run; ",ncouldntrun # if (noutputfrom) printf "%d Output from; ",noutputfrom if (noutputfrom) printf "%d Cron output; ",noutputfrom if (nlogwatch) printf "%d LogWatch; ",nlogwatch if (nbadheader) printf "%d Bad header; ",nbadheader if (nreturnedmail) printf "%d Returned mail; ",nreturnedmail if (nfstab) printf "%d /etc/fstab differences; ",nfstab if (nissue) printf "%d /etc/issue differences; ",nissue if (nresolv) printf "%d /etc/resolv.conf differences; ",nresolv if (ndmesg) printf "%d dmesg differences; ",ndmesg if (nconfiguration) printf "%d configuration differences; ",nconfiguration if (nldns) printf "%d Legacy DNS reports; ",nldns if (ndns) printf "%d DNS differences; ",ndns if (nstartup) printf "%d startup differences; ",nstartup if (nhosts) printf "%d problems in /etc/hosts; ",nhosts if (nnfsprobs) printf "%d problems with NFS; ",nnfsprobs if (nntpprobs) printf "%d problems with NTP; ",nntpprobs if (nsshchgs) printf "%d Changes for /usr/bin/ssh; ",nsshchgs if (ngrub) printf "%d grub.conf differences; ",ngrub if (nsudo) printf "%d sudo -l differences; ",nsudo # if (nchkconfig) printf "%d chkconfig --list differences; ",nchkconfig if (nchkconfig) printf "%d chkconfig differences; ",nchkconfig if (nsmartdconf) printf "%d smartd.conf differences; ",nsmartdconf if (nsystemctl) printf "%d systemctl differences; ",nsystemctl if (nastro) printf "%d Astro; ",nastro if (nnsswitch) printf "%d /etc/nsswitch.conf differences; ",nnsswitch if (ncssd) printf "%d check-sys-stuff -v differences; ",ncssd if (nxinetd) printf "%d /etc/xinetd.d differences; ",nxinetd if (ndev) printf "%d /dev differences; ",ndev if (nwcns) printf "%d Could not send warnings; ",nwcns if (nic) printf "%d NetID Change Confirmations; ",nic if (nes) printf "%d /etc/services differences; ",nes if (nssh) printf "%d /etc/ssh/ssh key differences; ",nssh if (ncpui) printf "%d cpuinfo differences; ",ncpui if (neg) printf "%d /etc/group differences; ",neg if (ntmf) printf "%d test messages; ",ntmf if (nrc) printf "%d root crontab differences; ",nrc if (ltso) printf "%d logging to spock; ",ltso if (arg) printf "%d grad account removals; ",arg if (ari) printf "%d ilab account removals; ",ari if (ndmi) printf "%d dmidecode differences; ",ndmi if (ndevq) printf "%d deviceQuery differences; ",ndevq if (sssd) printf "%d sssd.conf differences; ",sssd if (sudoc) printf "%d sudoers differences; ",sudoc if (dpkg) printf "%d dpkg -l differences; ",dpkg if (nslcd) printf "%d nslcd.conf differences; ",nslcd if (nfh) printf "%d fix-hostname messages; ",nfh if (nmd) printf "%d MegaCli differences; ",nmd if (nep) printf "%d /etc/passwd differences; ",nep if (ngd) printf "%d group differences; ",ngd if (nwso) printf "%d watch-subnets outputs; ",nwso if (nad) printf "%d alternatives differences; ",nad if (sld) printf "%d snap list differences; ",sld if (oom) printf "%d OOM related messages; ",oom if (inxi) printf "%d inxi -FZ differences; ",inxi if (tld) printf "%d tune2fs -l differences; ",tld if (und) printf "%d uname differences; ",und if (fl) printf "%d /freespace/local messages; ",fl if (rod) printf "%d distribute-crontab messages; ",rod if (nlm) printf "%d NIC Link messages; ",nlm if (cip) printf "%d Changes in passwd entries; ",cip if (pid) printf "%d problems in DNS; ",pid if (ld) printf "%d lcsrdrop messages; ",ld if (pd) printf "%d postfix differences; ",pd if (kj) printf "%d killjob messages; ",kj if (am) printf "%d accounts messages; ",am if (nm) printf "%d NIC mentions; ",nm if (mi) printf "%d maintain-IPA messages; ",mi if (maos) printf "%d mailq and/or sendmail problems; ",maos if (etd) printf "%d ethtool differences; ",etd if (lspd) printf "%d lspci differences; ",lspd if (sb) printf "%d Slow backups; ",sb if (ldc) printf "%d ldap.conf differences; ",ldc if (rq) printf "%d rpm -qa differences; ",rq if (sdc) printf "%d smartd.conf differences; ",sdc if (wpd) printf "%d web page differences; ",wpd if (lsb) printf "%d lsb-release differences; ",lsb if (osr) printf "%d os-release differences; ",osr if (ali) printf "%d aliases differences; ",ali if (wf) printf "%d watch-flaky-dns messages; ",wf if (iD>14) printf "HILL SWITCH IS STILL DOWN; ",iD if (iD > 0 && iD<=14) printf "%d Hill Center nagios DOWN messages; ",iD if (rom) printf "%d Read-only messages; ",rom if (nvd) printf "%d nvidia-smi problems; ",nvd if (nvdd) printf "%d nvidia-smi differences; ",nvdd if (dc) printf "%d distribute-crontab results; ",dc if (rs) printf "%d rsyslog differences; ",rs if (atqj) printf "%d atq/atjob differences; ",atqj if (um) printf "%d undelivered mails; ",um if (cs) printf "%d coresysadmins messages; ",cs # *** if (nothers) { if (nothers != NR) { if (nothers != 1) { print nothers,"others:" } else { print nothers,"other:" } } for (i=1;i<=nothers;i++) print other[i] } else print "" } }