forked from Cacti/plugin_syslog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyslog_counter.php
66 lines (56 loc) · 2.83 KB
/
syslog_counter.php
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
<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2007-2017 The Cacti Group |
| |
| 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: The Complete RRDTool-based Graphing Solution |
+-------------------------------------------------------------------------+
| This code is designed, written, and maintained by the Cacti Group. See |
| about.php and/or the AUTHORS file for specific developer information. |
+-------------------------------------------------------------------------+
| http://www.cacti.net/ |
+-------------------------------------------------------------------------+
*/
/* do NOT run this script through a web browser */
if (!isset($_SERVER['argv'][0]) || isset($_SERVER['REQUEST_METHOD']) || isset($_SERVER['REMOTE_ADDR'])) {
die('<br><strong>This script is only meant to run at the command line.</strong>');
}
$no_http_headers = true;
// PHP5 uses a different base path apparently
if (file_exists('include/auth.php')) {
include(dirname(__FILE__) . '/../../include/global.php');
} else {
chdir('../../');
include(dirname(__FILE__) . '/../../include/global.php');
}
$sli = read_config_option('syslog_last_incoming');
$slt = read_config_option('syslog_last_total');
$line = syslog_db_fetch_row("SHOW TABLE STATUS LIKE 'syslog_incoming'");
$i_rows = $line['Auto_increment'];
$line = syslog_db_fetch_row("SHOW TABLE STATUS LIKE 'syslog'");
$total_rows = $line['Auto_increment'];
if ($sli == "") {
$sql = "REPLACE INTO settings VALUES ('syslog_last_incoming','$i_rows')";
}else{
$sql = "UPDATE settings SET value='$i_rows' WHERE name='syslog_last_incoming'";
}
db_execute($sql);
if ($slt == "") {
$sql = "REPLACE INTO settings VALUES ('syslog_last_total','$total_rows')";
}else{
$sql = "UPDATE settings SET value='$total_rows' WHERE name='syslog_last_total'";
}
db_execute($sql);
if ($sli == '') $sli = 0;
if ($slt == '') $slt = 0;
print 'total:' . ($total_rows-$slt) . ' incoming:' . ($i_rows-$sli);