-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfill.php
76 lines (58 loc) · 1.72 KB
/
fill.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
/**
* Script to send random data to a graphite server, usefull for testing new
* graphite installs and getting your config in shape.
*
* @author Stuart Grimshaw <[email protected]>
* @version $Id$
* @copyright Stuart Grimshaw <[email protected]>, 08 April, 2012
* @package default
*/
require_once 'src/GraphiteFiller/Connection.php';
use GraphiteFiller\Connection;
$date = strtotime('-1 day');
$time = '00:00:00';
$interval = 1;
$max = 10;
$stat = "test.stat";
$port = 2003;
$host = "localhost";
// Check the parameters passes to the script.
if(count($argv <= 1)) {
// print options.
}
$arrOpts = getopt("dtimhps", array('date:', 'time:', 'interval:', 'max:', 'host:', 'port:', 'stat:'));
if(isset( $arrOpts['date'] ) && $arrOpts[ 'date' ]) {
$date = strtotime($arrOpts['date']);
}
if(isset($arrOpts['time']) && $arrOpts[ 'time' ]) {
$time = $arrOpts[ 'time' ];
}
if(isset($arrOpts['interval']) && $arrOpts[ 'interval' ]) {
$interval = $arrOpts[ 'interval' ];
}
if(isset($arrOpts['max']) && $arrOpts[ 'max' ]) {
$max = $arrOpts[ 'max' ];
}
if(isset($arrOpts['stat']) && $arrOpts[ 'stat' ]) {
$stat = $arrOpts[ 'stat' ];
print "Stat = " . $stat . "\n";
}
if(isset($arrOpts['host']) && $arrOpts[ 'host' ]) {
$host = $arrOpts[ 'host' ];
}
if(isset($arrOpts['port']) && $arrOpts[ 'port' ]) {
$port = $arrOpts[ 'port' ];
}
// work out the start date.
$statDate = $date + strtotime("Januray 1 1970 $time");
print "Start date is " . date("Y-m-d h:m:s", $statDate) . "\n";
print "Stat is " . $stat . "\n";
$conn = new Connection($host, $port);
$conn->connect();
while($statDate < time()) {
$value = rand(0, $max);
$conn->send($stat, $value, $statDate);
$statDate += $interval;
}
?>