1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310
|
<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004 Ian Berry |
| |
| This program is free software; 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 program 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 for more details. |
+-------------------------------------------------------------------------+
| cacti: a php-based graphing solution |
+-------------------------------------------------------------------------+
| Most of this code has been designed, written and is maintained by |
| Ian Berry. See about.php for specific developer credit. Any questions |
| or comments regarding this code should be directed to: |
| - iberry@raxnet.net |
+-------------------------------------------------------------------------+
| - raXnet - http://www.raxnet.net/ |
+-------------------------------------------------------------------------+
*/
include("./include/auth.php");
include_once("./lib/utility.php");
/* set default action */
if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; }
switch ($_REQUEST["action"]) {
case 'clear_poller_cache':
include_once("./include/top_header.php");
repopulate_poller_cache();
utilities();
utilities_view_poller_cache();
include_once("./include/bottom_footer.php");
break;
case 'view_snmp_cache':
include_once("./include/top_header.php");
utilities();
utilities_view_snmp_cache();
include_once("./include/bottom_footer.php");
break;
case 'view_poller_cache':
include_once("./include/top_header.php");
utilities();
utilities_view_poller_cache();
include_once("./include/bottom_footer.php");
break;
case 'view_logfile':
include_once("./include/top_header.php");
utilities();
utilities_view_logfile();
include_once("./include/bottom_footer.php");
break;
case 'clear_logfile':
include_once("./include/top_header.php");
utilities_clear_logfile();
utilities();
utilities_view_logfile();
include_once("./include/bottom_footer.php");
break;
default:
include_once("./include/top_header.php");
utilities();
include_once("./include/bottom_footer.php");
break;
}
/* -----------------------
Utilities Functions
----------------------- */
function utilities_view_logfile() {
global $colors;
$logfile = read_config_option("path_cactilog");
if ($logfile == "") {
$logfile = "./log/rrd.log";
}
/* helps determine output color */
$linecolor = True;
/* read logfile into an array and display */
if (file_exists($logfile)) {
$logcontents = file($logfile);
}else{
touch($logfile);
$logcontents = file($logfile);
}
$logcontents = array_reverse($logcontents);
html_start_box("<strong>View Cacti Log File</strong> [" . sizeof($logcontents) . " Item" . ((sizeof($logcontents) > 0) ? "s" : "") . "]", "98%", $colors["header"], "3", "center", "");
$i = 0;
foreach ($logcontents as $item) {
if (strpos($item,":") <> 0) {
if ($linecolor = True) {
$linecolor = False;
}else{
$linecolor = True;
}
}
switch ($linecolor) {
case True:
form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i);
?>
<td>
<?php print $item;?>
</td>
</tr>
<?php
break;
case False:
form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i); $i++;
?>
<td>
<?php print $item;?>
</td>
</tr>
<?php
break;
}
}
html_end_box();
}
function utilities_clear_logfile() {
$logfile = read_config_option("path_cactilog");
if ($logfile == "") {
$logfile = "./log/rrd.log";
}
if (file_exists($logfile)) {
unlink($logfile);
touch($logfile);
}
}
function utilities_view_snmp_cache() {
global $colors;
$snmp_cache = db_fetch_assoc("select host_snmp_cache.*,
host.description,
snmp_query.name
from host_snmp_cache,snmp_query,host
where host_snmp_cache.host_id=host.id
and host_snmp_cache.snmp_query_id=snmp_query.id
order by host_snmp_cache.host_id,host_snmp_cache.snmp_query_id,host_snmp_cache.snmp_index");
html_start_box("<strong>View SNMP Cache</strong> [" . sizeof($snmp_cache) . " Item" . ((sizeof($snmp_cache) > 0) ? "s" : "") . "]", "98%", $colors["header"], "3", "center", "");
$i = 0;
if (sizeof($snmp_cache) > 0) {
foreach ($snmp_cache as $item) {
form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i);
?>
<td>
Host: <?php print $item["description"];?>, SNMP Query: <?php print $item["name"];?>
</td>
</tr>
<?php
form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i);
?>
<td>
Index: <?php print $item["snmp_index"];?>, Field Name: <?php print $item["field_name"];?>, Field Value: <?php print $item["field_value"];?>
</td>
</tr>
<?php
form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i); $i++;
?>
<td>
OID: <?php print $item["oid"];?>
</td>
</tr>
<?php
}
}
html_end_box();
}
function utilities_view_poller_cache() {
global $colors;
$poller_cache = db_fetch_assoc("select
poller_item.*,
data_template_data.name_cache,
data_local.host_id
from poller_item,data_template_data,data_local
where poller_item.local_data_id=data_template_data.local_data_id
and data_template_data.local_data_id=data_local.id");
html_start_box("<strong>View Poller Cache</strong> [" . sizeof($poller_cache) . " Item" . ((sizeof($poller_cache) > 0) ? "s" : "") . "]", "98%", $colors["header"], "3", "center", "");
$i = 0;
if (sizeof($poller_cache) > 0) {
foreach ($poller_cache as $item) {
form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i);
?>
<td>
Data Source: <?php print $item["name_cache"];?>
</td>
</tr>
<?php
form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i);
?>
<td>
RRD: <?php print $item["rrd_path"];?>
</td>
</tr>
<?php
form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i); $i++;
?>
<td>
Action: <?php print $item["action"];?>, <?php print ((($item["action"] == "1") || ($item["action"] == "2")) ? "Script: " . $item["arg1"] : "OID: " . $item["arg1"] . " (Host: " . $item["hostname"] . ", Community: " . $item["snmp_community"] . ")");?>
</td>
</tr>
<?php
}
}
html_end_box();
}
function utilities() {
global $colors;
html_start_box("<strong>Cacti System Utilities</strong>", "98%", $colors["header"], "3", "center", "");
html_header(array("Poller Cache Administration"), 2);
?>
<colgroup span="3">
<col valign="top" width="20"></col>
<col valign="top" width="10"></col>
</colgroup>
<tr bgcolor="#<?php print $colors["form_alternate1"];?>">
<td class="textArea">
<p><a href='utilities.php?action=view_poller_cache'>View Poller Cache</a></p>
</td>
<td class="textArea">
<p>This is the data that is being passed to the poller each time it runs. This data is then in turn executed/interpreted and the results are fed into the rrd files for graphing or the database for display.</p>
</td>
</tr>
<tr bgcolor="#<?php print $colors["form_alternate2"];?>">
<td class="textArea">
<p><a href='utilities.php?action=view_snmp_cache'>View SNMP Cache</a></p>
</td>
<td class="textArea">
<p>The SNMP cache stores information gathered from SNMP queries. It is used by cacti to determine the OID to use when gathering information from an SNMP-enabled host.</p>
</td>
</tr>
<tr bgcolor="#<?php print $colors["form_alternate1"];?>">
<td class="textArea">
<p><a href='utilities.php?action=clear_poller_cache'>Clear Poller Cache</a></p>
</td>
<td class="textArea">
<p>The poller cache will be cleared and re-generated if you select this option. Sometimes host/data source data can get out of sync with the cache in which case it makes sense to clear the cache and start over.</p>
</td>
</tr>
<?php html_header(array("System Log Administration"), 2);?>
<tr bgcolor="#<?php print $colors["form_alternate1"];?>">
<td class="textArea">
<p><a href='utilities.php?action=view_logfile'>View Cacti Log File</a></p>
</td>
<td class="textArea">
<p>The Cacti Log File stores statistic, error and other message depending on system settings. This information can be used to identify problems with the poller and application.</p>
</td>
</tr>
<tr bgcolor="#<?php print $colors["form_alternate2"];?>">
<td class="textArea">
<p><a href='utilities.php?action=clear_logfile'>Clear Cacti Log File</a></p>
</td>
<td class="textArea">
<p>This action will reset the Cacti Log File. Please note that if you are using the Syslog/Eventlog only, this action will have no effect.</p>
</td>
</tr>
<?php
html_end_box();
}
?>
|