root / plugins / google / googlecode @ 6c3ce4e1
Historique | Voir | Annoter | Télécharger (2,88 ko)
| 1 | 76847027 | Stig Sandbeck Mathisen | #!/bin/bash |
|---|---|---|---|
| 2 | 6d02dc52 | K?re Hartvig Jensen | ########################## |
| 3 | # googlecode_ |
||
| 4 | ########################## |
||
| 5 | # Munin Plugin to display the number of downloads |
||
| 6 | # from a google code repository |
||
| 7 | # Copyright 2009 (C) Kaare Hartvig Jensen (hartvig.de) |
||
| 8 | # |
||
| 9 | # This program is free software: you can redistribute it and/or modify |
||
| 10 | # it under the terms of the GNU General Public License as published by |
||
| 11 | # the Free Software Foundation, either version 3 of the License, or |
||
| 12 | # (at your option) any later version. |
||
| 13 | # |
||
| 14 | # This program is distributed in the hope that it will be useful, |
||
| 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 17 | # GNU General Public License for more details. |
||
| 18 | # |
||
| 19 | # You should have received a copy of the GNU General Public License |
||
| 20 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
||
| 21 | |||
| 22 | # Usage: |
||
| 23 | # Create symbolic link from /etc/munin/plugins/googlecode_projectname to |
||
| 24 | # /usr/share/munin/plugins/googlecode_ |
||
| 25 | # |
||
| 26 | # Here, projectname is the name of the project you wish to monitor. |
||
| 27 | # googlecode_ will look at the downloads list, and list the number |
||
| 28 | # of downloads for a given file. googlecode_ assumes, that the file |
||
| 29 | # names take the form "projectname_" or "projectname-", such as |
||
| 30 | # "sinthgunt_2.0.2_all.deb" for the sinthgunt project hosted at |
||
| 31 | # www.sinthgunt.org |
||
| 32 | |||
| 33 | # Get project name |
||
| 34 | PROJECTNAME=`basename $0 | sed 's/^googlecode_//g'` |
||
| 35 | |||
| 36 | # Get list of files and the number of downloads |
||
| 37 | declare -a files |
||
| 38 | files=( $(lynx -source http://code.google.com/p/$PROJECTNAME/downloads/list | html2text -nobs -ascii -width 100 | grep $PROJECTNAME[-_] | sed 's/ */ /g' | tac | sed 's/Featured*/ /g') ) |
||
| 39 | Nfiles=${#files[@]}
|
||
| 40 | if [ "$1" = "autoconf" ]; then |
||
| 41 | echo yes |
||
| 42 | exit 0 |
||
| 43 | fi |
||
| 44 | |||
| 45 | # Config. |
||
| 46 | if [ "$1" = "config" ]; then |
||
| 47 | echo "graph_title Number of downloads of $PROJECTNAME from Google Code " |
||
| 48 | echo "graph_args --base 1000 --lower-limit 0" |
||
| 49 | echo "graph_vlabel number of downloads" |
||
| 50 | 6c3ce4e1 | dipohl | echo "graph_category other" |
| 51 | 6d02dc52 | K?re Hartvig Jensen | echo "graph_info This graph shows the number of downloads of $PROJECTNAME from Google Code." |
| 52 | j=0 |
||
| 53 | for (( i = 1 ; i < $Nfiles ; i=i+5 )) |
||
| 54 | do |
||
| 55 | if [ $i = 1 ]; then # first one must be area. |
||
| 56 | name="site_${j}"
|
||
| 57 | echo "${name}.label ${files[$i-1]}"
|
||
| 58 | echo "${name}.draw AREA"
|
||
| 59 | # echo "${name}.type COUNTER"
|
||
| 60 | echo "${name}.info The number of downloads of $PROJECTNAME from google code."
|
||
| 61 | j=$((j+1)) |
||
| 62 | else # the rest is stacked on top of the area. |
||
| 63 | name="site_${j}"
|
||
| 64 | echo "${name}.label ${files[$i-1]}"
|
||
| 65 | echo "${name}.draw STACK"
|
||
| 66 | # echo "${name}.type COUNTER"
|
||
| 67 | echo "${name}.info The number of downloads of $PROJECTNAME from google code."
|
||
| 68 | j=$((j+1)) |
||
| 69 | fi |
||
| 70 | done |
||
| 71 | exit 0 |
||
| 72 | fi |
||
| 73 | |||
| 74 | # Pring number of downloads. |
||
| 75 | |||
| 76 | j=0 |
||
| 77 | for (( i = 1 ; i < $Nfiles ; i=i+5 )) |
||
| 78 | do |
||
| 79 | name="site_${j}"
|
||
| 80 | value=${files[$i+3]}
|
||
| 81 | echo "${name}.value ${value}"
|
||
| 82 | j=$((j+1)) |
||
| 83 | done |
