Recurring script for server maintenance

We made a little bash script for our server maintenance to assign different tasks to different servers.

Simple but helpful. Maybe someone else needs it.

# Tasks
a1="- Check tasks\n"
a2="- Check HDD space\n"
a3="- Update OS\n"
a4="- Check RAID-Status\n"
a5="- Chech Hardware\n"
a6="- Check Event Log\n"
a7="- Check Event Log DNS-Server\n"
a8="- Check Event Log Security\n"
a9="- Check Event Log DFS-Replication\n"

# server
serverliste=(checkMK zammad dc01 dc03 dc04 fileserver01 filserver02)

#Tasks to server
checkMK="a1 a2 a3"
zammad="a1 a2 a3"
dc01="a1 a2 a3 a6 a8 a9"
dc02="a1 a2 a3 a6 a7 a8 a9"
dc03="a1 a2 a3 a6 a7 a8 a9"
fileserver01="a1 a2 a3 a4 a5"
fileserver02="a1 a2 a3 a4 a5"

for i in "${serverliste[@]}"
 do
string=""
   for j in ${!i} 
   do 
   string="${string}${!j}"
   done
   curl -u ticket@domain.de:PassOfInternalTicketUser -H "Content-Type: application/json" -X POST -d "{\"title\":\"WARTUNG $i\",\"group\": \"Wartung\",\"article\":{\"subject\":\"WARTUNG $i\",\"body\":\"${string}\",\"type\":\"note\",\"internal\":false},\"customer\":\"EMAIL@CUSTOM.ER\",\"note\": : \"some note\"}" http://zammadhost/api/v1/tickets
done

And a cron that runs once a month
0 7 1 * * /home/zammad/skripte/wartung.sh > /dev/null 2>&1

maybe this saves you 5-10 minutes

2 Likes