Posts

script for amc expiry email notification .

This Script will send the reminder email 90 Days before the AMC Expires .

The Number of Days you can change by changing the NU Value . the email@domain.com should be replaced with your email id. The send-mail Path can be replaced by the send-mail path of the server.


There is need to create a Data file which will contain the Information for AMC of the Equipment. The input.txt format is shown below .


#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
#script for amc expiry email notification.
NU="90"
FROM="admin@domain.com"
#value1=$(echo $line| awk -F\ '{print $1}' input.txt)
#value2=$(echo $line| awk -F\ '{print $2}' input.txt)
#value3=$(echo $line| awk -F\ '{print $3}' input.txt)
DATEN=$(date +%s)
IFS="|"
while read -r value1 value2 value3
do
echo "value1 is " $value1
echo  "value 2 is " $value2
echo  "value 3 is " $value3
dat2=$(date -d "$value3" +'%Y%m%d')
echo "dat…

How to Create a Delegated Admin Account in Zimbra 8.x

How to Create a Delegated Admin Account in Zimbra 8.x.

Create a File as shown below with the contents . 

Replace the domain.com and helpdesk Email id with your domain and helpdesk (Delegated Admin ) Name.

#vi admindelegate

#!/bin/bash
# $1 domain.com
# $2 helpdesk
zmprov ma $2 zimbraIsDelegatedAdminAccount TRUE
zmprov ma $2 zimbraAdminConsoleUIComponents cartBlancheUI
zimbraAdminConsoleUIComponents domainListView zimbraAdminConsoleUIComponents
accountListView zimbraAdminConsoleUIComponents DLListView
zmprov ma $2 zimbraDomainAdminMaxMailQuota 0
zmprov grantRight domain $1 usr $2 +createAccount
zmprov grantRight domain $1 usr $2 +createAlias
zmprov grantRight domain $1 usr $2 +createCalendarResource
zmprov grantRight domain $1 usr $2 +createDistributionList
zmprov grantRight domain $1 usr $2 +deleteAlias
zmprov grantRight domain $1 usr $2 +listDomain
zmprov grantRight domain $1 usr $2 +domainAdminRights
zmprov grantRight domain $1 usr $2 +configureQuota
zmprov grantRight domain $1 usr $2 set.account.zimbr…

SCRIPT TO SHOW INVALID LOGIN ATTEMPTS IN RED COLOR AND VALID LOGIN IN GREEN COLOR FOR ZIMBRA 8.x

Create a File by using#vi /usr/bin/watchaudit with the following contents 
tail -f /opt/zimbra/log/audit.log | awk '
  /INFO/ {print "\033[32m" $0 "\033[39m"}
  /WARN/ {print "\033[31m" $0 "\033[39m"}
'

Close and Save the File.

Run the Watchaudit File in SSH Console .

#chmod +x /usr/bin/watchaudit

#/usr/bin/watchaudit

Script for release the RAM cache everyday

# This is the script for release the memory cache everyday #
top -b -n 1 | head > /tmp/file1.txt
sleep 10
sync; echo 1 > /proc/sys/vm/drop_caches
sleep 20
top -b -n 1 | head  > /tmp/file2.txt
cat /tmp/file1.txt /tmp/file2.txt > /tmp/ram.txt

EMAIL_BODY="
Hello Sysadmin Team,

This is the RAM status after releases:
$(cat /tmp/ram.txt)
Thanks,
DC Team
"

echo "Subject: RAM status for ABC Server" "$EMAIL_BODY" | /opt/zimbra/postfix-2.10.3.2z/sbin/sendmail -t alert@domain.com.

The Above Script will clear the Unused RAM . This will send the email before and after Clearing the RAM.
Use This script when very Less number of users are using the server.This script will run on Linux Server (RedHat/Centos).The Script can be run during Night Time using Crontab.Kindly update the Email ID and Sendmail path correctly as per  your server.

The Script for Temperature Alert using email from the Linux Server (If it Cross 40 c)

#! /bin/bash
TEMP=$(sensors | grep "id 0" | cut -d + -f2 | cut -d . -f1)
if [ "$TEMP" -ge 40 ]; then
echo $TEMP
date > /tmp/temp
sensors >> /tmp/temp
TEMP_BODY="
Hello Helpdesk Team,
This is the Temperature Alert Message forABC Server at DC Location,CITY:
$(cat /tmp/temp)
Regards,
Datacenter TEAM
"
echo "Subject: ALERT High Temperature for Server at DC Location " "$TEMP_BODY" | /opt/postfix-2.10.3.2z/sbin/sendmail -t email@domain.com
fi


In this Script Replace the email@domain.com with Correct Email id and Sendmail path with correct Send-mail path. In this script we are monitoring the CPU Temperature. This Script will work on Linux Server (Red Hat/Centos ) 

Password Expiry notification for the users in zimbra 8.x within 7 Days for the email users

This Script will run as cron tab daily basis and it will alert the users for whom password is going to expire within 7 days. It will also alert admin for the users for whom password expired.
Kindly replace the domain.com with your own domain name and the  /opt/zimbra/postfix-2.10.3.2z/sbin/sendmail  path to the actual path of postfix
#!/bin/bash
#Script for zimbra password expiry email notification.
# Meant to be performed as daily cronjob run as zimbra user. 
# redirect output to a file to get a 'log file' of sorts.

# Time taken of script;
echo "$SECONDS Started on: $(date)"
# Set variables:
# First notification in days, then last warning:
FIRST="7"
LAST="3"
# pass expiry in days, we are assuming passwd exiry is 150 Days
POLICY="150"
# Sent from:
FROM="admin@domain.com"
# Get all users - it should run once only.
USERS=$(ionice -c3 /opt/zimbra/bin/zmprov -l gaa domain.com)

#Todays date, in seconds:
DATE=$(date +%s)
# Iterate through them in for lo…

Zimbra backup open source for zimbra 8.x for 7 Days

The Script will take the backup in the /backup/zimbra/1 , /backup/zimbra/2 , /backup/zimbra/3 ,  /backup/zimbra/4 , /backup/zimbra/5 , /backup/zimbra/6 , /backup/zimbra/7 and after 7th day it will overwrite the day1 folder. 

This will keep the full backup for all the users in the 7 folders. 
In this script  replace the domain.com with your company domain name.
The Script can be schedule in cron tab jobs.


#!/bin/bash -x
DateToday=`date -I`
FolderZ=`date +%d`
X=$FolderZ
W2=7
W3=14
W4=21
W5=28
if [ "$X" -lt 8 ]
then
X=`expr $X - 0`
echo $X
elif [ "$X" -lt 15 ]
then
X=`expr $X - $W2`
elif [ "$X" -lt 22 ]
then
X=`expr $X - $W3`
elif [ "$X" -lt 29 ]
then
X=`expr $X - $W4`
else
X=`expr $X - $W5`
fi
echo $X
rm -rf /backup/zimbra/$X/*
su zimbra -c "/opt/zimbra/libexec/zmslapcat /backup/ldapbkp"
su zimbra -c "/opt/zimbra/libexec/zmslapcat -c /backup/ldapbkp"
sudo -u zimbra /opt/zimbra/bin/zmprov -l gaa -v | grep uid | grep -v spam | grep -v ham | grep -v zimbra | gre…