Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link thru to nagios #60

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config.php.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ $api_type = "nagios-api";

// Your Nagios hosts
$nagios_hosts = array(
array("hostname" => "nagios01.dc1.company.com", "port" => "6315", "protocol" => "http", "tag" => "DC1", "tagcolour" => "#336699"),
array("hostname" => "nagios01.dc1.company.com", "port" => "6315", "protocol" => "http", "tag" => "DC1", "tagcolour" => "#336699", "weburl" => "http://nagios.company.com/nagios"),
array("hostname" => "nagios01.dc2.company.com", "port" => "6315", "protocol" => "http", "tag" => "DC2", "tagcolour" => "#696969"),
array("hostname" => "nagios01.dc3.company.com", "port" => "6315", "protocol" => "http", "tag" => "DC3", "tagcolour" => "#4169E1"),
// and so on...
Expand Down
1 change: 1 addition & 0 deletions htdocs/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ table { border: 1px solid #c6c6c6; background-color: #F0F0F0; bord
*border-collapse: collapse; -webkit-border-radius: 4px;
-moz-border-radius: 4px; border-radius: 4px; }
th { border: 1px black solid; background-color: #D8D8D8 }
a, a:link, a:hover { color: unset; }
.widetable { width: 100%; clear: both }
.bold { font-weight: bold; }
.status_green { background-color: #269926; color: white; padding: 3px }
Expand Down
4 changes: 2 additions & 2 deletions htdocs/nagdash.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
"host" => $service['hostname'],
"service" => $service['service_name']]);
echo "</span></td>";
echo "<td class='bold {$nagios_service_status_colour[$service['service_state']]} {$soft_style}'>{$blink_tag}{$service['service_name']}<span class='detail'>{$service['detail']}</span></td>";
echo "<td class='bold {$nagios_service_status_colour[$service['service_state']]} {$soft_style}'><a href='{$service['weburl']}' target=\"_blank\">{$blink_tag}{$service['service_name']}</a><span class='detail'>{$service['detail']}</span></td>";
echo "<td>{$service['duration']}</td>";
echo "<td>{$service['current_attempt']}/{$service['max_attempts']}</td>";
echo "</tr>";
Expand Down Expand Up @@ -186,7 +186,7 @@
echo "<tr class='known_service'>";
$tag = NagdashHelpers::print_tag($service['tag'], count($nagios_hosts));
echo "<td>{$service['hostname']} " . $tag . "</td>";
echo "<td>{$service['service_name']}</td>";
echo "<td><a href='{$service['weburl']}' target=\"_blank\">{$service['service_name']}</a></td>";
echo "<td class='{$nagios_service_status_colour[$service['service_state']]}'>{$nagios_service_status[$service['service_state']]} ({$status_text})</td>";
echo "<td>{$service['duration']}</td>";
echo "<td>{$service['current_attempt']}/{$service['max_attempts']}</td>";
Expand Down
3 changes: 3 additions & 0 deletions phplib/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,10 @@ static function get_nagios_host_data($nagios_hosts, $unwanted_hosts, $api_type)
if (is_string($host_state)) {
$errors[] = "Could not connect to API on host {$host['hostname']}, port {$host['port']}: {$host_state}";
} else {
# copy 'tag' and 'weburl' from the config to the state
foreach ($host_state as $this_host => $null) {
$host_state[$this_host]['tag'] = $host['tag'];
$host_state[$this_host]['weburl'] = isset($host['weburl']) ? $host['weburl'] : null;
}
$state += (array) $host_state;
}
Expand Down Expand Up @@ -284,6 +286,7 @@ static function parse_nagios_host_data($state, $filter, $api_cols, $filter_selec
if ($service_detail['last_state_change'] >= $state_change_backstop) {
array_push($$array_name, array(
"hostname" => $hostname,
"weburl" => "{$host_detail['weburl']}/cgi-bin/extinfo.cgi?type=2&host={$hostname}&service={$service_name}",
"service_name" => $service_name,
"service_state" => $service_detail[$api_cols['state']],
"duration" => timeago($service_detail['last_state_change']),
Expand Down