Created
November 29, 2011 20:36
-
-
Save erickr/1406381 to your computer and use it in GitHub Desktop.
Redmine open ticket plugin for munin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php -q | |
<?php | |
$url = 'url-for-the-atom-list-of-tickets-in-redmine'; | |
$fc = file_get_contents($url); | |
$s = simplexml_load_string($fc); | |
$by_status = array(); | |
foreach( $s->entry as $entry ) { | |
$part_title = substr($entry->title, 0, strpos($entry->title, ':')); | |
if( ereg("\(([a-zA-z ]*)\)", $part_title, $match) ) | |
$status = $match[1]; | |
else | |
$status = ''; | |
if( !isset($by_status[$status]) ) | |
$by_status[$status] = 1; | |
else | |
$by_status[$status]++; | |
} | |
ksort($by_status); | |
if ((count($argv) > 1) && ($argv[1] == 'config')) | |
{ | |
print("graph_title Open redmine tickets | |
graph_category Redmine | |
"); | |
foreach( $by_status as $status => $count ) | |
echo str_replace(' ', '', $status).".label ".$status."\n"; | |
echo "\n"; | |
exit(); | |
} | |
foreach( $by_status as $status => $count ) | |
echo str_replace(' ', '', $status).".value ".$count."\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment