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    


cacti qmail-qstat via tcpserver

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



Joined: 06 May 2008
Posts: 4

PostPosted: Tue May 06, 2008 4:58 am    Post subject: cacti qmail-qstat via tcpserver Reply with quote

The qmail system has a command /var/qmail/bin/qmail-qstat which shows the number of messages in your mail queue, and also the number of unprocessed messages; I've graphed both these numbers on a single chart as follows:

Steps 3 and 4 can be skipped if you import the attached xml template files.

1. Create a daemontools service for providing the qmail-qstat results over tcpip:

mkdir -p /service/.qmail-qstat
mv qmail-qstat-service-run.sh /service/.qmail-qstat/run
chmod 755 /service/.qmail-qstat/run
mv /service/.qmail-qstat /service/qmail-qstat
sleep 5
svstat /service/qmail-qstat

2. Place qmailq.pl into scripts/qmailq.pl, this is a modified file from the original author Jeremy Garcia; it now calls `nc 127.0.0.1 82' to collect the output of /var/qmail/bin/qmail-qstat

3. Go into the cacti console gui and under the Templates area, click Data Templates. Make a new template named qmail-qstat with data source items 'messages' and 'unprocessed'. If you're new to cacti you want to fashion this after the load average example.

4. Still under the cacti console gui for the Templates area subheading, click Graph templates. This one is a bit more involved so the short explanation is to fashion it after the load average example, and to key on the 'messages' and 'unprocessed' names. Set your colors like red for the messages value, and yellow for the unprocessed value.

5. Console gui, Collection Methods area, click on Data Input methods. You're adding a qmail-qstat entry that will be a Script/Command with the following input string: perl <path_cacti>/scripts/qmailq.pl and there are no input strings, however for output strings you need to add 'messages' and 'unprocessed'

6. Under the console Management section, Data Sources, add a new entry for qmail-qstat which pulls from the data template area you just created. Look for the option to turn on data source debug mode at the top right of your cacti screen. It will show the rrdtool create command you should try to run manually in /var/lib/cacti/rra or similar directory, in case of any problems; check your permissions!

7. Add the new graph under console area Management section, then Graph Management. You will be pulling the data from the data source you just defined. The graph is generated from the rra file that already exists; the main cacti poller script that you run every 5 minutes is updating that rra file with new values.

I've attached the data and graph templates for qmail-qstat as well, which you can import into cacti as .xml files. If anyone sees anything to clean up please do so and repost your solution. I like this approach because you no longer need an suid script; the stats are pulled in over tcp over a service that is guaranteed to run properly, under daemontools.



qmail-qstat-service-run.sh
 Description:

Download
 Filename:  qmail-qstat-service-run.sh
 Filesize:  95 Bytes
 Downloaded:  62 Time(s)


cacti_graph_template_qmail-qstat.xml
 Description:

Download
 Filename:  cacti_graph_template_qmail-qstat.xml
 Filesize:  8.51 KB
 Downloaded:  59 Time(s)


cacti_data_template_qmail-qstat.xml
 Description:

Download
 Filename:  cacti_data_template_qmail-qstat.xml
 Filesize:  3.81 KB
 Downloaded:  45 Time(s)


qmailq.pl
 Description:

Download
 Filename:  qmailq.pl
 Filesize:  776 Bytes
 Downloaded:  48 Time(s)

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