From 43bcea3777de207abb255b249028892826dfa4f2 Mon Sep 17 00:00:00 2001 From: adefaria Date: Mon, 7 Apr 2014 15:33:23 -0700 Subject: [PATCH] Removed references to Machines. Updated rexec and Rexec.pm to use Clearadm's database instead. --- bin/rexec | 308 ++++++++++++++++---------------- clearadm/lib/Clearadm.pm | 13 +- etc/machines.conf | 16 -- lib/Machines.pm | 370 --------------------------------------- lib/Rexec.pm | 4 + lib/machines.sql | 138 --------------- 6 files changed, 174 insertions(+), 675 deletions(-) delete mode 100644 etc/machines.conf delete mode 100644 lib/Machines.pm delete mode 100644 lib/machines.sql diff --git a/bin/rexec b/bin/rexec index 39359d4..3dad3ac 100755 --- a/bin/rexec +++ b/bin/rexec @@ -1,86 +1,88 @@ -#!/usr/local/bin/perl -################################################################################ -# -# File: $RCSfile: rexec,v $ -# Revision: $Revision: 1.1 $ -# Description: Remotely run processes on other machines -# Author: Andrew@ClearSCM.com -# Created: Tue Jan 8 15:57:27 MST 2008 -# Modified: $Date: 2008/02/29 15:09:15 $ -# Language: perl -# -# (c) Copyright 2008, ClearSCM, Inc., all rights reserved -# -################################################################################ +#!/usr/bin/perl use strict; use warnings; -use FindBin; -use Getopt::Long; -use Term::ANSIColor qw(:constants); -use POSIX ":sys_wait_h"; +=pod -my $libs; +=head1 NAME $RCSfile: rexec,v $ -BEGIN { - $libs = $ENV{SITE_PERLLIB} ? $ENV{SITE_PERLLIB} : "$FindBin::Bin/lib"; +Run arbitrary command on a set of machines - die "Unable to find libraries\n" if !$libs and !-d $libs; -} +=head1 VERSION -use lib $libs; +=over -use Display; -use Logger; -use Machines; -use Rexec; -use Utils; +=item Author + +Andrew DeFaria -our $_host; -our $_skip = 0; -our $_currentHost; +=item Revision -my $_log = 0; -my $_quiet = 0; -my $_alternateFile; -my $_parallel = 0; +$Revision: 1.0 $ -my $_totalMachines = 0; -my $_totalExecutions = 0; -my $_totalFailures = 0; -my $_totalConnectFailures = 0; -my $_totalSkips = 0; +=item Created: -my (%_workerStatuses, %_workerNames); +Tue Jan 8 15:57:27 MST 2008 -sub Usage { - my $msg = shift; +=item Modified: - display "ERROR: $msg\n" if defined $msg; +$Date: 2008/02/29 15:09:15 $ - display "rexec\t[-v] [-d] [-u] "; - display "\t-v\tTurn on verbose mode"; - display "\t-d\tTurn on debug mode"; - display "\t-u\tThis usage message"; - display "\tCommand to execute remotely"; +=back - exit 1; -} # Usage +=head1 SYNOPSIS -sub printStats { - display YELLOW . "Machines: " . RESET . "$_totalMachines " . - MAGENTA . "Executions/Failures: " . RESET . "($_totalExecutions/$_totalFailures) " . - BLUE . "Connect Failures/Skips: " . RESET . "($_totalConnectFailures/$_totalSkips)"; -} # printStats + Usage: rexec [-u|sage] [-v|erbose] [-d|ebug] [-t|ype ] + + + Where: + -u|sage Print this usage + -v|erbose: Verbose mode + -d|ebug: Print debug messages + -t|ype: Machine type (Linux, Windows) + : Command to execute + +=head1 DESCRIPTION + +This script will perform and arbitrary command on a set of machines. + +=cut + +use FindBin; +use Getopt::Long; +use Pod::Usage; +use Term::ANSIColor qw(:constants); +use POSIX ":sys_wait_h"; + +use lib "$FindBin::Bin/../lib", "$FindBin::Bin/../clearadm/lib"; + +use Display; +use Clearadm; +use Logger; +use Rexec; +use Utils; + +my %total; +my ($currentHost, $skip, $log); + +my %opts = ( + usage => sub { pod2usage }, + help => sub { pod2usage (-verbose => 2)}, + verbose => sub { set_verbose }, + debug => sub { set_debug }, + parallel => 0, +); + +my (%workerStatuses, %workerNames); sub Interrupted { use Term::ReadKey; - display BLUE . "\nInterrupted execution on $_host" . RESET; + display BLUE . "\nInterrupted execution on $currentHost" . RESET; - printStats; + Stats \%total, $log; - display_nolf "Executing on " . YELLOW . $_host . RESET . " - " + display_nolf "Executing on " . YELLOW . $currentHost . RESET . " - " . GREEN . BOLD . "S" . RESET . GREEN . "kip" . RESET . ", " . CYAN . BOLD . "C" . RESET . CYAN . "ontinue" . RESET . " or " . MAGENTA . BOLD . "A" . RESET . MAGENTA . "bort run" . RESET . " (" @@ -102,17 +104,19 @@ sub Interrupted { if ($answer eq "s") { *STDOUT->flush; - display "Skipping $_host"; - $_skip = 1; - $_totalSkips++; + display "Skipping $currentHost"; + $skip = 1; + $total{Skips}++; } elsif ($answer eq "a") { display RED . "Aborting run". RESET; - printStats; + Stats \%total, $log; exit; } else { display "Continuing..."; - $_skip = 0; + $skip = 0; } # if + + return; } # Interrupted sub workerDeath { @@ -120,67 +124,71 @@ sub workerDeath { my $status = $?; # Ignore all child deaths except for processes we started - next if !exists $_workerStatuses{$worker}; + next if !exists $workerStatuses{$worker}; - $_workerStatuses{$worker} = $status; + $workerStatuses{$worker} = $status; } # while $SIG{CHLD} = \&workerDeath; + + return; } # workerDeath -sub execute ($$$) { +sub execute ($$;$) { my ($cmd, $host, $prompt) = @_; - my @lines; + my ($remoteHost, @lines); + # Mark $currentHost for interrupt + $currentHost = $host; + + # Start a log... + $log = Logger->new (name => $host) if $opts{log}; + verbose_nolf "Connecting to machine $host..."; + display_nolf YELLOW . "$host:" . RESET; + eval { - $_currentHost = new Rexec ( - host => $host, - prompt => $prompt, + $remoteHost = Rexec->new ( + host => $host, + prompt => $prompt, ); }; # Problem with creating Rexec object. Log error if logging and return. - if ($@ or !$_currentHost) { - if ($_log) { - my $log = new Logger (name => $_host); - - $log->err ("Unable to connect to $host to execute command\n$cmd"); + if ($@ || !$remoteHost) { + if ($opts{log}) { + $log->err ("Unable to connect to $host to execute command: $cmd") if $opts{log}; + } else { + display RED . 'ERROR:' . RESET . " Unable to connect to $host to execute command: $cmd"; } # if - $_totalConnectFailures++; + $total{ConnectFailures}++; return (1, ()); } # if verbose " connected"; - display YELLOW . "$host:" . RESET . UNDERLINE . "$cmd" . RESET unless $_quiet; + display UNDERLINE . "$cmd" . RESET unless $opts{quiet}; - @lines = $_currentHost->exec ($cmd); + @lines = $remoteHost->execute ($cmd); - if ($_skip) { + if ($skip) { # Kick current connection - kill INT => $_currentHost->{handle}->pid; + kill INT => $remoteHost->{handle}->pid; } # if - if ($_parallel != 0) { - if ($_log) { - my $log = new Logger (name => $_host); - - $log->err ("Unable to connect to $host to execute command\n$cmd"); - } # if - - $_totalConnectFailures++; - } # if +# if ($opts{parallel} != 0) { +# $log->err ("Unable to connect to $host to execute command\n$cmd") if $opts{log}; +# +# $total{ConnectFailures}++; +# } # if verbose "Disconnected from $host"; - my $status = $_currentHost->status; - - undef $_currentHost; + my $status = $remoteHost->status; return ($status, @lines); } # execute @@ -190,25 +198,29 @@ sub parallelize ($%) { my $thread_count = 1; - foreach $_host (sort keys %machines) { - if ($thread_count <= $_parallel) { - debug "Processing $_host ($thread_count)"; + foreach my $host (sort keys %machines) { + if ($thread_count <= $opts{parallel}) { + debug "Processing $host ($thread_count)"; $thread_count++; if (my $pid = fork) { # In parent process - record this host and its status - $_workerNames{$pid} = $_host; + $workerNames{$pid} = $host; } else { # In spawned child... $pid = $$; - debug "Starting process for $_host [$pid]"; + debug "Starting process for $host [$pid]"; - $_workerNames{$pid} = $_host; + $workerNames{$pid} = $host; + + # Mark currentHost for interrupt (How does this work in the presence + # of parallelization?). + $currentHost = $host; - my ($status, @lines) = execute $cmd, $_host, $machines{$_host}; + my ($status, @lines) = execute $cmd, $host, $machines{$host}; - my $log = new Logger (name => $_host); + $log = Logger->new (name => $host); $log->log ($_) foreach (@lines); @@ -219,44 +231,46 @@ sub parallelize ($%) { debug "Waiting for somebody to exit..."; my $reaped = wait; - debug "Reaped $_workerNames{$reaped} [$reaped] (Status: $?)"; - $_workerStatuses{$reaped} = $? >> 8 if $reaped != -1; + debug "Reaped $workerNames{$reaped} [$reaped] (Status: $?)"; + $workerStatuses{$reaped} = $? >> 8 if $reaped != -1; $thread_count--; } # if } # foreach # Wait for all kids - my %threads = %_workerNames; + my %threads = %workerNames; foreach (keys %threads) { if (waitpid ($_, 0) == -1) { delete $threads{$_}; } else { - $_workerStatuses{$_} = $? >> 8; - debug "$threads{$_} [$_] exited with a status of $_workerStatuses{$_}"; + $workerStatuses{$_} = $? >> 8; + debug "$threads{$_} [$_] exited with a status of $workerStatuses{$_}"; } # if } # foreach debug "All processed completed - Status:"; if (get_debug) { - foreach (sort keys %_workerStatuses) { - debug "$_workerNames{$_}\t[$_]:\tStatus: $_workerStatuses{$_}"; + foreach (sort keys %workerStatuses) { + debug "$workerNames{$_}\t[$_]:\tStatus: $workerStatuses{$_}"; } # foreach } # if # Gather output... display "Output of all executions"; - foreach $_host (sort keys %machines) { - if (-f "$_host.log") { - display "$_host:$_" foreach (ReadFile ("$_host.log")); + foreach my $host (sort keys %machines) { + if (-f "$host.log") { + display "$host:$_" foreach (ReadFile ("$host.log")); #unlink "$_host.log"; } else { - warning "Unable to find output for $_host ($_host.log missing)"; + warning "Unable to find output for $host ($host.log missing)"; } # if } # foreach + + return; } # parallelize # Print the totals if interrupted @@ -264,63 +278,57 @@ $SIG{INT} = \&Interrupted; # Get our options GetOptions ( - "usage" => sub { Usage "" }, - "verbose" => sub { set_verbose }, - "debug" => sub { set_debug }, - "log" => \$_log, - "quiet" => \$_quiet, - "file=s" => \$_alternateFile, - "parallel:i" => \$_parallel, -) || Usage "Unknown parameter"; - -my $cmd = join " ", @ARGV; - -error "No command specified", 1 if !$cmd; - -my $machines = Machines->new (file => $_alternateFile); -my %machines = $machines->all (); - -if ($_parallel > 0) { - parallelize ($cmd, %machines); - printStats; + \%opts, + 'usage', + 'help', + 'verbose', + 'debug', + 'log', + 'quiet', + 'type=s', + 'parallel=i', +); + +my $cmd = join ' ', @ARGV; + +pod2usage ('No command specified') unless $cmd; + +my $machines = Clearadm->new; + +if ($opts{parallel} > 0) { + #parallelize ($cmd, %machines); + Stats \%total, $log; exit; } # if -display "NOTE: Logging output to .log" if $_log; +display "NOTE: Logging outputs to .log" if $opts{log}; -foreach $_host (sort keys (%machines)) { - $_totalMachines++; +foreach ($machines->SearchSystem ("type='$opts{type}'")) { + my %system = %$_; + $total{Machines}++; - my ($status, @lines) = execute $cmd, $_host, $machines{$_host}; + my ($status, @lines) = execute $cmd, $system{name}; - if ($_skip) { - $_skip = 0; + if ($skip) { + $skip = 0; next; } # if if (defined $status) { if ($status == 0) { - $_totalExecutions++; + $total{Executions}++; } else { - if ($_log) { - my $log = new Logger (name => $_host); - - $log->err ("Unable to execute command on $_host\n$cmd"); - } # if - - $_totalFailures++; + $total{Failures}++; next; } # if } # if - if ($_log) { - my $log = new Logger (name => $_host); - + if ($opts{log}) { $log->log ($_) foreach (@lines); } else { display $_ foreach (@lines); } # if } # foreach -printStats; \ No newline at end of file +Stats \%total, $log; \ No newline at end of file diff --git a/clearadm/lib/Clearadm.pm b/clearadm/lib/Clearadm.pm index 7e57109..fb63079 100644 --- a/clearadm/lib/Clearadm.pm +++ b/clearadm/lib/Clearadm.pm @@ -86,6 +86,7 @@ use warnings; use Carp; use DBI; +use File::Basename; use Net::Domain qw(hostdomain); use FindBin; @@ -97,7 +98,9 @@ use Display; use GetConfig; use Mail; -our %CLEAROPTS = GetConfig ("$FindBin::Bin/etc/clearadm.conf"); +my $conf = dirname (__FILE__) . '/../etc/clearadm.conf'; + +our %CLEAROPTS = GetConfig ($conf); # Globals our $VERSION = '$Revision: 1.54 $'; @@ -484,6 +487,14 @@ sub FindSystem (;$) { return $self->_getRecords ('system', $condition); } # FindSystem +sub SearchSystem (;$) { + my ($self, $condition) = @_; + + $condition = "name like '%'" unless $condition; + + return $self->_getRecords ('system', $condition); +} # SearchSystem + sub AddPackage (%) { my ($self, %package) = @_; diff --git a/etc/machines.conf b/etc/machines.conf deleted file mode 100644 index 17f2146..0000000 --- a/etc/machines.conf +++ /dev/null @@ -1,16 +0,0 @@ -############################################################################### -# -# File: $RCSfile: machines.conf,v $ -# Revision: $Revision: 1.0 $ -# Description: Config file for Machines -# Author: Andrew@ClearSCM.com -# Created: Fri Apr 4 14:29:21 PDT 2014 -# Modified: $Date: $ -# Language: conf -# -# (c) Copyright 2014, ClearSCM, Inc., all rights reserved -# -############################################################################### -MACHINES_SERVER: adefaria-lt -MACHINES_USERNAME: machines -MACHINES_PASSWORD: machines diff --git a/lib/Machines.pm b/lib/Machines.pm deleted file mode 100644 index c872eda..0000000 --- a/lib/Machines.pm +++ /dev/null @@ -1,370 +0,0 @@ -=pod - -=head1 NAME $RCSfile: Machines.pm,v $ - -Abstraction of machines. - -=head1 VERSION - -=over - -=item Author - -Andrew DeFaria - -=item Revision - -$Revision: 1.4 $ - -=item Created - -Tue Jan 8 17:24:16 MST 2008 - -=item Modified - -$Date: 2011/11/16 19:46:13 $ - -=back - -=head1 SYNOPSIS - -This module handles the details of providing information about -machines while obscuring the mechanism for storing such information. - - my $machines = Machines->new; - - foreach ($machine->all) { - my %machine = %{$_}; - display "Machine: $machine{name}"; - disp.ay "Owner: $machine{owner}" - } # if - -=head1 DESCRIPTION - -This module provides information about machines - -=head1 ROUTINES - -The following routines are exported: - -=cut - -package Machines; - -use strict; -use warnings; - -use Carp; -use DBI; -use FindBin; - -use DateUtils; -use Display; -use GetConfig; - -our %MACHINESOPTS = GetConfig ("$FindBin::Bin/../etc/machines.conf"); - -my $defaultFilesystemThreshold = 90; -my $defaultFilesystemHist = '6 months'; -my $defaultLoadavgHist = '6 months'; - -# Internal methods -sub _dberror ($$) { - my ($self, $msg, $statement) = @_; - - my $dberr = $self->{db}->err; - my $dberrmsg = $self->{db}->errstr; - - $dberr ||= 0; - $dberrmsg ||= 'Success'; - - my $message = ''; - - if ($dberr) { - my $function = (caller (1)) [3]; - - $message = "$function: $msg\nError #$dberr: $dberrmsg\n" - . "SQL Statement: $statement"; - } # if - - return $dberr, $message; -} # _dberror - -sub _formatValues (@) { - my ($self, @values) = @_; - - my @returnValues; - - # Quote data values - push @returnValues, $_ eq '' ? 'null' : $self->{db}->quote ($_) - foreach (@values); - - return @returnValues; -} # _formatValues - -sub _formatNameValues (%) { - my ($self, %rec) = @_; - - my @nameValueStrs; - - push @nameValueStrs, "$_=" . $self->{db}->quote ($rec{$_}) - foreach (keys %rec); - - return @nameValueStrs; -} # _formatNameValues - -sub _error () { - my ($self) = @_; - - if ($self->{msg}) { - if ($self->{errno}) { - carp $self->{msg}; - } else { - cluck $self->{msg}; - } # if - } # if -} # _error - -sub _addRecord ($%) { - my ($self, $table, %rec) = @_; - - my $statement = "insert into $table ("; - $statement .= join ',', keys %rec; - $statement .= ') values ('; - $statement .= join ',', $self->_formatValues (values %rec); - $statement .= ')'; - - my ($err, $msg); - - $self->{db}->do ($statement); - - return $self->_dberror ("Unable to add record to $table", $statement); -} # _addRecord - -sub _checkRequiredFields ($$) { - my ($fields, $rec) = @_; - - foreach my $fieldname (@$fields) { - my $found = 0; - - foreach (keys %$rec) { - if ($fieldname eq $_) { - $found = 1; - last; - } # if - } # foreach - - return "$fieldname is required" - unless $found; - } # foreach - - return; -} # _checkRequiredFields - -sub _connect (;$) { - my ($self, $dbserver) = @_; - - $dbserver ||= $MACHINESOPTS{MACHINES_SERVER}; - - my $dbname = 'machines'; - my $dbdriver = 'mysql'; - - $self->{db} = DBI->connect ( - "DBI:$dbdriver:$dbname:$dbserver", - $MACHINESOPTS{MACHINES_USERNAME}, - $MACHINESOPTS{MACHINES_PASSWORD}, - {PrintError => 0}, - ) or croak ( - "Couldn't connect to $dbname database " - . "as $MACHINESOPTS{MACHINESADM_USERNAME}\@$MACHINESOPTS{MACHINESADM_SERVER}" - ); - - $self->{dbserver} = $dbserver; - - return; -} # _connect - -sub _getRecords ($$) { - my ($self, $table, $condition) = @_; - - my ($err, $msg); - - my $statement = "select * from $table where $condition"; - - my $sth = $self->{db}->prepare ($statement); - - unless ($sth) { - ($err, $msg) = $self->_dberror ('Unable to prepare statement', $statement); - - croak $msg; - } # if - - my $attempts = 0; - my $maxAttempts = 3; - my $sleepTime = 30; - my $status; - - # We've been having the server going away. Supposedly it should reconnect so - # here we simply retry up to $maxAttempts times to re-execute the statement. - # (Are there other places where we need to do this?) - $err = 2006; - - while ($err == 2006 and $attempts++ < $maxAttempts) { - $status = $sth->execute; - - if ($status) { - $err = 0; - last; - } else { - ($err, $msg) = $self->_dberror ('Unable to execute statement', - $statement); - } # if - - last if $err == 0; - - croak $msg unless $err == 2006; - - my $timestamp = YMDHMS; - - $self->Error ("$timestamp: Unable to talk to DB server.\n\n$msg\n\n" - . "Will try again in $sleepTime seconds", -1); - - # Try to reconnect - $self->_connect ($self->{dbserver}); - - sleep $sleepTime; - } # while - - $self->Error ("After $maxAttempts attempts I could not connect to the database", $err) - if ($err == 2006 and $attempts > $maxAttempts); - - my @records; - - while (my $row = $sth->fetchrow_hashref) { - push @records, $row; - } # while - - return @records; -} # _getRecord - - -sub new { - my ($class, %parms) = @_; - -=pod - -=head2 new ($server) - -Construct a new Machines object. - -=cut - - # Merge %parms with %MACHINEOPTS - foreach (keys %parms) { - $MACHINESOPTS{$_} = $parms{$_}; - } # foreach; - - my $self = bless {}, $class; - - $self->_connect (); - - return $self; -} # new - -sub add (%) { - my ($self, %system) = @_; - - my @requiredFields = qw( - name - admin - type - ); - - my $result = _checkRequiredFields \@requiredFields, \%system; - - return -1, "add: $result" if $result; - - $system{loadavgHist} ||= $defaultLoadavgHist; - - return $self->_addRecord ('system', %system); -} # add - -sub delete ($) { - my ($self, $name) = @_; - - return $self->_deleteRecord ('system', "name='$name'"); -} # delete - -sub update ($%) { - my ($self, $name, %update) = @_; - - return $self->_updateRecord ('system', "name='$name'", %update); -} # update - -sub get ($) { - my ($self, $system) = @_; - - return unless $system; - - my @records = $self->_getRecords ( - 'system', - "name='$system' or alias like '%$system%'" - ); - - if ($records[0]) { - return %{$records[0]}; - } else { - return; - } # if -} # get - -sub find (;$) { - my ($self, $condition) = @_; - - return $self->_getRecords ('system', $condition); -} # find - -1; - -=pod - -=head1 CONFIGURATION AND ENVIRONMENT - -MACHINES: If set then points to a flat file containing machine -names. Note this is providied as a way to quickly use an alternate -"machine database". As such only minimal information is support. - -=head1 DEPENDENCIES - - Display - Rexec - -=head1 INCOMPATABILITIES - -None yet... - -=head1 BUGS AND LIMITATIONS - -There are no known bugs in this module. - -Please report problems to Andrew DeFaria . - -=head1 LICENSE AND COPYRIGHT - -This Perl Module is freely available; you can redistribute it and/or -modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -This Perl Module is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License (L) for more -details. - -You should have received a copy of the GNU General Public License -along with this Perl Module; if not, write to the Free Software Foundation, -Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -reserved. - -=cut diff --git a/lib/Rexec.pm b/lib/Rexec.pm index 71fdd22..8d6a9a3 100644 --- a/lib/Rexec.pm +++ b/lib/Rexec.pm @@ -500,6 +500,10 @@ Returns: # Close any prior opened sessions $self->logoff if ($self->{handle}); + # Check to see if this machines is known in DNS. If not then the chance is + # good that we will not be able to log in + return unless gethostbyname $self->{host}; + my $remote; if ($self->{protocol}) { diff --git a/lib/machines.sql b/lib/machines.sql deleted file mode 100644 index 0d9a2d4..0000000 --- a/lib/machines.sql +++ /dev/null @@ -1,138 +0,0 @@ -system-- ----------------------------------------------------------------------------- --- --- File: $RCSfile: machines.sql,v $ --- Revision: $Revision: 1.0 $ --- Description: Create the machines database --- Author: Andrew@DeFaria.com --- Created: Fri Apr 4 10:31:11 PDT 2014 --- Modified: $Date: $ --- Language: SQL --- --- Copyright (c) 2014, ClearSCM, Inc., all rights reserved --- --- ----------------------------------------------------------------------------- --- Warning: The following line will delete the old database! -drop database if exists machines; - --- Create a new database -create database machines; - --- Now let's focus on this new database -use machines; - --- system: Define what makes up a system or machine -create table system ( - name varchar (255) not null, - alias varchar (255), - active enum ( - 'true', - 'false' - ) not null default 'true', - admin tinytext, - email tinytext, - os tinytext, - type enum ( - 'Linux', - 'Unix', - 'Windows' - ) not null, - region tinytext, - lastheardfrom datetime, - description text, - loadavgHist enum ( - '1 month', - '2 months', - '3 months', - '4 months', - '5 months', - '6 months', - '7 months', - '8 months', - '9 months', - '10 months', - '11 months', - '1 year' - ) not null default '6 months', - loadavgThreshold float (4,2) default 5.00, - - primary key (name) -) engine=innodb; -- system - --- package: A package is any software package that we wish to keep track of -create table package ( - system varchar (255) not null, - name varchar (255) not null, - version tinytext not null, - vendor tinytext, - description text, - - key packageIndex (name), - key systemIndex (system), - foreign key systemLink (system) references system (name) - on delete cascade - on update cascade, - primary key (system, name) -) engine=innodb; -- package - --- filesystem: A systems file systems that we are monitoring -create table filesystem ( - system varchar (255) not null, - filesystem varchar (255) not null, - fstype tinytext not null, - mount tinytext, - threshold int default 90, - notification varchar (255), - filesystemHist enum ( - '1 month', - '2 months', - '3 months', - '4 months', - '5 months', - '6 months', - '7 months', - '8 months', - '9 months', - '10 months', - '11 months', - '1 year' - ) not null default '6 months', - - key filesystemIndex (filesystem), - foreign key systemLink (system) references system (name) - on delete cascade - on update cascade, - primary key (system, filesystem) -) engine=innodb; -- filesystem - --- fs: Contains a snapshot reading of a filesystem at a given date and time -create table fs ( - system varchar(255) not null, - filesystem varchar(255) not null, - mount varchar(255) not null, - timestamp datetime not null, - size bigint, - used bigint, - free bigint, - reserve bigint, - - key mountIndex (mount), - primary key (system, filesystem, timestamp), - foreign key filesystemLink (system, filesystem) - references filesystem (system, filesystem) - on delete cascade - on update cascade -) engine=innodb; -- fs - --- loadavg: Contains a snapshot reading of a system's load average -create table loadavg ( - system varchar(255) not null, - timestamp datetime not null, - uptime tinytext, - users int, - loadavg float (4,2), - - primary key (system, timestamp), - foreign key systemLink (system) references system (name) - on delete cascade - on update cascade -) engine=innodb; -- loadavg \ No newline at end of file -- 2.17.1