Your escalation definition will work for every service state (warning, critical, unknown or recovery) and it will send only 3rd and 4th email to nagiosadmin and ithelpdesk. All other email will go to default recepient you have defined in service definition of Check_HP_Col_Toner_Level.
If you want to send an email only to nagiosadmin when the service is in warning state and run a script when the service is critical then you’ll have to take another approach. It could be done, not the way it meant to be but it can be achieved.
Create one contact that has a command that runs the script under notification command, like this:
And put it in some contactgroup:
Then define the command that would issue the script:
# 'ticket_script command definition'
With these you will have a contact upon whom will only in Critical service state (take a look at the service_notification_options c variable that defines that) be issued a service_notification_commands ticket_script which we have defined to run your script.
After that is set and done, you will have to define another service escalation but only for Critical states that would escalate the problem to the contact defined above (not really escalate the problem to the contact but run the script, 'cause we’ve defined it that way):
With this you will get first email (read first executing of the script, which will also be the last cause I assume you don’t want to create more then one ticket for a problem) only when the service goes to Critical state.
If you like that then it is it. If you don’t want ithelpdesk to be notified with Warning notifications then you could remove the service escalation you’ve defined and define the contacts only through the service definition, but that is of your choice and configurable to your needs.