2 # a reporting program, to report information to the MCP
7 our @EXPORT_OK = qw( reports report );
9 sub reports { #should be autogenerated i guess
10 qw( freeside_version debian_version pg_version
11 apache_version apache_mpm
19 $report =~ /^(\w+)$/ or die;
20 eval "report_$report();";
24 foreach my $report ( reports() ) {
25 print "$report: ". report($report). "\n";
29 sub report_freeside_version {
30 chomp( my $fs_version =
31 `grep '^VERSION=' /home/ivan/freeside/Makefile | cut -d= -f2`
36 sub report_debian_version {
37 chomp( my $deb_version = `cat /etc/debian_version` );
41 sub report_pg_version {
42 chomp( my $pg_version = `echo 'show server_version' | psql -t freeside` );
43 chomp($pg_version); #two?
44 $pg_version =~ s/^ +//;
48 sub report_apache_version {
49 chomp( my $apache_version =
50 `/usr/sbin/apache2 -v | head -1 | cut -d: -f2 | cut -d/ -f2 | cut -d' ' -f1`
55 sub report_apache_mpm {
56 chomp( my $apache_mpm =
57 `/usr/sbin/apache2 -V | grep '^Server MPM' | cut -d: -f2`
59 $apache_mpm =~ s/^ +//;
63 sub report_payment_gateways {
64 my @gateways = split(/\n/,
65 `aptitude -F '%c %p' search 'libbusiness-onlinepayment-.*' | grep '^i ' | grep -v '^i libbusiness-onlinepayment-perl' | cut -c29- | cut -d- -f1`
67 join(', ', @gateways);
70 #sub report_ssh_vulnkey{
71 # my $ssh_vulnkey = `ssh-vulnkey -a | grep COMPROMISED`;
76 open LOAD, "</proc/loadavg" || return;
77 my($one, $five, $fifteen) = split ' ', <LOAD>;
79 ($one, $five, $fifteen);
82 sub report_freememory {
83 open MEM, "</proc/meminfo" || return;
85 my @interesting = qw( MemFree Cached SwapFree );
87 /^(\w*):\s*(\d*) kB$/ || next;
88 next unless grep { $_ eq $1 } @interesting;