Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 63 lines (45 sloc) 1.03 KB
#!/usr/bin/php
<?php
#%# family=auto
#%# capabilities=autoconf
function get_bookmark_count () {
require_once '/usr/local/scripts/web.changineer.info/munin/IXR_Library.php';
$url = 'http://changineer.info/';
$ixr = new IXR_Client('http://b.hatena.ne.jp/xmlrpc');
$ixr->query('bookmark.getTotalCount',$url);
$count = $ixr->getResponse();
if(!$count) $count = 0;
return $count ;
}
function get_config () {
return <<< EOF
graph_title hatena bookmark count
graph_vlabel count
graph_category social media
count.label hatena bookmark count
count.min 0
count.draw LINE2
count.type GAUGE
EOF;
}
function get_autoconf(){
$web_addr = gethostbyname('changineer.info');
$remote_addr = gethostbyname(trim(`hostname`));
if ( $web_addr == $remote_addr ) {
return "yes";
} else {
return "no";
}
}
if (count($argv) == 1) {
print "count.value " . get_bookmark_count() ;
exit(0) ;
}
switch ($argv[1]) {
case "config":
print get_config();
break;
case "autoconf":
print get_autoconf();
break;
}