Monitoring of BGP session via Quagga daemon in Linux

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

gslavic
Posts: 8
Joined: Tue Feb 09, 2016 5:07 am

Re: Monitoring of BGP session via Quagga daemon in Linux

Post by gslavic »

red_neon wrote:gslavic,

Good, your snmpd daemon is running from user, who does not access to directory /tmp/ (could not reading data from /tmp/snmp_quagga_bgpd* files). Check command line with which runned snmpd and check user (snmp by default) in /etc/passwd. Maybe user snmp is locked in some directory
My command line from snmpd.service is

[Unit]
Description=Simple Network Management Protocol (SNMP) Daemon.
After=syslog.target network.target

[Service]
Type=notify
Environment=OPTIONS="-LS0-6d"
EnvironmentFile=-/etc/sysconfig/snmpd
ExecStart=/usr/sbin/snmpd $OPTIONS -f -u root
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target


3 problems:
1. I am running SNMPD as root ! Root should have access to all directories :-)
2. How to unlock the directory /tmp/ for the user ?
3. I don't have snmp as the user in /etc/passwd !
User avatar
red_neon
Posts: 24
Joined: Sun Mar 21, 2010 11:50 pm
Location: Moscow, Russia

Re: Monitoring of BGP session via Quagga daemon in Linux

Post by red_neon »

:D
Try to stop snmpd and run it manually

Code: Select all

systemctl stop snmpd
/usr/sbin/snmpd -LS0-6d -f -u root
I checked this command on my debian and it is works ok
"Imagination is more important than Knowledge."
gslavic
Posts: 8
Joined: Tue Feb 09, 2016 5:07 am

Re: Monitoring of BGP session via Quagga daemon in Linux

Post by gslavic »

red_neon wrote::D
Try to stop snmpd and run it manually

Code: Select all

systemctl stop snmpd
/usr/sbin/snmpd -LS0-6d -f -u root
I checked this command on my debian and it is works ok
Yes it works on my debian too :-)
Unfortunately it seems that the script / script-SNMP in combination doesn't not work on CentOS 7 !
User avatar
red_neon
Posts: 24
Joined: Sun Mar 21, 2010 11:50 pm
Location: Moscow, Russia

Re: Monitoring of BGP session via Quagga daemon in Linux

Post by red_neon »

Did you try run script in root-mode?

Code: Select all

my $_ROOT = 1;

# Path to "vtysh"
my $_vtysh = "/usr/bin/vtysh";
Or tried to change path to files with data?

Code: Select all

# Temp files for Cron-mode
my $_file_ipsum = "/tmp/snmp_quagga_bgpd_ipsum";
my $_file_rosum = "/tmp/snmp_quagga_bgpd_rosum";
my $_file_mem = "/tmp/snmp_quagga_bgpd_mem";
my $_file_ver = "/tmp/snmp_quagga_bgpd_ver";
my $_file_ipnei = "/tmp/snmp_quagga_bgpd_ipnei";
"Imagination is more important than Knowledge."
User avatar
red_neon
Posts: 24
Joined: Sun Mar 21, 2010 11:50 pm
Location: Moscow, Russia

Re: Monitoring of BGP session via Quagga daemon in Linux

Post by red_neon »

gslavic,
I think I understood where is the problem, SELinux blocking access for snmpd. I checked script with disabled selinux and it works.
If you do not want to disable snmp-module in selinux - then try create rules for it :D .


UPD: disable just snmp module in selinux:

Code: Select all

semodule -d snmp
systemctl restart snmpd
"Imagination is more important than Knowledge."
gslavic
Posts: 8
Joined: Tue Feb 09, 2016 5:07 am

Re: Monitoring of BGP session via Quagga daemon in Linux

Post by gslavic »

red_neon wrote:gslavic,
I think I understood where is the problem, SELinux blocking access for snmpd. I checked script with disabled selinux and it works.
If you do not want to disable snmp-module in selinux - then try create rules for it :D .


UPD: disable just snmp module in selinux:

Code: Select all

semodule -d snmp
systemctl restart snmpd
That is not the reason ...

Code: Select all

[root@rtr-XXXX ~]#  getenforce
Enforcing
[root@rtr-XXXX ~]# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   enforcing
Mode from config file:          disabled
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      28
[root@rtr-palata ~]# setenforce 0
[root@rtr-palata ~]# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   permissive
Mode from config file:          disabled
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      28
[root@rtr-XXXX ~]# sudo snmpwalk -v 2c XXX.XXX.XXX.XXX -c XXXXX .1.3.6.1.4.1.2021.190.1000.3
UCD-SNMP-MIB::ucdavis.190.1000.3.1.0 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.190.1000.3.1.0.1 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.190.1000.3.1.1.1 = INTEGER: 2
UCD-SNMP-MIB::ucdavis.190.1000.3.1.2.1 = STRING: "unknown"
UCD-SNMP-MIB::ucdavis.190.1000.3.1.3.1 = STRING: "n/a"
UCD-SNMP-MIB::ucdavis.190.1000.3.1.4.1 = STRING: "n/a"
UCD-SNMP-MIB::ucdavis.190.1000.3.1.5.1 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.190.1000.3.1.6.1 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.190.1000.3.1.7.1 = Gauge32: 0
UCD-SNMP-MIB::ucdavis.190.1000.3.1.8.1 = Gauge32: 0
UCD-SNMP-MIB::ucdavis.190.1000.3.1.9.1 = Gauge32: 0
UCD-SNMP-MIB::ucdavis.190.1000.3.1.10.1 = Gauge32: 0
UCD-SNMP-MIB::ucdavis.190.1000.3.1.11.1 = Gauge32: 0
UCD-SNMP-MIB::ucdavis.190.1000.3.2.0 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.190.1000.3.3.0 = INTEGER: 0
[root@rtr-XXXX ~]# getenforce
Permissive
[root@rtr-XXXX ~]#     
I have set SElinux in permissive mode and it didn't help with a problem. When I get in the office I will try to move the problematic files to some other location ...
User avatar
red_neon
Posts: 24
Joined: Sun Mar 21, 2010 11:50 pm
Location: Moscow, Russia

Re: Monitoring of BGP session via Quagga daemon in Linux

Post by red_neon »

Code: Select all

[root@localhost ~]# getenforce
Enforcing
[root@localhost ~]# snmpwalk -v 2c -c public 127.00.0.1 .1.3.6.1.4.1.2021.190.1000.3
UCD-SNMP-MIB::ucdavis.190.1000.3.1.0 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.190.1000.3.1.0.1 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.190.1000.3.1.1.1 = INTEGER: 2
UCD-SNMP-MIB::ucdavis.190.1000.3.1.2.1 = STRING: "unknown"
UCD-SNMP-MIB::ucdavis.190.1000.3.1.3.1 = STRING: "n/a"
UCD-SNMP-MIB::ucdavis.190.1000.3.1.4.1 = STRING: "n/a"
UCD-SNMP-MIB::ucdavis.190.1000.3.1.5.1 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.190.1000.3.1.6.1 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.190.1000.3.1.7.1 = Gauge32: 0
UCD-SNMP-MIB::ucdavis.190.1000.3.1.8.1 = Gauge32: 0
UCD-SNMP-MIB::ucdavis.190.1000.3.1.9.1 = Gauge32: 0
UCD-SNMP-MIB::ucdavis.190.1000.3.1.10.1 = Gauge32: 0
UCD-SNMP-MIB::ucdavis.190.1000.3.1.11.1 = Gauge32: 0
UCD-SNMP-MIB::ucdavis.190.1000.3.2.0 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.190.1000.3.3.0 = INTEGER: 0
[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce
Permissive
[root@localhost ~]# snmpwalk -v 2c -c public 127.00.0.1 .1.3.6.1.4.1.2021.190.1000.3
UCD-SNMP-MIB::ucdavis.190.1000.3.1.0 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.190.1000.3.1.0.1 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.190.1000.3.1.1.1 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.190.1000.3.1.2.1 = STRING: "0.99.22.4"
UCD-SNMP-MIB::ucdavis.190.1000.3.1.3.1 = STRING: "n/a"
UCD-SNMP-MIB::ucdavis.190.1000.3.1.4.1 = STRING: "n/a"
UCD-SNMP-MIB::ucdavis.190.1000.3.1.5.1 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.190.1000.3.1.6.1 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.190.1000.3.1.7.1 = Gauge32: 0
UCD-SNMP-MIB::ucdavis.190.1000.3.1.8.1 = Gauge32: 0
UCD-SNMP-MIB::ucdavis.190.1000.3.1.9.1 = Gauge32: 0
UCD-SNMP-MIB::ucdavis.190.1000.3.1.10.1 = Gauge32: 0
UCD-SNMP-MIB::ucdavis.190.1000.3.1.11.1 = Gauge32: 0
UCD-SNMP-MIB::ucdavis.190.1000.3.2.0 = INTEGER: 0
[root@localhost ~]# 

Code: Select all

[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-327.4.5.el7.x86_64 #1 SMP Mon Jan 25 22:07:14 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]# cat /etc/os-release 
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

[root@localhost ~]# 
"Imagination is more important than Knowledge."
gslavic
Posts: 8
Joined: Tue Feb 09, 2016 5:07 am

Re: Monitoring of BGP session via Quagga daemon in Linux

Post by gslavic »

Just menage to make it work !
There was evidently some systematic problem with SElinux.
semodule -d snmp was returning garbage messages, and refusing to go to permissive mod.

Now the output of the commands is as it should be ...

Code: Select all

[root@rtr-XXX ~]# sudo snmpwalk -v 2c XXX.XXX.XXX.XXX -c XXXX .1.3.6.1.4.1.2021.190.1000.3
UCD-SNMP-MIB::ucdavis.190.1000.3.1.0 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.190.1000.3.1.0.1 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.190.1000.3.1.1.1 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.190.1000.3.1.2.1 = STRING: "0.99.23.1"
UCD-SNMP-MIB::ucdavis.190.1000.3.1.3.1 = STRING: "XXX.XXX.XXX.XXX"
UCD-SNMP-MIB::ucdavis.190.1000.3.1.4.1 = STRING: "XXXXX"
UCD-SNMP-MIB::ucdavis.190.1000.3.1.5.1 = INTEGER: 45
UCD-SNMP-MIB::ucdavis.190.1000.3.1.6.1 = INTEGER: 37
UCD-SNMP-MIB::ucdavis.190.1000.3.1.7.1 = Gauge32: 602616
UCD-SNMP-MIB::ucdavis.190.1000.3.1.8.1 = Gauge32: 290111
UCD-SNMP-MIB::ucdavis.190.1000.3.1.9.1 = Gauge32: 1192498
UCD-SNMP-MIB::ucdavis.190.1000.3.1.10.1 = Gauge32: 98299
UCD-SNMP-MIB::ucdavis.190.1000.3.1.11.1 = Gauge32: 15798
UCD-SNMP-MIB::ucdavis.190.1000.3.2.0 = INTEGER: 6
UCD-SNMP-MIB::ucdavis.190.1000.3.2.1.1 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.190.1000.3.2.1.2 = INTEGER: 2
UCD-SNMP-MIB::ucdavis.190.1000.3.2.1.3 = INTEGER: 3
UCD-SNMP-MIB::ucdavis.190.1000.3.2.1.4 = INTEGER: 4
UCD-SNMP-MIB::ucdavis.190.1000.3.2.1.5 = INTEGER: 5
UCD-SNMP-MIB::ucdavis.190.1000.3.2.1.6 = INTEGER: 6
UCD-SNMP-MIB::ucdavis.190.1000.3.2.2.1 = INTEGER: 8
UCD-SNMP-MIB::ucdavis.190.1000.3.2.2.2 = INTEGER: 8
UCD-SNMP-MIB::ucdavis.190.1000.3.2.2.3 = INTEGER: 8
UCD-SNMP-MIB::ucdavis.190.1000.3.2.2.4 = INTEGER: 8
UCD-SNMP-MIB::ucdavis.190.1000.3.2.2.5 = INTEGER: 8
BUT now Cacti has "started to behave" irregularly !
Look at this !!!

Code: Select all

Data Query Debug Information
+ Running data query [18].
+ Found type = '3' [SNMP Query].
+ Found data query XML file at '/usr/share/cacti/site/resource/snmp_queries/snmp_quagga_bgpd_router_queries.xml'
+ XML file parsed ok.
+ Executing SNMP get for num of indexes @ '.1.3.6.1.4.1.2021.190.1000.3.1.0' Index Count: 1
+ Executing SNMP walk for list of indexes @ '.1.3.6.1.4.1.2021.190.1000.3.1.1' Index Count: 0
+ No SNMP data returned
AND

Code: Select all

Associated Data Queries
Data Query Name	Debugging	Re-Index Method	Status
1) rn - Quagga - Get BGP Neighbors Information	(Verbose Query)	Uptime Goes Backwards	Success [0 Items, 0 Rows]	Reload Data Query   Delete Data Query Association
2) rn - Quagga - Get BGP Router Information	(Verbose Query)	Uptime Goes Backwards	Success [0 Items, 0 Rows]	Reload Data Query   Delete Data Query Association
When I do the "walk" from the machine that is doing the cacti queries I am getting the normal result.

Code: Select all

root@SOX-4:~# sudo snmpwalk -v 2c XXX.XXX.XXX.XXX -c XXXXXX .1.3.6.1.4.1.2021.190.1000.3
UCD-SNMP-MIB::ucdavis.190.1000.3.1.0 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.190.1000.3.1.0.1 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.190.1000.3.1.1.1 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.190.1000.3.1.2.1 = STRING: "0.99.23.1"
UCD-SNMP-MIB::ucdavis.190.1000.3.1.3.1 = STRING: "XXX.XXX.XXX.XXX"
UCD-SNMP-MIB::ucdavis.190.1000.3.1.4.1 = STRING: "XXX"
UCD-SNMP-MIB::ucdavis.190.1000.3.1.5.1 = INTEGER: 45
UCD-SNMP-MIB::ucdavis.190.1000.3.1.6.1 = INTEGER: 37
UCD-SNMP-MIB::ucdavis.190.1000.3.1.7.1 = Gauge32: 602538
UCD-SNMP-MIB::ucdavis.190.1000.3.1.8.1 = Gauge32: 290061
UCD-SNMP-MIB::ucdavis.190.1000.3.1.9.1 = Gauge32: 1192370
UCD-SNMP-MIB::ucdavis.190.1000.3.1.10.1 = Gauge32: 98290
UCD-SNMP-MIB::ucdavis.190.1000.3.1.11.1 = Gauge32: 15799
UCD-SNMP-MIB::ucdavis.190.1000.3.2.0 = INTEGER: 6
UCD-SNMP-MIB::ucdavis.190.1000.3.2.1.1 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.190.1000.3.2.1.2 = INTEGER: 2
UCD-SNMP-MIB::ucdavis.190.1000.3.2.1.3 = INTEGER: 3
UCD-SNMP-MIB::ucdavis.190.1000.3.2.1.4 = INTEGER: 4
UCD-SNMP-MIB::ucdavis.190.1000.3.2.1.5 = INTEGER: 5
UCD-SNMP-MIB::ucdavis.190.1000.3.2.1.6 = INTEGER: 6
UCD-SNMP-MIB::ucdavis.190.1000.3.2.2.1 = INTEGER: 8
UCD-SNMP-MIB::ucdavis.190.1000.3.2.2.2 = INTEGER: 8
UCD-SNMP-MIB::ucdavis.190.1000.3.2.2.3 = INTEGER: 8
UCD-SNMP-MIB::ucdavis.190.1000.3.2.2.4 = INTEGER: 8
UCD-SNMP-MIB::ucdavis.190.1000.3.2.2.5 = INTEGER: 8
UCD-SNMP-MIB::ucdavis.190.1000.3.2.2.6 = INTEGER: 5
UCD-SNMP-MIB::ucdavis.190.1000.3.2.3.1 = STRING: "[8] Neighbors"
UCD-SNMP-MIB::ucdavis.190.1000.3.2.3.2 = STRING: "[8] Neighbors"
UCD-SNMP-MIB::ucdavis.190.1000.3.2.3.3 = STRING: "[8] Neighbors"
UCD-SNMP-MIB::ucdavis.190.1000.3.2.3.4 = STRING: "[8] Neighbors"
UCD-SNMP-MIB::ucdavis.190.1000.3.2.3.5 = STRING: "[8] Neighbors"
UCD-SNMP-MIB::ucdavis.190.1000.3.2.3.6 = STRING: "[8] Neighbors"
UCD-SNMP-MIB::ucdavis.190.1000.3.2.4.1 = STRING: "1"
UCD-SNMP-MIB::ucdavis.190.1000.3.2.4.2 = STRING: "1"
UCD-SNMP-MIB::ucdavis.190.1000.3.2.4.3 = STRING: "1"
UCD-SNMP-MIB::ucdavis.190.1000.3.2.4.4 = STRING: "1"


BUT the cacti simply does not recognize the fact that there is a lot more data in that "walk".

I feel the need to thank you for your time and patience :-)

Best regards,
Goran Slavic
Serbian Open eXhange
User avatar
red_neon
Posts: 24
Joined: Sun Mar 21, 2010 11:50 pm
Location: Moscow, Russia

Re: Monitoring of BGP session via Quagga daemon in Linux

Post by red_neon »

gslavic, good!

Do other queries work? I mean standard templates like traffic etc.
snmp_quagga_bgpd_router_queries.xml is a small table, i think your Cacti could not run snmpwalk cmd, try check path in settings /cacti/settings.php?tab=path




P.S.
I added problem solution with SELinux to first post :)


# !!! WARNING !!! If your linux are used SELinux (like CentOS), you must disable policy for snmp (or create a new policy yourself)
# For disable snmp-module in SELinux:
# $ semodule -d snmp
# $ systemctl restart snmpd
#
"Imagination is more important than Knowledge."
ahouston
Posts: 6
Joined: Wed Jul 12, 2006 5:41 am

[FIX] - MySQL Problem with 'Get BGP Neighbors Information'

Post by ahouston »

Hoping this helps someone - I ran into a problem on an Ubuntu 13.03 installation with MySQL version 5.5.41, although I suspect this affects some other versions.

The short story is that the snmp_quagga_bgpd_neighbors_queries.xml uses 'index' as a field name which MySQL throws its toys out the cot about, presumably this is a reserved word.

There is a mysql assoc error in the logs which gives a little more info when you run the query manually:

Code: Select all

mysql> use cacti
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> SELECT * FROM (SELECT host_id, snmp_query_id, snmp_index, MAX(CASE WHEN field_name='as_number' THEN field_value ELSE NULL END) AS 'as_number', MAX(CASE WHEN field_name='bgp_router' THEN field_value ELSE NULL END) AS 'bgp_router', MAX(CASE WHEN field_name='ifOperStatus' THEN field_value ELSE NULL END) AS 'ifOperStatus', MAX(CASE WHEN field_name='index' THEN field_value ELSE NULL END) AS 'index', MAX(CASE WHEN field_name='num_of_neighbors' THEN field_value ELSE NULL END) AS 'num_of_neighbors', MAX(CASE WHEN field_name='peer1_desc' THEN field_value ELSE NULL END) AS 'peer1_desc', MAX(CASE WHEN field_name='peer2_desc' THEN field_value ELSE NULL END) AS 'peer2_desc', MAX(CASE WHEN field_name='peer3_desc' THEN field_value ELSE NULL END) AS 'peer3_desc', MAX(CASE WHEN field_name='peer4_desc' THEN field_value ELSE NULL END) AS 'peer4_desc', MAX(CASE WHEN field_name='quagga_ver' THEN field_value ELSE NULL END) AS 'quagga_ver', MAX(CASE WHEN field_name='type_graph' THEN field_value ELSE NULL END) AS 'type_graph' FROM host_snmp_cache WHERE host_id=916 AND snmp_query_id=24 GROUP BY host_id, snmp_query_id, snmp_index ) AS results ORDER BY CAST(index AS unsigned) LIMIT 0,30;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'index AS unsigned) LIMIT 0,30' at line 1

I changed snmp_quagga_bgpd_neighbors_queries.xml to replace 'index' with 'idx' and it solved the problem:

Code: Select all

<interface>
        <name>Quagga BGPD Monitoring (Neighbors Info)</name>
        <description>Monitoring of BGP session via Quagga daemon in Linux.</description>
        <oid_index>.1.3.6.1.4.1.2021.190.1000.3.2.1</oid_index>
        <oid_num_indexes>.1.3.6.1.4.1.2021.190.1000.3.2.0</oid_num_indexes>
        <index_order>idx</index_order>
        <index_order_type>numeric</index_order_type>
        <index_title_format>|chosen_order_field|</index_title_format>

        <fields>
                <idx>
                        <name>Group</name>
                        <method>walk</method>
                        <source>value</source>
                        <direction>input</direction>
                        <oid>.1.3.6.1.4.1.2021.190.1000.3.2.1</oid>
                </idx>
I've attached the modified files, as you need to also update the cacti_data_query_rn_-_quagga_-_get_bgp_neighbors_information.xml to get the field carrying through to the graph template correctly.
Attachments
quagga_bgpd_mon_v1.0a_fix.zip
(225.06 KiB) Downloaded 103 times
User avatar
red_neon
Posts: 24
Joined: Sun Mar 21, 2010 11:50 pm
Location: Moscow, Russia

Re: [FIX] - MySQL Problem with 'Get BGP Neighbors Informatio

Post by red_neon »

ahouston wrote:

Code: Select all

mysql> use cacti
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> SELECT * FROM (SELECT host_id, snmp_query_id, snmp_index, MAX(CASE WHEN field_name='as_number' THEN field_value ELSE NULL END) AS 'as_number', MAX(CASE WHEN field_name='bgp_router' THEN field_value ELSE NULL END) AS 'bgp_router', MAX(CASE WHEN field_name='ifOperStatus' THEN field_value ELSE NULL END) AS 'ifOperStatus', MAX(CASE WHEN field_name='index' THEN field_value ELSE NULL END) AS 'index', MAX(CASE WHEN field_name='num_of_neighbors' THEN field_value ELSE NULL END) AS 'num_of_neighbors', MAX(CASE WHEN field_name='peer1_desc' THEN field_value ELSE NULL END) AS 'peer1_desc', MAX(CASE WHEN field_name='peer2_desc' THEN field_value ELSE NULL END) AS 'peer2_desc', MAX(CASE WHEN field_name='peer3_desc' THEN field_value ELSE NULL END) AS 'peer3_desc', MAX(CASE WHEN field_name='peer4_desc' THEN field_value ELSE NULL END) AS 'peer4_desc', MAX(CASE WHEN field_name='quagga_ver' THEN field_value ELSE NULL END) AS 'quagga_ver', MAX(CASE WHEN field_name='type_graph' THEN field_value ELSE NULL END) AS 'type_graph' FROM host_snmp_cache WHERE host_id=916 AND snmp_query_id=24 GROUP BY host_id, snmp_query_id, snmp_index ) AS results ORDER BY CAST(index AS unsigned) LIMIT 0,30;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'index AS unsigned) LIMIT 0,30' at line 1
ahouston, just put index into ' ' in your request, like

Code: Select all

'index' AS unsigned
;)
"Imagination is more important than Knowledge."
ahouston
Posts: 6
Joined: Wed Jul 12, 2006 5:41 am

Re: [FIX] - MySQL Problem with 'Get BGP Neighbors Informatio

Post by ahouston »

red_neon wrote:
ahouston, just put index into ' ' in your request, like

Code: Select all

'index' AS unsigned
;)
<Nods> - I tested this running the query manually. The problem is (I stand to be corrected on this) that I believe the query is built by Cacti automatically from the query's XML, so fixing this would involve fixing Cacti's source code which isn't the optimal solution as an update to Cacti could break things again unless it's addressed upstream.

This suspect that this might be a bug in Cacti 0.8.8g where MySQL reserved words need to be enclosed in quotes, but it seemed much easier to work around it in the template than to trawl through the code.

Awesome work by the way, my graphs are looking super sweet!
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests