US: 1-941-4621-069
  
Cyprus: 3-572-2052-781

Go Back   ISPsystem.com Forums > ISPmanager > Troubleshooting

Notices

Reply
 
Thread Tools
Old 09-03-2009, 11:50 PM   #1
Junior Member
 
Join Date: Aug 2009
Posts: 24
getnetworks is on a distinguished road
Default Adding items to ISPmanager menu

We've been going through the docs on how to add items to the ISPmanager menu and we have one problem and one recommendation:

1) The docs state this:

"As a category name use the value of the name attribute of the XML-node node for appropriate category of the navigation menu described in /usr/local/ispmgr/etc/ispmgr_menu.xml."

Unfortunately there's no such file on the server. We're guessing that in the example "tool" isn't a valid name as we don't seem to be getting the menu item showing up in ISPmanager, but since that noted file doesn't exist, we have no idea what the value needs to be.

2) In the sample code on the docs page (and the supplied .xml files in the /usr/local/ispmgr/etc/ directory), can you please make sure each element is on a new line. Having all of the elements on one line makes it very difficult to go through the code, and in the case of supplied language files such as /usr/local/*mgr/etc/*.xml, it is very necessary, as we clean up some of the badly-translated content, grammatical errors, etc., and properly having the elements one-to-a-line will greatly help in running diffs between old and new versions of the originals so we can determine what lines need to update in our versions of those files (in case new elements are added, old elements have name changes, etc.).

Thank you in advance. The sooner we can get an answer to #1, the sooner we can continue our testing, so please assist ASAP.
getnetworks is offline   Reply With Quote
Old 09-04-2009, 06:02 AM   #2
ISPsystem team
 
Join Date: Jan 2009
Posts: 111
GakcaT is on a distinguished road
Default

1) Unfortunately, there is old offline version of documentation in ISPmanager. Now you can see revised version of documentation at http://www.ispsystem.com/en/software...documentation/. But at the present time there isn't any information about ISPmanager API on this website.
Information about menu levels is located in /usr/local/ispmgr/etc/ispmgr.xml file.
What are your working hours? We have a difference in time zones, I'll try answer on your questions ASAP.

2) Do you mean "Nodes are placed on new lines and their values are placed on the same lines"? We store all nodes on new lines. Also we handle these *.xml files (look for changes, mistakes and etc.). This is not a problem.

Last edited by tanya; 09-07-2009 at 04:10 AM.
GakcaT is offline   Reply With Quote
Old 09-08-2009, 07:48 PM   #3
Junior Member
 
Join Date: Aug 2009
Posts: 24
getnetworks is on a distinguished road
Default

Quote:
Originally Posted by GakcaT View Post
1) Unfortunately, there is old offline version of documentation in ISPmanager. Now you can see revised version of documentation at http://www.ispsystem.com/en/software...documentation/. But at the present time there isn't any information about ISPmanager API on this website.
Information about menu levels is located in /usr/local/ispmgr/etc/ispmgr.xml file.
What are your working hours? We have a difference in time zones, I'll try answer on your questions ASAP.
Thank you. We're usually available from 8am-2am EST.

We've made some progress on this topic and have created our test scenario of adding an item; however, the docs are very lacking in the toolbar button to column data area. We've managed to get the column data via a CGI to present the XML data properly, but we cannot seem to figure out how to interact with the toolbar buttons.

Essentially, we have 3 buttons (start/stop/restart) and the column data present a single line of information. We cannot figure out how to have the buttons interact with that data. When the page loads, all buttons are disabled, and when we click on the single item in the column data, the buttons activate, but if we click on any of the buttons, nothing happens. What is actually going on behind the scenes when a button is created, i.e., what kind of POST/GET request is made and with what specific data?

Ideally, we'd like for the system to recognize that the item is 'running' (we have a status in one of our columns) and then only activate the stop/restart buttons if it is running. If the status is reporting 'stopped', then only the start/restart buttons activate. But of course, before we can even pursue that possibility, we just need the buttons to actually work.


Quote:
Originally Posted by GakcaT View Post
2) Do you mean "Nodes are placed on new lines and their values are placed on the same lines"? We store all nodes on new lines. Also we handle these *.xml files (look for changes, mistakes and etc.). This is not a problem.
The grammar, terminology, etc. are not suitable for our service and customers (your russian-to-english translations are not quite accurate and our customers are used to different terminology), so we need to be able to update those .xml files accordingly. We don't mind doing so, as long as we can track any changes in your versions of it between upgrades/releases; however, you do not have each element on a single line, so tracking becomes very difficult. For example, you might currently have something like the following:

---
...
</message><messages name="messagesname1">
<msg name="msgname1">String for name1</msg>
<msg name="msgname2">String for name2</msg>
<msg name="msgname3">String for name3</msg><msg name="msgname4">String for name4</msg><msg name="msgname5">String for name5</msg>
</message><messages name="messagesname2">
...
---

As you can see above, you have the closing tag for the previous messages element on the same line as the next messages element opening tag, as well as having *3* msg elements on one line. This poses us a problem as in some cases you have more than 100 elements on a single line in the xml files and if just one of them changes between your releases, the diff reports that the line with 100 elements has changed, but we then need to manually review that single line to figure out what actually changed, which is very time-consuming. What we need is for your xml files to cleanly have a single element on each line, such as:

---
...
</messages>
<messages name="messagesname1">
<msg name="msgname1">String for name1</msg>
<msg name="msgname2">String for name2</msg>
<msg name="msgname3">String for name3</msg>
<msg name="msgname4">String for name4</msg>
<msg name="msgname5">String for name5</msg>
</messages>
<messages name="messagesname2">
...
---

Thank you for your attention to this matter.
getnetworks is offline   Reply With Quote
Old 09-09-2009, 12:04 PM   #4
ISPsystem team
 
Join Date: Jan 2009
Posts: 111
GakcaT is on a distinguished road
Default

1) I'll write an working example (with extended explanations) and publish it a little bit later.

2) We aren't going to change the current .xml files structure.
Quote:
Originally Posted by getnetworks
The grammar, terminology, etc. are not suitable for our service and customers (your russian-to-english translations are not quite accurate and our customers are used to different terminology), so we need to be able to update those .xml files accordingly. We don't mind doing so, as long as we can track any changes in your versions of it between upgrades/releases
All questions about transalation you can discuss with tanya via email.
GakcaT is offline   Reply With Quote
Old 09-09-2009, 06:32 PM   #5
Junior Member
 
Join Date: Aug 2009
Posts: 24
getnetworks is on a distinguished road
Default

Quote:
Originally Posted by GakcaT View Post
1) I'll write an working example (with extended explanations) and publish it a little bit later.
Excellent, but we only have 4 days left on our trial.

Quote:
Originally Posted by GakcaT View Post
2) We aren't going to change the current .xml files structure.
I'm not asking you to "change the structure", I'm asking you to "clean up the code" so that you don't have single lines with many elements (quite simply, just making sure to put a carriage return in after each element as dictated by *proper* XML formatting).
getnetworks is offline   Reply With Quote
Old 09-14-2009, 11:36 AM   #6
ISPsystem team
 
Join Date: Jan 2009
Posts: 111
GakcaT is on a distinguished road
Default

This small example reads information about services from /tmp/services.txt and allows to stop/start/edit the services. Also you can add/delete services with the plugin.
1) Add information about services to /tmp/services.txt. For example:
httpd /etc/init.d/httpd
mysqld /etc/init.d/mysqld

2) The content of ispmgr_mod_myplugin.xml file:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<mgrdata>
        <handler name="servstate.pl" type="cgi">
                <func>service_management</func>
                <func>service_management.start</func>
                <func>service_management.stop</func>
                <func>service_management.edit</func>
                <func>service_management.delete</func>
        </handler>

        <mainmenu level="7">
                <node name="tool">
                        <node name="service_management"/>
                </node>
        </mainmenu>

        <metadata name="service_management" type="list" key="item">
                <toolbar>
                        <toolbtn func="service_management.edit" type="new" img="t-new" name="new"/>
                        <toolbtn func="service_management.edit" type="edit" img="t-edit" name="edit" default="yes"/>
                        <toolbtn func="service_management.start" type="group" img="t-start" name="start"/>
                        <toolbtn func="service_management.stop" type="group" img="t-stop" name="stop"/>
                        <toolbtn func="service_management.delete" type="group" img="t-delete" name="delete"/>
                </toolbar>
                <coldata>
                        <col sort="alpha" sorted="yes" name="item" type="data"/>
                        <col name="service_status" sort="status">
                                <prop name="active" onimg="p-on" defimg="p-off" stat="yes"/>
                        </col>
                </coldata>
        </metadata>
        <metadata name="service_management.edit" type="form">
                <form>
                        <field name="item">
                                <input type="text" name="item"/>
                        </field>
                        <field name="init_info">
                                <input type="text" name="init_info"/>
			</field>
                </form>
        </metadata>

        <lang name="en">
                <messages name="desktop">
                        <msg name="menu_service_management">Testing service</msg>
                </messages>
                <messages name="service_management">
                        <msg name="msg_service_management_start">Do you really want to start the services?</msg>
                        <msg name="msg_service_management_stop">Do you really want to stop the services?</msg>
                        <msg name="msg_service_management_delete">Do you really want to delete the services?</msg>
                </messages>
                <messages name="service_management.edit">
                        <msg name="title">Service properties</msg>
                        <msg name="item">Service name</msg>
                        <msg name="init_info">Path to start script</msg>
                </messages>
        </lang>
        <lang name="ru">
                <messages name="desktop">
                        <msg name="menu_service_management">Тестовый модуль</msg>
                </messages>
                <messages name="service_management.edit">
                        <msg name="title">Свойства службы</msg>
                        <msg name="item">Служба</msg>
                        <msg name="init_info">Путь к скрипту запуска</msg>
                </messages>
                 <messages name="service_management">
                        <msg name="msg_service_management_start">Вы действительно хотите запустить службы?</msg>
                        <msg name="msg_service_management_stop">Вы действительно хотите остановить службы?</msg>
                         <msg name="msg_service_management_delete">Вы действительно хотите удалить службы?</msg>
                 </messages>
        </lang>
</mgrdata>
Quote:
Originally Posted by getnetworks
When the page loads, all buttons are disabled, and when we click on the single item in the column data, the buttons activate, but if we click on any of the buttons, nothing happens.
As I think your buttons don't work because you didn't add the messages for them. For example:
<msg name="msg_service_management_start">Do you really want to start the services?</msg>


3) The content of servstate.pl:
Code:
#!/usr/bin/perl

use CGI;

$Q = new CGI;

$func = $Q->param("func");

print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
print "<doc>";

if ($func eq "service_management") {	
	&List;
} elsif ($func eq "service_management.start") {
	&Start;
} elsif ($func eq "service_management.stop") {
	&Stop;
} elsif ($func eq "service_management.delete") {	
	&Delete;
} elsif ($func eq "service_management.edit") {
	if ($Q->param("sok")) {
		if ($Q->param("elid")) {			
			&Set;
		} else {			
			&New;
		}
		print "<ok/>";
	} else {		 
		&Get;
	}
}
	
print "</doc>";
exit 0;

sub List {
	if (open(IN, "/tmp/services.txt")) {
		while (<IN>) {
			chomp;
			@Service_Info = split(/ /);
			$Service_Name = $Service_Info[0];
			open(PS_OUT, "ps -e | grep $Service_Name |") or print "<error>Can't execute 'ps'</error>";
			while (<PS_OUT>) {
				$output .= $_;;
			}
			if (index($output, $Service_Name) != -1) {
				print "<elem><item>$Service_Name</item><active/></elem>";
			} else {
				print "<elem><item>$Service_Name</item></elem>";
			}			
		}
		close(IN);
	}
}

sub Get {
	$elid = $Q->param("elid");
	
	if ($elid) {
		if (open(IN, "/tmp/services.txt")) {
			while (<IN>) {
				chomp;				
				@Service_Info = split(/ /);				
				if ($Service_Info[0] eq $elid) {
					print "<elid>$elid</elid><item>$elid</item><init_info>$Service_Info[1]</init_info>";
				}				
			}
			close(IN);
		}		
	}
}

sub Set {
	$item = $Q->param("item");
	$init_info = $Q->param("init_info");
	if (open(IN, "/tmp/services.txt")) {
		if (open(OUT, ">/tmp/services_new.txt")) {
			for (<IN>) {
				chomp;
				@Service_Info = split(/ /);
				if ($Service_Info[0] eq $item) {
					print OUT "$item $init_info\n";
				} else {
					print OUT "$_\n";
				}
			}
			print "<ok/>";
			close(OUT);
			close(IN);	
			rename("/tmp/services_new.txt", "/tmp/services.txt");		
		}		
	} else {
		print "<error>Can't update info</error>";
	}		
}

sub New {
	$item = $Q->param("item");
	$init_info = $Q->param("init_info");
	if (open(ADD, ">>/tmp/services.txt")) {
		print ADD "$item $init_info\n";
		close(ADD);
		print "<ok/>";		
	} else {
		print "<error>Item wasn't added</error>";
	}
}

sub Delete {
	$elid = $Q->param("elid");
	if (open(IN, "/tmp/services.txt")) {
		if (open(OUT, ">/tmp/services_new.txt")) {
			for (<IN>) {				
				chomp;
				@Service_Info = split(/ /);
				print OUT "$_\n" if ($Service_Info[0] ne $elid);				
			}
			close(OUT);
		}
		close(IN);
	}	
	
	rename("/tmp/services_new.txt", "/tmp/services.txt");
	print "<ok/>";
}

sub Start {
	$elid = $Q->param("elid");
	if (open(IN, "/tmp/services.txt")) {
		while (<IN>) {
			chomp;				
			@Service_Info = split(/ /);
			if ($elid eq $Service_Info[0]) {				
				if (open(START_OUT, "$Service_Info[1] start |")) {
					print "<ok/>";
				} else {
					print "<error>Can't start the application!</error>";
				}
			}		
		}
		close(IN);
	}		
}

sub Stop {
	$elid = $Q->param("elid");
	if (open(IN, "/tmp/services.txt")) {
		while (<IN>) {
			chomp;				
			@Service_Info = split(/ /);
			if ($elid eq $Service_Info[0]) {
				if (open(START_OUT, "$Service_Info[1] stop |")) {
					print "<ok/>";
				} else {
					print "<error>Can't stop the application!</error>";
				}
			}		
		}
		close(IN);
	}	
}
Quote:
Originally Posted by getnetworks
Ideally, we'd like for the system to recognize that the item is 'running' (we have a status in one of our columns) and then only activate the stop/restart buttons if it is running. If the status is reporting 'stopped', then only the start/restart buttons activate.
There are some restrictions in ISPmanager. It's impossible to change buttons activity.

Last edited by GakcaT; 09-17-2009 at 03:30 AM.
GakcaT is offline   Reply With Quote
Old 09-16-2009, 11:36 PM   #7
Junior Member
 
Join Date: Aug 2009
Posts: 24
getnetworks is on a distinguished road
Default

This was helpful; thank you.

However, when we highlight the item in the list and try clicking on any of the toolbar buttons (stop/start/restart), a dialog box just pops up saying "No selection". Any ideas?
getnetworks is offline   Reply With Quote
Old 09-17-2009, 05:12 AM   #8
ISPsystem team
 
Join Date: Jan 2009
Posts: 111
GakcaT is on a distinguished road
Default

What is being written in the ISPmanager logfile when you press a button?
Each element from the table has the element id (tag <elid>). When you press a button your application sends a request to ISPmanager, the request has to include the tag <elid>element_id</elid>.

Last edited by GakcaT; 09-17-2009 at 05:20 AM.
GakcaT is offline   Reply With Quote
Old 09-17-2009, 08:49 PM   #9
Junior Member
 
Join Date: Aug 2009
Posts: 24
getnetworks is on a distinguished road
Default

Quote:
Originally Posted by GakcaT View Post
What is being written in the ISPmanager logfile when you press a button?
Each element from the table has the element id (tag <elid>). When you press a button your application sends a request to ISPmanager, the request has to include the tag <elid>element_id</elid>.
We weren't getting anything, so we switched our modified files back over to exactly what you provided. The log now shows a request to 'INFO Request [#.#.#.#][root] 'func=service_management'', but on the GUI itself, it isn't displaying the page title or any of the services we added to the /tmp/services.txt file per your instructions. We even ran 'rm -rf /usr/local/ispmgr/var/.xmlcache ; killall ispmgr' to purge the cache. Something is definitely wrong. We are running the latest build posted yesterday.
getnetworks is offline   Reply With Quote
Old 09-18-2009, 08:18 AM   #10
ISPsystem team
 
Join Date: Jan 2009
Posts: 111
GakcaT is on a distinguished road
Default

It's difficult to determine the problem. Write a ticket to our support team (if it's possible, provide an access to the test server).
GakcaT is offline   Reply With Quote
Reply

Tags
adding, items, menu

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:24 PM.