Slaughter Variables
slaughter allows you to write your policies in a combination of pure-perl, and a set of primitive functions it provides. These primitives are augmented by variables which are discovered/set at run-tim.
This page documents the standard variables which are provided, but you should note that the variables are determined at run-time based upon your own local system so yours might differ.
Dumping Variables
To see which variables, and information, has been collected about your own system you can run:
slaughter --dump
(You may run this without being root).
Using Variables
You have two choices when it comes to using the variables in your policies:
- Using them from the global name-space.
- Using them from the global %template hash.
For example the variable "fqdn" is thus accessible via either of these:
print $fqdn . "\n";
print $template->{'fqdn'} . "\n";
Variables
The following variables are available:
| Variable | Usage/Meaning/Contents |
| arch | Either i386 or amd64, depending upon the type of the system. |
| bits | 32 or 64 depending on the client system. |
| domain | The domain portion of the hostname. |
| fqdn | The fully qualified (long) hostname of the client system. |
| hostname | The short (unqualified) hostname of the client system. |
| kernel | The version of the kernel running upon the client system. |
| kvm | 1 if the guest is a KVM guest. |
| load_average_1 | Load average for the past one minute. |
| load_average_5 | Load average for the past five minutes. |
| load_average_15 | Load average for the past fifteen minutes. |
| raid | 1 if some form of RAID was detected. |
| release | The symbolic name of the current distributions release, via LSB. |
| server | The name of the server the client is running against. |
| softwareraid | 1 if software RAID was detected. |
| verbose | 0 or 1 depending on whether the slaugher run was launched wiht --verbose |
| xen | 1 if the guest is a Xen system (domU or dom0). |
In addition to these variables IP addresses are also dynamically determined - both IPv6 and IPv4. There are two variables setup:
- $ip_count
- The count of (IPv4) IP addresses.
- $ip6_count
- The count of IPv6 IP addresses.
You can loop through the addresses with code such as this:
my $count = 1;
while ($count < $ip6_count )
{
print "IPv6 address $count is : $template->{'ip6_$count'}\n";
$count += 1;
}
i.e. The variable "$ip_1" is setup for the first IP address, the variable $ip6_1 contains the first IPv6 address, etc.
|