About cookies on this site Our websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising. For more information, please review your options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.
Question & Answer
Question
How to add a custom graph (cacti fundamentals) I want to graph the number of users logged on to each LSF host. How to do that in RTM?
Answer
This can be achieved in RTM. The major steps are:

1) Write a script (which will collect data from the LSF hosts)
2) Write a Data Input Method (to execute the script and return data to cacti)
3) Write a Data Template (To define RRDfile data sources and RRA settings and link to the Data Input Method)
4) Write a Graph Template (to define your Graphs, graph items, look and feel etc)
5) Associate Graph Template with a Host Template (For future automation for any new hosts, add it to Grid Host template)
6) Create a graph to check if it works
Step 1) Create a script:
# ownership - root:root permissions - 644 # cat /opt/IBM/cacti/scripts/loggedinusers.sh #!/bin/sh count=`rsh $1 who | wc -l` echo $count
Step 2) Create a Data Input Method:
From Console -> Collection Methods -> Data Input Method -> Click Add (on upper right)
Choose a Name, "Script/Command" and Input String

Press Save.
Now define the Input field by pressing Add and later saving it:

Also, define your output field, which is the variable to store the output of the script (by pressing add and later saving it):

Step 3: Create a Data Template
From Console -> Templates -> Data Templates -> Add
Choose the Data Input Method you created in the previous step. Also, for the Data Source Name, use the format |host_description| which will be automatically populated by cacti to create multiple data sources, one per host. Press Save to

Step 4) Create a Graph Template
From Console -> Templates -> Graph Template -> Add
Define the construction of the graph as below.

Step 5) Associate Graph Template to a Host Template
From Console -> Templates -> Host Templates -> Click Grid Host -> Associated Graph Templates
From the drop down menu, choose the Graph Template created in previous step. Press Add to add it. Press Save

Now any new host that is added to the cluster will automatically have this graph.
Step 6) To create graphs for existing hosts
From Console -> Devices -> Click Any Grid Host Device -> Associated Graph Templates -> Add the graphs template created before and press Save.
On the top, click "Create Graphs for this Host" and Check the box for this graph and press "Create" button.

You see a message that Graph has been created.

Now wait for 10 mins (2 polling cycles) and you start to see data in the graphs
Note: Since poller is running as Apache (nologin user) which sometimes does not have rsh permissions to run commands on other hosts, if root is needed, the following can be done:
# cat /opt/IBM/cacti/scripts/runasroot.c # create this file #include <stdio.h> main(int argc, const char *argv[]) { setuid(0); if(argc == 2) execl("/usr/bin/rsh", argv[1], "/usr/bin/who | wc -l", (char *) 0); else printf("This script requires 1 argument <hostname>"); }
# gcc runasroot.c -o runasroot # chown root:root runasroot # chmod +s runasroot
In Console -> Collection Methods -> Data Input Methods -> Click the data input method created previously, in the input string section, put the executable name as below. Poller cache is modified automatically on Save.

Related Information
[{"Product":{"code":"SSVMSD","label":"Platform RTM"},"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Component":"Graphs","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"9.1.0;9.1.2;9.1.3;9.1.4","Edition":"","Line of Business":{"code":"","label":""}},{"Product":{"code":"SSZT2D","label":"IBM Spectrum LSF RTM"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":" ","Platform":[{"code":"","label":""}],"Version":"","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}},{"Product":{"code":"SSZT2D","label":"IBM Spectrum LSF RTM"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":" ","Platform":[{"code":"","label":""}],"Version":"","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]
Was this topic helpful?
Document Information
More support for:
Platform RTM
Software version:
9.1.0, 9.1.2, 9.1.3, 9.1.4
Document number:
628557
Modified date:
12 April 2021
UID
isg3T1023544
Manage My Notification Subscriptions