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
2abf9c19
Commit
2abf9c19
authored
Nov 03, 2015
by
Emmanuel Kasper
Committed by
Dietmar Maurer
Nov 03, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move pvereport functionality into a separate PVE package
parent
4b5e5726
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
108 additions
and
93 deletions
+108
-93
Makefile
PVE/Makefile
+1
-0
Report.pm
PVE/Report.pm
+105
-0
pvereport
bin/pvereport
+2
-93
No files found.
PVE/Makefile
View file @
2abf9c19
...
...
@@ -15,6 +15,7 @@ PERLSOURCE = \
APLInfo.pm
\
AutoBalloon.pm
\
CephTools.pm
\
Report.pm
\
VZDump.pm
all
:
pvecfg.pm ${SUBDIRS}
...
...
PVE/Report.pm
0 → 100644
View file @
2abf9c19
package
PVE::
Report
;
use
strict
;
use
warnings
;
use
PVE::
pvecfg
;
use
PVE::
Tools
;
my
$report
;
my
@general
=
('
hostname
',
'
pveversion --verbose
',
'
cat /etc/hosts
',
'
top -b -n 1 | head -n 15
',
'
pvesubscription get
',
'
lscpu
');
my
@storage
=
('
cat /etc/pve/storage.cfg
',
'
pvesm status
',
'
cat /etc/fstab
',
'
mount
',
'
df --human
');
my
@volumes
=
('
lvdisplay
',
'
vgdisplay
',
'
zpool status
',
'
zfs list
');
my
@machines
=
('
qm list
',
sub
{
dir2text
('
/etc/pve/qemu-server/
',
'
\
d.*conf
')
});
my
@net
=
('
ifconfig
',
'
cat /etc/network/interfaces
',
sub
{
dir2text
('
/etc/pve/firewall/
',
'
.*fw
')
},
'
iptables-save
');
my
@cluster
=
('
pvecm nodes
',
'
pvecm status
');
my
@bios
=
('
dmidecode -t bios
');
if
(
PVE::pvecfg::
version
()
>=
4.0
)
{
push
@cluster
,
'
cat /etc/pve/corosync.conf 2> /dev/null
'
;
push
@machines
,
sub
{
dir2text
('
/etc/pve/lxc/
',
'
\
d.*conf
')
};
}
else
{
push
@general
,
'
grep --max-count=1 "model name" /proc/cpuinfo
';
push
@machines
,
sub
{
dir2text
('
/etc/pve/openvz/
',
'
\
d.*conf
')
};
push
@cluster
,
'
clustat
',
'
cat /etc/cluster.conf 2> /dev/null
';
}
my
$general_report
=
{
title
=>
'
general system info
',
commands
=>
\
@general
,
};
my
$storage_report
=
{
title
=>
'
info about storage (lvm and zfs)
',
commands
=>
\
@storage
,
};
my
$volume_report
=
{
title
=>
'
info about virtual machines
',
commands
=>
\
@machines
,
};
my
$net_report
=
{
title
=>
'
info about network and firewall
',
commands
=>
\
@net
,
};
my
$cluster_report
=
{
title
=>
'
info about clustering
',
commands
=>
\
@cluster
,
};
my
$bios_report
=
{
title
=>
'
info about bios
',
commands
=>
\
@bios
,
};
my
@global_report
=
(
$general_report
,
$storage_report
,
$volume_report
,
$net_report
,
$cluster_report
,
$bios_report
);
# output the content of all the files of a directory
sub
dir2text
{
my
(
$target_dir
,
$regexp
)
=
@_
;
PVE::Tools::
dir_glob_foreach
(
$target_dir
,
$regexp
,
sub
{
my
(
$file
)
=
@_
;
$report
.=
"
# cat
$target_dir$file
\n
";
$report
.=
PVE::Tools::
file_get_contents
(
$target_dir
.
$file
)
.
"
\n
";
});
}
# execute commands and display their output as if they've been done on a interactive shell
# so the local sysadmin can reproduce what we're doing
sub
do_execute
{
my
(
$command
)
=
@_
;
$report
.=
"
#
$command
\n
";
open
(
COMMAND
,
"
$command
2>&1 |
");
while
(
<
COMMAND
>
)
{
$report
.=
$_
;
}
}
sub
generate
{
foreach
my
$subreport
(
@global_report
)
{
my
$title
=
$subreport
->
{'
title
'};
my
@commands
=
@
{
$subreport
->
{'
commands
'}};
$report
.=
"
\n
====
$title
====
\n
";
foreach
my
$command
(
@commands
)
{
if
(
ref
$command
eq
'
CODE
')
{
&
$command
;
}
else
{
do_execute
(
$command
);
next
;
}
}
}
return
$report
;
}
bin/pvereport
View file @
2abf9c19
...
...
@@ -2,102 +2,11 @@
use
strict
;
use
warnings
;
use
PVE::
pvecfg
;
use
PVE::
Tools
;
use
PVE::
Report
;
(
$>
==
0
)
||
die
"
please run as root
\n
";
# output the content of all the files of a directory
sub
dir2text
{
my
(
$target_dir
,
$regexp
)
=
@_
;
PVE::Tools::
dir_glob_foreach
(
$target_dir
,
$regexp
,
sub
{
my
(
$file
)
=
@_
;
print
"
# cat
$target_dir$file
\n
";
print
PVE::Tools::
file_get_contents
(
$target_dir
.
$file
)
.
"
\n
";
});
}
my
@general
=
('
hostname
',
'
pveversion --verbose
',
'
cat /etc/hosts
',
'
top -b -n 1 | head -n 15
',
'
pvesubscription get
',
'
lscpu
');
my
@storage
=
('
cat /etc/pve/storage.cfg
',
'
pvesm status
',
'
cat /etc/fstab
',
'
mount
',
'
df --human
');
my
@volumes
=
('
lvdisplay
',
'
vgdisplay
',
'
zpool status
',
'
zfs list
');
my
@machines
=
('
qm list
',
sub
{
dir2text
('
/etc/pve/qemu-server/
',
'
\
d.*conf
')
});
my
@net
=
('
ifconfig
',
'
cat /etc/network/interfaces
',
sub
{
dir2text
('
/etc/pve/firewall/
',
'
.*fw
')
},
'
iptables-save
');
my
@cluster
=
('
pvecm nodes
',
'
pvecm status
');
my
@bios
=
('
dmidecode -t bios
');
if
(
PVE::pvecfg::
version
()
>=
4.0
)
{
push
@cluster
,
'
cat /etc/pve/corosync.conf 2> /dev/null
'
;
push
@machines
,
sub
{
dir2text
('
/etc/pve/lxc/
',
'
\
d.*conf
')
};
}
else
{
push
@general
,
'
grep --max-count=1 "model name" /proc/cpuinfo
';
push
@machines
,
sub
{
dir2text
('
/etc/pve/openvz/
',
'
\
d.*conf
')
};
push
@cluster
,
'
clustat
',
'
cat /etc/cluster.conf 2> /dev/null
';
}
my
$general_report
=
{
title
=>
'
general system info
',
commands
=>
\
@general
,
};
my
$storage_report
=
{
title
=>
'
info about storage (lvm and zfs)
',
commands
=>
\
@storage
,
};
my
$volume_report
=
{
title
=>
'
info about virtual machines
',
commands
=>
\
@machines
,
};
my
$net_report
=
{
title
=>
'
info about network and firewall
',
commands
=>
\
@net
,
};
my
$cluster_report
=
{
title
=>
'
info about clustering
',
commands
=>
\
@cluster
,
};
my
$bios_report
=
{
title
=>
'
info about bios
',
commands
=>
\
@bios
,
};
my
@global_report
=
(
$general_report
,
$storage_report
,
$volume_report
,
$net_report
,
$cluster_report
,
$bios_report
);
# execute commands and display their output as if they've been done on a interactive shell
# so the local sysadmin can reproduce what we're doing
sub
do_execute
{
my
(
$command
)
=
@_
;
print
"
#
$command
\n
";
system
$command
;
print
"
\n
";
}
foreach
my
$subreport
(
@global_report
)
{
my
$title
=
$subreport
->
{'
title
'};
my
@commands
=
@
{
$subreport
->
{'
commands
'}};
print
"
====
"
.
$title
.
"
====
\n
";
foreach
my
$command
(
@commands
)
{
if
(
ref
$command
eq
'
CODE
')
{
&
$command
;
}
else
{
do_execute
(
$command
);
next
;
}
}
}
print
PVE::Report::
generate
();
__END__
...
...
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