Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pve-manager
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
pve-manager
Commits
9e132b16
Commit
9e132b16
authored
Jun 23, 2015
by
Alexandre Derumier
Committed by
Dietmar Maurer
Jun 23, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add graphite plugin V2
Signed-off-by:
Alexandre Derumier
<
aderumier@odiso.com
>
parent
aced2be5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
86 additions
and
19 deletions
+86
-19
Graphite.pm
PVE/Status/Graphite.pm
+78
-11
Plugin.pm
PVE/Status/Plugin.pm
+4
-4
pvestatd
bin/pvestatd
+4
-4
No files found.
PVE/Status/Graphite.pm
View file @
9e132b16
...
...
@@ -7,6 +7,8 @@ use PVE::Status::Plugin;
# example config (/etc/pve/status.cfg)
#graphite:
# graphiteserver test
# port 2003
# path proxmox.mycluster
# disable 0
#
...
...
@@ -19,8 +21,16 @@ sub type {
sub
properties
{
return
{
graphiteserver
=>
{
type
=>
'
string
',
description
=>
"
External graphite statistic server
",
type
=>
'
string
',
format
=>
'
dns-name
',
description
=>
"
External graphite statistic server dns name
",
},
port
=>
{
type
=>
'
integer
',
description
=>
"
graphite server port
",
},
path
=>
{
type
=>
'
string
',
format
=>
'
graphite-path
',
description
=>
"
root graphite path (ex: proxmox.mycluster.mykey)
",
},
};
}
...
...
@@ -28,33 +38,90 @@ sub properties {
sub
options
{
return
{
graphiteserver
=>
{},
port
=>
{
optional
=>
1
},
path
=>
{
optional
=>
1
},
disable
=>
{
optional
=>
1
},
};
}
# Plugin implementation
sub
update_node_status
{
my
(
$plugin_config
,
$node
,
$data
)
=
@_
;
my
(
$class
,
$plugin_config
,
$node
,
$data
,
$ctime
)
=
@_
;
write_graphite_hash
(
$plugin_config
,
$data
,
$ctime
,
"
nodes.
$node
");
# implement me
}
sub
update_qemu_status
{
my
(
$plugin_config
,
$vmid
,
$data
)
=
@_
;
# implement me
my
(
$class
,
$plugin_config
,
$vmid
,
$data
,
$ctime
)
=
@_
;
write_graphite_hash
(
$plugin_config
,
$data
,
$ctime
,
"
qemu.
$vmid
");
}
sub
update_lxc_status
{
my
(
$
plugin_config
,
$vmid
,
$data
)
=
@_
;
my
(
$
class
,
$plugin_config
,
$vmid
,
$data
,
$ctime
)
=
@_
;
# implement me
write_graphite_hash
(
$plugin_config
,
$data
,
$ctime
,
"
lxc.
$vmid
");
}
sub
update_storage_status
{
my
(
$plugin_config
,
$storeid
,
$data
)
=
@_
;
my
(
$class
,
$plugin_config
,
$nodename
,
$storeid
,
$data
,
$ctime
)
=
@_
;
write_graphite_hash
(
$plugin_config
,
$data
,
$ctime
,
"
storages.
$nodename
.
$storeid
");
}
sub
write_graphite_hash
{
my
(
$plugin_config
,
$d
,
$ctime
,
$object
)
=
@_
;
my
$host
=
$plugin_config
->
{
graphiteserver
};
my
$port
=
$plugin_config
->
{
port
}
?
$plugin_config
->
{
port
}
:
2003
;
my
$path
=
$plugin_config
->
{
path
}
?
$plugin_config
->
{
path
}
:
'
proxmox
';
my
$carbon_socket
=
IO::Socket::
IP
->
new
(
PeerAddr
=>
$host
,
PeerPort
=>
$port
,
Proto
=>
'
udp
',
);
write_graphite
(
$carbon_socket
,
$d
,
$ctime
,
$path
.
"
.
$object
");
$carbon_socket
->
close
()
if
$carbon_socket
;
# implement me
}
sub
write_graphite
{
my
(
$carbon_socket
,
$d
,
$ctime
,
$path
)
=
@_
;
for
my
$key
(
keys
%
$d
)
{
my
$value
=
$d
->
{
$key
};
my
$oldpath
=
$path
;
$key
=~
s/\./-/g
;
$path
.=
"
.
$key
";
if
(
defined
$value
)
{
if
(
ref
$value
eq
'
HASH
'
)
{
write_graphite
(
$carbon_socket
,
$value
,
$ctime
,
$path
);
}
else
{
$carbon_socket
->
send
(
"
$path
$value
$ctime
"
);
}
}
$path
=
$oldpath
;
}
}
PVE::JSONSchema::
register_format
('
graphite-path
',
\&
pve_verify_graphite_path
);
sub
pve_verify_graphite_path
{
my
(
$path
,
$noerr
)
=
@_
;
my
$regex
=
"
([a-zA-Z0-9]([a-zA-Z0-9
\
-]*[a-zA-Z0-9])?)
";
if
(
$path
!~
/^(${regex}\.)*${regex}$/
)
{
return
undef
if
$noerr
;
die
"
value does not look like a valid graphite path
\n
";
}
return
$path
;
}
1
;
PVE/Status/Plugin.pm
View file @
9e132b16
...
...
@@ -48,25 +48,25 @@ sub parse_section_header {
}
sub
update_node_status
{
my
(
$
plugin_config
,
$node
,
$data
)
=
@_
;
my
(
$
class
,
$plugin_config
,
$node
,
$data
,
$ctime
)
=
@_
;
die
"
please implement inside plugin
";
}
sub
update_qemu_status
{
my
(
$
plugin_config
,
$vmid
,
$data
)
=
@_
;
my
(
$
class
,
$plugin_config
,
$vmid
,
$data
,
$ctime
)
=
@_
;
die
"
please implement inside plugin
";
}
sub
update_lxc_status
{
my
(
$
plugin_config
,
$vmid
,
$data
)
=
@_
;
my
(
$
class
,
$plugin_config
,
$vmid
,
$data
,
$ctime
)
=
@_
;
die
"
please implement inside plugin
";
}
sub
update_storage_status
{
my
(
$
plugin_config
,
$storeid
,
$data
)
=
@_
;
my
(
$
class
,
$plugin_config
,
$nodename
,
$storeid
,
$data
,
$ctime
)
=
@_
;
die
"
please implement inside plugin
";
}
...
...
bin/pvestatd
View file @
9e132b16
...
...
@@ -119,7 +119,7 @@ sub update_node_status {
next
if
$plugin_config
->
{
disable
};
my
$plugin
=
PVE::Status::
Plugin
->
lookup
(
$plugin_config
->
{
type
});
my
$d
=
{};
# fixme: what data?
$plugin
->
update_node_status
(
$plugin_config
,
$nodename
,
$d
);
$plugin
->
update_node_status
(
$plugin_config
,
$nodename
,
$d
,
$ctime
);
}
}
...
...
@@ -197,7 +197,7 @@ sub update_qemu_status {
my
$plugin_config
=
$status_cfg
->
{
ids
}
->
{
$id
};
next
if
$plugin_config
->
{
disable
};
my
$plugin
=
PVE::Status::
Plugin
->
lookup
(
$plugin_config
->
{
type
});
$plugin
->
update_qemu_status
(
$plugin_config
,
$vmid
,
$d
);
$plugin
->
update_qemu_status
(
$plugin_config
,
$vmid
,
$d
,
$ctime
);
}
}
}
...
...
@@ -244,7 +244,7 @@ sub update_lxc_status {
my
$plugin_config
=
$status_cfg
->
{
ids
}
->
{
$id
};
next
if
$plugin_config
->
{
disable
};
my
$plugin
=
PVE::Status::
Plugin
->
lookup
(
$plugin_config
->
{
type
});
$plugin
->
update_lxc_status
(
$plugin_config
,
$vmid
,
$d
);
$plugin
->
update_lxc_status
(
$plugin_config
,
$vmid
,
$d
,
$ctime
);
}
}
}
...
...
@@ -274,7 +274,7 @@ sub update_storage_status {
my
$plugin_config
=
$status_cfg
->
{
ids
}
->
{
$id
};
next
if
$plugin_config
->
{
disable
};
my
$plugin
=
PVE::Status::
Plugin
->
lookup
(
$plugin_config
->
{
type
});
$plugin
->
update_storage_status
(
$plugin_config
,
$
storeid
,
$d
);
$plugin
->
update_storage_status
(
$plugin_config
,
$
nodename
,
$storeid
,
$d
,
$ctime
);
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment