Hi there,
Im trying to setup a cronjob to email the vmwarevSphereCheck report daily/weekly. However setup in the crontab - nothing happens. I don't get an email.
This is a snipnet from my crontab.
*/6 * * * * root run-parts /home/vi-admin/vmwarevSphereHealthCheck/vmwarevSphereHealthCheck.pl --conf /home/vi-admin/vmwarevSphereHealthCheck/t*****2.conf --username domain\\username --password G******* --datacenter TO***** --email yes --type datacenter --server vcenter
I am able to run the job from within the directory with the (( ./vmwarevSphereHealthCheck.pl)) command - but nothing...
I have also tried to setup a shell script. Again it runs if I manually do it - but it doesn't run from cron.
I have enabled the root account as well in /etc/passwd. Nothing again.
I know its not a permissions issue because the script runs if I do it manually - just not sure if the crontab job is setup correctly or if Im missing something in my script..
But I noticed that once I've enabled the root account I get the above error if I run the full path. Error connecting to server at 'https://localhost/sdk/webService': Connection refused...
Any ideas?
thanks in advance...
I noticed your crontab does not look like mines and you're trying to run it under "root", not only that you're using "sudo" ....
It should look like this - http://3.bp.blogspot.com/_QdBk6LH358Q/TUR7LCE6ThI/AAAAAAAAB9c/UK6X2OVtB74/s1600/cron2.png
The script needs to run under the vi-admin account and not any other as the vi-fastpass is only accessible from that account. Please ensure your configuration matches what I've documented
It means the "VI_SERVER" variable is not making it into the script and it defaults to "localhost" which is not what you want.
Take a look at this post for more details on setting up cron & vi-fastpass on vMA - http://www.virtuallyghetto.com/2011/01/how-to-automate-cron-vi-fastpass.html
thanks for the reply...I have looked at your posts extensively - but i must be missing something
I did what your post says and this is the reply i get
Re: Error connecting to server at 'https://localhost/sdk/webService': Connection refused# ./example4.sh
./example4.sh Re: Error connecting to server at 'https://localhost/sdk/webService': Connection refused
If you look at the example4.sh script, the first parameter is a vCenter server target, if you're getting back "localhost" it means either A) you're doing something wrong B) you don't actually have a target specified.
Can you run "vifp listservers -l" and provide me with the output
If I run that command - I get
gow.gow.corp vcenter fauth
I didn't add any esx host because the instructions state that I can add only the vcenter if it manages all the hosts
I'm just confused as to why I can run the script manually from multiple path locations and get it to email me - however within crontab - it doesn't email.......
Thanks in advance
If your cron entry or something is not configured, it will not work. Can you provide the output of your crontab and it is beingn executed by vi-admin account?
not sure exactly what you mean by output - but here is the crontab jobs
I do not receive any errors from tail -f /var/log/cron if I were to watch the log file live...
*/6 * * * * root sudo /home/vi-admin/vmwarevSphereHealthCheck/vmwarevSphereHealthCheck.pl conf g*****4.corptype datacenter --datacenter Toronto --email yes
I also have tried the following
*/3 **** root sudo /home/vi-admin/vmwarevSphereHealthCheck/example4.sh g****04.g****gs.corp
*/7 **** root sudo /home/vi-admin/vmwarevSphereHealthCheck/toronto2.sh
I have enabled the root account in /etc/passwd
As I mentioned before If I run the first job mentioned above - from anywhere it works..your example4.sh returns the error mentioned before and if I run the ./toronto2.sh from within that path - it also works...
permissions on the .pl and .sh files are as follwed
-rwxrwxrwx 1 vi-admin root 1808 Mar 10 09:28 toronto2.conf
-rwxrwxrwx 1 vi-admin root 199 Mar 10 15:58 toronto2.sh
thanks for everything -
Does your cron entry for example4.sh look like the following?
http://3.bp.blogspot.com/_QdBk6LH358Q/TUR7LCE6ThI/AAAAAAAAB9c/UK6X2OVtB74/s1600/cron2.png
If not, it needs to be. Make note of the LD_LIBRARY_PATH
This is an exact cut and past from my crontab
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/vmware/vma/lib64:/opt/vmware/vma/lib
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
*/3 **** root sudo /home/vi-admin/vmwarevSphereHealthCheck/example4.sh gowops04.gowlings.corp
and if I run the /example4.sh from within the path above I get the following
Re: Error connecting to server at 'https://localhost/sdk/webService': Connection refused$ ./example4.sh
./example4.sh Re: Error connecting to server at 'https://localhost/sdk/webService': Connection refused
Re: Error connecting to server at 'https://localhost/sdk/webService': Connection refused$
and here is what I have edited in my example4.sh
#!/bin/bash
if $# -ne 1 ; then
echo "$0 Re: Error connecting to server at 'https://localhost/sdk/webService': Connection refused"
exit 1
fi
VCENTER=$1
source /opt/vmware/vma/bin/vifptarget -s $"
fi
One thing I noticed is that you utilize vi-fastpass, or at least I assume you are since you're copying the script I have on my blog .... but you're still specifying the credentials to the vCenter target? Any particular reason why? The whole point of using the vi-fastpass is not having to do so.
Here is my example4.sh script if you have not looked at it carefully:
#!/bin/bash
if
[ $
# -ne 1 ]; then
echo
"$0 [VCENTER_SERVER]"
exit
1
fi
VCENTER=
$1
source /opt/vmware/vma/bin/vifptarget -s ${VCENTER} > /dev/null 2>&1
if
[ $? -eq 0 ]; then
/home/vi-admin/vmwarevSphereHealthCheck.pl --type vcenter --report /home/vi-admin/vmware_health_report.html
else
echo
"Unable to intialize vi-fastpass on target ${VCENTER}"
fi
So first off, in a previous reply you were able to run the "vifp listservers" and it returned back a single target which is a vCenter, correct?
If so, can you run the following commands and let me know if it's successful:
vifptarget -s [VCENTER_TARGET]
vmwarevSphereHealthCheck.pl --type vcenter
If the final comand produces the report, then you need to run that exact command in the cron entry, you don't need to specify the username/password/server as the script already provides that already by using the vi-fastpass db.
This is what I wrote and my answer...
I removed the credentials out of the example4.sh so it looks exactly like yours
Re: Error connecting to server at 'https://localhost/sdk/webService': Connection refused$ vifptarget -s g***04.g***s.corp
Re: Error connecting to server at 'https://localhost/sdk/webService': Connection refused[g****04.g***s.corp]$ vmwarevSphereHealthCheck.pl --type vcenter
-bash: vmwarevSphereHealthCheck.pl: command not found
Re: Error connecting to server at 'https://localhost/sdk/webService': Connection refused[g***04.g****s.corp]$
the only difference is that I have an extra folder structure then you do...
you have:
/home/vi-admin/vmwarevSphereHealthCheck.pl
where as mine says
/home/vi-admin/vmwarevSphereHealthCheck/vmwarevSphereHealthCheck.pl
did I do the command incorrectly?
sorry correction
you asked for me do run the following vmwarevSphereHealthCheck.pl --type vcenter
I had to run the following command to make it work....
Re: Error connecting to server at 'https://localhost/sdk/webService': Connection refused[g******04.gowlings.corp]$ ./vmwarevSphereHealthCheck.pl --type vcenter
Hate to bother,
But Ive cracked my head all day at this thing - but Im still not getting anything...
Here is my crontab
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/vmware/vma/lib64:/opt/vmware/vma/lib
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
#run-parts
#01 * * * * root run-parts /etc/cron.hourly
#02 4 * * * root run-parts /etc/cron.daily
#22 4 * * 0 root run-parts /etc/cron.weekly
#42 4 1 * * root run-parts /etc/cron.monthly
*/10 * * * * root sudo /home/vi-admin/vmwarevSphereHealthCheck/vmwarevSphereHealthCheck.pl
*/25 * * * * root sudo /home/vi-admin/vmwarevSphereHealthCheck/example4.sh --type vCenter
*/5 * * * * root sudo /home/vi-admin/vmwarevSphereHealthCheck/toronto2.sh
and none of those jobs generate an email.
Here is your example4.sh
#!/bin/bash
if $# -ne 1 ; then
echo "$0 Re: Error connecting to server at 'https://localhost/sdk/webService': Connection refused"
exit 1
fi
VCENTER=$1
source /opt/vmware/vma/bin/vifptarget -s $"
fi
and EVER?YTHING you email me about this morning - has works....
thoughts?
I noticed your crontab does not look like mines and you're trying to run it under "root", not only that you're using "sudo" ....
It should look like this - http://3.bp.blogspot.com/_QdBk6LH358Q/TUR7LCE6ThI/AAAAAAAAB9c/UK6X2OVtB74/s1600/cron2.png
The script needs to run under the vi-admin account and not any other as the vi-fastpass is only accessible from that account. Please ensure your configuration matches what I've documented