-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete_device.php
More file actions
executable file
·55 lines (45 loc) · 1.21 KB
/
Copy pathdelete_device.php
File metadata and controls
executable file
·55 lines (45 loc) · 1.21 KB
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
#!/usr/bin/env php
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage cli
* @copyright (C) Adam Armstrong
*
*/
chdir(dirname($argv[0]));
$options = getopt("d");
if (isset($options['d'])) {
array_shift($argv);
} // for compatibility
include("includes/observium.inc.php");
print_message("%g" . OBSERVIUM_PRODUCT . " " . OBSERVIUM_VERSION . "\n%WRemove Device%n\n", 'color');
// Remove a host and all related data from the system
if ($argv[1]) {
$host = strtolower($argv[1]);
if (is_numeric($host)) {
$id = $host;
} else {
$id = get_device_id_by_hostname($host);
}
$delete_rrd = isset($argv[2]) && strtolower($argv[2]) === 'rrd';
// Test if a valid id was fetched from get_device_id_by_hostname()
if (isset($id) && is_numeric($id)) {
print_warning(delete_device($id, $delete_rrd));
print_success("Device $host removed.");
} else {
print_error("Device $host doesn't exist!");
}
} else {
print_message("%n
USAGE:
$scriptname <hostname> [rrd]
EXAMPLE:
%WKeep RRDs%n: $scriptname <hostname>
%WRemove RRDs%n: $scriptname <hostname> rrd
%rInvalid arguments!%n", 'color', FALSE);
}
// EOF