CPU-Usage of more than one PC via Script

Started by cme, August 17, 2007, 01:47:55 AM

Previous topic - Next topic

cme

Hi!

*** This is my first post and therefore I want to say "Thank You!" to the developer of NetXMS for his great work ***
I'm going to use the app. for my final-exam preparation in my apprenticeship at Siemens in Paderborn (Germany).


One task of NetXMS will be to inform the admin about any (already added in NetXMS) PC of the net which has a
CPU usage of more than 80%.
I already know that I can add the usage in "data collection" --> then add a rule in event processing policy editor with
action "SYS_THRESHOLD_REACHED" that send an static text via email to the admin.

Now do I have to do these steps for every host?

I want to do that dynamically that in the mail the hostname will be shown like
"CPU of PC23 is above 80%..."

I just want to have one event for that. Is that possible? How? Other possiblities?
May be a script like message_text="CPU of %hostname% is about cpu.usage(host)" ...

I've never written a script in NetXMS.

Second question:

I have the event SYS_THRESHOLD_REACHED let's say for this CPU monitoring...
If I further want to watch the DiskUsage.. (if it's above 90%)
Do I have to create another new event like this or use another one?
So do I have to create such a event for every "thing" that is watched?
Example:
CPU -> CPU_TOO_HIGH -> action: email "CPU of PC123 too high.."
Disk -> DISK_FULL -> action: "Disk of PC123 too full.."
..

greetings -
Christian.

Victor Kirhenshtein

Quote from: cme on August 17, 2007, 01:47:55 AM

One task of NetXMS will be to inform the admin about any (already added in NetXMS) PC of the net which has a
CPU usage of more than 80%.
I already know that I can add the usage in "data collection" --> then add a rule in event processing policy editor with
action "SYS_THRESHOLD_REACHED" that send an static text via email to the admin.

Now do I have to do these steps for every host?

I want to do that dynamically that in the mail the hostname will be shown like
"CPU of PC23 is above 80%..."

Hello!

You can achieve this using templates:
1. Create template object (in Templates subtree)
2. In data collection configuration for template object, create DCI for CPU utilization as usual
3. Apply template to nodes where you wish to check CPU utilization

In event processing policy, you can use macros in alarm texts. For example, if you wish to include node name and actual CPU utilization in alarm (or e-mail text, etc.), you may write your text like this:
CPU utilization on node %n is %4%%

%n will be replaced by node name, %4 by actual DCI value, and %% with single % character. You can find complete list of available macros in User's Manual (section 8.6) or here:
https://www.netxms.org/documentation/macros.shtml

Best regards,
Victor

Victor Kirhenshtein

Quote from: cme on August 17, 2007, 01:47:55 AM
Second question:

I have the event SYS_THRESHOLD_REACHED let's say for this CPU monitoring...
If I further want to watch the DiskUsage.. (if it's above 90%)
Do I have to create another new event like this or use another one?
So do I have to create such a event for every "thing" that is watched?
Example:
CPU -> CPU_TOO_HIGH -> action: email "CPU of PC123 too high.."
Disk -> DISK_FULL -> action: "Disk of PC123 too full.."
..

Yes, it's the main idea - you create different events for different thresholds, so you can process them differently. After NetXMS installation you already have some example events for threshold violations - their names starts with DC_ prefix.

Also, you may create different events for different thresholds (for example HIGH_CPU_USAGE and LOW_DISK_SPACE), but handle them identically - for example, write one rule in event processing policy:

add both HIGH_CPU_USAGE and LOW_DISK_SPACE to event field;
in alarm generation field as alarm text use %m macro, which will expand to actual event's text.

With this approach, you can have relatively simple event processing policy but use meaningful texts in alarms and messages.