Cacti (home)ForumsRepositoryDocumentation
Cacti: offical forums and support  

 FAQFAQ   SearchSearch   MemberlistMemberlist    RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in    


Script Queries important question

 
Post new topic   Reply to topic    Cacti Forum Index -> Scripts and Templates
Author Message
leventkurt



Joined: 07 Jul 2008
Posts: 9

PostPosted: Thu Jul 24, 2008 8:35 am    Post subject: Script Queries important question Reply with quote

Hi there,

I wanted to create my own E1-Line script to learn how cacti script queries are working and fill my company's need for e1 graphs.

I'll write everthing down one-by-one to let you see what's really missing and find me a solution:

1- Created a basic data template, left in default and changed followings:
name: "e1 line data template"
data source name: "e1 line data source"
method: "get script data (indexed)"
internal source name: e1line

2- Created a basic graph template, dupped from "Windows - Logged in Users" graph template. Then I changed graph area sources into e1line data sources.

3- Created a data query with the following:
name: SNMP - E1
desc: SNMP - E1 Connections
xml: <path_cacti>/resource/script_queries/e1.xml
method: get script data (indexed)
associated new e1 graph template

4- Created XML file <path_cacti>/resource/script_queries/e1.xml
Code:

<e1s>
        <name>Get E1 Lines</name>
        <description>Gets E1 Lines on a device.</description>
        <script_path>|path_cacti|/scripts/query_e1.sh</script_path>
        <arg_prepend>|host_hostname| '|host_snmp_community|'</arg_prepend>
        <arg_index>index</arg_index>
        <arg_query>query</arg_query>
        <arg_get>get</arg_get>
        <arg_num_indexes>num_indexes</arg_num_indexes>
        <output_delimeter>!</output_delimeter>
        <index_order>e1name</index_order>
        <index_order_type>alphabetic</index_order_type>
        <index_title_format>|chosen_order_field|</index_title_format>

        <fields>
                <e1name>
                        <name>Device Name</name>
                        <direction>input</direction>
                        <query_name>e1name</query_name>
                </e1name>
                <status>
                        <name>Status</name>
                        <direction>input</direction>
                        <query_name>status</query_name>
                </status>
                <alias>
                        <name>Alias</name>
                        <direction>input</direction>
                        <query_name>alias</query_name>
                </alias>

                <total>
                        <name>Total</name>
                        <direction>output</direction>
                        <query_name>total</query_name>
                </total>
        </fields>
</e1s>


Note: I used '|host_snmp_community|' instead of |host_snmp_community| because some routers have & sign in community names.

5- Created |path_cacti|/scripts/query_e1.sh file, with following outputs:
Code:

# /apache/apache-2.0.63/htdocs/cacti/scripts/query_e1.sh X.X.X.X 'YYYY' index
16

# /apache/apache-2.0.63/htdocs/cacti/scripts/query_e1.sh X.X.X.X 'YYYY' index 
6.0
6.1
6.2
6.3
6.4
6.5
6.6
6.7
7.0
7.1
7.2
7.3
7.4
7.5
7.6
7.7

# /apache/apache-2.0.63/htdocs/cacti/scripts/query_e1.sh X.X.X.X 'YYYY' query e1name
6.0!6.0
6.1!6.1
6.2!6.2
6.3!6.3
6.4!6.4
6.5!6.5
6.6!6.6
6.7!6.7
7.0!7.0
7.1!7.1
7.2!7.2
7.3!7.3
7.4!7.4
7.5!7.5
7.6!7.6
7.7!7.7

# /apache/apache-2.0.63/htdocs/cacti/scripts/query_e1.sh X.X.X.X 'YYYY' query status
6.0!up
6.1!up
6.2!up
6.3!up
6.4!up
6.5!up
6.6!down
6.7!down
7.0!down
7.1!down
7.2!down
7.3!down
7.4!down
7.5!down
7.6!down
7.7!down

# /apache/apache-2.0.63/htdocs/cacti/scripts/query_e1.sh X.X.X.X 'YYYY' query alias
6.0!Vodafone Voice E1 DDF:1
6.1!Vodafone Voice E1 DDF:2
6.2!Vodafone Voice E1 DDF:3
6.3!Vodafone Voice E1 DDF:4
6.4!Vodafone Voice E1 DDF:5
6.5!Vodafone Voice E1 DDF:6
6.6!
6.7!
7.0!
7.1!
7.2!
7.3!
7.4!
7.5!
7.6!
7.7!

# /apache/apache-2.0.63/htdocs/cacti/scripts/query_e1.sh X.X.X.X 'YYYY' get total 6.0
11
# /apache/apache-2.0.63/htdocs/cacti/scripts/query_e1.sh X.X.X.X 'YYYY' get total 6.1
19
# /apache/apache-2.0.63/htdocs/cacti/scripts/query_e1.sh X.X.X.X 'YYYY' get total 6.2
15
# /apache/apache-2.0.63/htdocs/cacti/scripts/query_e1.sh X.X.X.X 'YYYY' get total 6.3
18
# /apache/apache-2.0.63/htdocs/cacti/scripts/query_e1.sh X.X.X.X 'YYYY' get total 6.4
25
# /apache/apache-2.0.63/htdocs/cacti/scripts/query_e1.sh X.X.X.X 'YYYY' get total 6.5
26
# /apache/apache-2.0.63/htdocs/cacti/scripts/query_e1.sh X.X.X.X 'YYYY' get total 6.6
# /apache/apache-2.0.63/htdocs/cacti/scripts/query_e1.sh X.X.X.X 'YYYY' get total 6.7
# /apache/apache-2.0.63/htdocs/cacti/scripts/query_e1.sh X.X.X.X 'YYYY' get total 7.0
# /apache/apache-2.0.63/htdocs/cacti/scripts/query_e1.sh X.X.X.X 'YYYY' get total 7.1
# /apache/apache-2.0.63/htdocs/cacti/scripts/query_e1.sh X.X.X.X 'YYYY' get total 7.2
# /apache/apache-2.0.63/htdocs/cacti/scripts/query_e1.sh X.X.X.X 'YYYY' get total 7.3
# /apache/apache-2.0.63/htdocs/cacti/scripts/query_e1.sh X.X.X.X 'YYYY' get total 7.4
# /apache/apache-2.0.63/htdocs/cacti/scripts/query_e1.sh X.X.X.X 'YYYY' get total 7.5
# /apache/apache-2.0.63/htdocs/cacti/scripts/query_e1.sh X.X.X.X 'YYYY' get total 7.6
# /apache/apache-2.0.63/htdocs/cacti/scripts/query_e1.sh X.X.X.X 'YYYY' get total 7.7


6- I added this data query to device X.X.X.X, and problem begins

It says "Success [48 Items, 16 Rows]" for the query; but if I click to "Create graph for this host" it says "This data query returned 0 rows, perhaps there was a problem executing this data query. You can run this data query in debug mode to get more information."

I did the debug, but found nothing suspecious:
Code:

+ Running data query [12].
+ Found type = '4 '[script query].
+ Found data query XML file at '/apache/apache-2.0.63/htdocs/cacti/resource/script_queries/e1.xml'
+ XML file parsed ok.
+ Executing script for list of indexes '/apache/apache-2.0.63/htdocs/cacti/scripts/query_e1.sh X.X.X.X 'YYYY' index'
+ Executing script query '/apache/apache-2.0.63/htdocs/cacti/scripts/query_e1.sh X.X.X.X 'YYYY' query e1name'
+ Found item [e1name='6.0'] index: 6.0
+ Found item [e1name='6.1'] index: 6.1
+ Found item [e1name='6.2'] index: 6.2
+ Found item [e1name='6.3'] index: 6.3
+ Found item [e1name='6.4'] index: 6.4
+ Found item [e1name='6.5'] index: 6.5
+ Found item [e1name='6.6'] index: 6.6
+ Found item [e1name='6.7'] index: 6.7
+ Found item [e1name='7.0'] index: 7.0
+ Found item [e1name='7.1'] index: 7.1
+ Found item [e1name='7.2'] index: 7.2
+ Found item [e1name='7.3'] index: 7.3
+ Found item [e1name='7.4'] index: 7.4
+ Found item [e1name='7.5'] index: 7.5
+ Found item [e1name='7.6'] index: 7.6
+ Found item [e1name='7.7'] index: 7.7
+ Executing script query '/apache/apache-2.0.63/htdocs/cacti/scripts/query_e1.sh X.X.X.X 'YYYY' query status'
+ Found item [status='up'] index: 6.0
+ Found item [status='up'] index: 6.1
+ Found item [status='up'] index: 6.2
+ Found item [status='up'] index: 6.3
+ Found item [status='up'] index: 6.4
+ Found item [status='up'] index: 6.5
+ Found item [status='down'] index: 6.6
+ Found item [status='down'] index: 6.7
+ Found item [status='down'] index: 7.0
+ Found item [status='down'] index: 7.1
+ Found item [status='down'] index: 7.2
+ Found item [status='down'] index: 7.3
+ Found item [status='down'] index: 7.4
+ Found item [status='down'] index: 7.5
+ Found item [status='down'] index: 7.6
+ Found item [status='down'] index: 7.7
+ Executing script query '/apache/apache-2.0.63/htdocs/cacti/scripts/query_e1.sh X.X.X.X 'YYYY' query alias'
+ Found item [alias='Vodafone Voice E1 DDF:1'] index: 6.0
+ Found item [alias='Vodafone Voice E1 DDF:2'] index: 6.1
+ Found item [alias='Vodafone Voice E1 DDF:3'] index: 6.2
+ Found item [alias='Vodafone Voice E1 DDF:4'] index: 6.3
+ Found item [alias='Vodafone Voice E1 DDF:5'] index: 6.4
+ Found item [alias='Vodafone Voice E1 DDF:6'] index: 6.5
+ Found item [alias=''] index: 6.6
+ Found item [alias=''] index: 6.7
+ Found item [alias=''] index: 7.0
+ Found item [alias=''] index: 7.1
+ Found item [alias=''] index: 7.2
+ Found item [alias=''] index: 7.3
+ Found item [alias=''] index: 7.4
+ Found item [alias=''] index: 7.5
+ Found item [alias=''] index: 7.6
+ Found item [alias=''] index: 7.7
+ Found data query XML file at '/apache/apache-2.0.63/htdocs/cacti/resource/script_queries/e1.xml'
+ Found data query XML file at '/apache/apache-2.0.63/htdocs/cacti/resource/script_queries/e1.xml'
+ Found data query XML file at '/apache/apache-2.0.63/htdocs/cacti/resource/script_queries/e1.xml'


Do I miss something?

Thanks from now.
Back to top
leventkurt



Joined: 07 Jul 2008
Posts: 9

PostPosted: Thu Jul 24, 2008 5:27 pm    Post subject: Reply with quote

I retried all of the above and managed to list all E1 interfaces with a script (ss1.jpg)

But It doesn't create a rrd file (ss3.jpg)? if I copy the line from data source and create manually it doesnt update the file neither?

In the example cacti should send
Code:

/apache/apache-2.0.63/htdocs/cacti/scripts/query_e1.sh X.X.X.X 'YYYY' get total 4.5


to the script to get and fill the value, but script's log doesn't show an incoming request?



ss1.JPG
 Description:
 Filesize:  65.5 KB
 Viewed:  1117 Time(s)

ss1.JPG



ss2.JPG
 Description:
 Filesize:  81.99 KB
 Viewed:  1117 Time(s)

ss2.JPG



ss3.JPG
 Description:
 Filesize:  111.75 KB
 Viewed:  1117 Time(s)

ss3.JPG


Back to top
leventkurt



Joined: 07 Jul 2008
Posts: 9

PostPosted: Fri Jul 25, 2008 3:15 am    Post subject: Reply with quote

Hi again, the problem still continuing:

1- Cacti did not create a rrd file for this script query associated graphs
2- If I create manually the rrd file, numbers stay in NAN status
3- I have a line,
Code:

date=`date +'%F %T'`
echo "$date >> $0 $1 $2 $3 $4 $5" >> /apache/apache-2.0.63/htdocs/cacti/scripts/query_e1.log

In my script so that i can see incoming requests, as I said there is no request with a get line.

I attach some more screen shots to help you to help me out.



ss_1.JPG
 Description:
I tried with and without "total" in query type id nothing changed.
 Filesize:  112.8 KB
 Viewed:  1099 Time(s)

ss_1.JPG



ss_2.JPG
 Description:
 Filesize:  128.29 KB
 Viewed:  1099 Time(s)

ss_2.JPG



ss_3.JPG
 Description:
 Filesize:  61.15 KB
 Viewed:  1099 Time(s)

ss_3.JPG



ss_4.JPG
 Description:
 Filesize:  68.36 KB
 Viewed:  1099 Time(s)

ss_4.JPG


Back to top
TheWitness
Developer


Joined: 14 May 2002
Posts: 9671
Location: MI, USA

PostPosted: Fri Jul 25, 2008 12:27 pm    Post subject: Reply with quote

First, you don't need the word "total" in your data template (the one with the circle around it).

Second, you should get the updated template.php from branches/0.8.7/lib/teplate.php SVN as it corrects a rather nasty bug when modifying data template. There is also another file, branches/0.8.7/utilities.php that should be updated.

Then, you should "Repopulate" your poller cache and look for entries in the Poller Cache with your script name. If you see them in there, that means they are being polled.

TheWitness
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Cacti Forum Index -> Scripts and Templates All times are GMT - 5 Hours
Page 1 of 1

 



Powered by phpBB © 2001, 2005 phpBB Group