This shows you the differences between two versions of the page.
userspace:current_opsi_errors [2014/04/25 15:00] test old revision restored |
userspace:current_opsi_errors [2021/08/23 08:37] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | <code bash> | ||
- | #!/bin/bash | ||
- | # License: GPL | ||
- | # NO WARRANTY | ||
- | |||
- | # This script was written to find out which opsi products failed recently. | ||
- | # opsi-admin returns a list of all products where state is " | ||
- | # is " | ||
- | # last time. After that, this script tries to get the cause of the error by | ||
- | # grep for "fatal error" at the opsi logfile. | ||
- | |||
- | # If you have any suggestions, | ||
- | # please put them here: http:// | ||
- | |||
- | # Copyright User " | ||
- | |||
- | FOLDER=$HOME/ | ||
- | ERRORSBEFORE=$FOLDER/ | ||
- | ERRORSNOW=$FOLDER/ | ||
- | CLIENTLIST=/ | ||
- | NEWERRORS=/ | ||
- | NOW=`date +%Y-%m-%d_%H-%M-%S` | ||
- | |||
- | # First call of this script: There is no list from " | ||
- | # so create an empty list. | ||
- | if [[ ! -f $ERRORSBEFORE ]] | ||
- | then mkdir -p $FOLDER | ||
- | echo ' | ||
- | echo ' | ||
- | fi | ||
- | |||
- | # Get all packages on clients where state=unknown and action=none. Remove " and , - then sort and save the list. | ||
- | opsi-admin -d method productOnClient_getIdents ' | ||
- | |||
- | # Compare list before and after this check. List " | ||
- | diff $ERRORSBEFORE $ERRORSNOW| grep '>' | ||
- | cat $NEWERRORS | cut -f3 -d';' | ||
- | |||
- | # No new errors since last call. Clean up and exit. | ||
- | if ! [[ -s $NEWERRORS ]] | ||
- | then rm $NEWERRORS | ||
- | mv $ERRORSNOW $ERRORSBEFORE | ||
- | exit 0 | ||
- | fi | ||
- | |||
- | # List new errors. | ||
- | echo -e 'List of products on clients with state: | ||
- | cat $NEWERRORS | ||
- | echo -e ' | ||
- | |||
- | # Search for error message of failed product(s). | ||
- | cd / | ||
- | for client in `cat $CLIENTLIST` | ||
- | do if [[ ! -s $client.log ]] | ||
- | then echo " | ||
- | else | ||
- | # Find all failed packages of one client. Search logfile for error message(s). Then write client | ||
- | # and product name before the text of the error message. | ||
- | grep $client $NEWERRORS | cut -f1 -d';' | ||
- | do grep -B20 " | ||
- | done | ||
- | fi | ||
- | done | ||
- | |||
- | rm $NEWERRORS | ||
- | mv $ERRORSNOW $ERRORSBEFORE | ||
- | </ |