Configure email notification about volumes status of NetApp Storage ONTAP 9.3
- Setup ssh passwordless login to netapp storage from your client machine.
a. Generate an SSH key in Linux machine.
After generating the key the default key path is ~.ssh/id_rsa.pub. The same key would be used for authentication.
[user1@client1$ ssh-keygen -q -f ~/.ssh/id_rsa -t rsaOutput:
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
b. Verify the keys that has been generated
[user1@client1]$ ls -l ~/.ssh
total 12
-rw — — — — 1 client1 client1 1679 Jan 20 11:47 id_rsa
-rw-r — r — 1 client1 client1 401 Jan 20 11:47 id_rsa.pub
c. Login to storage cluster, and create a new user “monitor” with authentication type as publickey
netapp::> security login create -username monitor -application ssh -authmethod publickey -role admin
d. Copy the public key contents of the id_rsa.pub and place it between quotes in the security login publickey create command.
You will need to add the public key for each client user you wish to have access via this account. Each key should be added to its own index id.
Note: Take caution not to add carriage returns or other data that modifies the keystring, leave it in one line.
Syntaxnetapp::> security login publickey create -username (user) -index 1 -publickey “???”Example netapp::>security login publickey create -username monitor -index 1 -publickey "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDR0m7pErTujed/8xc7aql253j3SZ8gC1vjdao4rDJfdQdGM6S01RQzX1WSmau7kFO/4Qdnrz88rK6CRBLN7v0OGjECboPv+v39qmIZPhjma9pHrsGvoZM81vYcf/mtEsr76Idr8Bo6iLcSJ92iSnkBzClkF/SbHwZBJ6zeLeza0L2VtT5z1epBAPVeL user1@client1"
e. Verify creation
netapp::> security login publickey show -username monitor
f. Test access from the host. It will not ask username and password.
[user1@client1]$ ssh monitor@netapp1
2. Check storage volume status from remote , manually.
[user1@client1]$ ssh monitor@netapp1 volume showFor specific svm volume status[user1@client1]$ ssh monitor@netapp1 volume show -vsphere svm01
3. Create a script file that executes above command and mails the output.
We assume your client machine have access to a smtp server and have sendmail/postfix configured.
[user1@client1]$ vim /user1/script1.sh
#!/bin/bash#create a variable td holding todays date.
td=`date '+%F'`#Redirect stoarge volume status to a logfile suffixed with todaydate
ssh monitor@netapp1 volume show -vsphere svm01 >> /log/log.$td#email the content of logfile.
#Note: Modify the command according to your configured mail service.
mail -s "storage volume status" myemail@abc.com < /log/log.$td
4. Create a cronjob that runs everyday at 10:30 PM night.
[user1@client1]$ crontab -e
30 22 * * * /user1/script1.sh
Thats it .