|
Blog -
Dynastys Blog
|
|
Written by Allen Sanabria
|
|
Monday, 05 October 2009 14:08 |
|
Today I was given a task to have my manager emailed once a day. If any of our Data Stores in ESX 3.5 are over 80% utilized. So I said to my self. What would be the easiest way to do this???? Well I've written two scripts in the past, that could help me accomplish that. The first script VMstoragePool.py will list all of the Data Stores in Vmware and its utilization. The 2nd script is check_datastore.py, and this script will return OK, WARNING, or CRITICAL, depending on the thresholds you set. So by effectively combining the 2 scripts I was able to get what I want. Example below...
python VMstoragePool.py -u "https://esxhostA" -a "login passwd" |grep "DataStore Name" |awk {'print $3'} |for line in `xargs`;do python check_datastore.py -u "https://esxhostA" -a "login passwd" -d $line -w 80 -c 90 -m "GB"|grep -P "WARNING|CRITICAL";done|mail user@domain.com CRITICAL XythosVol2 57GB Avail 94% used |avail=57 WARNING XythosVol1 62GB Avail 87% used |avail=62 WARNING LinuxVol1 57GB Avail 88% used |avail=57 WARNING WinVol1 75GB Avail 84% used |avail=75 WARNING BBSCVOL1 122GB Avail 88% used |avail=122 CRITICAL NSSharedVOL1 46GB Avail 95% used |avail=46
So I can run this script in cron once a day and pipe the output to email him directly. Simple yet effective! On a side note, I fixed both chec_datastore.py and VMstoragePool.py to effectivly parse passwd's that used characters like !@#$%^.
Both scripts can be downlaoded here..
Download check_esx_datastore.py | | File Title: | check_esx_datastore.py (Details) | | File Type: | py | | File Version: | 1.1 | | File Size: | 4.58 Kb | | License: | Copyright (C) 2008 Allen Sanabria
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | | File Author: | Allen Sanabria | | File HomePage: | http://www.linuxdynasty.org/howto-monitor-and-add-multiple-data-points-the-easy-way-in-zenoss.html | | Downloads: | 509 | | Rating: | ( Votes) | | Your Vote: | |
| | and Download VMstoragePool.py | | File Title: | VMstoragePool.py (Details) | | File Type: | py | | File Version: | 1.1 | | File Size: | 4.77 Kb | | License: | Copyright (C) 2008 Allen Sanabria
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | | File Author: | Allen Sanabria | | File HomePage: | | | Downloads: | 123 | | Rating: | ( Votes) | | Your Vote: | |
| |
|
|
Last Updated on Monday, 05 October 2009 14:31 |