Debugging plugins


Recommended Posts

Hey guys,

 

I'm trying to understand how the plugin system works. Sofar the only thing I'm trying to achive is "installing" a bash script to /usr/local/bin and the rc script that is needed to start/stop it. The two scripts are working if I copy them manually to their locations. Also had a version that involved copying them to their location by adding them to the flaskdrive and tinker with the go script but the go script is executed way after the plugins got installed.

 

I tried to reverse engineer some plugins and figured that the bash and rc file could be embedded in de .plg. Can't be hard right? After I rebooted the plugin ended up in /boot/config/pluging-error so I expected some logging since nothing showed up in /var/log/syslog.

Please tell me where plugin installation logs are.

 

Eg. I'm not creating an elaborate frontend page to start or stop of enable/disable te service, at least not for now since I'm not going to publish it. I just want fire up a script as service when unraid starts - whenever the array is started or not..

 

Sidenote: I think it would be awesome if limetech would create documentation about how the plugin-system works and what to do and what you deffo should not do -

Edited by sjoerd
Link to comment
1 hour ago, sjoerd said:

I tried to reverse engineer some plugins and figured that the bash and rc file could be embedded in de .plg. Can't be hard right?

Take a look at these plugins https://github.com/dcflachs/compose_plugin https://github.com/dcflachs/swapfile_plugin particularly the pkg_build.sh as an example of how to build a .plg

 

1 hour ago, sjoerd said:

Sidenote: I think it would be awesome if limetech would create documentation about how the plugin-system works and what to do and what you deffo should not do -

Its something I was asking for a long time ago, but it never happened. 

  • Thanks 1
Link to comment
15 hours ago, sjoerd said:

After I rebooted the plugin ended up in /boot/config/pluging-error so I expected some logging since nothing showed up in /var/log/syslog.

Do you have the source somewhere?

Since this is a xml you have to escape special characters.

 

I would also recommend to not embed the rc file in the plg file since this can and will complicate things.

 

BTW, you don't have to reboot to install a plugin, simply put the plg file somewhere on your server and then install it through the build int plugin installer:

grafik.png.5880ee5687c9bdbf81c6f77a7668b301.png

 

With that you will see what is happening, or in this case not. I suspect a formatting error or something similar.

 

May I ask what plugin you are trying to create?

 

15 hours ago, sjoerd said:

I just want fire up a script as service when unraid starts - whenever the array is started or not..

You can use events for that, look for example here for the LXC plugin, these events will trigger when they are placed in /usr/local/emhttp/plugins/<PLUGINNAME>/events/<EVENT>

(so to speak disks_mounted is when the Array starts and umounting_disks is when the Array stops).

Link to comment
Posted (edited)

I got two goals here. The first one is obviously to learn more about unraid, slack and how to make unraid plugins. Second goal is more practical: I'm trying to create put a netdev_stats.ini (just a name I came up with) along with al the other ini's in /var/local/emhttp/state that gathers the current bandwidth from various interfaces. As far as I can tell it's not available. Well, third goal is to actually use that ini for a 4x20 lcd display I'm working on to display cpu, parity status, bandwidth maybe how much space is left.

 

For now the raw bash script and rc script only get current rx/tx bytes from the interface, no bandwidth calculation yet although I already had that mechanism working for an other project. Just need to implement that.

Output sofar (still need to filter out unwanted/need interfaces) and is refreshed every second:

```

cat /var/local/emhttp/netdev_stats.ini
[eth0]
rx=19769200081
tx=1175170966119
 
[bond0]
rx=19769200081
tx=1175170966119
 
[vhost0]
rx=17744066178
tx=1125304306954
 
[docker0]
rx=1088068
tx=1328220
 
[macvtap0]
rx=130047218
tx=226070299
 
[veth1fe2317]
rx=774598
tx=827228
 
[veth6ee30bd]
rx=0
tx=2126
 
[vethd83e77e]
rx=130137
tx=1428591
 
[veth21b8a2c]
rx=0
tx=49676
 
[vethcdc0f00]
rx=99847108
tx=3512523901
 
[veth5b30f33]
rx=0
tx=2126

```

Next iteration is ofc that actual bandwidth is shown on tx/rx. I think only eth0 and/or bond0 are usefull tho.

 

So @ich777 what you are saying is that I should make a txz with the files in their appropriate path and only put the symlinks and chown command in the plg.. Will also check the install plugin page - I have seen that page but faded since we only use the CA nowadays 🙂

@primeval_god I will check those out (also the links @ich777 posted.

 

Disclaimer: the scripts might not 100% bulletproof and maybe some things are not done the right way.

 

image.png.cd22e267be90997b825c278a6097d104.png

image.png.7b72bd88d22e87e62115a94bfc824ffa.png

 

netdev_stats.plg netdev_stats.sh rc.netdev_stats

Edited by sjoerd
Link to comment

That cool's - I was not aware about that, still - I want to understand the plg thingy and I already made a couple of classes in python that gather data from the ini-files, and sends them to the lcd using a uart. I usually want to try it myself, if I think its doable with the knowledge I got, before I get "ready-to-go" plugins 🙂.

Been tinkering with atmeg and esp for quite some time and thought this would be cool (but as always - whatever you come up with, you are not the first one :)

Link to comment
1 hour ago, sjoerd said:

That cool's - I was not aware about that, still - I want to understand the plg thingy and I already made a couple of classes in python that gather data from the ini-files, and sends them to the lcd using a uart. I usually want to try it myself, if I think its doable with the knowledge I got, before I get "ready-to-go" plugins 🙂.

Been tinkering with atmeg and esp for quite some time and thought this would be cool (but as always - whatever you come up with, you are not the first one :)

Here is my repo if you want to use for examples.

 

https://github.com/SimonFair/unraid-lcd plan is to create a client to show Unraid specific info, but not built yet.

 

client.php is my starter for 10 based on a pfsense plugin.

 

 

  • Like 1
  • Thanks 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.