ScanCore: Difference between revisions

From Alteeve Wiki
Jump to navigation Jump to search
 
(32 intermediate revisions by the same user not shown)
Line 3: Line 3:
{{warning|1=This is little more that raw notes, do not consider anything here to be valid or accurate at this time.}}
{{warning|1=This is little more that raw notes, do not consider anything here to be valid or accurate at this time.}}


= Installing =
= ScanCore - The Decision Engine =


== PostgreSQL Setup ==
ScanCore is, at its core, a "decision engine".


<syntaxhighlight lang="bash">
It was created as a way for [[Anvil!]] systems to make intelligent decisions based on data coming in from any number of places. It generates alerts for admins, so in this regard it is an alert and monitoring solution, but that is almost a secondary benefit.
yum install -y postgresql postgresql-server postgresql-plperl postgresql-contrib postgresql-libs Scanner
 
</syntaxhighlight>
The core of ScanCore has no way of gathering data and it doesn't care how data is collected. It walks through a special <span class="code">agents</span> directory and any agent it finds in there, it runs. Each agent connects to any number of ScanCore databases, checks whatever it knows how to scan, compares the current data with static limits and compares against historic values (as it deems fit) and records data (new or changed values) into the database.
<syntaxhighlight lang="text">
 
...
An agent may decide to take independent action, like sending an alert or attempting a recovery of the devices or software it monitors, and then exits. If an agent doesn't find any hardware or software it knows about, it immediately exits without doing anything further.
Complete!
 
</syntaxhighlight>
After all agents run, ScanCore runs through post-scan tasks, depending on whether the machine it is running on is an Anvil! node or a ScanCore database. This is where the "decision engine" comes into play.
 
Lets look at a couple of examples;
 
== Example 1; Overheating ==
 
ScanCore can tell the difference between a local node overheating and the room it is in overheating.
 
If the node itself has overheated, it will migrate servers over to the healthy peer. If the enough temperature sensors go critical, the node will power off.
 
If, however, both nodes are overheating then ScanCore can deduce that the room is overheating. In this case, it can automatically shed load to reduce the amount of heat being pumped into the room and slow down the rate of heating. Later, when the room cools, it will automatically reboot the shedded node and reform the Anvil! pair, restoring redundancy without ever requiring a human's input.
 
How does it do this?
 
Multiple scan agents record thermal data. The <span class="code">scan-ipmitool</span> tool checks the host's [[IPMI]] sensor data which includes many thermal sensors and their upper and lower warning and critical thresholds. The <span class="code">scan-storcli</span> agent scan [[AVAGO]]-based [[RAID]] controllers and the attached hard drives and solid state drives. These also have thermal data. This is true also for many UPSes, ethernet switches and so forth.
 
As each agent checks its thermal sensors, any within nominal ranges are recorded by the agent in its database tables. Any that are in a <span class="code">warning</span> state though, that is, overly warm or cool but not yet a problem, get pushed into a special '<span class="code">temperature</span>' database table. Alone, ScanCore does nothing more than mark the node's health as 'warning' and no further action is taken.
 
If a given agent finds a given sensor reaching a '<span class="code">critical</span>' state, that is hot enough or cold enough to be a real concern, it it also pushed into the '<span class="code">temperature</span>' table. At the end of the scan, ScanCore will "add up" the number of sensors that are critical.
 
If the sum of the sensors exceed a limit, and if the host is a <span class="code">node</span>, ScanCore will take action by shutting down. Each sensor has a default weight of '<span class="code">1</span>' and by default, the shutdown threshold is "greater than five". So by default, a node will shut down when 6 or more sensors go critical. This is entirely configurable on a per-sensor basis as well as the shutdown threshold.
 
Later, when the still-accessible temperature sensors return to an acceptable level, ScanCore running on any one of the dashboards will power the node back up. Note that ScanCore will check how many times a node has overheated recently and extend a "cool-down" period before rebooting a node. This way, a node with a chronic overheating condition will be rebooted less often. Once repaired though, the reboots will eventually be "forgotten" and the cool-down delay will reset.
 
What about thermal load shedding?
 
The example above spoke to a single node overheating. If you recall, ScanCore does "post-scan calculations". When on a node, this includes a check to see if the peer's temperature has entered a "warning" state when it has as well. Using a similar heuristic, when both nodes have enough temperature sensors in 'warning' or 'critical' state for more than a set period of time, one of the nodes will be withdrawn and shut down.
 
Unlike the example above, which shutdown the host node after a critical heuristic is passed, the load-shedding kicks in only when both nodes are registering a thermal event at the same time for more than a set (and configurable) period of time.
 
== Example 2; Loss of input power ==
 
In all Anvil! systems, at least two network-monitored UPSes are powering the nodes' redundant power supplies. Thus, the loss of one UPS does not pose a risk to the system and can be ignored. Traditionally, most UPS monitoring software would assume it was the sole power provider for a machine and would initiate a shutdown if it reached critically low power levels.
 
With ScanCore, it understands that each node has two (or more) power sources. If one UPS loses mains power, an alert will be registered but nothing more will be done. Should the one UPS deplete entirely, the power will be lost and additional alerts will be registered when input power is lost to one of the redundant power supplies, but otherwise nothing more will happen.
 
Thus, ScanCore is redundancy-aware.
 
Consider another power scenario; Power is lost the both UPSes feeding a node. In this case, ScanCore does two things;
 
# It begins monitoring the estimated hold-up time of the ''strongest'' UPS. If the strongest UPS drops below a minimum hold-up time, a graceful shutdown of hosted servers is initiated followed by the node(s) withdrawing and powering off. Note that if different UPSes power the nodes, ScanCore will know that the peer is healthy and will migrate servers to the node with power long before the node needs to shutdown.
 
In a typical install, the same pair of UPSes power both nodes in the Anvil!. In the case where power is lost to both UPSes, a timer is checked. Once both nodes have been running on UPS batteries for more than two minutes, load shedding will occur. If needed, servers will migrate to consolidate on one node, then the sacrificial node will withdraw and power off to extend the runtime of the remaining node.
 
If, after load shedding, power stays out for too long and minimum hold-up times are crossed, the remaining node will gracefully shut down the servers and then power itself off.
 
Later, power is restored.
 
At this point, the Striker dashboards will boot (if all power was lost). Once up, they will note that both nodes are off and check the UPSes. If both UPSes are depleted (or minimally charged), they will take no action. Instead, they will monitor the charge rate of the UPSes. Once one of the UPSes hits a minimum charge percentage, it will boot the nodes and restore full Anvil! services, including booting all servers.
 
The logic behind the delay is to ensure that, if mains power is lost immediately after powering the nodes back on, there is sufficient charge for the nodes to power back up, detect the loss and shut back down safely.
 
== Example 3; Node Health ==
 
The final example will show how ScanCore can react to a localized node issue.
 
Consider the scenario where Node 1 is the active host. The RAID controller on the host reports that a hard drive is potentially failing. An alert is generated but no further action is taken.
 
Later, a drive fails entirely and the node enters a degraded state.
 
At this point, ScanCore would note that Node 1 is now in a 'warning' state and the peer node is 'ok' and a timer is started. Recall that ScanCore can't determine the nature of a warning, so it pauses a little bit to avoid taking action on a transient issue. Two minutes after the failure, with the 'warning' state still present, ScanCore will migrate all hosted servers over to Node 2.
 
It will remain in the Anvil! and no further action will be taken. However, now, if a second drive were to fail (assuming RAID level 5), Node 1 would be lost and fenced, but no interruption would occur because the servers were already moved as a precaution.
 
If the drive is replaced before any further issues arise, Node 1 would return to an 'ok' state but nothing else would happen. Servers would be left on Node 2 because there is no benefit or concern around which node is hosting the servers at any given time.
 
= Scan Agents =
 
When an agent runs and connects to the database layer, a timestamp is created and that time stamp is then used for all databases changes made in that given pass. This means that the modification timestamps will be the same for a given pass, regardless of the actual time when the record was changed. This makes resynchronization far more sane, at the cost of some resolution.
 
If your agent needs accurate record change timestamps, please make a note to record that current time as a separate database column.
 
* [[List of ScanCore Agents]]
 
== DB Resync ==
 
Part of the difference between ScanCore and various other tools is that ScanCore is designed from its core as a resilient project. The data collected by agents needs to, from the user's perspective, sync N-way between ScanCore databases without the user needing to worry about backups, recoveries and whatnot.
 
How does this work?
 
In essence, the data Agents collects can be categorized in one of two ways;


DB config:
* Data that is global (like data on servers on the [[Anvil!]] platform)
* Data that is target-bound (like a host's sensor data from IPMI interfaces or a given machines view of UPSes it cares about)


<syntaxhighlight lang="bash">
As an agent author, you need to consider that data may exist in some databases and not others.
/etc/init.d/postgresql initdb
</syntaxhighlight>
<syntaxhighlight lang="text">
Initializing database:                                    [  OK  ]
</syntaxhighlight>


Start
Consider;


<syntaxhighlight lang="bash">
A site has two Striker dashboards acting as ScanCore databases. This is a satellite office so you data replicates to a third Striker at head office. Meanwhile, head-office is collecting data from many different sites and the two dashboards on your site doesn't care about the data on the head-office site from those other locations.
/etc/init.d/postgresql start
</syntaxhighlight>
<syntaxhighlight lang="text">
Starting postgresql service:                              [  OK  ]
</syntaxhighlight>


Create the striker user.
{{warning|1=Isolating data onto a limited number of databases is an efficiency effort, '''not''' a security effort! If you don't trust a ScanCore database machine, don't connect to it, period. Similarly, if you don't trust trust a machine with access to your database, don't give the owner access.}}


<syntaxhighlight lang="bash">
You also need to plan for N-directional resynchronization.
su - postgres -c "createuser --no-superuser --createdb --no-createrole striker"
</syntaxhighlight>
<syntaxhighlight lang="bash">
# no output expected
</syntaxhighlight>


Set 'postgres' and 'striker' user passwords:
Also consider;


<syntaxhighlight lang="bash">
Power is lost to both/all UPSes and load-shedding takes "Striker 2" offline. Now data is being recorded to "Striker 1" that will need to be copied to Striker 2 later. Time passes and all power is lost. Power is restored, but for some reason Striker 2 boots up first and starts collecting data. Eventually, Striker 1 comes back online.  
su - postgres -c "psql -U postgres"
</syntaxhighlight>
<syntaxhighlight lang="text">
psql (8.4.20)
Type "help" for help.
</syntaxhighlight>


<syntaxhighlight lang="bash">
Now, Striker 1 has data that 2 doesn't, and Striker 2 has data that 1 doesn't.
postgres=# \password
</syntaxhighlight>
<syntaxhighlight lang="text">
Enter new password:
Enter it again:
</syntaxhighlight>


<syntaxhighlight lang="bash">
ScanCore has already solved this problem using the following schemes, depending on which type of data your agent collects.
postgres=# \password striker
</syntaxhighlight>
<syntaxhighlight lang="text">
Enter new password:
Enter it again:
</syntaxhighlight>


Exit.
{{note|1=Yes, this is expensive in terms of memory and processing power, relatively speaking. However, a lot of effort is made to never <span class="code">UPDATE</span> the database unless something actually changes, keeping the <span class="code">history</span> schema as small and efficient as possible. For this reason, even data collected from many nodes over a long period of time should not add up to too much. If you are concerned, be sure to run periodic archiving of the data.}}


<syntaxhighlight lang="bash">
{{warning|1=As this is written, automatic archiving has not been implemented, though it is planned to be implemented shortly.}}
postgres=# \q
</syntaxhighlight>


Configure access
=== Resync Global Data ===


<syntaxhighlight lang="bash">
This is the simplest data to resync because it will go to all databases, no matter what. This is rare in practice but provides a good starting point.
cp /var/lib/pgsql/data/pg_hba.conf /var/lib/pgsql/data/pg_hba.conf.striker
vim /var/lib/pgsql/data/pg_hba.conf
diff -u /var/lib/pgsql/data/pg_hba.conf.striker /var/lib/pgsql/data/pg_hba.conf
</syntaxhighlight>
<syntaxhighlight lang="diff">
--- /var/lib/pgsql/data/pg_hba.conf.striker 2015-01-16 15:24:38.985895621 -0500
+++ /var/lib/pgsql/data/pg_hba.conf 2015-01-16 15:26:42.611236927 -0500
@@ -65,9 +65,13 @@
# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
+# dashboards
+host    all        all        10.20.4.0/24          md5
+# node servers
+host    all        all        10.20.70.0/24        md5
# "local" is for Unix domain socket connections only
-local  all        all                              ident
+local  all        all                              md5
# IPv4 local connections:
host    all        all        127.0.0.1/32          ident
# IPv6 local connections:
</syntaxhighlight>


<syntaxhighlight lang="bash">
The process;
cp /var/lib/pgsql/data/postgresql.conf /var/lib/pgsql/data/postgresql.conf.striker
vim /var/lib/pgsql/data/postgresql.conf
diff -u /var/lib/pgsql/data/postgresql.conf.striker /var/lib/pgsql/data/postgresql.conf
</syntaxhighlight>
<syntaxhighlight lang="diff">
--- /var/lib/pgsql/data/postgresql.conf.striker 2015-01-16 15:33:30.970370628 -0500
+++ /var/lib/pgsql/data/postgresql.conf 2015-01-16 15:34:16.603482692 -0500
@@ -56,6 +56,7 @@
# - Connection Settings -
+listen_addresses = '*'
#listen_addresses = 'localhost' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost', '*' = all
</syntaxhighlight>


<syntaxhighlight lang="bash">
The agent starts and connects to the databases. As part of the connection process, a check is made to see if any databases are behind (see <span class="code">[https://github.com/ClusterLabs/striker/blob/master/AN/Tools/DB.pm AN::Tools::DB.pm->find_behind_databases()]</span>). If so, the agent will act on this by initiating a resync.
/etc/init.d/postgresql restart
</syntaxhighlight>
<syntaxhighlight lang="text">
Stopping postgresql service:                               [  OK  ]
Starting postgresql service:                               [  OK  ]
</syntaxhighlight>


== Striker Database Setup ==
The resync process is fundamentally simple; All records are read in from it's history schema of all connected databases into a common hash based on the time a given record was recorded and the unique ID of the record. The same data is loaded into database-specific hash for later comparison. We also note for each unique record that we've seen at least one copy of the record for a later step. An example "record" would be a server's UUID, which uniquely identifies it regardless of the host node or Anvil!.


Create DB:
Here is an example of how the data is read in:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="perl">
su - postgres -c "createdb --owner striker scanner"
my $query = "
</syntaxhighlight>
SELECT
<syntaxhighlight lang="text">
    server_uuid,
Password:
    server_name,
    server_stop_reason,
    server_start_after,
    server_start_delay,
    server_note,
    server_definition,
    server_host,
    server_state,
    server_migration_type,
    server_pre_migration_script,
    server_pre_migration_arguments,
    server_post_migration_script,
    server_post_migration_arguments,
    modified_date
FROM
    history.servers
;";
</syntaxhighlight>
</syntaxhighlight>


Now download the SQL files we're going to load.
Without constraints, ''all'' data in the table will be read in. This data is recorded in the 'unified' hash using the modification time and the unique identifier as keys.


<syntaxhighlight lang="bash">
<syntaxhighlight lang="perl">
git clone https://github.com/digimer/striker.git
# Record this in the unified and local hashes.
$an->data->{db_data}{unified}{servers}{modified_date}{$modified_date}{server_uuid}{$server_uuid} = {
server_name => $server_name,
server_stop_reason => $server_stop_reason,
server_start_after => $server_start_after,
server_start_delay => $server_start_delay,
server_note => $server_note,
server_definition => $server_definition,
server_host => $server_host,
server_state => $server_state,
server_migration_type => $server_migration_type,
server_pre_migration_script => $server_pre_migration_script,
server_pre_migration_arguments => $server_pre_migration_arguments,
server_post_migration_script => $server_post_migration_script,
server_post_migration_arguments => $server_post_migration_arguments,
};
</syntaxhighlight>
</syntaxhighlight>
<syntaxhighlight lang="text">
 
Initialized empty Git repository in /root/striker/.git/
Next, for the current Database ID that we're reading from, note that the server with the given ID exists in the <span class="code">public</span> database schema. We'll also set this 'seen' as '0' for now. We'll see why in a moment.
remote: Counting objects: 3602, done.
remote: Compressing objects: 100% (57/57), done.
<syntaxhighlight lang="perl">
remote: Total 3602 (delta 25), reused 0 (delta 0)
$an->data->{db_data}{$id}{servers}{server_uuid}{$server_uuid}{'exists'} = 1;
Receiving objects: 100% (3602/3602), 7.88 MiB | 1024 KiB/s, done.
$an->data->{db_data}{$id}{servers}{server_uuid}{$server_uuid}{seen}    = 0;
Resolving deltas: 100% (2307/2307), done.
</syntaxhighlight>
</syntaxhighlight>


<syntaxhighlight lang="bash">
Finally, record the same data in another hash, identified by the currently active database ID in another hash.
cd striker
git checkout scanner
<syntaxhighlight lang="perl">
</syntaxhighlight>
$an->data->{db_data}{$id}{servers}{modified_date}{$modified_date}{server_uuid}{$server_uuid} = {
<syntaxhighlight lang="text">
server_name => $server_name,
Branch scanner set up to track remote branch scanner from origin.
server_stop_reason => $server_stop_reason,
Switched to a new branch 'scanner'
server_start_after => $server_start_after,
server_start_delay => $server_start_delay,
server_note => $server_note,
server_definition => $server_definition,
server_host => $server_host,
server_state => $server_state,
server_migration_type => $server_migration_type,
server_pre_migration_script => $server_pre_migration_script,
server_pre_migration_arguments => $server_pre_migration_arguments,
server_post_migration_script => $server_post_migration_script,
server_post_migration_arguments => $server_post_migration_arguments,
};
</syntaxhighlight>
</syntaxhighlight>


<syntaxhighlight lang="bash">
So, once the read is done from all accessible databases, we'll have a set of hashes; One being the unified collection of all data from both/all sources, plus a hash for each database.
cd Scanner/SQL/
 
ls -lah
{{note|1=This looks a little complicated, but it is worth the mental effort. With this in place, users will never need to worry about data recovery or synchronization so long as even one copy of the database exists somewhere. ScanCore database servers can come and go or be destroyed and replaced trivially. So please bear with it... The logic seems complex, but it is fundamentally quite simple.}}
</syntaxhighlight>
<syntaxhighlight lang="text">
total 40K
drwxr-xr-x.  2 root root 4.0K Jan 16 15:18 .
drwxr-xr-x. 13 root root 4.0K Jan 16 15:18 ..
-rw-r--r--.  1 root root 3.3K Jan 16 15:18 01_create_node.sql
-rw-r--r--. 1 root root 3.3K Jan 16 15:18 02_create_alerts.sql
-rw-r--r--.  1 root root 2.5K Jan 16 15:18 03_create_alert_listeners.sql
-rw-r--r--. 1 root root 1.2K Jan 16 15:18 04_load_alert_listeners.sql
-rw-r--r--.  1 root root 3.3K Jan 16 15:18 05_create_random_agent.sql
-rw-r--r--.  1 root root 3.4K Jan 16 15:18 06_create_snm_apc_ups.sql
-rw-r--r--.  1 root root 3.3K Jan 16 15:18 07_create_ipmi.sql
-rw-r--r--.  1 root root 3.3K Jan 16 15:18 08_create_raid.sql
</syntaxhighlight>


Load SQL files
With this, here is the sync process:


These are currently hard-coded to 'alteeve' user, switch to the 'striker' user.
# Walk through the unified records for each given modification timestamp, newest records first, oldest records last.
## Walk through each unique record for the given timestamp (continuing the example, this would be each server's UUID).
### Loop through each connected database ID.
#### Check to see if the unique record ID '''has been seen''' in the resync process yet. (''Note'': This will always be 'not' the first time because the first instance of a record at the most recent time stamp will go into the <span class="code">public</span> schema where all other records will go into the <span class="code">history</span> schema.)
##### '''IF NOT seen''':
###### Mark the record as now having been seen.
###### Check to see if the unique record ID '''exists at all''' on this database.
####### '''IF exists''': Does the record at the current time stamp exist?
######## '''IF NOT at this timestamp''': <span class="code">UPDATE</span> the <span class="code">public</span> schema (the record was already in the <span class="code">public</span> schema, but it was old).
####### '''IF NOT exists''': <span class="code">INSERT</span> it into the <span class="code">public</span> schema as the record didn't exist yet.
##### '''IF seen''':
###### Does it exist at this timestamp?
####### '''If not at this timestamp''': <span class="code">INSERT</span> it into the <span class="code">history</span> schema at the current timestamp.


<syntaxhighlight lang="bash">
All of these <span class="code">UPDATE</span> and <span class="code">INSERT</span> calls go into an array per database. When all the unified records have been processed, each database array with one or more records is then sent to the given database to be processed in one transaction.
sed -i 's/alteeve/striker/' *
</syntaxhighlight>
<syntaxhighlight lang="bash">
# Enter the password sooooo many times ;_;
</syntaxhighlight>


Test:
Lastly, the hashes that stored all the unified and per-DB records is deleted to clear up memory.


<syntaxhighlight lang="bash">
Voila! Your data is now synchronized on all databases!
psql -U striker -d scanner -c "SELECT * FROM alert_listeners"
</syntaxhighlight>
<syntaxhighlight lang="text">
Password for user striker:
</syntaxhighlight>
<syntaxhighlight lang="text">
id |      name      |    mode      |  level  |  contact_info  | language | added_by |            updated           
----+----------------+---------------+---------+----------------+----------+----------+-------------------------------
  1 | screen        | Screen        | DEBUG  | screen        | en_CA    |        0 | 2014-12-11 14:42:13.273057-05
  2 | Tom Legrady    | Email        | DEBUG  | tom@striker.ca | en_CA    |        0 | 2014-12-11 16:54:25.477321-05
  3 | Health Monitor | HealthMonitor | WARNING |                | en_CA    |        0 | 2015-01-14 14:08:15-05
(3 rows)
</syntaxhighlight>


Done!
=== Resync Target-Bound Data ===


== Configure Scan Core on a Node ==
The only difference between resync'ing global data from target-bound records in that a constraint is used on the initial reading of data from the connected databases.


Install dependencies:
We will use <span class="code">[https://github.com/ClusterLabs/striker/blob/master/ScanCore/agents/scan-bond/scan-bond scan-bond]</span> agent which monitors bonded network interfaces on each node or Striker dashboard. In all cases, the state of the bonds only matters to the one host with the actual bonds. The other nodes and dashboards don't care about it.


#TODO - postgresql (client only)
In this example, then, the bond records will be bound to the <span class="code">hosts</span> -> <span class="code">host_uuid</span>, which is stored on each machine in <span class="code">/etc/striker/host.uuid</span> and is presented in ScanCore in the <span class="code">sys::host_uuid</span> variable.


Clone the git repo:
The read, then, looks like this;


<syntaxhighlight lang="bash">
<syntaxhighlight lang="perl">
git clone https://github.com/digimer/striker.git
my $query = "
</syntaxhighlight>
SELECT
<syntaxhighlight lang="text">
    bond_uuid,
Initialized empty Git repository in /root/striker/.git/
    bond_name,
remote: Counting objects: 3602, done.
    bond_mode,
remote: Compressing objects: 100% (57/57), done.
    bond_primary_slave,
remote: Total 3602 (delta 25), reused 0 (delta 0)
    bond_primary_reselect,
Receiving objects: 100% (3602/3602), 7.88 MiB | 586 KiB/s, done.
    bond_active_slave,  
Resolving deltas: 100% (2307/2307), done.
    bond_mii_status,  
    bond_mii_polling_interval,  
    bond_up_delay,  
    bond_down_delay,  
    modified_date
FROM
    history.bond
WHERE
    bond_host_uuid = ".$an->data->{sys}{use_db_fh}->quote($an->data->{sys}{host_uuid})."
;";
</syntaxhighlight>
</syntaxhighlight>


<syntaxhighlight lang="bash">
With the <span class="code">WHERE bond_host_uuid = ".$an->data->{sys}{use_db_fh}->quote($an->data->{sys}{host_uuid})."</span> constraint, all of the data read in from the database will come from the current host machine. Bond records for other nodes and dashboard systems will be ignored.
cd striker/
git checkout scanner
</syntaxhighlight>
<syntaxhighlight lang="text">
Switched to branch 'scanner'
</syntaxhighlight>


<syntaxhighlight lang="bash">
In this way, our data will sync between the ScanCore databases we use, but we ''won't'' sync bond records for other hosts (which may sync between an entirely different set of ScanCore databases).
git pull origin scanner
</syntaxhighlight>
<syntaxhighlight lang="text">
From https://github.com/digimer/striker
* branch            scanner    -> FETCH_HEAD
Merge made by recursive.
.gitignore                                        |  19 +
Scanner/Agents/ipmi                                |  257 +
Scanner/Agents/raid                                |  257 +
Scanner/Agents/random-agent                        |  278 +
Scanner/Agents/snmp_apc_ups                        |  271 +
Scanner/Bin/clean                                  |  20 +
Scanner/Bin/db                                    |  130 +
Scanner/Bin/dbclean                                |  10 +
Scanner/Bin/dbclean_cmds                          |    5 +
Scanner/Config/db.conf                            |    7 +
Scanner/Config/ipmi.conf                          |  246 +
Scanner/Config/raid.conf                          |  50 +
Scanner/Config/scanner.conf                        |  39 +
Scanner/Config/snmp_apc_ups.conf                  |  203 +
...ng_an_agent_by_extending_existing_perl_classes. |  299 +
Scanner/MIB/powernet412.mib.txt                    |70988 ++++++++++++++++++++
Scanner/Makefile                                  |  86 +
Scanner/Messages/ipmi.xml                          |  33 +
Scanner/Messages/raid.xml                          |  33 +
Scanner/Messages/random-agent.xml                  |  31 +
Scanner/Messages/scanner.xml                      |  30 +
Scanner/Messages/snmp_apc_ups.xml                  |  37 +
Scanner/RPMS/load_rpm_packages.sh                  |  66 +
.../RPMS/perl-Capture-Tiny-0.27-1.el6.noarch.rpm  |  Bin 0 -> 26684 bytes
.../RPMS/perl-Class-Tiny-1.000-1.rhel6.noarch.rpm  |  Bin 0 -> 26280 bytes
Scanner/RPMS/perl-Clone-0.37-1.el6.x86_64.rpm      |  Bin 0 -> 14072 bytes
.../perl-Clone-debuginfo-0.37-1.el6.x86_64.rpm    |  Bin 0 -> 28724 bytes
.../RPMS/perl-Const-Fast-0.006-1.el6.noarch.rpm    |  Bin 0 -> 17024 bytes
Scanner/RPMS/perl-Crypt-CBC-2.33-1.el6.noarch.rpm  |  Bin 0 -> 27504 bytes
Scanner/RPMS/perl-Crypt-DES-2.07-1.el6.x86_64.rpm  |  Bin 0 -> 15168 bytes
.../perl-Crypt-DES-debuginfo-2.07-1.el6.x86_64.rpm |  Bin 0 -> 33232 bytes
.../RPMS/perl-Data-OptList-0.109-1.el6.noarch.rpm  |  Bin 0 -> 16604 bytes
...l-Devel-GlobalDestruction-0.13-1.el6.noarch.rpm |  Bin 0 -> 8344 bytes
...evel-GlobalDestruction-XS-0.01-1.el6.x86_64.rpm |  Bin 0 -> 9420 bytes
...lDestruction-XS-debuginfo-0.01-1.el6.x86_64.rpm |  Bin 0 -> 25800 bytes
.../RPMS/perl-Exporter-Tiny-0.042-1.el6.noarch.rpm |  Bin 0 -> 31612 bytes
Scanner/RPMS/perl-Net-SNMP-v6.0.1-1.el6.noarch.rpm |  Bin 0 -> 103156 bytes
Scanner/RPMS/perl-Net-SSH2-0.53-1.el6.x86_64.rpm  |  Bin 0 -> 88340 bytes
.../perl-Net-SSH2-debuginfo-0.53-1.el6.x86_64.rpm  |  Bin 0 -> 97188 bytes
.../RPMS/perl-Params-Util-1.07-1.el6.x86_64.rpm    |  Bin 0 -> 34748 bytes
...erl-Params-Util-debuginfo-1.07-1.el6.x86_64.rpm |  Bin 0 -> 30988 bytes
.../perl-Proc-Background-1.10-1.el6.noarch.rpm    |  Bin 0 -> 25128 bytes
.../RPMS/perl-Sub-Exporter-0.987-1.el6.noarch.rpm  |  Bin 0 -> 54936 bytes
...-Exporter-Progressive-0.001011-1.el6.noarch.rpm |  Bin 0 -> 8976 bytes
.../RPMS/perl-Sub-Install-0.928-1.el6.noarch.rpm  |  Bin 0 -> 17236 bytes
.../RPMS/perl-TermReadKey-2.32-1.el6.x86_64.rpm    |  Bin 0 -> 30880 bytes
...erl-TermReadKey-debuginfo-2.32-1.el6.x86_64.rpm |  Bin 0 -> 48532 bytes
.../RPMS/perl-Test-Output-1.03-1.el6.noarch.rpm    |  Bin 0 -> 14272 bytes
...perl-XML-NamespaceSupport-1.11-1.el6.noarch.rpm |  Bin 0 -> 14592 bytes
Scanner/RPMS/perl-XML-SAX-0.99-1.el6.noarch.rpm    |  Bin 0 -> 52952 bytes
.../RPMS/perl-XML-SAX-Base-1.08-1.el6.noarch.rpm  |  Bin 0 -> 29288 bytes
.../RPMS/perl-XML-SAX-Expat-0.51-1.el6.noarch.rpm  |  Bin 0 -> 11148 bytes
Scanner/RPMS/perl-XML-Simple-2.20-1.el6.noarch.rpm |  Bin 0 -> 76704 bytes
Scanner/SQL/01_create_node.sql                    |  119 +
Scanner/SQL/02_create_alerts.sql                  |  162 +
Scanner/SQL/03_create_alert_listeners.sql          |  97 +
Scanner/SQL/04_load_alert_listeners.sql            |  56 +
Scanner/SQL/05_create_random_agent.sql            |  148 +
Scanner/SQL/06_create_snm_apc_ups.sql              |  152 +
Scanner/SQL/07_create_ipmi.sql                    |  152 +
Scanner/SQL/08_create_raid.sql                    |  152 +
Scanner/Src/Makefile                              |  37 +
Scanner/Src/README                                |  26 +
Scanner/Src/wipmi.c                                |  14 +
Scanner/Src/wstorcli.c                            |  89 +
Scanner/lib/AN/Agent.pm                            |  327 +
Scanner/lib/AN/Alerts.pm                          |  525 +
Scanner/lib/AN/Cluster.pm                          |10790 +++
Scanner/lib/AN/Common.pm                          | 1640 +
Scanner/lib/AN/DBS.pm                              |  296 +
Scanner/lib/AN/Email.pm                            |  221 +
Scanner/lib/AN/FlagFile.pm                        |  487 +
Scanner/lib/AN/HealthMonitor.pm                    |  224 +
Scanner/lib/AN/IPMI/Temp.pm                        |  202 +
Scanner/lib/AN/InstallManifest.pm                  | 3348 +
Scanner/lib/AN/Listener.pm                        |  217 +
Scanner/lib/AN/MonitorAgent.pm                    |  313 +
Scanner/lib/AN/Msg_xlator.pm                      |  254 +
Scanner/lib/AN/OneAlert.pm                        |  226 +
Scanner/lib/AN/OneDB.pm                            |  509 +
Scanner/lib/AN/RAID/Temp.pm                        |  343 +
Scanner/lib/AN/SNMP/APC_UPS.pm                    |  686 +
Scanner/lib/AN/Scanner.pm                          |  923 +
Scanner/lib/AN/Screen.pm                          |  164 +
Scanner/lib/AN/Striker.pm                          |12081 ++++
Scanner/lib/AN/Unix.pm                            |  225 +
Scanner/scanner                                    |  306 +
Scanner/t/10-an-agent.t                            |  265 +
Scanner/t/15-an-onealert.t                        |  122 +
Scanner/t/20-an-onedb.t                            |  262 +
Scanner/t/25-an-screen.t                          |  60 +
Scanner/t/30-an-email.t                            |  60 +
Scanner/t/35-an-msg_xlator.t                      |  194 +
Scanner/t/40-an-flagfile.t                        |  240 +
Scanner/t/45-an-listener.t                        |  93 +
Scanner/t/50-an-monitoragent.t                    |  45 +
Scanner/t/55-an-dbs.t                              |  283 +
Scanner/t/60-an-unix.t                            |  71 +
Scanner/t/65-an-alerts.t                          |  385 +
Scanner/t/70-an-snmp-apc_ups.t                    | 1117 +
Scanner/t/75-an-ipmi-temp.t                        |  171 +
Scanner/t/test_coverage                            |  11 +
102 files changed, 112285 insertions(+), 0 deletions(-)
create mode 100644 .gitignore
create mode 100755 Scanner/Agents/ipmi
create mode 100755 Scanner/Agents/raid
create mode 100755 Scanner/Agents/random-agent
create mode 100755 Scanner/Agents/snmp_apc_ups
create mode 100755 Scanner/Bin/clean
create mode 100755 Scanner/Bin/db
create mode 100755 Scanner/Bin/dbclean
create mode 100755 Scanner/Bin/dbclean_cmds
create mode 100644 Scanner/Config/db.conf
create mode 100644 Scanner/Config/ipmi.conf
create mode 100644 Scanner/Config/raid.conf
create mode 100644 Scanner/Config/scanner.conf
create mode 100644 Scanner/Config/snmp_apc_ups.conf
create mode 100644 Scanner/Docs/Writing_an_agent_by_extending_existing_perl_classes.
create mode 100644 Scanner/MIB/powernet412.mib.txt
create mode 100644 Scanner/Makefile
create mode 100644 Scanner/Messages/ipmi.xml
create mode 100644 Scanner/Messages/raid.xml
create mode 100644 Scanner/Messages/random-agent.xml
create mode 100644 Scanner/Messages/scanner.xml
create mode 100644 Scanner/Messages/snmp_apc_ups.xml
create mode 100755 Scanner/RPMS/load_rpm_packages.sh
create mode 100644 Scanner/RPMS/perl-Capture-Tiny-0.27-1.el6.noarch.rpm
create mode 100644 Scanner/RPMS/perl-Class-Tiny-1.000-1.rhel6.noarch.rpm
create mode 100644 Scanner/RPMS/perl-Clone-0.37-1.el6.x86_64.rpm
create mode 100644 Scanner/RPMS/perl-Clone-debuginfo-0.37-1.el6.x86_64.rpm
create mode 100644 Scanner/RPMS/perl-Const-Fast-0.006-1.el6.noarch.rpm
create mode 100644 Scanner/RPMS/perl-Crypt-CBC-2.33-1.el6.noarch.rpm
create mode 100644 Scanner/RPMS/perl-Crypt-DES-2.07-1.el6.x86_64.rpm
create mode 100644 Scanner/RPMS/perl-Crypt-DES-debuginfo-2.07-1.el6.x86_64.rpm
create mode 100644 Scanner/RPMS/perl-Data-OptList-0.109-1.el6.noarch.rpm
create mode 100644 Scanner/RPMS/perl-Devel-GlobalDestruction-0.13-1.el6.noarch.rpm
create mode 100644 Scanner/RPMS/perl-Devel-GlobalDestruction-XS-0.01-1.el6.x86_64.rpm
create mode 100644 Scanner/RPMS/perl-Devel-GlobalDestruction-XS-debuginfo-0.01-1.el6.x86_64.rpm
create mode 100644 Scanner/RPMS/perl-Exporter-Tiny-0.042-1.el6.noarch.rpm
create mode 100644 Scanner/RPMS/perl-Net-SNMP-v6.0.1-1.el6.noarch.rpm
create mode 100644 Scanner/RPMS/perl-Net-SSH2-0.53-1.el6.x86_64.rpm
create mode 100644 Scanner/RPMS/perl-Net-SSH2-debuginfo-0.53-1.el6.x86_64.rpm
create mode 100644 Scanner/RPMS/perl-Params-Util-1.07-1.el6.x86_64.rpm
create mode 100644 Scanner/RPMS/perl-Params-Util-debuginfo-1.07-1.el6.x86_64.rpm
create mode 100644 Scanner/RPMS/perl-Proc-Background-1.10-1.el6.noarch.rpm
create mode 100644 Scanner/RPMS/perl-Sub-Exporter-0.987-1.el6.noarch.rpm
create mode 100644 Scanner/RPMS/perl-Sub-Exporter-Progressive-0.001011-1.el6.noarch.rpm
create mode 100644 Scanner/RPMS/perl-Sub-Install-0.928-1.el6.noarch.rpm
create mode 100644 Scanner/RPMS/perl-TermReadKey-2.32-1.el6.x86_64.rpm
create mode 100644 Scanner/RPMS/perl-TermReadKey-debuginfo-2.32-1.el6.x86_64.rpm
create mode 100644 Scanner/RPMS/perl-Test-Output-1.03-1.el6.noarch.rpm
create mode 100644 Scanner/RPMS/perl-XML-NamespaceSupport-1.11-1.el6.noarch.rpm
create mode 100644 Scanner/RPMS/perl-XML-SAX-0.99-1.el6.noarch.rpm
create mode 100644 Scanner/RPMS/perl-XML-SAX-Base-1.08-1.el6.noarch.rpm
create mode 100644 Scanner/RPMS/perl-XML-SAX-Expat-0.51-1.el6.noarch.rpm
create mode 100644 Scanner/RPMS/perl-XML-Simple-2.20-1.el6.noarch.rpm
create mode 100644 Scanner/SQL/01_create_node.sql
create mode 100644 Scanner/SQL/02_create_alerts.sql
create mode 100644 Scanner/SQL/03_create_alert_listeners.sql
create mode 100644 Scanner/SQL/04_load_alert_listeners.sql
create mode 100644 Scanner/SQL/05_create_random_agent.sql
create mode 100644 Scanner/SQL/06_create_snm_apc_ups.sql
create mode 100644 Scanner/SQL/07_create_ipmi.sql
create mode 100644 Scanner/SQL/08_create_raid.sql
create mode 100644 Scanner/Src/Makefile
create mode 100644 Scanner/Src/README
create mode 100644 Scanner/Src/wipmi.c
create mode 100644 Scanner/Src/wstorcli.c
create mode 100644 Scanner/lib/AN/Agent.pm
create mode 100644 Scanner/lib/AN/Alerts.pm
create mode 100644 Scanner/lib/AN/Cluster.pm
create mode 100644 Scanner/lib/AN/Common.pm
create mode 100644 Scanner/lib/AN/DBS.pm
create mode 100644 Scanner/lib/AN/Email.pm
create mode 100644 Scanner/lib/AN/FlagFile.pm
create mode 100644 Scanner/lib/AN/HealthMonitor.pm
create mode 100644 Scanner/lib/AN/IPMI/Temp.pm
create mode 100755 Scanner/lib/AN/InstallManifest.pm
create mode 100644 Scanner/lib/AN/Listener.pm
create mode 100644 Scanner/lib/AN/MonitorAgent.pm
create mode 100644 Scanner/lib/AN/Msg_xlator.pm
create mode 100644 Scanner/lib/AN/OneAlert.pm
create mode 100644 Scanner/lib/AN/OneDB.pm
create mode 100644 Scanner/lib/AN/RAID/Temp.pm
create mode 100644 Scanner/lib/AN/SNMP/APC_UPS.pm
create mode 100644 Scanner/lib/AN/Scanner.pm
create mode 100644 Scanner/lib/AN/Screen.pm
create mode 100644 Scanner/lib/AN/Striker.pm
create mode 100644 Scanner/lib/AN/Unix.pm
create mode 100755 Scanner/scanner
create mode 100644 Scanner/t/10-an-agent.t
create mode 100644 Scanner/t/15-an-onealert.t
create mode 100644 Scanner/t/20-an-onedb.t
create mode 100644 Scanner/t/25-an-screen.t
create mode 100644 Scanner/t/30-an-email.t
create mode 100644 Scanner/t/35-an-msg_xlator.t
create mode 100644 Scanner/t/40-an-flagfile.t
create mode 100644 Scanner/t/45-an-listener.t
create mode 100644 Scanner/t/50-an-monitoragent.t
create mode 100644 Scanner/t/55-an-dbs.t
create mode 100644 Scanner/t/60-an-unix.t
create mode 100644 Scanner/t/65-an-alerts.t
create mode 100644 Scanner/t/70-an-snmp-apc_ups.t
create mode 100644 Scanner/t/75-an-ipmi-temp.t
create mode 100755 Scanner/t/test_coverage
</syntaxhighlight>


<syntaxhighlight lang="bash">
The rest of the synchronization is process is exactly the same as above. The unified and per-DB hashes will be processed exactly the same way (just with a subset of the data).
ls -lah
</syntaxhighlight>
<syntaxhighlight lang="text">
total 180K
drwxr-xr-x.  9 root root 4.0K Jan 16 16:35 .
dr-xr-x---. 14 root root 4.0K Jan 16 16:32 ..
-rwxr-xr-x.  1 root root 122K Jan 16 16:33 anvil_setup
drwxr-xr-x.  4 root root 4.0K Jan 16 16:33 cgi-bin
-rw-r--r--.  1 root root 7.4K Jan 16 16:33 CHANGELOG
drwxr-xr-x.  8 root root 4.0K Jan 16 16:35 .git
-rw-r--r--.  1 root root  279 Jan 16 16:35 .gitignore
drwxr-xr-x.  2 root root 4.0K Jan 16 16:33 guacamole
drwxr-xr-x.  3 root root 4.0K Jan 16 16:33 html
-rw-r--r--.  1 root root 3.4K Jan 16 16:33 README.md
drwxr-xr-x. 13 root root 4.0K Jan 16 16:35 Scanner
-rw-r--r--.  1 root root 3.7K Jan 16 16:33 striker.conf
drwxr-xr-x. 2 root root 4.0K Jan 16 16:33 t
drwxr-xr-x.  2 root root 4.0K Jan 16 16:33 tools
</syntaxhighlight>


<syntaxhighlight lang="bash">
Easy peasy!
cd Scanner/Config/
vim db.conf
git diff db.conf
</syntaxhighlight>
<syntaxhighlight lang="diff">
diff --git a/Scanner/Config/db.conf b/Scanner/Config/db.conf
index 9925faf..e39aa60 100644
--- a/Scanner/Config/db.conf
+++ b/Scanner/Config/db.conf
@@ -1,7 +1,6 @@
db::1::name      = scanner
db::1::db_type  = Pg
-db::1::host      = 10.255.4.251
-#db::1::host      = an-m01
+db::1::host      = 10.20.4.2
db::1::port      = 5432
-db::1::user      = alteeve
-db::1::password  = alteeve
+db::1::user      = striker
+db::1::password  = secret
</syntaxhighlight>


<syntaxhighlight lang="bash">
== Unit Parsing ==
cd ../RPMS
./load_rpm_packages.sh
</syntaxhighlight>
<syntaxhighlight lang="text">
# say 'y' when prompted
</syntaxhighlight>


<syntaxhighlight lang="bash">
One of the tricker bits of magic that ScanCore pulls off is the ability to simultaneously deliver alerts to different recipients in different languages. This is tricky because the agents setting alerts don't process the messages. So we need a standard way to pass values in an alert to ScanCore in a translatable format.
cd ..
make wrapper
</syntaxhighlight>
<syntaxhighlight lang="text">
cd Src && make
make[1]: Entering directory `/root/striker/Scanner/Src'
if [[ "root" != "root" ]] ; then \
    echo "Only root can create wrappers."; \
    echo "run as: sudo make"; \
else \
    cc -o wipmi wipmi.c; \
    cp wipmi ..; \
    chown root:root ../wipmi; \
    chmod 755  ../wipmi; \
    chmod u+s  ../wipmi; \
fi
if [[ "root" != "root" ]] ; then \
    echo "Only root can create wrappers."; \
    echo "run as: sudo make"; \
else \
    cc -o wstorcli wipmi.c; \
    cp wstorcli ..; \
    chown root:root ../wstorcli; \
    chmod 755  ../wstorcli; \
    chmod u+s  ../wstorcli; \
fi
make[1]: Leaving directory `/root/striker/Scanner/Src'
</syntaxhighlight>


Test:
This is done via the special '<span class="code">alerts</span>' table.


<syntaxhighlight lang="bash">
{{note|1=Explain this...}}
Agents/ipmi --verbose --verbose
</syntaxhighlight>
<syntaxhighlight lang="text">
ipmi loop 1 at 1421444884.53996 2378.437:27621.563 mSec.
^C
</syntaxhighlight>


Yay!
When setting a string to be later translated using double-bang variables line '<span class="code">!!$variable!$value!!</span>', the '<span class="code">$value</span>' will be analysed for certain suffixes. Those suffixes, when found, are translates into the language, unit or human readable appropriate values. For example, '<span class="code">!!size!1024 bytes!!</span>' will be translated to the language-appropriate base-2 human readable size, '<span class="code">1 KiB</span>'.


Similarly, temperatures can also be unit-converted for the notification target. So a value like '<span class="code">#!core_temperature!30 C!!</span>' can be translated to '<span class="code">30°C</span>' or, for users preferring imperial measurements, '<span class="code">68°F</span>'.


The full list of translated special suffixes are:


{{note|1=The 'suffix' strings are case sensitive! If you want your agent's alerts to use these translation, please mind the case and spelling. This is strict to minimise the chance of accidentally formatting a string not meant to be translated by this feature.}}


{|class="wikitable sortable"
!Suffix
!String Key
!Note
|-
|class="code"|%
|class="code"|tools_suffix_0016
|Percentage
|-
|class="code"|W
|class="code"|tools_suffix_0017
|[https://en.wikipedia.org/wiki/Watt Watts]
|-
|class="code"|vDC
|class="code"|tools_suffix_0018
|[https://en.wikipedia.org/wiki/Volt Volts] [https://en.wikipedia.org/wiki/Direct_current DC]
|-
|class="code"|vAC
|class="code"|tools_suffix_0019
|[https://en.wikipedia.org/wiki/Volt Volts] [https://en.wikipedia.org/wiki/Alternating_current AC]
|-
|class="code"|A
|class="code"|tools_suffix_0020
|[https://en.wikipedia.org/wiki/Ampere Amperes]
|-
|class="code"|RPM
|class="code"|tools_suffix_0021
|[https://en.wikipedia.org/wiki/Revolutions_per_minute Rotations Per Minute]
|-
|class="code"|Bps
|class="code"|tools_suffix_0022
|[https://en.wikipedia.org/wiki/Data_rate_units Bits per second]
|-
|class="code"|Kbps
|class="code"|tools_suffix_0023
|[https://en.wikipedia.org/wiki/Data_rate_units#Kilobit_per_second Kilobits per second]
|-
|class="code"|Mbps
|class="code"|tools_suffix_0024
|[https://en.wikipedia.org/wiki/Data_rate_units#Megabit_per_second Megabits per second]
|-
|class="code"|Gbps
|class="code"|tools_suffix_0025
|[https://en.wikipedia.org/wiki/Data_rate_units#Gigabit_per_second Gigabits per second]
|-
|class="code"|Tbps
|class="code"|tools_suffix_0026
|[https://en.wikipedia.org/wiki/Data_rate_units#Terabit_per_second Terabits per second]
|-
|class="code"|Bytes
|class="code"|--
|{{note|1=Only whole byte values are supported. Fractional byte values will not be converted.}}
These will be translated to the [[Base-2]] human readable size via the '<span class="code">[https://github.com/ClusterLabs/striker/blob/master/AN/Tools/Readable.pm AN::Tools::Readable->bytes_to_hr()]</span>' method. The suffix returned are those accepted by the [https://en.wikipedia.org/wiki/International_System_of_Quantities ISQ] for base-2 short forms. The [[IEC and SI Size Notations|sizes returned]] are; <span class="code">[[KiB]]</span>, <span class="code">[[MiB]]</span>, <span class="code">[[GiB]]</span>, [[TiB]], <span class="code">[[PiB]]</span>, <span class="code">[[EiB]]</span>, <span class="code">[[ZiB]]</span> and <span class="code">[[YiB]]</span>. <span class="code">KiB</span> is rounded to one decimal place, <span class="code">MiB</span> through <span class="code">TiB</span> are rounded to two decimal places and <span class="code">PiB</span> through <span class="code">YiB</span> are rounded to three decimal places.
|-
|class="code"|sec
|class="code" style="text-align: center;"|tools_suffix_0027
~<br />
tools_suffix_0031
|{{note|1=Only whole seconds are supported. Fractional values will not be converted.}}
The number of seconds given will be returned as a human-readable period of time in the short format '<span class="code">#w, #d, #h, #m, #s</span>' via the '<span class="code">[https://github.com/ClusterLabs/striker/blob/master/AN/Tools/Readable.pm AN::Tools::Readable->time()]</span>' method. If the number of seconds is too short for a number of minutes, hours, days or weeks, those units will be omitted.
|-
|class="code"|seconds
|class="code" style="text-align: center;"|tools_suffix_0032
~<br />
tools_suffix_0036
|{{note|1=Only whole seconds are supported. Fractional values will not be converted.}}
The number of seconds given will be returned as a human-readable period of time in the long format '<span class="code"># Weeks, # Days, # Hours, # Minutes, # Seconds</span>' via the '<span class="code">[https://github.com/ClusterLabs/striker/blob/master/AN/Tools/Readable.pm AN::Tools::Readable->time()]</span>' method. If the number of seconds is too short for a number of minutes, hours, days or weeks, those units will be omitted.
|-
|class="code"|Second
|class="code"|tools_suffix_0037
|Singular "Second".
|-
|class="code"|Seconds
|class="code"|tools_suffix_0038
|{{note|1=Note that this has a capitalised 'S'.}}
Plural "Seconds".
|-
|class="code"|Minute
|class="code"|tools_suffix_0039
|Singular "Minute"
|-
|class="code"|Minutes
|class="code"|tools_suffix_0040
|Plural "Minutes"
|-
|class="code"|Hour
|class="code"|tools_suffix_0041
|Singular "Hour".
|-
|class="code"|Hours
|class="code"|tools_suffix_0042
|Plural "Hours".
|-
|class="code"|Day
|class="code"|tools_suffix_0043
|Singular "Day".
|-
|class="code"|Days
|class="code"|tools_suffix_0044
|Plural "Days".
|-
|class="code"|Week
|class="code"|tools_suffix_0045
|Singular "Week".
|-
|class="code"|Weeks
|class="code"|tools_suffix_0046
|Plural "Weeks".
|-
|class="code"|C
|class="code" style="text-align: center;"|tools_suffix_0010
or<br />
tools_suffix_0012
|The value is in celsius. Which string is returned will depend on the notification target's preference for metric or imperial units of measurement. If metric (the default), <span class="code">tools_suffix_0010</span> is appended to the value and returned. If imperial, the value is converted to fahrenheit and the suffix <span class="code">tools_suffix_0012</span> will be appended.
|}


In some cases, the value returned by a string is a simple string in a given language (usually English). To translate this, certain values will be translated based on the table below.


{{note|1=Unlike 'value unit' pairs above, these are evaluated '''without''' case sensitivity.}}


----
{|class="wikitable sortable"
!Suffix
!String Key
!Note
|-
|class="code"|Yes
|class="code"|tools_suffix_0047
|The affirmative string "Yes".
|-
|class="code"|No
|class="code"|tools_suffix_0048
|The negative string "No".
|-
|class="code"|Enabled
|class="code"|tools_suffix_0049
|The string "Enabled".
|-
|class="code"|Disabled
|class="code"|tools_suffix_0050
|The string "Enabled".
|-
|class="code"|On
|class="code"|tools_suffix_0051
|The string "On".
|-
|class="code"|Off
|class="code"|tools_suffix_0052
|The string "Off".
|-
|class="code"|
|class="code"|
|
|}


<span class="code"></span>
<span class="code"></span>


<syntaxhighlight lang="perl">
</syntaxhighlight>
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
</syntaxhighlight>
</syntaxhighlight>

Latest revision as of 03:08, 6 July 2016

 AN!Wiki :: How To :: ScanCore

Warning: This is little more that raw notes, do not consider anything here to be valid or accurate at this time.

ScanCore - The Decision Engine

ScanCore is, at its core, a "decision engine".

It was created as a way for Anvil! systems to make intelligent decisions based on data coming in from any number of places. It generates alerts for admins, so in this regard it is an alert and monitoring solution, but that is almost a secondary benefit.

The core of ScanCore has no way of gathering data and it doesn't care how data is collected. It walks through a special agents directory and any agent it finds in there, it runs. Each agent connects to any number of ScanCore databases, checks whatever it knows how to scan, compares the current data with static limits and compares against historic values (as it deems fit) and records data (new or changed values) into the database.

An agent may decide to take independent action, like sending an alert or attempting a recovery of the devices or software it monitors, and then exits. If an agent doesn't find any hardware or software it knows about, it immediately exits without doing anything further.

After all agents run, ScanCore runs through post-scan tasks, depending on whether the machine it is running on is an Anvil! node or a ScanCore database. This is where the "decision engine" comes into play.

Lets look at a couple of examples;

Example 1; Overheating

ScanCore can tell the difference between a local node overheating and the room it is in overheating.

If the node itself has overheated, it will migrate servers over to the healthy peer. If the enough temperature sensors go critical, the node will power off.

If, however, both nodes are overheating then ScanCore can deduce that the room is overheating. In this case, it can automatically shed load to reduce the amount of heat being pumped into the room and slow down the rate of heating. Later, when the room cools, it will automatically reboot the shedded node and reform the Anvil! pair, restoring redundancy without ever requiring a human's input.

How does it do this?

Multiple scan agents record thermal data. The scan-ipmitool tool checks the host's IPMI sensor data which includes many thermal sensors and their upper and lower warning and critical thresholds. The scan-storcli agent scan AVAGO-based RAID controllers and the attached hard drives and solid state drives. These also have thermal data. This is true also for many UPSes, ethernet switches and so forth.

As each agent checks its thermal sensors, any within nominal ranges are recorded by the agent in its database tables. Any that are in a warning state though, that is, overly warm or cool but not yet a problem, get pushed into a special 'temperature' database table. Alone, ScanCore does nothing more than mark the node's health as 'warning' and no further action is taken.

If a given agent finds a given sensor reaching a 'critical' state, that is hot enough or cold enough to be a real concern, it it also pushed into the 'temperature' table. At the end of the scan, ScanCore will "add up" the number of sensors that are critical.

If the sum of the sensors exceed a limit, and if the host is a node, ScanCore will take action by shutting down. Each sensor has a default weight of '1' and by default, the shutdown threshold is "greater than five". So by default, a node will shut down when 6 or more sensors go critical. This is entirely configurable on a per-sensor basis as well as the shutdown threshold.

Later, when the still-accessible temperature sensors return to an acceptable level, ScanCore running on any one of the dashboards will power the node back up. Note that ScanCore will check how many times a node has overheated recently and extend a "cool-down" period before rebooting a node. This way, a node with a chronic overheating condition will be rebooted less often. Once repaired though, the reboots will eventually be "forgotten" and the cool-down delay will reset.

What about thermal load shedding?

The example above spoke to a single node overheating. If you recall, ScanCore does "post-scan calculations". When on a node, this includes a check to see if the peer's temperature has entered a "warning" state when it has as well. Using a similar heuristic, when both nodes have enough temperature sensors in 'warning' or 'critical' state for more than a set period of time, one of the nodes will be withdrawn and shut down.

Unlike the example above, which shutdown the host node after a critical heuristic is passed, the load-shedding kicks in only when both nodes are registering a thermal event at the same time for more than a set (and configurable) period of time.

Example 2; Loss of input power

In all Anvil! systems, at least two network-monitored UPSes are powering the nodes' redundant power supplies. Thus, the loss of one UPS does not pose a risk to the system and can be ignored. Traditionally, most UPS monitoring software would assume it was the sole power provider for a machine and would initiate a shutdown if it reached critically low power levels.

With ScanCore, it understands that each node has two (or more) power sources. If one UPS loses mains power, an alert will be registered but nothing more will be done. Should the one UPS deplete entirely, the power will be lost and additional alerts will be registered when input power is lost to one of the redundant power supplies, but otherwise nothing more will happen.

Thus, ScanCore is redundancy-aware.

Consider another power scenario; Power is lost the both UPSes feeding a node. In this case, ScanCore does two things;

  1. It begins monitoring the estimated hold-up time of the strongest UPS. If the strongest UPS drops below a minimum hold-up time, a graceful shutdown of hosted servers is initiated followed by the node(s) withdrawing and powering off. Note that if different UPSes power the nodes, ScanCore will know that the peer is healthy and will migrate servers to the node with power long before the node needs to shutdown.

In a typical install, the same pair of UPSes power both nodes in the Anvil!. In the case where power is lost to both UPSes, a timer is checked. Once both nodes have been running on UPS batteries for more than two minutes, load shedding will occur. If needed, servers will migrate to consolidate on one node, then the sacrificial node will withdraw and power off to extend the runtime of the remaining node.

If, after load shedding, power stays out for too long and minimum hold-up times are crossed, the remaining node will gracefully shut down the servers and then power itself off.

Later, power is restored.

At this point, the Striker dashboards will boot (if all power was lost). Once up, they will note that both nodes are off and check the UPSes. If both UPSes are depleted (or minimally charged), they will take no action. Instead, they will monitor the charge rate of the UPSes. Once one of the UPSes hits a minimum charge percentage, it will boot the nodes and restore full Anvil! services, including booting all servers.

The logic behind the delay is to ensure that, if mains power is lost immediately after powering the nodes back on, there is sufficient charge for the nodes to power back up, detect the loss and shut back down safely.

Example 3; Node Health

The final example will show how ScanCore can react to a localized node issue.

Consider the scenario where Node 1 is the active host. The RAID controller on the host reports that a hard drive is potentially failing. An alert is generated but no further action is taken.

Later, a drive fails entirely and the node enters a degraded state.

At this point, ScanCore would note that Node 1 is now in a 'warning' state and the peer node is 'ok' and a timer is started. Recall that ScanCore can't determine the nature of a warning, so it pauses a little bit to avoid taking action on a transient issue. Two minutes after the failure, with the 'warning' state still present, ScanCore will migrate all hosted servers over to Node 2.

It will remain in the Anvil! and no further action will be taken. However, now, if a second drive were to fail (assuming RAID level 5), Node 1 would be lost and fenced, but no interruption would occur because the servers were already moved as a precaution.

If the drive is replaced before any further issues arise, Node 1 would return to an 'ok' state but nothing else would happen. Servers would be left on Node 2 because there is no benefit or concern around which node is hosting the servers at any given time.

Scan Agents

When an agent runs and connects to the database layer, a timestamp is created and that time stamp is then used for all databases changes made in that given pass. This means that the modification timestamps will be the same for a given pass, regardless of the actual time when the record was changed. This makes resynchronization far more sane, at the cost of some resolution.

If your agent needs accurate record change timestamps, please make a note to record that current time as a separate database column.

DB Resync

Part of the difference between ScanCore and various other tools is that ScanCore is designed from its core as a resilient project. The data collected by agents needs to, from the user's perspective, sync N-way between ScanCore databases without the user needing to worry about backups, recoveries and whatnot.

How does this work?

In essence, the data Agents collects can be categorized in one of two ways;

  • Data that is global (like data on servers on the Anvil! platform)
  • Data that is target-bound (like a host's sensor data from IPMI interfaces or a given machines view of UPSes it cares about)

As an agent author, you need to consider that data may exist in some databases and not others.

Consider;

A site has two Striker dashboards acting as ScanCore databases. This is a satellite office so you data replicates to a third Striker at head office. Meanwhile, head-office is collecting data from many different sites and the two dashboards on your site doesn't care about the data on the head-office site from those other locations.

Warning: Isolating data onto a limited number of databases is an efficiency effort, not a security effort! If you don't trust a ScanCore database machine, don't connect to it, period. Similarly, if you don't trust trust a machine with access to your database, don't give the owner access.

You also need to plan for N-directional resynchronization.

Also consider;

Power is lost to both/all UPSes and load-shedding takes "Striker 2" offline. Now data is being recorded to "Striker 1" that will need to be copied to Striker 2 later. Time passes and all power is lost. Power is restored, but for some reason Striker 2 boots up first and starts collecting data. Eventually, Striker 1 comes back online.

Now, Striker 1 has data that 2 doesn't, and Striker 2 has data that 1 doesn't.

ScanCore has already solved this problem using the following schemes, depending on which type of data your agent collects.

Note: Yes, this is expensive in terms of memory and processing power, relatively speaking. However, a lot of effort is made to never UPDATE the database unless something actually changes, keeping the history schema as small and efficient as possible. For this reason, even data collected from many nodes over a long period of time should not add up to too much. If you are concerned, be sure to run periodic archiving of the data.
Warning: As this is written, automatic archiving has not been implemented, though it is planned to be implemented shortly.

Resync Global Data

This is the simplest data to resync because it will go to all databases, no matter what. This is rare in practice but provides a good starting point.

The process;

The agent starts and connects to the databases. As part of the connection process, a check is made to see if any databases are behind (see AN::Tools::DB.pm->find_behind_databases()). If so, the agent will act on this by initiating a resync.

The resync process is fundamentally simple; All records are read in from it's history schema of all connected databases into a common hash based on the time a given record was recorded and the unique ID of the record. The same data is loaded into database-specific hash for later comparison. We also note for each unique record that we've seen at least one copy of the record for a later step. An example "record" would be a server's UUID, which uniquely identifies it regardless of the host node or Anvil!.

Here is an example of how the data is read in:

		my $query = "
SELECT 
    server_uuid,
    server_name, 
    server_stop_reason, 
    server_start_after, 
    server_start_delay, 
    server_note, 
    server_definition, 
    server_host, 
    server_state, 
    server_migration_type, 
    server_pre_migration_script, 
    server_pre_migration_arguments, 
    server_post_migration_script, 
    server_post_migration_arguments, 
    modified_date 
FROM 
    history.servers 
;";

Without constraints, all data in the table will be read in. This data is recorded in the 'unified' hash using the modification time and the unique identifier as keys.

			# Record this in the unified and local hashes.
			$an->data->{db_data}{unified}{servers}{modified_date}{$modified_date}{server_uuid}{$server_uuid} = {
				server_name			=>	$server_name, 
				server_stop_reason		=>	$server_stop_reason, 
				server_start_after		=>	$server_start_after, 
				server_start_delay		=>	$server_start_delay, 
				server_note			=>	$server_note, 
				server_definition		=>	$server_definition, 
				server_host			=>	$server_host, 
				server_state			=>	$server_state, 
				server_migration_type		=>	$server_migration_type,
				server_pre_migration_script	=>	$server_pre_migration_script,
				server_pre_migration_arguments	=>	$server_pre_migration_arguments,
				server_post_migration_script	=>	$server_post_migration_script,
				server_post_migration_arguments	=>	$server_post_migration_arguments,
			};

Next, for the current Database ID that we're reading from, note that the server with the given ID exists in the public database schema. We'll also set this 'seen' as '0' for now. We'll see why in a moment.

			$an->data->{db_data}{$id}{servers}{server_uuid}{$server_uuid}{'exists'} = 1;
			$an->data->{db_data}{$id}{servers}{server_uuid}{$server_uuid}{seen}     = 0;

Finally, record the same data in another hash, identified by the currently active database ID in another hash.

			$an->data->{db_data}{$id}{servers}{modified_date}{$modified_date}{server_uuid}{$server_uuid} = {
				server_name			=>	$server_name, 
				server_stop_reason		=>	$server_stop_reason, 
				server_start_after		=>	$server_start_after, 
				server_start_delay		=>	$server_start_delay, 
				server_note			=>	$server_note, 
				server_definition		=>	$server_definition, 
				server_host			=>	$server_host, 
				server_state			=>	$server_state, 
				server_migration_type		=>	$server_migration_type,
				server_pre_migration_script	=>	$server_pre_migration_script,
				server_pre_migration_arguments	=>	$server_pre_migration_arguments,
				server_post_migration_script	=>	$server_post_migration_script,
				server_post_migration_arguments	=>	$server_post_migration_arguments,
			};

So, once the read is done from all accessible databases, we'll have a set of hashes; One being the unified collection of all data from both/all sources, plus a hash for each database.

Note: This looks a little complicated, but it is worth the mental effort. With this in place, users will never need to worry about data recovery or synchronization so long as even one copy of the database exists somewhere. ScanCore database servers can come and go or be destroyed and replaced trivially. So please bear with it... The logic seems complex, but it is fundamentally quite simple.

With this, here is the sync process:

  1. Walk through the unified records for each given modification timestamp, newest records first, oldest records last.
    1. Walk through each unique record for the given timestamp (continuing the example, this would be each server's UUID).
      1. Loop through each connected database ID.
        1. Check to see if the unique record ID has been seen in the resync process yet. (Note: This will always be 'not' the first time because the first instance of a record at the most recent time stamp will go into the public schema where all other records will go into the history schema.)
          1. IF NOT seen:
            1. Mark the record as now having been seen.
            2. Check to see if the unique record ID exists at all on this database.
              1. IF exists: Does the record at the current time stamp exist?
                1. IF NOT at this timestamp: UPDATE the public schema (the record was already in the public schema, but it was old).
              2. IF NOT exists: INSERT it into the public schema as the record didn't exist yet.
          2. IF seen:
            1. Does it exist at this timestamp?
              1. If not at this timestamp: INSERT it into the history schema at the current timestamp.

All of these UPDATE and INSERT calls go into an array per database. When all the unified records have been processed, each database array with one or more records is then sent to the given database to be processed in one transaction.

Lastly, the hashes that stored all the unified and per-DB records is deleted to clear up memory.

Voila! Your data is now synchronized on all databases!

Resync Target-Bound Data

The only difference between resync'ing global data from target-bound records in that a constraint is used on the initial reading of data from the connected databases.

We will use scan-bond agent which monitors bonded network interfaces on each node or Striker dashboard. In all cases, the state of the bonds only matters to the one host with the actual bonds. The other nodes and dashboards don't care about it.

In this example, then, the bond records will be bound to the hosts -> host_uuid, which is stored on each machine in /etc/striker/host.uuid and is presented in ScanCore in the sys::host_uuid variable.

The read, then, looks like this;

		my $query = "
SELECT 
    bond_uuid, 
    bond_name, 
    bond_mode, 
    bond_primary_slave, 
    bond_primary_reselect, 
    bond_active_slave, 
    bond_mii_status, 
    bond_mii_polling_interval, 
    bond_up_delay, 
    bond_down_delay, 
    modified_date 
FROM 
    history.bond
WHERE
    bond_host_uuid = ".$an->data->{sys}{use_db_fh}->quote($an->data->{sys}{host_uuid})."
;";

With the WHERE bond_host_uuid = ".$an->data->{sys}{use_db_fh}->quote($an->data->{sys}{host_uuid})." constraint, all of the data read in from the database will come from the current host machine. Bond records for other nodes and dashboard systems will be ignored.

In this way, our data will sync between the ScanCore databases we use, but we won't sync bond records for other hosts (which may sync between an entirely different set of ScanCore databases).

The rest of the synchronization is process is exactly the same as above. The unified and per-DB hashes will be processed exactly the same way (just with a subset of the data).

Easy peasy!

Unit Parsing

One of the tricker bits of magic that ScanCore pulls off is the ability to simultaneously deliver alerts to different recipients in different languages. This is tricky because the agents setting alerts don't process the messages. So we need a standard way to pass values in an alert to ScanCore in a translatable format.

This is done via the special 'alerts' table.

Note: Explain this...

When setting a string to be later translated using double-bang variables line '!!$variable!$value!!', the '$value' will be analysed for certain suffixes. Those suffixes, when found, are translates into the language, unit or human readable appropriate values. For example, '!!size!1024 bytes!!' will be translated to the language-appropriate base-2 human readable size, '1 KiB'.

Similarly, temperatures can also be unit-converted for the notification target. So a value like '#!core_temperature!30 C!!' can be translated to '30°C' or, for users preferring imperial measurements, '68°F'.

The full list of translated special suffixes are:

Note: The 'suffix' strings are case sensitive! If you want your agent's alerts to use these translation, please mind the case and spelling. This is strict to minimise the chance of accidentally formatting a string not meant to be translated by this feature.
Suffix String Key Note
% tools_suffix_0016 Percentage
W tools_suffix_0017 Watts
vDC tools_suffix_0018 Volts DC
vAC tools_suffix_0019 Volts AC
A tools_suffix_0020 Amperes
RPM tools_suffix_0021 Rotations Per Minute
Bps tools_suffix_0022 Bits per second
Kbps tools_suffix_0023 Kilobits per second
Mbps tools_suffix_0024 Megabits per second
Gbps tools_suffix_0025 Gigabits per second
Tbps tools_suffix_0026 Terabits per second
Bytes --
Note: Only whole byte values are supported. Fractional byte values will not be converted.

These will be translated to the Base-2 human readable size via the 'AN::Tools::Readable->bytes_to_hr()' method. The suffix returned are those accepted by the ISQ for base-2 short forms. The sizes returned are; KiB, MiB, GiB, TiB, PiB, EiB, ZiB and YiB. KiB is rounded to one decimal place, MiB through TiB are rounded to two decimal places and PiB through YiB are rounded to three decimal places.

sec tools_suffix_0027

~
tools_suffix_0031

Note: Only whole seconds are supported. Fractional values will not be converted.

The number of seconds given will be returned as a human-readable period of time in the short format '#w, #d, #h, #m, #s' via the 'AN::Tools::Readable->time()' method. If the number of seconds is too short for a number of minutes, hours, days or weeks, those units will be omitted.

seconds tools_suffix_0032

~
tools_suffix_0036

Note: Only whole seconds are supported. Fractional values will not be converted.

The number of seconds given will be returned as a human-readable period of time in the long format '# Weeks, # Days, # Hours, # Minutes, # Seconds' via the 'AN::Tools::Readable->time()' method. If the number of seconds is too short for a number of minutes, hours, days or weeks, those units will be omitted.

Second tools_suffix_0037 Singular "Second".
Seconds tools_suffix_0038
Note: Note that this has a capitalised 'S'.

Plural "Seconds".

Minute tools_suffix_0039 Singular "Minute"
Minutes tools_suffix_0040 Plural "Minutes"
Hour tools_suffix_0041 Singular "Hour".
Hours tools_suffix_0042 Plural "Hours".
Day tools_suffix_0043 Singular "Day".
Days tools_suffix_0044 Plural "Days".
Week tools_suffix_0045 Singular "Week".
Weeks tools_suffix_0046 Plural "Weeks".
C tools_suffix_0010

or
tools_suffix_0012

The value is in celsius. Which string is returned will depend on the notification target's preference for metric or imperial units of measurement. If metric (the default), tools_suffix_0010 is appended to the value and returned. If imperial, the value is converted to fahrenheit and the suffix tools_suffix_0012 will be appended.

In some cases, the value returned by a string is a simple string in a given language (usually English). To translate this, certain values will be translated based on the table below.

Note: Unlike 'value unit' pairs above, these are evaluated without case sensitivity.
Suffix String Key Note
Yes tools_suffix_0047 The affirmative string "Yes".
No tools_suffix_0048 The negative string "No".
Enabled tools_suffix_0049 The string "Enabled".
Disabled tools_suffix_0050 The string "Enabled".
On tools_suffix_0051 The string "On".
Off tools_suffix_0052 The string "Off".


 

Any questions, feedback, advice, complaints or meanderings are welcome.
Alteeve's Niche! Enterprise Support:
Alteeve Support
Community Support
© Alteeve's Niche! Inc. 1997-2024   Anvil! "Intelligent Availability®" Platform
legal stuff: All info is provided "As-Is". Do not use anything here unless you are willing and able to take responsibility for your own actions.