forked from Cacti/plugin_syslog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyslog_counter.php
53 lines (45 loc) · 2.39 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
<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2024 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/ |
+-------------------------------------------------------------------------+
*/
include(__DIR__ . '/../../include/cli_check.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);