You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by de...@apache.org on 2016/12/24 12:55:28 UTC
svn commit: r1775950 - in /uima/uima-ducc/trunk:
src/main/scripts/tools/ducc_disk_info
uima-ducc-duccdocs/src/site/tex/duccbook/part2/cli/tools-ducc-disk-info.tex
uima-ducc-duccdocs/src/site/tex/duccbook/part2/ducc-uguide.tex
Author: degenaro
Date: Sat Dec 24 12:55:28 2016
New Revision: 1775950
URL: http://svn.apache.org/viewvc?rev=1775950&view=rev
Log:
UIMA-5232 DUCC missing DUCC Book Documentation
> bin/tools/ducc_disk_info
Added:
uima/uima-ducc/trunk/uima-ducc-duccdocs/src/site/tex/duccbook/part2/cli/tools-ducc-disk-info.tex
Modified:
uima/uima-ducc/trunk/src/main/scripts/tools/ducc_disk_info
uima/uima-ducc/trunk/uima-ducc-duccdocs/src/site/tex/duccbook/part2/ducc-uguide.tex
Modified: uima/uima-ducc/trunk/src/main/scripts/tools/ducc_disk_info
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/src/main/scripts/tools/ducc_disk_info?rev=1775950&r1=1775949&r2=1775950&view=diff
==============================================================================
--- uima/uima-ducc/trunk/src/main/scripts/tools/ducc_disk_info (original)
+++ uima/uima-ducc/trunk/src/main/scripts/tools/ducc_disk_info Sat Dec 24 12:55:28 2016
@@ -74,61 +74,99 @@ def parse_cmdline():
parser.formatter.max_help_position = width
parser.add_option('--code', action='store_true', dest='flag_code', default=False,
help='display exit code, which is the greater of disk usage percentage and quota usage percentage')
+ parser.add_option('--debug', action='store_true', dest='flag_debug', default=False,
+ help='display debug information')
parser.add_option('--nomsg', action='store_false', dest='flag_msg', default=True,
help='suppress display of filesystem and quota percentages used message')
(options, args) = parser.parse_args()
+# normalize path to always end with /
+def normalize_path(path):
+ retVal = path
+ if(not path.endswith('/')):
+ retVal = path+'/'
+ return retVal
+
+# normalize quota value to bytes
+def normalize_quota(value):
+ if(value.endswith('M')):
+ tval = value.split('M')[0]
+ retVal = int(tval)*1024*1024
+ elif(value.endswith('k')):
+ tval = value.split('k')[0]
+ retVal = int(tval)*1024
+ else:
+ retVal = int(value)
+ return retVal
+
# determine quota usage
-def check_quota(target):
+def check_quota():
global code
global cmd_quota
global message
global filesystem
- p = subprocess.Popen([cmd_quota, '-f', filesystem], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- out, err = p.communicate()
- for line in out.splitlines():
- tokens = line.split()
- blocks = tokens[0]
- limit = tokens[2]
- blocks = int(tokens[0].replace('*',''))
- limit = int(tokens[2].replace('*',''))
try:
- pctused = str(int(round((blocks*1.0)/(limit*1.0)*100)))
- message = message+'quota='+pctused+'%'+' '
- if(pctused > code):
- code = pctused
- except:
+ p = subprocess.Popen([cmd_quota, '-A'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ out, err = p.communicate()
+ qfs = None
+ data = None
+ fs1 = normalize_path(filesystem)
+ #print fs1
+ for line in out.splitlines():
+ tokens = line.split()
+ #print tokens
+ if(qfs == None):
+ fs2 = normalize_path(tokens[0])
+ #print fs2
+ if(fs1 == fs2):
+ qfs = fs1
+ elif(data == None):
+ data = tokens
+ break
+ blocks = normalize_quota(data[0])
+ limit = normalize_quota(data[2])
+ qpct = int(blocks/(limit*1.0)*100)
+ #print qfs, blocks, limit, qpct
+ message = message+'quota='+str(qpct)+'%'+' '
+ except Exception,e:
+ emessage = 'Exception: '+str(e)
+ emessage = emessage.strip()
+ if(options.flag_debug):
+ print emessage
message = message+'quota='+'N/A'+' '
return
# determine filesystem usage
-def check_disk(target):
+def check_disk():
+ global ducc_home
global code
global cmd_df
global message
global filesystem
- p = subprocess.Popen([cmd_df, target], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- out, err = p.communicate()
- pctused = 0
- for line in out.splitlines():
- tokens = line.split()
- filesystem = tokens[0]
- if(':' in filesystem):
- filesystem = filesystem.rsplit(':',1)[1]
- pctused = tokens[4].split('%')[0]
try:
+ p = subprocess.Popen([cmd_df, ducc_home], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ out, err = p.communicate()
+ pctused = 0
+ for line in out.splitlines():
+ tokens = line.split()
+ filesystem = tokens[0].strip()
+ pctused = tokens[4].split('%')[0]
number = float(pctused)
- message = message+'filesystem='+pctused+'%'+' '
if(pctused > code):
code = pctused
- except:
+ message = message+'filesystem='+pctused+'%'+' '
+ except Exception,e:
+ emessage = 'Exception: '+str(e)
+ emessage = emessage.strip()
+ if(options.flag_debug):
+ print emessage
message = message+'filesystem='+'N/A'+' '
return
# process
-def process(target):
- check_disk(target)
- check_quota(target)
+def process():
+ check_disk()
+ check_quota()
return
# initialize
@@ -146,7 +184,7 @@ def main(argv):
global code
try:
initialize()
- process(ducc_home)
+ process()
except Exception,e:
message = 'Exception: '+str(e)
message = message.strip()
@@ -155,5 +193,5 @@ def main(argv):
if(options.flag_code):
sys.exit(code)
-if __name__ == "__main__":
+if __name__ == '__main__':
main(sys.argv[1:])
Added: uima/uima-ducc/trunk/uima-ducc-duccdocs/src/site/tex/duccbook/part2/cli/tools-ducc-disk-info.tex
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-duccdocs/src/site/tex/duccbook/part2/cli/tools-ducc-disk-info.tex?rev=1775950&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-duccdocs/src/site/tex/duccbook/part2/cli/tools-ducc-disk-info.tex (added)
+++ uima/uima-ducc/trunk/uima-ducc-duccdocs/src/site/tex/duccbook/part2/cli/tools-ducc-disk-info.tex Sat Dec 24 12:55:28 2016
@@ -0,0 +1,49 @@
+%
+% Licensed to the Apache Software Foundation (ASF) under one
+% or more contributor license agreements. See the NOTICE file
+% distributed with this work for additional information
+% regarding copyright ownership. The ASF licenses this file
+% to you under the Apache License, Version 2.0 (the
+% "License"); you may not use this file except in compliance
+% with the License. You may obtain a copy of the License at
+%
+% http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing,
+% software distributed under the License is distributed on an
+% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+% KIND, either express or implied. See the License for the
+% specific language governing permissions and limitations
+% under the License.
+%
+% Create well-known link to this spot for HTML version
+\ifpdf
+\else
+\HCode{<a name='DUCC_DISK_INFO'></a>}
+\fi
+ \section{tools/ducc\_disk\_info}
+ \label{sec:cli.tools-ducc-disk-info}
+
+ \paragraph{Description:}
+ The disk info tool is used to obtain information about DUCC disk usage.
+
+ \paragraph{Usage:}
+ \begin{description}
+ \item[Script] \ducchome/bin/tools/ducc\_disk\_info {\em options}
+ \end{description}
+
+ \paragraph{Options:}
+ \begin{description}
+ \item[$--$help]
+ Prints the usage text to the console.
+ \item[$--$code]
+ Prints the exit code, which is the greater of disk usage percentage and quota usage percentage.
+ \item[$--$debug ]
+ Prints internal debugging information, intended for DUCC developers or extended problem determination.
+ \item[$--$nomsg ]
+ Suppress display of filesystem and quota percentages used message.
+ \end{description}
+
+ \paragraph{Notes:}
+ None.
+
\ No newline at end of file
Modified: uima/uima-ducc/trunk/uima-ducc-duccdocs/src/site/tex/duccbook/part2/ducc-uguide.tex
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-duccdocs/src/site/tex/duccbook/part2/ducc-uguide.tex?rev=1775950&r1=1775949&r2=1775950&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-duccdocs/src/site/tex/duccbook/part2/ducc-uguide.tex (original)
+++ uima/uima-ducc/trunk/uima-ducc-duccdocs/src/site/tex/duccbook/part2/ducc-uguide.tex Sat Dec 24 12:55:28 2016
@@ -155,6 +155,7 @@ ducc_submit --specification 1.job --proc
The next sections describe various tools in detail.
+ \input{part2/cli/tools-ducc-disk-info.tex}
\input{part2/cli/tools-ducc-status.tex}
% Create well-known link to this spot for HTML version